OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrTextureDomain.h" | 9 #include "GrTextureDomain.h" |
10 #include "GrSimpleTextureEffect.h" | 10 #include "GrSimpleTextureEffect.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 ////////////////////////////////////////////////////////////////////////////// | 166 ////////////////////////////////////////////////////////////////////////////// |
167 | 167 |
168 class GrGLTextureDomainEffect : public GrGLFragmentProcessor { | 168 class GrGLTextureDomainEffect : public GrGLFragmentProcessor { |
169 public: | 169 public: |
170 GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor&
); | 170 GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor&
); |
171 | 171 |
172 virtual void emitCode(GrGLProgramBuilder*, | 172 virtual void emitCode(GrGLFPBuilder*, |
173 const GrFragmentProcessor&, | 173 const GrFragmentProcessor&, |
174 const GrProcessorKey&, | 174 const GrProcessorKey&, |
175 const char* outputColor, | 175 const char* outputColor, |
176 const char* inputColor, | 176 const char* inputColor, |
177 const TransformedCoordsArray&, | 177 const TransformedCoordsArray&, |
178 const TextureSamplerArray&) SK_OVERRIDE; | 178 const TextureSamplerArray&) SK_OVERRIDE; |
179 | 179 |
180 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 180 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; |
181 | 181 |
182 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 182 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
183 | 183 |
184 private: | 184 private: |
185 GrTextureDomain::GLDomain fGLDomain; | 185 GrTextureDomain::GLDomain fGLDomain; |
186 typedef GrGLFragmentProcessor INHERITED; | 186 typedef GrGLFragmentProcessor INHERITED; |
187 }; | 187 }; |
188 | 188 |
189 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendProcessorFactory
& factory, | 189 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendProcessorFactory
& factory, |
190 const GrProcessor&) | 190 const GrProcessor&) |
191 : INHERITED(factory) { | 191 : INHERITED(factory) { |
192 } | 192 } |
193 | 193 |
194 void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder, | 194 void GrGLTextureDomainEffect::emitCode(GrGLFPBuilder* builder, |
195 const GrFragmentProcessor& fp, | 195 const GrFragmentProcessor& fp, |
196 const GrProcessorKey& key, | 196 const GrProcessorKey& key, |
197 const char* outputColor, | 197 const char* outputColor, |
198 const char* inputColor, | 198 const char* inputColor, |
199 const TransformedCoordsArray& coords, | 199 const TransformedCoordsArray& coords, |
200 const TextureSamplerArray& samplers) { | 200 const TextureSamplerArray& samplers) { |
201 const GrTextureDomainEffect& textureDomainEffect = fp.cast<GrTextureDomainEf
fect>(); | 201 const GrTextureDomainEffect& textureDomainEffect = fp.cast<GrTextureDomainEf
fect>(); |
202 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 202 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); |
203 | 203 |
204 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 204 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
205 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); | 205 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
206 fGLDomain.sampleTexture(fsBuilder, domain, outputColor, coords2D, samplers[0
], inputColor); | 206 fGLDomain.sampleTexture(fsBuilder, domain, outputColor, coords2D, samplers[0
], inputColor); |
207 } | 207 } |
208 | 208 |
209 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman, | 209 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman, |
210 const GrProcessor& processor) { | 210 const GrProcessor& processor) { |
211 const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureD
omainEffect>(); | 211 const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureD
omainEffect>(); |
212 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 212 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); |
213 fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); | 213 fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); |
214 } | 214 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); | 298 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); |
299 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f
alse; | 299 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f
alse; |
300 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo
rdSet; | 300 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo
rdSet; |
301 return GrTextureDomainEffect::Create(textures[texIdx], | 301 return GrTextureDomainEffect::Create(textures[texIdx], |
302 matrix, | 302 matrix, |
303 domain, | 303 domain, |
304 mode, | 304 mode, |
305 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 305 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
306 coords); | 306 coords); |
307 } | 307 } |
OLD | NEW |