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

Side by Side Diff: src/gpu/effects/GrConfigConversionEffect.cpp

Issue 377263003: Revert of Make GrGLConfigConversionEffect work for Imagination and some other GPUs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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/effects/GrConfigConversionEffect.h ('k') | src/gpu/gl/GrGLShaderBuilder.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 2012 Google Inc. 2 * Copyright 2012 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 "GrConfigConversionEffect.h" 8 #include "GrConfigConversionEffect.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrTBackendEffectFactory.h" 10 #include "GrTBackendEffectFactory.h"
(...skipping 19 matching lines...) Expand all
30 const TransformedCoordsArray& coords, 30 const TransformedCoordsArray& coords,
31 const TextureSamplerArray& samplers) SK_OVERRIDE { 31 const TextureSamplerArray& samplers) SK_OVERRIDE {
32 builder->fsCodeAppendf("\t\t%s = ", outputColor); 32 builder->fsCodeAppendf("\t\t%s = ", outputColor);
33 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .type()); 33 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .type());
34 builder->fsCodeAppend(";\n"); 34 builder->fsCodeAppend(";\n");
35 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { 35 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) {
36 SkASSERT(fSwapRedAndBlue); 36 SkASSERT(fSwapRedAndBlue);
37 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor ); 37 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor );
38 } else { 38 } else {
39 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; 39 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb";
40 const char* outputColorH = "outputColorH";
41 switch (fPMConversion) { 40 switch (fPMConversion) {
42 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: 41 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion:
43 builder->fsCodeAppendf( 42 builder->fsCodeAppendf(
44 "\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a) ;\n", 43 "\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a) ;\n",
45 outputColor, outputColor, swiz, outputColor, outputColor ); 44 outputColor, outputColor, swiz, outputColor, outputColor );
46 break; 45 break;
47 case GrConfigConversionEffect::kMulByAlpha_RoundDown_PMConversio n: 46 case GrConfigConversionEffect::kMulByAlpha_RoundDown_PMConversio n:
48 // Add a compensation(0.001) here to avoid the side effect o f the floor operation. 47 // Add a compensation(0.001) here to avoid the side effect o f the floor operation.
49 // In Intel GPUs, the integer value converted from floor(%s. r * 255.0) / 255.0 48 // In Intel GPUs, the integer value converted from floor(%s. r * 255.0) / 255.0
50 // is less than the integer value converted from %s.r by 1 when the %s.r is 49 // is less than the integer value converted from %s.r by 1 when the %s.r is
51 // converted from the integer value 2^n, such as 1, 2, 4, 8, etc. 50 // converted from the integer value 2^n, such as 1, 2, 4, 8, etc.
52 builder->fsCodeAppendf( 51 builder->fsCodeAppendf(
53 "\t\t%s = vec4(floor(%s.%s * %s.a * 255.0 + 0.001) / 255 .0, %s.a);\n", 52 "\t\t%s = vec4(floor(%s.%s * %s.a * 255.0 + 0.001) / 255 .0, %s.a);\n",
54 outputColor, outputColor, swiz, outputColor, outputColor ); 53 outputColor, outputColor, swiz, outputColor, outputColor );
55 break; 54 break;
56 case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion: 55 case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion:
57 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n", 56 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
58 outputColor, outputColor, outputColor, swiz, outputColor , outputColor); 57 outputColor, outputColor, outputColor, swiz, outputColor , outputColor);
59 break; 58 break;
60 case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversio n: 59 case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversio n:
61 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n", 60 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
62 outputColor, outputColor, outputColor, swiz, outputColor , outputColor); 61 outputColor, outputColor, outputColor, swiz, outputColor , outputColor);
63 break; 62 break;
64 case GrConfigConversionEffect::kMulByAlpha_RoundUp_HIGHP_PMConve rsion:
65 builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
66 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outpu tColor);
67 builder->fsCodeAppendf(
68 "\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a) ;\n",
69 outputColorH, outputColorH, swiz, outputColorH, outputCo lorH);
70 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, output ColorH);
71 break;
72 case GrConfigConversionEffect::kMulByAlpha_RoundDown_HIGHP_PMCon version:
73 builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
74 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outpu tColor);
75 builder->fsCodeAppendf(
76 "\t\t%s = vec4(floor(%s.%s * %s.a * 255.0) / 255.0, %s.a );\n",
77 outputColorH, outputColorH, swiz, outputColorH, outputCo lorH);
78 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, output ColorH);
79 break;
80 case GrConfigConversionEffect::kDivByAlpha_RoundUp_HIGHP_PMConve rsion:
81 builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
82 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outpu tColor);
83 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
84 outputColorH, outputColorH, outputColorH, swiz, outputCo lorH, outputColorH);
85 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, output ColorH);
86 break;
87 case GrConfigConversionEffect::kDivByAlpha_RoundDown_HIGHP_PMCon version:
88 builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
89 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outpu tColor);
90 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
91 outputColorH, outputColorH, outputColorH, swiz, outputCo lorH, outputColorH);
92 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, output ColorH);
93 break;
94 default: 63 default:
95 SkFAIL("Unknown conversion op."); 64 SkFAIL("Unknown conversion op.");
96 break; 65 break;
97 } 66 }
98 } 67 }
99 SkString modulate; 68 SkString modulate;
100 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); 69 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
101 builder->fsCodeAppend(modulate.c_str()); 70 builder->fsCodeAppend(modulate.c_str());
102 } 71 }
103 72
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 177 }
209 desc.fFlags = kNone_GrTextureFlags; 178 desc.fFlags = kNone_GrTextureFlags;
210 SkAutoTUnref<GrTexture> dataTex(context->createUncachedTexture(desc, data, 0 )); 179 SkAutoTUnref<GrTexture> dataTex(context->createUncachedTexture(desc, data, 0 ));
211 if (!dataTex.get()) { 180 if (!dataTex.get()) {
212 return; 181 return;
213 } 182 }
214 183
215 static const PMConversion kConversionRules[][2] = { 184 static const PMConversion kConversionRules[][2] = {
216 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, 185 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion},
217 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, 186 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
218 {kDivByAlpha_RoundDown_HIGHP_PMConversion, kMulByAlpha_RoundUp_HIGHP_PMC onversion},
219 {kDivByAlpha_RoundUp_HIGHP_PMConversion, kMulByAlpha_RoundDown_HIGHP_PMC onversion},
220 }; 187 };
221 188
222 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); 189 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL);
223 190
224 bool failed = true; 191 bool failed = true;
225 192
226 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) { 193 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
227 *pmToUPMRule = kConversionRules[i][0]; 194 *pmToUPMRule = kConversionRules[i][0];
228 *upmToPMRule = kConversionRules[i][1]; 195 *upmToPMRule = kConversionRules[i][1];
229 196
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // The PM conversions assume colors are 0..255 268 // The PM conversions assume colors are 0..255
302 return NULL; 269 return NULL;
303 } 270 }
304 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, 271 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture,
305 swapRedAndB lue, 272 swapRedAndB lue,
306 pmConversio n, 273 pmConversio n,
307 matrix))); 274 matrix)));
308 return CreateEffectRef(effect); 275 return CreateEffectRef(effect);
309 } 276 }
310 } 277 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConfigConversionEffect.h ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698