1/* 2 * Copyright 2013 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#ifndef SkLumaColorFilter_DEFINED 9#define SkLumaColorFilter_DEFINED 10 11#include "SkColorFilter.h" 12 13/** 14 * Luminance-to-alpha color filter, as defined in 15 * http://www.w3.org/TR/SVG/masking.html#Masking 16 * http://www.w3.org/TR/css-masking/#MaskValues 17 * 18 * The resulting color is black with transparency equal to the 19 * luminance value modulated by alpha: 20 * 21 * C' = [ Lum * a, 0, 0, 0 ] 22 * 23 */ 24class SK_API SkLumaColorFilter : public SkColorFilter { 25public: 26 static SkColorFilter* Create(); 27 28 virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE; 29 30#if SK_SUPPORT_GPU 31 virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE; 32#endif 33 34 SK_TO_STRING_OVERRIDE() 35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) 36 37protected: 38#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING 39 SkLumaColorFilter(SkReadBuffer& buffer); 40#endif 41 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 42 43private: 44 SkLumaColorFilter(); 45 46 typedef SkColorFilter INHERITED; 47}; 48 49#endif 50