Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: src/gpu/effects/GrTextureDomainEffect.cpp

Issue 19449002: Replace all instances of GrRect with SkRect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrTextureDomainEffect.h ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 samplers[0], 101 samplers[0],
102 coords); 102 coords);
103 builder->fsCodeAppend(";\n"); 103 builder->fsCodeAppend(";\n");
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, 108 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
109 const GrDrawEffect& drawEffect) { 109 const GrDrawEffect& drawEffect) {
110 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>(); 110 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>();
111 const GrRect& domain = texDom.domain(); 111 const SkRect& domain = texDom.domain();
112 112
113 float values[4] = { 113 float values[4] = {
114 SkScalarToFloat(domain.left()), 114 SkScalarToFloat(domain.left()),
115 SkScalarToFloat(domain.top()), 115 SkScalarToFloat(domain.top()),
116 SkScalarToFloat(domain.right()), 116 SkScalarToFloat(domain.right()),
117 SkScalarToFloat(domain.bottom()) 117 SkScalarToFloat(domain.bottom())
118 }; 118 };
119 // vertical flip if necessary 119 // vertical flip if necessary
120 if (kBottomLeft_GrSurfaceOrigin == texDom.texture(0)->origin()) { 120 if (kBottomLeft_GrSurfaceOrigin == texDom.texture(0)->origin()) {
121 values[1] = 1.0f - values[1]; 121 values[1] = 1.0f - values[1];
(...skipping 22 matching lines...) Expand all
144 texDom.coordsType(), 144 texDom.coordsType(),
145 texDom.texture(0)); 145 texDom.texture(0));
146 return key | matrixKey; 146 return key | matrixKey;
147 } 147 }
148 148
149 149
150 /////////////////////////////////////////////////////////////////////////////// 150 ///////////////////////////////////////////////////////////////////////////////
151 151
152 GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture, 152 GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture,
153 const SkMatrix& matrix, 153 const SkMatrix& matrix,
154 const GrRect& domain, 154 const SkRect& domain,
155 WrapMode wrapMode, 155 WrapMode wrapMode,
156 bool bilerp, 156 bool bilerp,
157 CoordsType coordsType) { 157 CoordsType coordsType) {
158 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; 158 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
159 if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) { 159 if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) {
160 return GrSimpleTextureEffect::Create(texture, matrix, bilerp); 160 return GrSimpleTextureEffect::Create(texture, matrix, bilerp);
161 } else { 161 } else {
162 SkRect clippedDomain; 162 SkRect clippedDomain;
163 // We don't currently handle domains that are empty or don't intersect t he texture. 163 // We don't currently handle domains that are empty or don't intersect t he texture.
164 // It is OK if the domain rect is a line or point, but it should not be inverted. We do not 164 // It is OK if the domain rect is a line or point, but it should not be inverted. We do not
(...skipping 13 matching lines...) Expand all
178 wrapMode, 178 wrapMode,
179 bilerp, 179 bilerp,
180 coordsType))); 180 coordsType)));
181 return CreateEffectRef(effect); 181 return CreateEffectRef(effect);
182 182
183 } 183 }
184 } 184 }
185 185
186 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, 186 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture,
187 const SkMatrix& matrix, 187 const SkMatrix& matrix,
188 const GrRect& domain, 188 const SkRect& domain,
189 WrapMode wrapMode, 189 WrapMode wrapMode,
190 bool bilerp, 190 bool bilerp,
191 CoordsType coordsType) 191 CoordsType coordsType)
192 : GrSingleTextureEffect(texture, matrix, bilerp, coordsType) 192 : GrSingleTextureEffect(texture, matrix, bilerp, coordsType)
193 , fWrapMode(wrapMode) 193 , fWrapMode(wrapMode)
194 , fTextureDomain(domain) { 194 , fTextureDomain(domain) {
195 } 195 }
196 196
197 GrTextureDomainEffect::~GrTextureDomainEffect() { 197 GrTextureDomainEffect::~GrTextureDomainEffect() {
198 198
(...skipping 20 matching lines...) Expand all
219 /////////////////////////////////////////////////////////////////////////////// 219 ///////////////////////////////////////////////////////////////////////////////
220 220
221 GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect); 221 GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect);
222 222
223 GrEffectRef* GrTextureDomainEffect::TestCreate(SkMWCRandom* random, 223 GrEffectRef* GrTextureDomainEffect::TestCreate(SkMWCRandom* random,
224 GrContext*, 224 GrContext*,
225 const GrDrawTargetCaps&, 225 const GrDrawTargetCaps&,
226 GrTexture* textures[]) { 226 GrTexture* textures[]) {
227 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : 227 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
228 GrEffectUnitTest::kAlphaTextureIdx; 228 GrEffectUnitTest::kAlphaTextureIdx;
229 GrRect domain; 229 SkRect domain;
230 domain.fLeft = random->nextUScalar1(); 230 domain.fLeft = random->nextUScalar1();
231 domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1); 231 domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1);
232 domain.fTop = random->nextUScalar1(); 232 domain.fTop = random->nextUScalar1();
233 domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1); 233 domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1);
234 WrapMode wrapMode = random->nextBool() ? kClamp_WrapMode : kDecal_WrapMode; 234 WrapMode wrapMode = random->nextBool() ? kClamp_WrapMode : kDecal_WrapMode;
235 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 235 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
236 bool bilerp = random->nextBool(); 236 bool bilerp = random->nextBool();
237 CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_Coord sType; 237 CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_Coord sType;
238 return GrTextureDomainEffect::Create(textures[texIdx], 238 return GrTextureDomainEffect::Create(textures[texIdx],
239 matrix, 239 matrix,
240 domain, 240 domain,
241 wrapMode, 241 wrapMode,
242 bilerp, 242 bilerp,
243 coords); 243 coords);
244 } 244 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomainEffect.h ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698