SkLumaColorFilter.h revision 6c1ee2d4e727357451c8a6fcf4a08e75890b5d6d
16c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org/*
26c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org * Copyright 2013 Google Inc.
36c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
46c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be
56c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org * found in the LICENSE file.
66c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org */
76c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
86c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#ifndef SkLumaColorFilter_DEFINED
96c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#define SkLumaColorFilter_DEFINED
106c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
116c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#include "SkColorFilter.h"
126c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
136c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org/**
146c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  Luminance-to-alpha color filter, as defined in
156c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  http://www.w3.org/TR/SVG/masking.html#Masking
166c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  http://www.w3.org/TR/css-masking/#MaskValues
176c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
186c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  Each color is scaled by the (unpremultiplied) luminance value:
196c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
206c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  C' = [Lum * a, Lum * r, Lum * g, Lum * b]
216c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
226c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org */
236c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgclass SK_API SkLumaColorFilter : public SkColorFilter {
246c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgpublic:
256c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    static SkColorFilter* Create();
266c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
276c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE;
286c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
296c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#if SK_SUPPORT_GPU
306c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    virtual GrEffectRef* asNewEffect(GrContext*) const SK_OVERRIDE;
316c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#endif
326c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
336c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
346c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
356c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
366c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgprotected:
376c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SkLumaColorFilter(SkFlattenableReadBuffer& buffer);
386c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
396c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
406c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgprivate:
416c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SkLumaColorFilter();
426c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
436c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    typedef SkColorFilter INHERITED;
446c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org};
456c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
466c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#endif
47