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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } else { | 21 } else { |
22 fMode = mode; | 22 fMode = mode; |
23 } | 23 } |
24 | 24 |
25 if (fMode != kIgnore_Mode) { | 25 if (fMode != kIgnore_Mode) { |
26 // We don't currently handle domains that are empty or don't intersect t
he texture. | 26 // We don't currently handle domains that are empty or don't intersect t
he texture. |
27 // It is OK if the domain rect is a line or point, but it should not be
inverted. We do not | 27 // It is OK if the domain rect is a line or point, but it should not be
inverted. We do not |
28 // handle rects that do not intersect the [0..1]x[0..1] rect. | 28 // handle rects that do not intersect the [0..1]x[0..1] rect. |
29 SkASSERT(domain.fLeft <= domain.fRight); | 29 SkASSERT(domain.fLeft <= domain.fRight); |
30 SkASSERT(domain.fTop <= domain.fBottom); | 30 SkASSERT(domain.fTop <= domain.fBottom); |
31 fDomain.fLeft = SkMaxScalar(domain.fLeft, kFullRect.fLeft); | 31 fDomain.fLeft = SkScalarPin(domain.fLeft, kFullRect.fLeft, kFullRect.fRi
ght); |
32 fDomain.fRight = SkMinScalar(domain.fRight, kFullRect.fRight); | 32 fDomain.fRight = SkScalarPin(domain.fRight, kFullRect.fLeft, kFullRect.f
Right); |
33 fDomain.fTop = SkMaxScalar(domain.fTop, kFullRect.fTop); | 33 fDomain.fTop = SkScalarPin(domain.fTop, kFullRect.fTop, kFullRect.fBotto
m); |
34 fDomain.fBottom = SkMinScalar(domain.fBottom, kFullRect.fBottom); | 34 fDomain.fBottom = SkScalarPin(domain.fBottom, kFullRect.fTop, kFullRect.
fBottom); |
35 SkASSERT(fDomain.fLeft <= fDomain.fRight); | 35 SkASSERT(fDomain.fLeft <= fDomain.fRight); |
36 SkASSERT(fDomain.fTop <= fDomain.fBottom); | 36 SkASSERT(fDomain.fTop <= fDomain.fBottom); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 ////////////////////////////////////////////////////////////////////////////// | 40 ////////////////////////////////////////////////////////////////////////////// |
41 | 41 |
42 void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder, | 42 void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder, |
43 const GrTextureDomain& textureDoma
in, | 43 const GrTextureDomain& textureDoma
in, |
44 const char* outColor, | 44 const char* outColor, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); | 302 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); |
303 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f
alse; | 303 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f
alse; |
304 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoord
Set; | 304 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoord
Set; |
305 return GrTextureDomainEffect::Create(textures[texIdx], | 305 return GrTextureDomainEffect::Create(textures[texIdx], |
306 matrix, | 306 matrix, |
307 domain, | 307 domain, |
308 mode, | 308 mode, |
309 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 309 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
310 coords); | 310 coords); |
311 } | 311 } |
OLD | NEW |