tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrTextureDomainEffect.h" |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 9 | #include "GrSimpleTextureEffect.h" |
bsalomon@google.com | 2eaaefd | 2012-10-29 19:51:22 +0000 | [diff] [blame] | 10 | #include "GrTBackendEffectFactory.h" |
bsalomon@google.com | d698f77 | 2012-10-25 13:22:00 +0000 | [diff] [blame] | 11 | #include "gl/GrGLEffect.h" |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 12 | #include "gl/GrGLEffectMatrix.h" |
| 13 | #include "SkFloatingPoint.h" |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 14 | |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 15 | class GrGLTextureDomainEffect : public GrGLEffect { |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 16 | public: |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 17 | GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 18 | |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 19 | virtual void emitCode(GrGLShaderBuilder*, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 20 | const GrDrawEffect&, |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 21 | EffectKey, |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 22 | const char* outputColor, |
| 23 | const char* inputColor, |
| 24 | const TextureSamplerArray&) SK_OVERRIDE; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 25 | |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 26 | virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 27 | |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 28 | static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 29 | |
| 30 | private: |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 31 | GrGLUniformManager::UniformHandle fNameUni; |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 32 | GrGLEffectMatrix fEffectMatrix; |
| 33 | GrGLfloat fPrevDomain[4]; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 34 | |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 35 | typedef GrGLEffect INHERITED; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
bsalomon@google.com | 396e61f | 2012-10-25 19:00:29 +0000 | [diff] [blame] | 38 | GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& factory, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 39 | const GrDrawEffect& drawEffect) |
bsalomon@google.com | 374e759 | 2012-10-23 17:30:45 +0000 | [diff] [blame] | 40 | : INHERITED(factory) |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 41 | , fNameUni(GrGLUniformManager::kInvalidUniformHandle) |
| 42 | , fEffectMatrix(drawEffect.castEffect<GrTextureDomainEffect>().coordsType()) { |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 43 | fPrevDomain[0] = SK_FloatNaN; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 44 | } |
| 45 | |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 46 | void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 47 | const GrDrawEffect& drawEffect, |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 48 | EffectKey key, |
bsalomon@google.com | 22a800a | 2012-10-26 19:16:46 +0000 | [diff] [blame] | 49 | const char* outputColor, |
| 50 | const char* inputColor, |
| 51 | const TextureSamplerArray& samplers) { |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 52 | const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>(); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 53 | |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 54 | const char* coords; |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 55 | fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 56 | const char* domain; |
tomhudson@google.com | 57143a2 | 2012-07-17 19:07:35 +0000 | [diff] [blame] | 57 | fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 58 | kVec4f_GrSLType, "TexDom", &domain); |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 59 | if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) { |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 60 | |
bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 61 | builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n", |
| 62 | coords, domain, domain); |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 63 | |
bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 64 | builder->fsCodeAppendf("\t%s = ", outputColor); |
| 65 | builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 66 | inputColor, |
| 67 | samplers[0], |
| 68 | "clampCoord"); |
bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 69 | builder->fsCodeAppend(";\n"); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 70 | } else { |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 71 | GrAssert(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode()); |
robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 72 | |
| 73 | if (kImagination_GrGLVendor == builder->ctxInfo().vendor()) { |
skia.committer@gmail.com | 0c23faf | 2013-03-03 07:16:29 +0000 | [diff] [blame] | 74 | // On the NexusS and GalaxyNexus, the other path (with the 'any' |
| 75 | // call) causes the compilation error "Calls to any function that |
| 76 | // may require a gradient calculation inside a conditional block |
robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 77 | // may return undefined results". This appears to be an issue with |
| 78 | // the 'any' call since even the simple "result=black; if (any()) |
| 79 | // result=white;" code fails to compile. |
bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 80 | builder->fsCodeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\n"); |
| 81 | builder->fsCodeAppend("\tvec4 inside = "); |
| 82 | builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, |
| 83 | inputColor, |
| 84 | samplers[0], |
| 85 | coords); |
| 86 | builder->fsCodeAppend(";\n"); |
robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 87 | |
bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 88 | builder->fsCodeAppendf("\tfloat x = abs(2.0*(%s.x - %s.x)/(%s.z - %s.x) - 1.0);\n", |
| 89 | coords, domain, domain, domain); |
| 90 | builder->fsCodeAppendf("\tfloat y = abs(2.0*(%s.y - %s.y)/(%s.w - %s.y) - 1.0);\n", |
| 91 | coords, domain, domain, domain); |
| 92 | builder->fsCodeAppend("\tfloat blend = step(1.0, max(x, y));\n"); |
| 93 | builder->fsCodeAppendf("\t%s = mix(inside, outside, blend);\n", outputColor); |
robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 94 | } else { |
bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 95 | builder->fsCodeAppend("\tbvec4 outside;\n"); |
| 96 | builder->fsCodeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", coords, domain); |
| 97 | builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", coords, domain); |
| 98 | builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ", outputColor); |
| 99 | builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, |
| 100 | inputColor, |
| 101 | samplers[0], |
| 102 | coords); |
| 103 | builder->fsCodeAppend(";\n"); |
robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 104 | } |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 105 | } |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 106 | } |
| 107 | |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 108 | void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, |
| 109 | const GrDrawEffect& drawEffect) { |
| 110 | const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>(); |
| 111 | const GrRect& domain = texDom.domain(); |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 112 | |
| 113 | float values[4] = { |
bsalomon@google.com | 8171288 | 2012-11-01 17:12:34 +0000 | [diff] [blame] | 114 | SkScalarToFloat(domain.left()), |
| 115 | SkScalarToFloat(domain.top()), |
| 116 | SkScalarToFloat(domain.right()), |
| 117 | SkScalarToFloat(domain.bottom()) |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 118 | }; |
| 119 | // vertical flip if necessary |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 120 | if (kBottomLeft_GrSurfaceOrigin == texDom.texture(0)->origin()) { |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 121 | values[1] = 1.0f - values[1]; |
| 122 | values[3] = 1.0f - values[3]; |
| 123 | // The top and bottom were just flipped, so correct the ordering |
| 124 | // of elements so that values = (l, t, r, b). |
| 125 | SkTSwap(values[1], values[3]); |
| 126 | } |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 127 | if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) { |
| 128 | uman.set4fv(fNameUni, 0, 1, values); |
| 129 | } |
| 130 | fEffectMatrix.setData(uman, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 131 | texDom.getMatrix(), |
| 132 | drawEffect, |
| 133 | texDom.texture(0)); |
skia.committer@gmail.com | 1aa90cf | 2012-11-06 13:18:25 +0000 | [diff] [blame] | 134 | } |
bsalomon@google.com | 92b6a94 | 2012-11-02 19:50:26 +0000 | [diff] [blame] | 135 | |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 136 | GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, |
| 137 | const GrGLCaps&) { |
| 138 | const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>(); |
| 139 | EffectKey key = texDom.wrapMode(); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 140 | key <<= GrGLEffectMatrix::kKeyBits; |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 141 | EffectKey matrixKey = GrGLEffectMatrix::GenKey(texDom.getMatrix(), |
| 142 | drawEffect, |
| 143 | texDom.coordsType(), |
| 144 | texDom.texture(0)); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 145 | return key | matrixKey; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | |
| 149 | /////////////////////////////////////////////////////////////////////////////// |
| 150 | |
bsalomon@google.com | 0ac6af4 | 2013-01-16 15:16:18 +0000 | [diff] [blame] | 151 | GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture, |
| 152 | const SkMatrix& matrix, |
| 153 | const GrRect& domain, |
| 154 | WrapMode wrapMode, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 155 | bool bilerp, |
| 156 | CoordsType coordsType) { |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 157 | static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
| 158 | if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) { |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 159 | return GrSimpleTextureEffect::Create(texture, matrix, bilerp); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 160 | } else { |
| 161 | SkRect clippedDomain; |
| 162 | // We don't currently handle domains that are empty or don't intersect the texture. |
bsalomon@google.com | fe4e491 | 2012-11-08 20:32:13 +0000 | [diff] [blame] | 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. |
| 165 | GrAssert(domain.fLeft <= domain.fRight); |
| 166 | GrAssert(domain.fTop <= domain.fBottom); |
| 167 | clippedDomain.fLeft = SkMaxScalar(domain.fLeft, kFullRect.fLeft); |
| 168 | clippedDomain.fRight = SkMinScalar(domain.fRight, kFullRect.fRight); |
| 169 | clippedDomain.fTop = SkMaxScalar(domain.fTop, kFullRect.fTop); |
| 170 | clippedDomain.fBottom = SkMinScalar(domain.fBottom, kFullRect.fBottom); |
| 171 | GrAssert(clippedDomain.fLeft <= clippedDomain.fRight); |
| 172 | GrAssert(clippedDomain.fTop <= clippedDomain.fBottom); |
bsalomon@google.com | 0ac6af4 | 2013-01-16 15:16:18 +0000 | [diff] [blame] | 173 | |
bsalomon@google.com | 6340a41 | 2013-01-22 19:55:59 +0000 | [diff] [blame] | 174 | AutoEffectUnref effect(SkNEW_ARGS(GrTextureDomainEffect, (texture, |
| 175 | matrix, |
| 176 | clippedDomain, |
| 177 | wrapMode, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 178 | bilerp, |
| 179 | coordsType))); |
bsalomon@google.com | a1ebbe4 | 2013-01-16 15:51:47 +0000 | [diff] [blame] | 180 | return CreateEffectRef(effect); |
bsalomon@google.com | 0ac6af4 | 2013-01-16 15:16:18 +0000 | [diff] [blame] | 181 | |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 182 | } |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 183 | } |
| 184 | |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 185 | GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 186 | const SkMatrix& matrix, |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 187 | const GrRect& domain, |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 188 | WrapMode wrapMode, |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 189 | bool bilerp, |
| 190 | CoordsType coordsType) |
| 191 | : GrSingleTextureEffect(texture, matrix, bilerp, coordsType) |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 192 | , fWrapMode(wrapMode) |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 193 | , fTextureDomain(domain) { |
| 194 | } |
| 195 | |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 196 | GrTextureDomainEffect::~GrTextureDomainEffect() { |
| 197 | |
| 198 | } |
| 199 | |
bsalomon@google.com | 396e61f | 2012-10-25 19:00:29 +0000 | [diff] [blame] | 200 | const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const { |
| 201 | return GrTBackendEffectFactory<GrTextureDomainEffect>::getInstance(); |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 202 | } |
| 203 | |
bsalomon@google.com | 8a252f7 | 2013-01-22 20:35:13 +0000 | [diff] [blame] | 204 | bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const { |
bsalomon@google.com | 6340a41 | 2013-01-22 19:55:59 +0000 | [diff] [blame] | 205 | const GrTextureDomainEffect& s = CastEffect<GrTextureDomainEffect>(sBase); |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 206 | return this->hasSameTextureParamsMatrixAndCoordsType(s) && |
| 207 | this->fTextureDomain == s.fTextureDomain; |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { |
| 211 | if (kDecal_WrapMode == fWrapMode) { |
| 212 | *validFlags = 0; |
| 213 | } else { |
| 214 | this->updateConstantColorComponentsForModulation(color, validFlags); |
| 215 | } |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 216 | } |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 217 | |
| 218 | /////////////////////////////////////////////////////////////////////////////// |
| 219 | |
bsalomon@google.com | f271cc7 | 2012-10-24 19:35:13 +0000 | [diff] [blame] | 220 | GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 221 | |
bsalomon@google.com | 73a9694 | 2013-02-13 16:31:19 +0000 | [diff] [blame] | 222 | GrEffectRef* GrTextureDomainEffect::TestCreate(SkMWCRandom* random, |
sugoi@google.com | e0e385c | 2013-03-11 18:50:03 +0000 | [diff] [blame] | 223 | GrContext*, |
bsalomon@google.com | 0ac6af4 | 2013-01-16 15:16:18 +0000 | [diff] [blame] | 224 | GrTexture* textures[]) { |
bsalomon@google.com | 6f261be | 2012-10-24 19:07:10 +0000 | [diff] [blame] | 225 | int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 226 | GrEffectUnitTest::kAlphaTextureIdx; |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 227 | GrRect domain; |
| 228 | domain.fLeft = random->nextUScalar1(); |
| 229 | domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1); |
| 230 | domain.fTop = random->nextUScalar1(); |
| 231 | domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1); |
bsalomon@google.com | 7b7cdd1 | 2012-11-07 16:17:24 +0000 | [diff] [blame] | 232 | WrapMode wrapMode = random->nextBool() ? kClamp_WrapMode : kDecal_WrapMode; |
| 233 | const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame^] | 234 | bool bilerp = random->nextBool(); |
| 235 | CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_CoordsType; |
| 236 | return GrTextureDomainEffect::Create(textures[texIdx], |
| 237 | matrix, |
| 238 | domain, |
| 239 | wrapMode, |
| 240 | bilerp, |
| 241 | coords); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 242 | } |