Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: src/effects/SkLumaColorFilter.cpp

Issue 25048002: Express (GLSL expression, possibly known value) pairs as a class (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: addressing review comments Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLumaXfermode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 virtual void emitCode(GrGLShaderBuilder* builder, 115 virtual void emitCode(GrGLShaderBuilder* builder,
116 const GrDrawEffect&, 116 const GrDrawEffect&,
117 EffectKey, 117 EffectKey,
118 const char* outputColor, 118 const char* outputColor,
119 const char* inputColor, 119 const char* inputColor,
120 const TransformedCoordsArray&, 120 const TransformedCoordsArray&,
121 const TextureSamplerArray&) SK_OVERRIDE { 121 const TextureSamplerArray&) SK_OVERRIDE {
122 if (NULL == inputColor) { 122 if (NULL == inputColor) {
123 inputColor = GrGLSLOnesVecf(4); 123 inputColor = "vec4(1)";
124 } 124 }
125 125
126 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is 126 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is
127 // transparent black. 127 // transparent black.
128 builder->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor); 128 builder->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor);
129 builder->fsCodeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb) ;\n", 129 builder->fsCodeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb) ;\n",
130 SK_ITU_BT709_LUM_COEFF_R, 130 SK_ITU_BT709_LUM_COEFF_R,
131 SK_ITU_BT709_LUM_COEFF_G, 131 SK_ITU_BT709_LUM_COEFF_G,
132 SK_ITU_BT709_LUM_COEFF_B, 132 SK_ITU_BT709_LUM_COEFF_B,
133 inputColor); 133 inputColor);
134 builder->fsCodeAppendf("\t%s = vec4(%s.rgb * luma / nonZeroAlpha, lu ma);\n", 134 builder->fsCodeAppendf("\t%s = vec4(%s.rgb * luma / nonZeroAlpha, lu ma);\n",
135 outputColor, inputColor); 135 outputColor, inputColor);
136 136
137 } 137 }
138 138
139 private: 139 private:
140 typedef GrGLEffect INHERITED; 140 typedef GrGLEffect INHERITED;
141 }; 141 };
142 142
143 private: 143 private:
144 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { 144 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE {
145 return true; 145 return true;
146 } 146 }
147 }; 147 };
148 148
149 GrEffectRef* SkLumaColorFilter::asNewEffect(GrContext*) const { 149 GrEffectRef* SkLumaColorFilter::asNewEffect(GrContext*) const {
150 return LumaColorFilterEffect::Create(); 150 return LumaColorFilterEffect::Create();
151 } 151 }
152 #endif 152 #endif
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLumaXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698