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

Side by Side Diff: src/gpu/glsl/GrGLSLShaderBuilder.cpp

Issue 2326093002: Fix color gamut xform matrices in GPU code (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « src/gpu/GrColorSpaceXform.cpp ('k') | no next file » | 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 2014 Google Inc. 2 * Copyright 2014 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 "GrSwizzle.h" 8 #include "GrSwizzle.h"
9 #include "glsl/GrGLSLShaderBuilder.h" 9 #include "glsl/GrGLSLShaderBuilder.h"
10 #include "glsl/GrGLSLCaps.h" 10 #include "glsl/GrGLSLCaps.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 GrGLSLShaderVar("color", kVec4f_GrSLType), 142 GrGLSLShaderVar("color", kVec4f_GrSLType),
143 GrGLSLShaderVar("xform", kMat44f_GrSLType), 143 GrGLSLShaderVar("xform", kMat44f_GrSLType),
144 }; 144 };
145 SkString functionBody; 145 SkString functionBody;
146 if (kPremul_SkAlphaType == colorXformHelper->alphaType()) { 146 if (kPremul_SkAlphaType == colorXformHelper->alphaType()) {
147 // Unpremultiply 147 // Unpremultiply
148 functionBody.append("\tfloat nonZeroAlpha = max(color.a, 0.00001);\n" 148 functionBody.append("\tfloat nonZeroAlpha = max(color.a, 0.00001);\n"
149 "\tcolor.rgb = color.rgb / nonZeroAlpha;\n"); 149 "\tcolor.rgb = color.rgb / nonZeroAlpha;\n");
150 } 150 }
151 // Gamut xform, clamp to destination gamut 151 // Gamut xform, clamp to destination gamut
152 functionBody.append("\tcolor.rgb = clamp((vec4(color.rgb, 1.0) * xform).rgb, 0.0, 1.0);\n"); 152 functionBody.append("\tcolor.rgb = clamp((xform * vec4(color.rgb, 1.0)).rgb, 0.0, 1.0);\n");
153 if (kPremul_SkAlphaType == colorXformHelper->alphaType()) { 153 if (kPremul_SkAlphaType == colorXformHelper->alphaType()) {
154 // Re-multiply by alpha 154 // Re-multiply by alpha
155 functionBody.append("\tcolor.rgb = color.rgb * nonZeroAlpha;\n"); 155 functionBody.append("\tcolor.rgb = color.rgb * nonZeroAlpha;\n");
156 } 156 }
157 functionBody.append("\treturn color;"); 157 functionBody.append("\treturn color;");
158 SkString colorGamutXformFuncName; 158 SkString colorGamutXformFuncName;
159 this->emitFunction(kVec4f_GrSLType, 159 this->emitFunction(kVec4f_GrSLType,
160 "colorGamutXform", 160 "colorGamutXform",
161 SK_ARRAY_COUNT(gColorGamutXformArgs), 161 SK_ARRAY_COUNT(gColorGamutXformArgs),
162 gColorGamutXformArgs, 162 gColorGamutXformArgs,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // append the 'footer' to code 253 // append the 'footer' to code
254 this->code().append("}"); 254 this->code().append("}");
255 255
256 for (int i = 0; i <= fCodeIndex; i++) { 256 for (int i = 0; i <= fCodeIndex; i++) {
257 fCompilerStrings[i] = fShaderStrings[i].c_str(); 257 fCompilerStrings[i] = fShaderStrings[i].c_str();
258 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); 258 fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
259 } 259 }
260 260
261 fFinalized = true; 261 fFinalized = true;
262 } 262 }
OLDNEW
« no previous file with comments | « src/gpu/GrColorSpaceXform.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698