| 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 "GrTextureDomainEffect.h" | 8 #include "GrTextureDomainEffect.h" |
| 9 #include "GrSimpleTextureEffect.h" | 9 #include "GrSimpleTextureEffect.h" |
| 10 #include "GrTBackendEffectFactory.h" | 10 #include "GrTBackendEffectFactory.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n", | 60 builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n", |
| 61 coords, domain, domain); | 61 coords, domain, domain); |
| 62 | 62 |
| 63 builder->fsCodeAppendf("\t%s = ", outputColor); | 63 builder->fsCodeAppendf("\t%s = ", outputColor); |
| 64 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha
derType, | 64 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha
derType, |
| 65 inputColor, | 65 inputColor, |
| 66 samplers[0], | 66 samplers[0], |
| 67 "clampCoord"); | 67 "clampCoord"); |
| 68 builder->fsCodeAppend(";\n"); | 68 builder->fsCodeAppend(";\n"); |
| 69 } else { | 69 } else { |
| 70 GrAssert(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode()); | 70 SkASSERT(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode()); |
| 71 | 71 |
| 72 if (kImagination_GrGLVendor == builder->ctxInfo().vendor()) { | 72 if (kImagination_GrGLVendor == builder->ctxInfo().vendor()) { |
| 73 // On the NexusS and GalaxyNexus, the other path (with the 'any' | 73 // On the NexusS and GalaxyNexus, the other path (with the 'any' |
| 74 // call) causes the compilation error "Calls to any function that | 74 // call) causes the compilation error "Calls to any function that |
| 75 // may require a gradient calculation inside a conditional block | 75 // may require a gradient calculation inside a conditional block |
| 76 // may return undefined results". This appears to be an issue with | 76 // may return undefined results". This appears to be an issue with |
| 77 // the 'any' call since even the simple "result=black; if (any()) | 77 // the 'any' call since even the simple "result=black; if (any()) |
| 78 // result=white;" code fails to compile. | 78 // result=white;" code fails to compile. |
| 79 builder->fsCodeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\n"
); | 79 builder->fsCodeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\n"
); |
| 80 builder->fsCodeAppend("\tvec4 inside = "); | 80 builder->fsCodeAppend("\tvec4 inside = "); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 GrTextureParams::FilterMode filterMod
e, | 155 GrTextureParams::FilterMode filterMod
e, |
| 156 CoordsType coordsType) { | 156 CoordsType coordsType) { |
| 157 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 157 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
| 158 if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) { | 158 if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) { |
| 159 return GrSimpleTextureEffect::Create(texture, matrix, filterMode); | 159 return GrSimpleTextureEffect::Create(texture, matrix, filterMode); |
| 160 } else { | 160 } else { |
| 161 SkRect clippedDomain; | 161 SkRect clippedDomain; |
| 162 // We don't currently handle domains that are empty or don't intersect t
he texture. | 162 // We don't currently handle domains that are empty or don't intersect t
he texture. |
| 163 // It is OK if the domain rect is a line or point, but it should not be
inverted. We do not | 163 // It is OK if the domain rect is a line or point, but it should not be
inverted. We do not |
| 164 // handle rects that do not intersect the [0..1]x[0..1] rect. | 164 // handle rects that do not intersect the [0..1]x[0..1] rect. |
| 165 GrAssert(domain.fLeft <= domain.fRight); | 165 SkASSERT(domain.fLeft <= domain.fRight); |
| 166 GrAssert(domain.fTop <= domain.fBottom); | 166 SkASSERT(domain.fTop <= domain.fBottom); |
| 167 clippedDomain.fLeft = SkMaxScalar(domain.fLeft, kFullRect.fLeft); | 167 clippedDomain.fLeft = SkMaxScalar(domain.fLeft, kFullRect.fLeft); |
| 168 clippedDomain.fRight = SkMinScalar(domain.fRight, kFullRect.fRight); | 168 clippedDomain.fRight = SkMinScalar(domain.fRight, kFullRect.fRight); |
| 169 clippedDomain.fTop = SkMaxScalar(domain.fTop, kFullRect.fTop); | 169 clippedDomain.fTop = SkMaxScalar(domain.fTop, kFullRect.fTop); |
| 170 clippedDomain.fBottom = SkMinScalar(domain.fBottom, kFullRect.fBottom); | 170 clippedDomain.fBottom = SkMinScalar(domain.fBottom, kFullRect.fBottom); |
| 171 GrAssert(clippedDomain.fLeft <= clippedDomain.fRight); | 171 SkASSERT(clippedDomain.fLeft <= clippedDomain.fRight); |
| 172 GrAssert(clippedDomain.fTop <= clippedDomain.fBottom); | 172 SkASSERT(clippedDomain.fTop <= clippedDomain.fBottom); |
| 173 | 173 |
| 174 AutoEffectUnref effect(SkNEW_ARGS(GrTextureDomainEffect, (texture, | 174 AutoEffectUnref effect(SkNEW_ARGS(GrTextureDomainEffect, (texture, |
| 175 matrix, | 175 matrix, |
| 176 clippedDomain, | 176 clippedDomain, |
| 177 wrapMode, | 177 wrapMode, |
| 178 filterMode, | 178 filterMode, |
| 179 coordsType))); | 179 coordsType))); |
| 180 return CreateEffectRef(effect); | 180 return CreateEffectRef(effect); |
| 181 | 181 |
| 182 } | 182 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 234 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
| 235 bool bilerp = random->nextBool(); | 235 bool bilerp = random->nextBool(); |
| 236 CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_Coord
sType; | 236 CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_Coord
sType; |
| 237 return GrTextureDomainEffect::Create(textures[texIdx], | 237 return GrTextureDomainEffect::Create(textures[texIdx], |
| 238 matrix, | 238 matrix, |
| 239 domain, | 239 domain, |
| 240 wrapMode, | 240 wrapMode, |
| 241 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 241 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
| 242 coords); | 242 coords); |
| 243 } | 243 } |
| OLD | NEW |