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

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

Issue 83153006: HQ filtering for tiled/bleed drawBitmap (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix build warning for case where filter mode is unrecognized. Created 7 years 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/gpu/effects/GrBicubicEffect.h ('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 #include "GrBicubicEffect.h" 1 #include "GrBicubicEffect.h"
2 2
3 #define DS(x) SkDoubleToScalar(x) 3 #define DS(x) SkDoubleToScalar(x)
4 4
5 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { 5 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
6 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), 6 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0),
7 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), 7 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0),
8 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), 8 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0),
9 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), 9 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
10 }; 10 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 GrGLShaderVar("c3", kVec4f_GrSLType), 66 GrGLShaderVar("c3", kVec4f_GrSLType),
67 }; 67 };
68 builder->fsEmitFunction(kVec4f_GrSLType, 68 builder->fsEmitFunction(kVec4f_GrSLType,
69 "cubicBlend", 69 "cubicBlend",
70 SK_ARRAY_COUNT(gCubicBlendArgs), 70 SK_ARRAY_COUNT(gCubicBlendArgs),
71 gCubicBlendArgs, 71 gCubicBlendArgs,
72 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" 72 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n"
73 "\tvec4 c = coefficients * ts;\n" 73 "\tvec4 c = coefficients * ts;\n"
74 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3; \n", 74 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3; \n",
75 &cubicBlendName); 75 &cubicBlendName);
76 builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5, 0.5);\n", coords2 D.c_str(), imgInc); 76 builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_s tr(), imgInc);
77 builder->fsCodeAppendf("\tvec2 f = fract(coord / %s);\n", imgInc); 77 // We unnormalize the coord in order to determine our fractional offset (f) within the texel
78 // We then snap coord to a texel center and renormalize. The snap prevents c ases where the
79 // starting coords are near a texel boundary and accumulations of imgInc wou ld cause us to skip/
80 // double hit a texel.
81 builder->fsCodeAppendf("\tcoord /= %s;\n", imgInc);
82 builder->fsCodeAppend("\tvec2 f = fract(coord);\n");
83 builder->fsCodeAppendf("\tcoord = (coord - f + vec2(0.5)) * %s;\n", imgInc);
78 for (int y = 0; y < 4; ++y) { 84 for (int y = 0; y < 4; ++y) {
79 for (int x = 0; x < 4; ++x) { 85 for (int x = 0; x < 4; ++x) {
80 SkString coord; 86 SkString coord;
81 coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1); 87 coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1);
82 builder->fsCodeAppendf("\tvec4 s%d%d = ", x, y); 88 builder->fsCodeAppendf("\tvec4 s%d%d = ", x, y);
83 builder->fsAppendTextureLookup(samplers[0], coord.c_str()); 89 builder->fsAppendTextureLookup(samplers[0], coord.c_str());
84 builder->fsCodeAppend(";\n"); 90 builder->fsCodeAppend(";\n");
85 } 91 }
86 builder->fsCodeAppendf("\tvec4 s%d = %s(%s, f.x, s0%d, s1%d, s2%d, s3%d) ;\n", y, cubicBlendName.c_str(), coeff, y, y, y, y); 92 builder->fsCodeAppendf("\tvec4 s%d = %s(%s, f.x, s0%d, s1%d, s2%d, s3%d) ;\n", y, cubicBlendName.c_str(), coeff, y, y, y, y);
87 } 93 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 const GrDrawTargetCaps&, 158 const GrDrawTargetCaps&,
153 GrTexture* textures[]) { 159 GrTexture* textures[]) {
154 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : 160 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
155 GrEffectUnitTest::kAlphaTextureIdx; 161 GrEffectUnitTest::kAlphaTextureIdx;
156 SkScalar coefficients[16]; 162 SkScalar coefficients[16];
157 for (int i = 0; i < 16; i++) { 163 for (int i = 0; i < 16; i++) {
158 coefficients[i] = random->nextSScalar1(); 164 coefficients[i] = random->nextSScalar1();
159 } 165 }
160 return GrBicubicEffect::Create(textures[texIdx], coefficients); 166 return GrBicubicEffect::Create(textures[texIdx], coefficients);
161 } 167 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698