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"
1206ca8ec87cf6fab57cadd043a5ac18c4154a4129bungeman#include "SkRefCnt.h"
136c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
141f49f26353997195030aeab41c8665e1860d2958Mike Kleinclass SkRasterPipeline;
151f49f26353997195030aeab41c8665e1860d2958Mike Klein
166c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org/**
176c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  Luminance-to-alpha color filter, as defined in
186c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  http://www.w3.org/TR/SVG/masking.html#Masking
196c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *  http://www.w3.org/TR/css-masking/#MaskValues
206c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
21d494b09f554d470fc6411d0924879bbfb0cb0e95commit-bot@chromium.org *  The resulting color is black with transparency equal to the
22d494b09f554d470fc6411d0924879bbfb0cb0e95commit-bot@chromium.org *  luminance value modulated by alpha:
236c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
24d494b09f554d470fc6411d0924879bbfb0cb0e95commit-bot@chromium.org *    C' = [ Lum * a, 0, 0, 0 ]
256c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org *
266c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org */
276c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgclass SK_API SkLumaColorFilter : public SkColorFilter {
286c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgpublic:
29d053ce9c54d4e5937a142278359e5a4cde18095ereed    static sk_sp<SkColorFilter> Make();
30d053ce9c54d4e5937a142278359e5a4cde18095ereed
3136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
326c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
336c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#if SK_SUPPORT_GPU
34618d304eb394d64779be0ecdc5eff898242faa8fBrian Osman    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, SkColorSpace*) const override;
356c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#endif
366c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
370f10f7bf1fb43ca6346dc220a076773b1f19a367commit-bot@chromium.org    SK_TO_STRING_OVERRIDE()
386c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
396c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
406c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgprotected:
4136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    void flatten(SkWriteBuffer&) const override;
426c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
436c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.orgprivate:
446c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    SkLumaColorFilter();
45ac04fef619ad3939a25e66bdaef6f6b1e7f5ca50Herb Derby    bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
46744908e5e81f81f34288a1b5547aa4ea990ad13dMike Klein                        bool shaderIsOpaque) const override;
476c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
486c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org    typedef SkColorFilter INHERITED;
496c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org};
506c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org
516c1ee2d4e727357451c8a6fcf4a08e75890b5d6dcommit-bot@chromium.org#endif
52