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

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

Issue 15719007: Make GrGLConfigConversionEffect work on Intel GPUs (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Simplity the shader Created 7 years, 6 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 | « no previous file | 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 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor ); 43 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor );
44 } else { 44 } else {
45 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; 45 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb";
46 switch (fPMConversion) { 46 switch (fPMConversion) {
47 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: 47 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion:
48 builder->fsCodeAppendf( 48 builder->fsCodeAppendf(
49 "\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a) ;\n", 49 "\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a) ;\n",
50 outputColor, outputColor, swiz, outputColor, outputColor ); 50 outputColor, outputColor, swiz, outputColor, outputColor );
51 break; 51 break;
52 case GrConfigConversionEffect::kMulByAlpha_RoundDown_PMConversio n: 52 case GrConfigConversionEffect::kMulByAlpha_RoundDown_PMConversio n:
53 // Add a compensation(0.001) here to avoid the side effect o f the floor operation.
54 // In Intel GPUs, the integer value converted from floor(%s. r * 255.0) / 255.0
55 // is less than the integer value converted from %s.r by 1 when the %s.r is
56 // converted from the integer value 2^n, such as 1, 2, 4, 8, etc.
53 builder->fsCodeAppendf( 57 builder->fsCodeAppendf(
54 "\t\t%s = vec4(floor(%s.%s * %s.a * 255.0) / 255.0, %s.a );\n", 58 "\t\t%s = vec4(floor(%s.%s * %s.a * 255.0 + 0.001) / 255 .0, %s.a);\n",
55 outputColor, outputColor, swiz, outputColor, outputColor ); 59 outputColor, outputColor, swiz, outputColor, outputColor );
56 break; 60 break;
57 case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion: 61 case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion:
58 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", 62 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",
59 outputColor, outputColor, outputColor, swiz, outputColor , outputColor); 63 outputColor, outputColor, outputColor, swiz, outputColor , outputColor);
60 break; 64 break;
61 case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversio n: 65 case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversio n:
62 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", 66 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",
63 outputColor, outputColor, outputColor, swiz, outputColor , outputColor); 67 outputColor, outputColor, outputColor, swiz, outputColor , outputColor);
64 break; 68 break;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // The PM conversions assume colors are 0..255 284 // The PM conversions assume colors are 0..255
281 return NULL; 285 return NULL;
282 } 286 }
283 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, 287 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture,
284 swapRedAndB lue, 288 swapRedAndB lue,
285 pmConversio n, 289 pmConversio n,
286 matrix))); 290 matrix)));
287 return CreateEffectRef(effect); 291 return CreateEffectRef(effect);
288 } 292 }
289 } 293 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698