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 *
18d494b09f554d470fc6411d0924879bbfb0cb0e95commit-bot@chromium.org *  The resulting color is black with transparency equal to the
19d494b09f554d470fc6411d0924879bbfb0cb0e95commit-bot@chromium.org *  luminance value modulated by alpha:
206c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
21d494b09f554d470fc6411d0924879bbfb0cb0e95commit-bot@chromium.org *    C' = [ Lum * a, 0, 0, 0 ]
226c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
236c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org */
246c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgclass SK_API SkLumaColorFilter : public SkColorFilter {
256c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgpublic:
266c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    static SkColorFilter* Create();
276c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
286c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE;
296c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
306c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#if SK_SUPPORT_GPU
31b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt    virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE;
326c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#endif
336c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
340f10f7bf1fb43ca6346dc220a076773b1f19a367commit-bot@chromium.org    SK_TO_STRING_OVERRIDE()
356c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
366c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
376c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgprotected:
389fa60daad4d5f54c0dbe3dbcc7608a8f6d721187reed#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
398b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org    SkLumaColorFilter(SkReadBuffer& buffer);
409fa60daad4d5f54c0dbe3dbcc7608a8f6d721187reed#endif
418b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
426c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
436c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgprivate:
446c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SkLumaColorFilter();
456c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
466c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    typedef SkColorFilter INHERITED;
476c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org};
486c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
496c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#endif
50