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

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 after revert 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
« no previous file with comments | « src/gpu/effects/GrSimpleTextureEffect.cpp ('k') | src/gpu/effects/GrYUVtoRGBEffect.cpp » ('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 "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 = effect.cast<GrTextureDoma inEffect>();
202 const GrTextureDomain& domain = effect.textureDomain(); 202 const GrTextureDomain& domain = textureDomainEffect.textureDomain();
203 203
204 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 204 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
205 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); 205 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
206 fGLDomain.sampleTexture(fsBuilder, domain, outputColor, coords2D, samplers[0 ], inputColor); 206 fGLDomain.sampleTexture(fsBuilder, domain, outputColor, coords2D, samplers[0 ], inputColor);
207 } 207 }
208 208
209 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman, 209 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman,
210 const GrDrawEffect& drawEffect) { 210 const GrEffect& effect) {
211 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 211 const GrTextureDomainEffect& textureDomainEffect = effect.cast<GrTextureDoma inEffect>();
212 const GrTextureDomain& domain = effect.textureDomain(); 212 const GrTextureDomain& domain = textureDomainEffect.textureDomain();
213 fGLDomain.setData(pdman, domain, effect.texture(0)->origin()); 213 fGLDomain.setData(pdman, domain, effect.texture(0)->origin());
214 } 214 }
215 215
216 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&, 216 void GrGLTextureDomainEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
217 GrEffectKeyBuilder* b) { 217 GrEffectKeyBuilder* b) {
218 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain(); 218 const GrTextureDomain& domain = effect.cast<GrTextureDomainEffect>().texture Domain();
219 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 219 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
220 } 220 }
221 221
222 222
223 /////////////////////////////////////////////////////////////////////////////// 223 ///////////////////////////////////////////////////////////////////////////////
224 224
225 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture, 225 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture,
226 const SkMatrix& matrix, 226 const SkMatrix& matrix,
227 const SkRect& domain, 227 const SkRect& domain,
228 GrTextureDomain::Mode mode, 228 GrTextureDomain::Mode mode,
(...skipping 28 matching lines...) Expand all
257 257
258 GrTextureDomainEffect::~GrTextureDomainEffect() { 258 GrTextureDomainEffect::~GrTextureDomainEffect() {
259 259
260 } 260 }
261 261
262 const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const { 262 const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const {
263 return GrTBackendEffectFactory<GrTextureDomainEffect>::getInstance(); 263 return GrTBackendEffectFactory<GrTextureDomainEffect>::getInstance();
264 } 264 }
265 265
266 bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const { 266 bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const {
267 const GrTextureDomainEffect& s = CastEffect<GrTextureDomainEffect>(sBase); 267 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>();
268 return this->hasSameTextureParamsMatrixAndSourceCoords(s) && 268 return this->hasSameTextureParamsMatrixAndSourceCoords(s) &&
269 this->fTextureDomain == s.fTextureDomain; 269 this->fTextureDomain == s.fTextureDomain;
270 } 270 }
271 271
272 void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { 272 void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
273 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper 273 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
274 *validFlags = 0; 274 *validFlags = 0;
275 } else { 275 } else {
276 this->updateConstantColorComponentsForModulation(color, validFlags); 276 this->updateConstantColorComponentsForModulation(color, validFlags);
277 } 277 }
(...skipping 19 matching lines...) Expand all
297 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 297 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
298 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse; 298 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse;
299 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet; 299 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet;
300 return GrTextureDomainEffect::Create(textures[texIdx], 300 return GrTextureDomainEffect::Create(textures[texIdx],
301 matrix, 301 matrix,
302 domain, 302 domain,
303 mode, 303 mode,
304 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 304 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
305 coords); 305 coords);
306 } 306 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrSimpleTextureEffect.cpp ('k') | src/gpu/effects/GrYUVtoRGBEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698