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 #include "GrMatrixConvolutionEffect.h" | 7 #include "GrMatrixConvolutionEffect.h" |
8 #include "gl/GrGLShaderBuilder.h" | 8 #include "gl/GrGLShaderBuilder.h" |
9 #include "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 const char* inputColor, | 22 const char* inputColor, |
23 const TransformedCoordsArray&, | 23 const TransformedCoordsArray&, |
24 const TextureSamplerArray&) SK_OVERRIDE; | 24 const TextureSamplerArray&) SK_OVERRIDE; |
25 | 25 |
26 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); | 26 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); |
27 | 27 |
28 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 28 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; |
29 | 29 |
30 private: | 30 private: |
31 typedef GrGLUniformManager::UniformHandle UniformHandle; | 31 typedef GrGLUniformManager::UniformHandle UniformHandle; |
32 typedef GrMatrixConvolutionEffect::TileMode TileMode; | 32 SkISize fKernelSize; |
33 SkISize fKernelSize; | 33 bool fConvolveAlpha; |
34 TileMode fTileMode; | |
35 bool fConvolveAlpha; | |
36 | 34 |
37 UniformHandle fBoundsUni; | 35 UniformHandle fBoundsUni; |
38 UniformHandle fKernelUni; | 36 UniformHandle fKernelUni; |
39 UniformHandle fImageIncrementUni; | 37 UniformHandle fImageIncrementUni; |
40 UniformHandle fKernelOffsetUni; | 38 UniformHandle fKernelOffsetUni; |
41 UniformHandle fGainUni; | 39 UniformHandle fGainUni; |
42 UniformHandle fBiasUni; | 40 UniformHandle fBiasUni; |
| 41 GrTextureDomain::GLDomain fDomain; |
43 | 42 |
44 typedef GrGLEffect INHERITED; | 43 typedef GrGLEffect INHERITED; |
45 }; | 44 }; |
46 | 45 |
47 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFa
ctory& factory, | 46 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFa
ctory& factory, |
48 const GrDrawEffect& dra
wEffect) | 47 const GrDrawEffect& dra
wEffect) |
49 : INHERITED(factory) { | 48 : INHERITED(factory) { |
50 const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvoluti
onEffect>(); | 49 const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvoluti
onEffect>(); |
51 fKernelSize = m.kernelSize(); | 50 fKernelSize = m.kernelSize(); |
52 fTileMode = m.tileMode(); | |
53 fConvolveAlpha = m.convolveAlpha(); | 51 fConvolveAlpha = m.convolveAlpha(); |
54 } | 52 } |
55 | 53 |
56 static void appendTextureLookup(GrGLShaderBuilder* builder, | |
57 const GrGLShaderBuilder::TextureSampler& sampler
, | |
58 const char* coord, | |
59 const char* bounds, | |
60 GrMatrixConvolutionEffect::TileMode tileMode) { | |
61 SkString clampedCoord; | |
62 switch (tileMode) { | |
63 case GrMatrixConvolutionEffect::kClamp_TileMode: | |
64 clampedCoord.printf("clamp(%s, %s.xy, %s.zw)", coord, bounds, bounds
); | |
65 coord = clampedCoord.c_str(); | |
66 break; | |
67 case GrMatrixConvolutionEffect::kRepeat_TileMode: | |
68 clampedCoord.printf("mod(%s - %s.xy, %s.zw - %s.xy) + %s.xy", coord,
bounds, bounds, bounds, bounds); | |
69 coord = clampedCoord.c_str(); | |
70 break; | |
71 case GrMatrixConvolutionEffect::kClampToBlack_TileMode: | |
72 builder->fsCodeAppendf("clamp(%s, %s.xy, %s.zw) != %s ? vec4(0, 0, 0
, 0) : ", coord, bounds, bounds, coord); | |
73 break; | |
74 } | |
75 builder->fsAppendTextureLookup(sampler, coord); | |
76 } | |
77 | |
78 void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder, | 54 void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder, |
79 const GrDrawEffect&, | 55 const GrDrawEffect& drawEffect, |
80 const GrEffectKey& key, | 56 const GrEffectKey& key, |
81 const char* outputColor, | 57 const char* outputColor, |
82 const char* inputColor, | 58 const char* inputColor, |
83 const TransformedCoordsArray& coords, | 59 const TransformedCoordsArray& coords, |
84 const TextureSamplerArray& samplers)
{ | 60 const TextureSamplerArray& samplers)
{ |
85 sk_ignore_unused_variable(inputColor); | 61 sk_ignore_unused_variable(inputColor); |
| 62 const GrTextureDomain& domain = drawEffect.castEffect<GrMatrixConvolutionEff
ect>().domain(); |
86 SkString coords2D = builder->ensureFSCoords2D(coords, 0); | 63 SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
87 fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 64 fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
88 kVec4f_GrSLType, "Bounds"); | 65 kVec4f_GrSLType, "Bounds"); |
89 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, | 66 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, |
90 kVec2f_GrSLType, "ImageIncrement"); | 67 kVec2f_GrSLType, "ImageIncrement"); |
91 fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibilit
y, | 68 fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibilit
y, |
92 kFloat_GrSLType, | 69 kFloat_GrSLType, |
93 "Kernel", | 70 "Kernel", |
94 fKernelSize.width() * fKernelSize.h
eight()); | 71 fKernelSize.width() * fKernelSize.heig
ht()); |
95 fKernelOffsetUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, | 72 fKernelOffsetUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, |
96 kVec2f_GrSLType, "KernelOffset"); | 73 kVec2f_GrSLType, "KernelOffset"); |
97 fGainUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 74 fGainUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
98 kFloat_GrSLType, "Gain"); | 75 kFloat_GrSLType, "Gain"); |
99 fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 76 fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
100 kFloat_GrSLType, "Bias"); | 77 kFloat_GrSLType, "Bias"); |
101 | 78 |
102 const char* bounds = builder->getUniformCStr(fBoundsUni); | |
103 const char* kernelOffset = builder->getUniformCStr(fKernelOffsetUni); | 79 const char* kernelOffset = builder->getUniformCStr(fKernelOffsetUni); |
104 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); | 80 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
105 const char* kernel = builder->getUniformCStr(fKernelUni); | 81 const char* kernel = builder->getUniformCStr(fKernelUni); |
106 const char* gain = builder->getUniformCStr(fGainUni); | 82 const char* gain = builder->getUniformCStr(fGainUni); |
107 const char* bias = builder->getUniformCStr(fBiasUni); | 83 const char* bias = builder->getUniformCStr(fBiasUni); |
108 int kWidth = fKernelSize.width(); | 84 int kWidth = fKernelSize.width(); |
109 int kHeight = fKernelSize.height(); | 85 int kHeight = fKernelSize.height(); |
110 | 86 |
111 builder->fsCodeAppend("\t\tvec4 sum = vec4(0, 0, 0, 0);\n"); | 87 builder->fsCodeAppend("\t\tvec4 sum = vec4(0, 0, 0, 0);\n"); |
112 builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords2D.c_str(),
kernelOffset, imgInc); | 88 builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords2D.c_str(),
kernelOffset, |
113 builder->fsCodeAppendf("\t\tfor (int y = 0; y < %d; y++) {\n", kHeight); | 89 imgInc); |
114 builder->fsCodeAppendf("\t\t\tfor (int x = 0; x < %d; x++) {\n", kWidth); | 90 builder->fsCodeAppend("\t\tvec4 c;\n"); |
115 builder->fsCodeAppendf("\t\t\t\tfloat k = %s[y * %d + x];\n", kernel, kWidth
); | 91 |
116 builder->fsCodeAppendf("\t\t\t\tvec2 coord2 = coord + vec2(x, y) * %s;\n", i
mgInc); | 92 for (int y = 0; y < kHeight; y++) { |
117 builder->fsCodeAppend("\t\t\t\tvec4 c = "); | 93 for (int x = 0; x < kWidth; x++) { |
118 appendTextureLookup(builder, samplers[0], "coord2", bounds, fTileMode); | 94 GrGLShaderBuilder::FSBlock block(builder); |
119 builder->fsCodeAppend(";\n"); | 95 builder->fsCodeAppendf("\t\tfloat k = %s[%d * %d + %d];\n", kernel,
y, kWidth, x); |
120 if (!fConvolveAlpha) { | 96 SkString coord; |
121 builder->fsCodeAppend("\t\t\t\tc.rgb /= c.a;\n"); | 97 coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc); |
| 98 fDomain.sampleTexture(builder, domain, "c", coord, samplers[0]); |
| 99 if (!fConvolveAlpha) { |
| 100 builder->fsCodeAppend("\t\tc.rgb /= c.a;\n"); |
| 101 } |
| 102 builder->fsCodeAppend("\t\tsum += c * k;\n"); |
| 103 } |
122 } | 104 } |
123 builder->fsCodeAppend("\t\t\t\tsum += c * k;\n"); | |
124 builder->fsCodeAppend("\t\t\t}\n"); | |
125 builder->fsCodeAppend("\t\t}\n"); | |
126 if (fConvolveAlpha) { | 105 if (fConvolveAlpha) { |
127 builder->fsCodeAppendf("\t\t%s = sum * %s + %s;\n", outputColor, gain, b
ias); | 106 builder->fsCodeAppendf("\t\t%s = sum * %s + %s;\n", outputColor, gain, b
ias); |
128 builder->fsCodeAppendf("\t\t%s.rgb = clamp(%s.rgb, 0.0, %s.a);\n", | 107 builder->fsCodeAppendf("\t\t%s.rgb = clamp(%s.rgb, 0.0, %s.a);\n", |
129 outputColor, outputColor, outputColor); | 108 outputColor, outputColor, outputColor); |
130 } else { | 109 } else { |
131 builder->fsCodeAppend("\t\tvec4 c = "); | 110 fDomain.sampleTexture(builder, domain, "c", coords2D, samplers[0]); |
132 appendTextureLookup(builder, samplers[0], coords2D.c_str(), bounds, fTil
eMode); | |
133 builder->fsCodeAppend(";\n"); | |
134 builder->fsCodeAppendf("\t\t%s.a = c.a;\n", outputColor); | 111 builder->fsCodeAppendf("\t\t%s.a = c.a;\n", outputColor); |
135 builder->fsCodeAppendf("\t\t%s.rgb = sum.rgb * %s + %s;\n", outputColor,
gain, bias); | 112 builder->fsCodeAppendf("\t\t%s.rgb = sum.rgb * %s + %s;\n", outputColor,
gain, bias); |
136 builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor
); | 113 builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor
); |
137 } | 114 } |
138 } | 115 } |
139 | 116 |
140 namespace { | |
141 | |
142 int encodeXY(int x, int y) { | |
143 SkASSERT(x >= 1 && y >= 1 && x * y <= 32); | |
144 if (y < x) | |
145 return 0x40 | encodeXY(y, x); | |
146 else | |
147 return (0x40 >> x) | (y - x); | |
148 } | |
149 | |
150 }; | |
151 | |
152 void GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect, | 117 void GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect, |
153 const GrGLCaps&, GrEffectKeyBuilder* b)
{ | 118 const GrGLCaps&, GrEffectKeyBuilder* b)
{ |
154 const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvoluti
onEffect>(); | 119 const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvoluti
onEffect>(); |
155 uint32_t key = encodeXY(m.kernelSize().width(), m.kernelSize().height()); | 120 SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFF
FF); |
156 key |= m.tileMode() << 7; | 121 uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height(); |
157 key |= m.convolveAlpha() ? 1 << 9 : 0; | 122 key |= m.convolveAlpha() ? 1 << 31 : 0; |
158 b->add32(key); | 123 b->add32(key); |
| 124 b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain())); |
159 } | 125 } |
160 | 126 |
161 void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman, | 127 void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman, |
162 const GrDrawEffect& drawEffect) { | 128 const GrDrawEffect& drawEffect) { |
163 const GrMatrixConvolutionEffect& conv = drawEffect.castEffect<GrMatrixConvol
utionEffect>(); | 129 const GrMatrixConvolutionEffect& conv = drawEffect.castEffect<GrMatrixConvol
utionEffect>(); |
164 GrTexture& texture = *conv.texture(0); | 130 GrTexture& texture = *conv.texture(0); |
165 // the code we generated was for a specific kernel size | 131 // the code we generated was for a specific kernel size |
166 SkASSERT(conv.kernelSize() == fKernelSize); | 132 SkASSERT(conv.kernelSize() == fKernelSize); |
167 SkASSERT(conv.tileMode() == fTileMode); | |
168 float imageIncrement[2]; | 133 float imageIncrement[2]; |
169 float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; | 134 float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; |
170 imageIncrement[0] = 1.0f / texture.width(); | 135 imageIncrement[0] = 1.0f / texture.width(); |
171 imageIncrement[1] = ySign / texture.height(); | 136 imageIncrement[1] = ySign / texture.height(); |
172 uman.set2fv(fImageIncrementUni, 1, imageIncrement); | 137 uman.set2fv(fImageIncrementUni, 1, imageIncrement); |
173 uman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset()); | 138 uman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset()); |
174 uman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.ker
nel()); | 139 uman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.ker
nel()); |
175 uman.set1f(fGainUni, conv.gain()); | 140 uman.set1f(fGainUni, conv.gain()); |
176 uman.set1f(fBiasUni, conv.bias()); | 141 uman.set1f(fBiasUni, conv.bias()); |
177 const SkIRect& bounds = conv.bounds(); | 142 fDomain.setData(uman, conv.domain(), texture.origin()); |
178 float left = (float) bounds.left() / texture.width(); | |
179 float top = (float) bounds.top() / texture.height(); | |
180 float right = (float) bounds.right() / texture.width(); | |
181 float bottom = (float) bounds.bottom() / texture.height(); | |
182 if (texture.origin() == kBottomLeft_GrSurfaceOrigin) { | |
183 uman.set4f(fBoundsUni, left, 1.0f - bottom, right, 1.0f - top); | |
184 } else { | |
185 uman.set4f(fBoundsUni, left, top, right, bottom); | |
186 } | |
187 } | 143 } |
188 | 144 |
189 GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, | 145 GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, |
190 const SkIRect& bounds, | 146 const SkIRect& bounds, |
191 const SkISize& kernelSize, | 147 const SkISize& kernelSize, |
192 const SkScalar* kernel, | 148 const SkScalar* kernel, |
193 SkScalar gain, | 149 SkScalar gain, |
194 SkScalar bias, | 150 SkScalar bias, |
195 const SkIPoint& kernelOffse
t, | 151 const SkIPoint& kernelOffse
t, |
196 TileMode tileMode, | 152 GrTextureDomain::Mode tileM
ode, |
197 bool convolveAlpha) | 153 bool convolveAlpha) |
198 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)), | 154 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)), |
199 fBounds(bounds), | |
200 fKernelSize(kernelSize), | 155 fKernelSize(kernelSize), |
201 fGain(SkScalarToFloat(gain)), | 156 fGain(SkScalarToFloat(gain)), |
202 fBias(SkScalarToFloat(bias) / 255.0f), | 157 fBias(SkScalarToFloat(bias) / 255.0f), |
203 fTileMode(tileMode), | 158 fConvolveAlpha(convolveAlpha), |
204 fConvolveAlpha(convolveAlpha) { | 159 fDomain(GrTextureDomain::MakeTexelDomain(texture, bounds), tileMode) { |
205 fKernel = new float[kernelSize.width() * kernelSize.height()]; | 160 fKernel = new float[kernelSize.width() * kernelSize.height()]; |
206 for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { | 161 for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { |
207 fKernel[i] = SkScalarToFloat(kernel[i]); | 162 fKernel[i] = SkScalarToFloat(kernel[i]); |
208 } | 163 } |
209 fKernelOffset[0] = static_cast<float>(kernelOffset.x()); | 164 fKernelOffset[0] = static_cast<float>(kernelOffset.x()); |
210 fKernelOffset[1] = static_cast<float>(kernelOffset.y()); | 165 fKernelOffset[1] = static_cast<float>(kernelOffset.y()); |
211 this->setWillNotUseInputColor(); | 166 this->setWillNotUseInputColor(); |
212 } | 167 } |
213 | 168 |
214 GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() { | 169 GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() { |
215 delete[] fKernel; | 170 delete[] fKernel; |
216 } | 171 } |
217 | 172 |
218 const GrBackendEffectFactory& GrMatrixConvolutionEffect::getFactory() const { | 173 const GrBackendEffectFactory& GrMatrixConvolutionEffect::getFactory() const { |
219 return GrTBackendEffectFactory<GrMatrixConvolutionEffect>::getInstance(); | 174 return GrTBackendEffectFactory<GrMatrixConvolutionEffect>::getInstance(); |
220 } | 175 } |
221 | 176 |
222 bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const { | 177 bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const { |
223 const GrMatrixConvolutionEffect& s = CastEffect<GrMatrixConvolutionEffect>(s
Base); | 178 const GrMatrixConvolutionEffect& s = CastEffect<GrMatrixConvolutionEffect>(s
Base); |
224 return this->texture(0) == s.texture(0) && | 179 return this->texture(0) == s.texture(0) && |
225 fKernelSize == s.kernelSize() && | 180 fKernelSize == s.kernelSize() && |
226 !memcmp(fKernel, s.kernel(), | 181 !memcmp(fKernel, s.kernel(), |
227 fKernelSize.width() * fKernelSize.height() * sizeof(float)) &
& | 182 fKernelSize.width() * fKernelSize.height() * sizeof(float)) &
& |
228 fGain == s.gain() && | 183 fGain == s.gain() && |
229 fBias == s.bias() && | 184 fBias == s.bias() && |
230 fKernelOffset == s.kernelOffset() && | 185 fKernelOffset == s.kernelOffset() && |
231 fTileMode == s.tileMode() && | 186 fConvolveAlpha == s.convolveAlpha() && |
232 fConvolveAlpha == s.convolveAlpha(); | 187 fDomain == s.domain(); |
233 } | 188 } |
234 | 189 |
235 GR_DEFINE_EFFECT_TEST(GrMatrixConvolutionEffect); | 190 GR_DEFINE_EFFECT_TEST(GrMatrixConvolutionEffect); |
236 | 191 |
237 GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random, | 192 GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random, |
238 GrContext* context, | 193 GrContext* context, |
239 const GrDrawTargetCaps&, | 194 const GrDrawTargetCaps&, |
240 GrTexture* textures[]) { | 195 GrTexture* textures[]) { |
241 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 196 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
242 GrEffectUnitTest::kAlphaTextureIdx; | 197 GrEffectUnitTest::kAlphaTextureIdx; |
243 int width = random->nextRangeU(1, MAX_KERNEL_SIZE); | 198 int width = random->nextRangeU(1, MAX_KERNEL_SIZE); |
244 int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width); | 199 int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width); |
245 SkISize kernelSize = SkISize::Make(width, height); | 200 SkISize kernelSize = SkISize::Make(width, height); |
246 SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); | 201 SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); |
247 for (int i = 0; i < width * height; i++) { | 202 for (int i = 0; i < width * height; i++) { |
248 kernel.get()[i] = random->nextSScalar1(); | 203 kernel.get()[i] = random->nextSScalar1(); |
249 } | 204 } |
250 SkScalar gain = random->nextSScalar1(); | 205 SkScalar gain = random->nextSScalar1(); |
251 SkScalar bias = random->nextSScalar1(); | 206 SkScalar bias = random->nextSScalar1(); |
252 SkIPoint kernelOffset = SkIPoint::Make(random->nextRangeU(0, kernelSize.widt
h()), | 207 SkIPoint kernelOffset = SkIPoint::Make(random->nextRangeU(0, kernelSize.widt
h()), |
253 random->nextRangeU(0, kernelSize.heig
ht())); | 208 random->nextRangeU(0, kernelSize.heig
ht())); |
254 SkIRect bounds = SkIRect::MakeXYWH(random->nextRangeU(0, textures[texIdx]->w
idth()), | 209 SkIRect bounds = SkIRect::MakeXYWH(random->nextRangeU(0, textures[texIdx]->w
idth()), |
255 random->nextRangeU(0, textures[texIdx]->h
eight()), | 210 random->nextRangeU(0, textures[texIdx]->h
eight()), |
256 random->nextRangeU(0, textures[texIdx]->w
idth()), | 211 random->nextRangeU(0, textures[texIdx]->w
idth()), |
257 random->nextRangeU(0, textures[texIdx]->h
eight())); | 212 random->nextRangeU(0, textures[texIdx]->h
eight())); |
258 TileMode tileMode = static_cast<TileMode>(random->nextRangeU(0, 2)); | 213 GrTextureDomain::Mode tileMode = static_cast<GrTextureDomain::Mode>(random->
nextRangeU(0, 2)); |
259 bool convolveAlpha = random->nextBool(); | 214 bool convolveAlpha = random->nextBool(); |
260 return GrMatrixConvolutionEffect::Create(textures[texIdx], | 215 return GrMatrixConvolutionEffect::Create(textures[texIdx], |
261 bounds, | 216 bounds, |
262 kernelSize, | 217 kernelSize, |
263 kernel.get(), | 218 kernel.get(), |
264 gain, | 219 gain, |
265 bias, | 220 bias, |
266 kernelOffset, | 221 kernelOffset, |
267 tileMode, | 222 tileMode, |
268 convolveAlpha); | 223 convolveAlpha); |
269 } | 224 } |
OLD | NEW |