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 "GrTextureDomain.h" | 8 #include "GrTextureDomain.h" |
9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "GrSimpleTextureEffect.h" | 10 #include "GrSimpleTextureEffect.h" |
11 #include "SkFloatingPoint.h" | 11 #include "SkFloatingPoint.h" |
12 #include "glsl/GrGLSLFragmentProcessor.h" | 12 #include "glsl/GrGLSLFragmentProcessor.h" |
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
14 #include "glsl/GrGLSLProgramDataManager.h" | 14 #include "glsl/GrGLSLProgramDataManager.h" |
| 15 #include "glsl/GrGLSLSampler.h" |
15 #include "glsl/GrGLSLShaderBuilder.h" | 16 #include "glsl/GrGLSLShaderBuilder.h" |
16 #include "glsl/GrGLSLTextureSampler.h" | |
17 #include "glsl/GrGLSLUniformHandler.h" | 17 #include "glsl/GrGLSLUniformHandler.h" |
18 | 18 |
19 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) | 19 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) |
20 : fIndex(index) { | 20 : fIndex(index) { |
21 | 21 |
22 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 22 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
23 if (domain.contains(kFullRect) && kClamp_Mode == mode) { | 23 if (domain.contains(kFullRect) && kClamp_Mode == mode) { |
24 fMode = kIgnore_Mode; | 24 fMode = kIgnore_Mode; |
25 } else { | 25 } else { |
26 fMode = mode; | 26 fMode = mode; |
(...skipping 15 matching lines...) Expand all Loading... |
42 } | 42 } |
43 | 43 |
44 ////////////////////////////////////////////////////////////////////////////// | 44 ////////////////////////////////////////////////////////////////////////////// |
45 | 45 |
46 void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, | 46 void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, |
47 GrGLSLUniformHandler* uniformHandl
er, | 47 GrGLSLUniformHandler* uniformHandl
er, |
48 const GrGLSLCaps* glslCaps, | 48 const GrGLSLCaps* glslCaps, |
49 const GrTextureDomain& textureDoma
in, | 49 const GrTextureDomain& textureDoma
in, |
50 const char* outColor, | 50 const char* outColor, |
51 const SkString& inCoords, | 51 const SkString& inCoords, |
52 const GrGLSLTextureSampler& sample
r, | 52 const GrGLSLSampler& sampler, |
53 const char* inModulateColor) { | 53 const char* inModulateColor) { |
54 SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode); | 54 SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode); |
55 SkDEBUGCODE(fMode = textureDomain.mode();) | 55 SkDEBUGCODE(fMode = textureDomain.mode();) |
56 | 56 |
57 if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) { | 57 if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) { |
58 const char* name; | 58 const char* name; |
59 SkString uniName("TexDom"); | 59 SkString uniName("TexDom"); |
60 if (textureDomain.fIndex >= 0) { | 60 if (textureDomain.fIndex >= 0) { |
61 uniName.appendS32(textureDomain.fIndex); | 61 uniName.appendS32(textureDomain.fIndex); |
62 } | 62 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 193 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); |
194 | 194 |
195 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 195 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
196 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 196 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
197 fGLDomain.sampleTexture(fragBuilder, | 197 fGLDomain.sampleTexture(fragBuilder, |
198 args.fUniformHandler, | 198 args.fUniformHandler, |
199 args.fGLSLCaps, | 199 args.fGLSLCaps, |
200 domain, | 200 domain, |
201 args.fOutputColor, | 201 args.fOutputColor, |
202 coords2D, | 202 coords2D, |
203 args.fSamplers[0], | 203 args.fTexSamplers[0], |
204 args.fInputColor); | 204 args.fInputColor); |
205 } | 205 } |
206 | 206 |
207 void GrGLTextureDomainEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 207 void GrGLTextureDomainEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
208 const GrProcessor& processor) { | 208 const GrProcessor& processor) { |
209 const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureD
omainEffect>(); | 209 const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureD
omainEffect>(); |
210 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 210 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); |
211 fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); | 211 fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); |
212 } | 212 } |
213 | 213 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 294 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
295 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 295 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
296 return GrTextureDomainEffect::Create( | 296 return GrTextureDomainEffect::Create( |
297 d->fTextures[texIdx], | 297 d->fTextures[texIdx], |
298 matrix, | 298 matrix, |
299 domain, | 299 domain, |
300 mode, | 300 mode, |
301 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, | 301 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, |
302 coords); | 302 coords); |
303 } | 303 } |
OLD | NEW |