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

Unified Diff: src/gpu/glsl/GrGLSLShaderBuilder.cpp

Issue 2329553002: Cleanup GPU gamut transformation code (Closed)
Patch Set: Switch from float[16] to SkMatrix44 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLProgramDataManager.cpp ('k') | src/image/SkImageShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLShaderBuilder.cpp
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index 26a7761f320dc77fc89b0a5bb38609dbe9917c19..6d77bdbf9a5c32cd3b70ed2dc481cc1d0a08d341 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -133,27 +133,14 @@ void GrGLSLShaderBuilder::appendColorGamutXform(SkString* out,
GrGLSLColorSpaceXformHelper* colorXformHelper) {
// Our color is (r, g, b, a), but we want to multiply (r, g, b, 1) by our matrix, then
// re-insert the original alpha. The supplied srcColor is likely to be of the form
- // "texture(...)", and we don't want to evaluate that twice.
- //
- // Worse: We can't do the transformation on premultiplied colors, so if the source is premul,
- // we need to unpremul, transform, then multiply again. Anyways, we wrap all of the work in a
- // function.
+ // "texture(...)", and we don't want to evaluate that twice, so wrap everything in a function.
static const GrGLSLShaderVar gColorGamutXformArgs[] = {
GrGLSLShaderVar("color", kVec4f_GrSLType),
GrGLSLShaderVar("xform", kMat44f_GrSLType),
};
SkString functionBody;
- if (kPremul_SkAlphaType == colorXformHelper->alphaType()) {
- // Unpremultiply
- functionBody.append("\tfloat nonZeroAlpha = max(color.a, 0.00001);\n"
- "\tcolor.rgb = color.rgb / nonZeroAlpha;\n");
- }
// Gamut xform, clamp to destination gamut
functionBody.append("\tcolor.rgb = clamp((xform * vec4(color.rgb, 1.0)).rgb, 0.0, 1.0);\n");
- if (kPremul_SkAlphaType == colorXformHelper->alphaType()) {
- // Re-multiply by alpha
- functionBody.append("\tcolor.rgb = color.rgb * nonZeroAlpha;\n");
- }
functionBody.append("\treturn color;");
SkString colorGamutXformFuncName;
this->emitFunction(kVec4f_GrSLType,
« no previous file with comments | « src/gpu/glsl/GrGLSLProgramDataManager.cpp ('k') | src/image/SkImageShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698