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 "glsl/GrGLSLFragmentShaderBuilder.h" | 10 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float dst[16], | 127 static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float dst[16], |
128 const SkScalar src[16]) { | 128 const SkScalar src[16]) { |
129 for (int y = 0; y < 4; y++) { | 129 for (int y = 0; y < 4; y++) { |
130 for (int x = 0; x < 4; x++) { | 130 for (int x = 0; x < 4; x++) { |
131 dst[x * 4 + y] = SkScalarToFloat(src[y * 4 + x]); | 131 dst[x * 4 + y] = SkScalarToFloat(src[y * 4 + x]); |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 136 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
137 sk_sp<GrColorSpaceXform> colorSpaceXform, | |
137 const SkScalar coefficients[16], | 138 const SkScalar coefficients[16], |
138 const SkMatrix &matrix, | 139 const SkMatrix &matrix, |
139 const SkShader::TileMode tileModes[2]) | 140 const SkShader::TileMode tileModes[2]) |
140 : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone _FilterMode)) | 141 : INHERITED(texture, std::move(colorSpaceXform), matrix, |
bsalomon
2016/07/15 15:09:24
Should this effect forward on the xform to the acc
Brian Osman
2016/07/15 15:29:02
Ah, that's a good point. The math should come out
| |
142 GrTextureParams(tileModes, GrTextureParams::kNone_FilterMode)) | |
141 , fDomain(GrTextureDomain::IgnoredDomain()) { | 143 , fDomain(GrTextureDomain::IgnoredDomain()) { |
142 this->initClassID<GrBicubicEffect>(); | 144 this->initClassID<GrBicubicEffect>(); |
143 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); | 145 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); |
144 } | 146 } |
145 | 147 |
146 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 148 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
149 sk_sp<GrColorSpaceXform> colorSpaceXform, | |
147 const SkScalar coefficients[16], | 150 const SkScalar coefficients[16], |
148 const SkMatrix &matrix, | 151 const SkMatrix &matrix, |
149 const SkRect& domain) | 152 const SkRect& domain) |
150 : INHERITED(texture, matrix, | 153 : INHERITED(texture, std::move(colorSpaceXform), matrix, |
151 GrTextureParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_ FilterMode)) | 154 GrTextureParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_ FilterMode)) |
152 , fDomain(domain, GrTextureDomain::kClamp_Mode) { | 155 , fDomain(domain, GrTextureDomain::kClamp_Mode) { |
153 this->initClassID<GrBicubicEffect>(); | 156 this->initClassID<GrBicubicEffect>(); |
154 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); | 157 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); |
155 } | 158 } |
156 | 159 |
157 GrBicubicEffect::~GrBicubicEffect() { | 160 GrBicubicEffect::~GrBicubicEffect() { |
158 } | 161 } |
159 | 162 |
160 void GrBicubicEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 163 void GrBicubicEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
(...skipping 18 matching lines...) Expand all Loading... | |
179 | 182 |
180 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); | 183 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); |
181 | 184 |
182 sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) { | 185 sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) { |
183 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 186 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
184 GrProcessorUnitTest::kAlphaTextureIdx; | 187 GrProcessorUnitTest::kAlphaTextureIdx; |
185 SkScalar coefficients[16]; | 188 SkScalar coefficients[16]; |
186 for (int i = 0; i < 16; i++) { | 189 for (int i = 0; i < 16; i++) { |
187 coefficients[i] = d->fRandom->nextSScalar1(); | 190 coefficients[i] = d->fRandom->nextSScalar1(); |
188 } | 191 } |
189 return GrBicubicEffect::Make(d->fTextures[texIdx], coefficients); | 192 return GrBicubicEffect::Make(d->fTextures[texIdx], nullptr, coefficients); |
190 } | 193 } |
191 | 194 |
192 ////////////////////////////////////////////////////////////////////////////// | 195 ////////////////////////////////////////////////////////////////////////////// |
193 | 196 |
194 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, | 197 bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, |
195 GrTextureParams::FilterMode* filterMode) { | 198 GrTextureParams::FilterMode* filterMode) { |
196 if (matrix.isIdentity()) { | 199 if (matrix.isIdentity()) { |
197 *filterMode = GrTextureParams::kNone_FilterMode; | 200 *filterMode = GrTextureParams::kNone_FilterMode; |
198 return false; | 201 return false; |
199 } | 202 } |
(...skipping 14 matching lines...) Expand all Loading... | |
214 // Use bilerp to handle rotation or fractional translation. | 217 // Use bilerp to handle rotation or fractional translation. |
215 *filterMode = GrTextureParams::kBilerp_FilterMode; | 218 *filterMode = GrTextureParams::kBilerp_FilterMode; |
216 } | 219 } |
217 return false; | 220 return false; |
218 } | 221 } |
219 // When we use the bicubic filtering effect each sample is read from the tex ture using | 222 // When we use the bicubic filtering effect each sample is read from the tex ture using |
220 // nearest neighbor sampling. | 223 // nearest neighbor sampling. |
221 *filterMode = GrTextureParams::kNone_FilterMode; | 224 *filterMode = GrTextureParams::kNone_FilterMode; |
222 return true; | 225 return true; |
223 } | 226 } |
OLD | NEW |