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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float
dst[16], | 128 static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float
dst[16], |
129 const
SkScalar src[16]) { | 129 const
SkScalar src[16]) { |
130 for (int y = 0; y < 4; y++) { | 130 for (int y = 0; y < 4; y++) { |
131 for (int x = 0; x < 4; x++) { | 131 for (int x = 0; x < 4; x++) { |
132 dst[x * 4 + y] = SkScalarToFloat(src[y * 4 + x]); | 132 dst[x * 4 + y] = SkScalarToFloat(src[y * 4 + x]); |
133 } | 133 } |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 137 GrBicubicEffect::GrBicubicEffect(GrProcessorDataManager* procDataManager, |
| 138 GrTexture* texture, |
138 const SkScalar coefficients[16], | 139 const SkScalar coefficients[16], |
139 const SkMatrix &matrix, | 140 const SkMatrix &matrix, |
140 const SkShader::TileMode tileModes[2]) | 141 const SkShader::TileMode tileModes[2]) |
141 : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone
_FilterMode)) | 142 : INHERITED(procDataManager, texture, matrix, |
| 143 GrTextureParams(tileModes, GrTextureParams::kNone_FilterMode)) |
142 , fDomain(GrTextureDomain::IgnoredDomain()) { | 144 , fDomain(GrTextureDomain::IgnoredDomain()) { |
143 this->initClassID<GrBicubicEffect>(); | 145 this->initClassID<GrBicubicEffect>(); |
144 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); | 146 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); |
145 } | 147 } |
146 | 148 |
147 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 149 GrBicubicEffect::GrBicubicEffect(GrProcessorDataManager* procDataManager, |
| 150 GrTexture* texture, |
148 const SkScalar coefficients[16], | 151 const SkScalar coefficients[16], |
149 const SkMatrix &matrix, | 152 const SkMatrix &matrix, |
150 const SkRect& domain) | 153 const SkRect& domain) |
151 : INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode, | 154 : INHERITED(procDataManager, texture, matrix, |
152 GrTextureParams::kNone_FilterMode
)) | 155 GrTextureParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_
FilterMode)) |
153 , fDomain(domain, GrTextureDomain::kClamp_Mode) { | 156 , fDomain(domain, GrTextureDomain::kClamp_Mode) { |
154 this->initClassID<GrBicubicEffect>(); | 157 this->initClassID<GrBicubicEffect>(); |
155 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); | 158 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi
cients); |
156 } | 159 } |
157 | 160 |
158 GrBicubicEffect::~GrBicubicEffect() { | 161 GrBicubicEffect::~GrBicubicEffect() { |
159 } | 162 } |
160 | 163 |
161 void GrBicubicEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 164 void GrBicubicEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
162 GrProcessorKeyBuilder* b) const { | 165 GrProcessorKeyBuilder* b) const { |
(...skipping 17 matching lines...) Expand all Loading... |
180 | 183 |
181 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); | 184 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); |
182 | 185 |
183 GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) { | 186 GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) { |
184 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 187 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
185 GrProcessorUnitTest::kAlphaTextureIdx; | 188 GrProcessorUnitTest::kAlphaTextureIdx; |
186 SkScalar coefficients[16]; | 189 SkScalar coefficients[16]; |
187 for (int i = 0; i < 16; i++) { | 190 for (int i = 0; i < 16; i++) { |
188 coefficients[i] = d->fRandom->nextSScalar1(); | 191 coefficients[i] = d->fRandom->nextSScalar1(); |
189 } | 192 } |
190 return GrBicubicEffect::Create(d->fTextures[texIdx], coefficients); | 193 return GrBicubicEffect::Create(d->fProcDataManager, d->fTextures[texIdx], co
efficients); |
191 } | 194 } |
192 | 195 |
193 ////////////////////////////////////////////////////////////////////////////// | 196 ////////////////////////////////////////////////////////////////////////////// |
194 | 197 |
195 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, | 198 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, |
196 GrTextureParams::FilterMode* filterMode)
{ | 199 GrTextureParams::FilterMode* filterMode)
{ |
197 if (matrix.isIdentity()) { | 200 if (matrix.isIdentity()) { |
198 *filterMode = GrTextureParams::kNone_FilterMode; | 201 *filterMode = GrTextureParams::kNone_FilterMode; |
199 return false; | 202 return false; |
200 } | 203 } |
(...skipping 14 matching lines...) Expand all Loading... |
215 // Use bilerp to handle rotation or fractional translation. | 218 // Use bilerp to handle rotation or fractional translation. |
216 *filterMode = GrTextureParams::kBilerp_FilterMode; | 219 *filterMode = GrTextureParams::kBilerp_FilterMode; |
217 } | 220 } |
218 return false; | 221 return false; |
219 } | 222 } |
220 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 223 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
221 // nearest neighbor sampling. | 224 // nearest neighbor sampling. |
222 *filterMode = GrTextureParams::kNone_FilterMode; | 225 *filterMode = GrTextureParams::kNone_FilterMode; |
223 return true; | 226 return true; |
224 } | 227 } |
OLD | NEW |