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 GrEffectRef* asNewEffect(GrContext*) const SK_OVERRIDE; 32#endif 33 34 SK_TO_STRING_OVERRIDE() 35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) 36 37protected: 38 SkLumaColorFilter(SkReadBuffer& buffer); 39 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 40 41private: 42 SkLumaColorFilter(); 43 44 typedef SkColorFilter INHERITED; 45}; 46 47#endif 48