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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 const GrDrawTargetCaps&, | 170 const GrDrawTargetCaps&, |
171 GrTexture* textures[]) { | 171 GrTexture* textures[]) { |
172 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 172 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
173 GrEffectUnitTest::kAlphaTextureIdx; | 173 GrEffectUnitTest::kAlphaTextureIdx; |
174 SkScalar coefficients[16]; | 174 SkScalar coefficients[16]; |
175 for (int i = 0; i < 16; i++) { | 175 for (int i = 0; i < 16; i++) { |
176 coefficients[i] = random->nextSScalar1(); | 176 coefficients[i] = random->nextSScalar1(); |
177 } | 177 } |
178 return GrBicubicEffect::Create(textures[texIdx], coefficients); | 178 return GrBicubicEffect::Create(textures[texIdx], coefficients); |
179 } | 179 } |
180 | |
181 ////////////////////////////////////////////////////////////////////////////// | |
182 | |
183 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, | |
184 GrTextureParams::FilterMode* filterMode) { | |
185 if (matrix.isIdentity()) { | |
186 *filterMode = GrTextureParams::kNone_FilterMode; | |
187 return false; | |
188 } | |
189 | |
190 SkScalar scales[2]; | |
191 if (!matrix.getScaleFactors(scales) || scales[0] < SK_Scalar1) { | |
robertphillips
2014/05/20 15:34:50
// b.c. the min scale factor is causing we will us
bsalomon
2014/05/20 16:13:06
Done.
| |
192 *filterMode = GrTextureParams::kMipMap_FilterMode; | |
193 return false; | |
194 } | |
robertphillips
2014/05/20 15:34:50
scales ?
bsalomon
2014/05/20 16:13:06
Done.
| |
195 // At this point if sacles[1] == SK_Scalar1 then the matrix doesn't do any s caling. | |
196 if (scales[1] == SK_Scalar1) { | |
197 if (matrix.rectStaysRect() && SkScalarIsInt(matrix.getTranslateX()) && | |
198 SkScalarIsInt(matrix.getTranslateY())) { | |
199 *filterMode = GrTextureParams::kNone_FilterMode; | |
200 } else { | |
201 *filterMode = GrTextureParams::kBilerp_FilterMode; | |
robertphillips
2014/05/20 15:34:50
// need bilerp in this case to handle the fraction
bsalomon
2014/05/20 16:13:06
Done.
| |
202 } | |
203 return false; | |
204 } | |
205 return true; | |
206 } | |
OLD | NEW |