| OLD | NEW | 
|---|
| 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  Loading... | 
| 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  Loading... | 
| 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 } | 
| OLD | NEW | 
|---|