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

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

Issue 385713005: Allow GrGLEffects to produce variable length keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: rebase Created 6 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
« no previous file with comments | « src/gpu/effects/GrTextureDomain.h ('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 "GrTextureDomain.h" 8 #include "GrTextureDomain.h"
9 #include "GrSimpleTextureEffect.h" 9 #include "GrSimpleTextureEffect.h"
10 #include "GrTBackendEffectFactory.h" 10 #include "GrTBackendEffectFactory.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 141
142 ////////////////////////////////////////////////////////////////////////////// 142 //////////////////////////////////////////////////////////////////////////////
143 143
144 class GrGLTextureDomainEffect : public GrGLEffect { 144 class GrGLTextureDomainEffect : public GrGLEffect {
145 public: 145 public:
146 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 146 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
147 147
148 virtual void emitCode(GrGLShaderBuilder*, 148 virtual void emitCode(GrGLShaderBuilder*,
149 const GrDrawEffect&, 149 const GrDrawEffect&,
150 EffectKey, 150 const GrEffectKey&,
151 const char* outputColor, 151 const char* outputColor,
152 const char* inputColor, 152 const char* inputColor,
153 const TransformedCoordsArray&, 153 const TransformedCoordsArray&,
154 const TextureSamplerArray&) SK_OVERRIDE; 154 const TextureSamplerArray&) SK_OVERRIDE;
155 155
156 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 156 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE;
157 157
158 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); 158 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*);
159 159
160 private: 160 private:
161 GrTextureDomain::GLDomain fGLDomain; 161 GrTextureDomain::GLDomain fGLDomain;
162 typedef GrGLEffect INHERITED; 162 typedef GrGLEffect INHERITED;
163 }; 163 };
164 164
165 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory, 165 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory,
166 const GrDrawEffect&) 166 const GrDrawEffect&)
167 : INHERITED(factory) { 167 : INHERITED(factory) {
168 } 168 }
169 169
170 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, 170 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
171 const GrDrawEffect& drawEffect, 171 const GrDrawEffect& drawEffect,
172 EffectKey key, 172 const GrEffectKey& key,
173 const char* outputColor, 173 const char* outputColor,
174 const char* inputColor, 174 const char* inputColor,
175 const TransformedCoordsArray& coords, 175 const TransformedCoordsArray& coords,
176 const TextureSamplerArray& samplers) { 176 const TextureSamplerArray& samplers) {
177 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 177 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>();
178 const GrTextureDomain& domain = effect.textureDomain(); 178 const GrTextureDomain& domain = effect.textureDomain();
179 179
180 SkString coords2D = builder->ensureFSCoords2D(coords, 0); 180 SkString coords2D = builder->ensureFSCoords2D(coords, 0);
181 fGLDomain.sampleTexture(builder, domain, outputColor, coords2D, samplers[0], inputColor); 181 fGLDomain.sampleTexture(builder, domain, outputColor, coords2D, samplers[0], inputColor);
182 } 182 }
183 183
184 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, 184 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
185 const GrDrawEffect& drawEffect) { 185 const GrDrawEffect& drawEffect) {
186 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 186 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>();
187 const GrTextureDomain& domain = effect.textureDomain(); 187 const GrTextureDomain& domain = effect.textureDomain();
188 fGLDomain.setData(uman, domain, effect.texture(0)->origin()); 188 fGLDomain.setData(uman, domain, effect.texture(0)->origin());
189 } 189 }
190 190
191 GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEf fect, 191 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&,
192 const GrGLCaps&) { 192 GrEffectKeyBuilder* b) {
193 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain(); 193 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain();
194 return GrTextureDomain::GLDomain::DomainKey(domain); 194 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
195 } 195 }
196 196
197 197
198 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
199 199
200 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture, 200 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture,
201 const SkMatrix& matrix, 201 const SkMatrix& matrix,
202 const SkRect& domain, 202 const SkRect& domain,
203 GrTextureDomain::Mode mode, 203 GrTextureDomain::Mode mode,
204 GrTextureParams::FilterMode filterMod e, 204 GrTextureParams::FilterMode filterMod e,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 270 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
271 bool bilerp = random->nextBool(); 271 bool bilerp = random->nextBool();
272 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet; 272 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet;
273 return GrTextureDomainEffect::Create(textures[texIdx], 273 return GrTextureDomainEffect::Create(textures[texIdx],
274 matrix, 274 matrix,
275 domain, 275 domain,
276 mode, 276 mode,
277 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 277 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
278 coords); 278 coords);
279 } 279 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.h ('k') | src/gpu/effects/GrYUVtoRGBEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698