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 "gl/GrGLContext.h" | 12 #include "gl/GrGLContext.h" |
13 #include "gl/GrGLFragmentProcessor.h" | 13 #include "gl/GrGLFragmentProcessor.h" |
14 #include "gl/builders/GrGLProgramBuilder.h" | 14 #include "gl/builders/GrGLProgramBuilder.h" |
15 #include "glsl/GrGLSLProgramDataManager.h" | 15 #include "glsl/GrGLSLProgramDataManager.h" |
| 16 #include "glsl/GrGLSLTextureSampler.h" |
16 | 17 |
17 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) | 18 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) |
18 : fIndex(index) { | 19 : fIndex(index) { |
19 | 20 |
20 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 21 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
21 if (domain.contains(kFullRect) && kClamp_Mode == mode) { | 22 if (domain.contains(kFullRect) && kClamp_Mode == mode) { |
22 fMode = kIgnore_Mode; | 23 fMode = kIgnore_Mode; |
23 } else { | 24 } else { |
24 fMode = mode; | 25 fMode = mode; |
25 } | 26 } |
(...skipping 12 matching lines...) Expand all Loading... |
38 SkASSERT(fDomain.fTop <= fDomain.fBottom); | 39 SkASSERT(fDomain.fTop <= fDomain.fBottom); |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 ////////////////////////////////////////////////////////////////////////////// | 43 ////////////////////////////////////////////////////////////////////////////// |
43 | 44 |
44 void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder, | 45 void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder, |
45 const GrTextureDomain& textureDoma
in, | 46 const GrTextureDomain& textureDoma
in, |
46 const char* outColor, | 47 const char* outColor, |
47 const SkString& inCoords, | 48 const SkString& inCoords, |
48 const GrGLProcessor::TextureSample
r sampler, | 49 const GrGLSLTextureSampler& sample
r, |
49 const char* inModulateColor) { | 50 const char* inModulateColor) { |
50 SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode); | 51 SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode); |
51 SkDEBUGCODE(fMode = textureDomain.mode();) | 52 SkDEBUGCODE(fMode = textureDomain.mode();) |
52 | 53 |
53 GrGLProgramBuilder* program = builder->getProgramBuilder(); | 54 GrGLProgramBuilder* program = builder->getProgramBuilder(); |
54 | 55 |
55 if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) { | 56 if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) { |
56 const char* name; | 57 const char* name; |
57 SkString uniName("TexDom"); | 58 SkString uniName("TexDom"); |
58 if (textureDomain.fIndex >= 0) { | 59 if (textureDomain.fIndex >= 0) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 292 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
292 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 293 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
293 return GrTextureDomainEffect::Create( | 294 return GrTextureDomainEffect::Create( |
294 d->fTextures[texIdx], | 295 d->fTextures[texIdx], |
295 matrix, | 296 matrix, |
296 domain, | 297 domain, |
297 mode, | 298 mode, |
298 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, | 299 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, |
299 coords); | 300 coords); |
300 } | 301 } |
OLD | NEW |