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 #include "SkRefCnt.h" 13 14 class SkRasterPipeline; 15 16 /** 17 * Luminance-to-alpha color filter, as defined in 18 * http://www.w3.org/TR/SVG/masking.html#Masking 19 * http://www.w3.org/TR/css-masking/#MaskValues 20 * 21 * The resulting color is black with transparency equal to the 22 * luminance value modulated by alpha: 23 * 24 * C' = [ Lum * a, 0, 0, 0 ] 25 * 26 */ 27 class SK_API SkLumaColorFilter : public SkColorFilter { 28 public: 29 static sk_sp<SkColorFilter> Make(); 30 31 #if SK_SUPPORT_GPU 32 sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, SkColorSpace*) const override; 33 #endif 34 35 SK_TO_STRING_OVERRIDE() 36 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) 37 38 protected: 39 void flatten(SkWriteBuffer&) const override; 40 41 private: 42 SkLumaColorFilter(); 43 void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, 44 bool shaderIsOpaque) const override; 45 46 typedef SkColorFilter INHERITED; 47 }; 48 49 #endif 50