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

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

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase Created 6 years, 3 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
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 "gl/builders/GrGLProgramBuilder.h" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrTextureDomain.h" 9 #include "GrTextureDomain.h"
10 #include "GrSimpleTextureEffect.h" 10 #include "GrSimpleTextureEffect.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat)); 160 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat));
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 165
166 ////////////////////////////////////////////////////////////////////////////// 166 //////////////////////////////////////////////////////////////////////////////
167 167
168 class GrGLTextureDomainEffect : public GrGLEffect { 168 class GrGLTextureDomainEffect : public GrGLEffect {
169 public: 169 public:
170 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 170 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrEffect&);
171 171
172 virtual void emitCode(GrGLProgramBuilder*, 172 virtual void emitCode(GrGLProgramBuilder*,
173 const GrDrawEffect&, 173 const GrEffect&,
174 const GrEffectKey&, 174 const GrEffectKey&,
175 const char* outputColor, 175 const char* outputColor,
176 const char* inputColor, 176 const char* inputColor,
177 const TransformedCoordsArray&, 177 const TransformedCoordsArray&,
178 const TextureSamplerArray&) SK_OVERRIDE; 178 const TextureSamplerArray&) SK_OVERRIDE;
179 179
180 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE; 180 virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVER RIDE;
181 181
182 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 182 static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuild er*);
183 183
184 private: 184 private:
185 GrTextureDomain::GLDomain fGLDomain; 185 GrTextureDomain::GLDomain fGLDomain;
186 typedef GrGLEffect INHERITED; 186 typedef GrGLEffect INHERITED;
187 }; 187 };
188 188
189 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory, 189 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory,
190 const GrDrawEffect&) 190 const GrEffect&)
191 : INHERITED(factory) { 191 : INHERITED(factory) {
192 } 192 }
193 193
194 void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder, 194 void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder,
195 const GrDrawEffect& drawEffect, 195 const GrEffect& effect,
196 const GrEffectKey& key, 196 const GrEffectKey& key,
197 const char* outputColor, 197 const char* outputColor,
198 const char* inputColor, 198 const char* inputColor,
199 const TransformedCoordsArray& coords, 199 const TransformedCoordsArray& coords,
200 const TextureSamplerArray& samplers) { 200 const TextureSamplerArray& samplers) {
201 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 201 const GrTextureDomainEffect& textureDomainEffect =
202 const GrTextureDomain& domain = effect.textureDomain(); 202 GrEffect::CastEffect<GrTextureDomainEffect>(effect);
203 const GrTextureDomain& domain = textureDomainEffect.textureDomain();
203 204
204 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 205 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
205 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); 206 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
206 fGLDomain.sampleTexture(fsBuilder, domain, outputColor, coords2D, samplers[0 ], inputColor); 207 fGLDomain.sampleTexture(fsBuilder, domain, outputColor, coords2D, samplers[0 ], inputColor);
207 } 208 }
208 209
209 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman, 210 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman,
210 const GrDrawEffect& drawEffect) { 211 const GrEffect& effect) {
211 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 212 const GrTextureDomainEffect& textureDomainEffect =
212 const GrTextureDomain& domain = effect.textureDomain(); 213 GrEffect::CastEffect<GrTextureDomainEffect>(effect);
214 const GrTextureDomain& domain = textureDomainEffect.textureDomain();
213 fGLDomain.setData(pdman, domain, effect.texture(0)->origin()); 215 fGLDomain.setData(pdman, domain, effect.texture(0)->origin());
214 } 216 }
215 217
216 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&, 218 void GrGLTextureDomainEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
217 GrEffectKeyBuilder* b) { 219 GrEffectKeyBuilder* b) {
218 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain(); 220 const GrTextureDomain& domain =
221 GrEffect::CastEffect<GrTextureDomainEffect>(effect).textureDomain();
219 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 222 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
220 } 223 }
221 224
222 225
223 /////////////////////////////////////////////////////////////////////////////// 226 ///////////////////////////////////////////////////////////////////////////////
224 227
225 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture, 228 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture,
226 const SkMatrix& matrix, 229 const SkMatrix& matrix,
227 const SkRect& domain, 230 const SkRect& domain,
228 GrTextureDomain::Mode mode, 231 GrTextureDomain::Mode mode,
(...skipping 28 matching lines...) Expand all
257 260
258 GrTextureDomainEffect::~GrTextureDomainEffect() { 261 GrTextureDomainEffect::~GrTextureDomainEffect() {
259 262
260 } 263 }
261 264
262 const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const { 265 const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const {
263 return GrTBackendEffectFactory<GrTextureDomainEffect>::getInstance(); 266 return GrTBackendEffectFactory<GrTextureDomainEffect>::getInstance();
264 } 267 }
265 268
266 bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const { 269 bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const {
267 const GrTextureDomainEffect& s = CastEffect<GrTextureDomainEffect>(sBase); 270 const GrTextureDomainEffect& s = GrEffect::CastEffect<GrTextureDomainEffect> (sBase);
268 return this->hasSameTextureParamsMatrixAndSourceCoords(s) && 271 return this->hasSameTextureParamsMatrixAndSourceCoords(s) &&
269 this->fTextureDomain == s.fTextureDomain; 272 this->fTextureDomain == s.fTextureDomain;
270 } 273 }
271 274
272 void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { 275 void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
273 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper 276 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
274 *validFlags = 0; 277 *validFlags = 0;
275 } else { 278 } else {
276 this->updateConstantColorComponentsForModulation(color, validFlags); 279 this->updateConstantColorComponentsForModulation(color, validFlags);
277 } 280 }
(...skipping 19 matching lines...) Expand all
297 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 300 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
298 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse; 301 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse;
299 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet; 302 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet;
300 return GrTextureDomainEffect::Create(textures[texIdx], 303 return GrTextureDomainEffect::Create(textures[texIdx],
301 matrix, 304 matrix,
302 domain, 305 domain,
303 mode, 306 mode,
304 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 307 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
305 coords); 308 coords);
306 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698