OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkLumaColorFilter.h" | 8 #include "SkLumaColorFilter.h" |
9 | 9 |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { | 88 static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { |
89 // this class always generates the same code. | 89 // this class always generates the same code. |
90 return 0; | 90 return 0; |
91 } | 91 } |
92 | 92 |
93 virtual void emitCode(GrGLShaderBuilder* builder, | 93 virtual void emitCode(GrGLShaderBuilder* builder, |
94 const GrDrawEffect&, | 94 const GrDrawEffect&, |
95 EffectKey, | 95 EffectKey, |
96 const char* outputColor, | 96 const char* outputColor, |
97 const char* inputColor, | 97 const GrGLSLExpr4& inputColor, |
98 const TransformedCoordsArray&, | 98 const TransformedCoordsArray&, |
99 const TextureSamplerArray&) SK_OVERRIDE { | 99 const TextureSamplerArray&) SK_OVERRIDE { |
100 if (NULL == inputColor) { | |
101 inputColor = "vec4(1)"; | |
102 } | |
103 | |
104 builder->fsCodeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", | 100 builder->fsCodeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", |
105 SK_ITU_BT709_LUM_COEFF_R, | 101 SK_ITU_BT709_LUM_COEFF_R, |
106 SK_ITU_BT709_LUM_COEFF_G, | 102 SK_ITU_BT709_LUM_COEFF_G, |
107 SK_ITU_BT709_LUM_COEFF_B, | 103 SK_ITU_BT709_LUM_COEFF_B, |
108 inputColor); | 104 inputColor.c_str()); |
109 builder->fsCodeAppendf("\t%s = vec4(0, 0, 0, luma);\n", | 105 builder->fsCodeAppendf("\t%s = vec4(0, 0, 0, luma);\n", |
110 outputColor); | 106 outputColor); |
111 | 107 |
112 } | 108 } |
113 | 109 |
114 private: | 110 private: |
115 typedef GrGLEffect INHERITED; | 111 typedef GrGLEffect INHERITED; |
116 }; | 112 }; |
117 | 113 |
118 private: | 114 private: |
119 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { | 115 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { |
120 return true; | 116 return true; |
121 } | 117 } |
122 }; | 118 }; |
123 | 119 |
124 GrEffectRef* SkLumaColorFilter::asNewEffect(GrContext*) const { | 120 GrEffectRef* SkLumaColorFilter::asNewEffect(GrContext*) const { |
125 return LumaColorFilterEffect::Create(); | 121 return LumaColorFilterEffect::Create(); |
126 } | 122 } |
127 #endif | 123 #endif |
OLD | NEW |