| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrBicubicEffect.h" | 8 #include "GrBicubicEffect.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float
dst[16], | 120 static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float
dst[16], |
| 121 const
SkScalar src[16]) { | 121 const
SkScalar src[16]) { |
| 122 for (int y = 0; y < 4; y++) { | 122 for (int y = 0; y < 4; y++) { |
| 123 for (int x = 0; x < 4; x++) { | 123 for (int x = 0; x < 4; x++) { |
| 124 dst[x * 4 + y] = SkScalarToFloat(src[y * 4 + x]); | 124 dst[x * 4 + y] = SkScalarToFloat(src[y * 4 + x]); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 GrBicubicEffect::GrBicubicEffect(GrProcessorDataManager* procDataManager, | 129 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
| 130 GrTexture* texture, | |
| 131 const SkScalar coefficients[16], | 130 const SkScalar coefficients[16], |
| 132 const SkMatrix &matrix, | 131 const SkMatrix &matrix, |
| 133 const SkShader::TileMode tileModes[2]) | 132 const SkShader::TileMode tileModes[2]) |
| 134 : INHERITED(procDataManager, texture, matrix, | 133 : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone
_FilterMode)) |
| 135 GrTextureParams(tileModes, GrTextureParams::kNone_FilterMode)) | |
| 136 , fDomain(GrTextureDomain::IgnoredDomain()) { | 134 , fDomain(GrTextureDomain::IgnoredDomain()) { |
| 137 this->initClassID<GrBicubicEffect>(); | 135 this->initClassID<GrBicubicEffect>(); |
| 138 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); | 136 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); |
| 139 } | 137 } |
| 140 | 138 |
| 141 GrBicubicEffect::GrBicubicEffect(GrProcessorDataManager* procDataManager, | 139 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
| 142 GrTexture* texture, | |
| 143 const SkScalar coefficients[16], | 140 const SkScalar coefficients[16], |
| 144 const SkMatrix &matrix, | 141 const SkMatrix &matrix, |
| 145 const SkRect& domain) | 142 const SkRect& domain) |
| 146 : INHERITED(procDataManager, texture, matrix, | 143 : INHERITED(texture, matrix, |
| 147 GrTextureParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_
FilterMode)) | 144 GrTextureParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_
FilterMode)) |
| 148 , fDomain(domain, GrTextureDomain::kClamp_Mode) { | 145 , fDomain(domain, GrTextureDomain::kClamp_Mode) { |
| 149 this->initClassID<GrBicubicEffect>(); | 146 this->initClassID<GrBicubicEffect>(); |
| 150 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); | 147 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); |
| 151 } | 148 } |
| 152 | 149 |
| 153 GrBicubicEffect::~GrBicubicEffect() { | 150 GrBicubicEffect::~GrBicubicEffect() { |
| 154 } | 151 } |
| 155 | 152 |
| 156 void GrBicubicEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 153 void GrBicubicEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 175 | 172 |
| 176 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); | 173 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); |
| 177 | 174 |
| 178 const GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) { | 175 const GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) { |
| 179 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 176 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
| 180 GrProcessorUnitTest::kAlphaTextureIdx; | 177 GrProcessorUnitTest::kAlphaTextureIdx; |
| 181 SkScalar coefficients[16]; | 178 SkScalar coefficients[16]; |
| 182 for (int i = 0; i < 16; i++) { | 179 for (int i = 0; i < 16; i++) { |
| 183 coefficients[i] = d->fRandom->nextSScalar1(); | 180 coefficients[i] = d->fRandom->nextSScalar1(); |
| 184 } | 181 } |
| 185 return GrBicubicEffect::Create(d->fProcDataManager, d->fTextures[texIdx], co
efficients); | 182 return GrBicubicEffect::Create(d->fTextures[texIdx], coefficients); |
| 186 } | 183 } |
| 187 | 184 |
| 188 ////////////////////////////////////////////////////////////////////////////// | 185 ////////////////////////////////////////////////////////////////////////////// |
| 189 | 186 |
| 190 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, | 187 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, |
| 191 GrTextureParams::FilterMode* filterMode)
{ | 188 GrTextureParams::FilterMode* filterMode)
{ |
| 192 if (matrix.isIdentity()) { | 189 if (matrix.isIdentity()) { |
| 193 *filterMode = GrTextureParams::kNone_FilterMode; | 190 *filterMode = GrTextureParams::kNone_FilterMode; |
| 194 return false; | 191 return false; |
| 195 } | 192 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 210 // Use bilerp to handle rotation or fractional translation. | 207 // Use bilerp to handle rotation or fractional translation. |
| 211 *filterMode = GrTextureParams::kBilerp_FilterMode; | 208 *filterMode = GrTextureParams::kBilerp_FilterMode; |
| 212 } | 209 } |
| 213 return false; | 210 return false; |
| 214 } | 211 } |
| 215 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 212 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
| 216 // nearest neighbor sampling. | 213 // nearest neighbor sampling. |
| 217 *filterMode = GrTextureParams::kNone_FilterMode; | 214 *filterMode = GrTextureParams::kNone_FilterMode; |
| 218 return true; | 215 return true; |
| 219 } | 216 } |
| OLD | NEW |