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

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

Issue 365853002: Rename GrGLUniformManager to GrGLProgramResourceManager (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: rebase Created 6 years, 4 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/gl/GrGLEffect.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 "GrTextureDomain.h" 8 #include "GrTextureDomain.h"
9 #include "GrSimpleTextureEffect.h" 9 #include "GrSimpleTextureEffect.h"
10 #include "GrTBackendEffectFactory.h" 10 #include "GrTBackendEffectFactory.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 builder->fsCodeAppendf("\t%s = ", outColor); 126 builder->fsCodeAppendf("\t%s = ", outColor);
127 builder->fsAppendTextureLookupAndModulate(inModulateColor, sampler, 127 builder->fsAppendTextureLookupAndModulate(inModulateColor, sampler,
128 clampedCoords.c_str()); 128 clampedCoords.c_str());
129 builder->fsCodeAppend(";\n"); 129 builder->fsCodeAppend(";\n");
130 break; 130 break;
131 } 131 }
132 } 132 }
133 } 133 }
134 134
135 void GrTextureDomain::GLDomain::setData(const GrGLUniformManager& uman, 135 void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
136 const GrTextureDomain& textureDomain, 136 const GrTextureDomain& textureDomain,
137 GrSurfaceOrigin textureOrigin) { 137 GrSurfaceOrigin textureOrigin) {
138 SkASSERT(textureDomain.mode() == fMode); 138 SkASSERT(textureDomain.mode() == fMode);
139 if (kIgnore_Mode != textureDomain.mode()) { 139 if (kIgnore_Mode != textureDomain.mode()) {
140 GrGLfloat values[4] = { 140 GrGLfloat values[4] = {
141 SkScalarToFloat(textureDomain.domain().left()), 141 SkScalarToFloat(textureDomain.domain().left()),
142 SkScalarToFloat(textureDomain.domain().top()), 142 SkScalarToFloat(textureDomain.domain().top()),
143 SkScalarToFloat(textureDomain.domain().right()), 143 SkScalarToFloat(textureDomain.domain().right()),
144 SkScalarToFloat(textureDomain.domain().bottom()) 144 SkScalarToFloat(textureDomain.domain().bottom())
145 }; 145 };
146 // vertical flip if necessary 146 // vertical flip if necessary
147 if (kBottomLeft_GrSurfaceOrigin == textureOrigin) { 147 if (kBottomLeft_GrSurfaceOrigin == textureOrigin) {
148 values[1] = 1.0f - values[1]; 148 values[1] = 1.0f - values[1];
149 values[3] = 1.0f - values[3]; 149 values[3] = 1.0f - values[3];
150 // The top and bottom were just flipped, so correct the ordering 150 // The top and bottom were just flipped, so correct the ordering
151 // of elements so that values = (l, t, r, b). 151 // of elements so that values = (l, t, r, b).
152 SkTSwap(values[1], values[3]); 152 SkTSwap(values[1], values[3]);
153 } 153 }
154 if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) { 154 if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) {
155 uman.set4fv(fDomainUni, 1, values); 155 pdman.set4fv(fDomainUni, 1, values);
156 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat)); 156 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat));
157 } 157 }
158 } 158 }
159 } 159 }
160 160
161 161
162 ////////////////////////////////////////////////////////////////////////////// 162 //////////////////////////////////////////////////////////////////////////////
163 163
164 class GrGLTextureDomainEffect : public GrGLEffect { 164 class GrGLTextureDomainEffect : public GrGLEffect {
165 public: 165 public:
166 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 166 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
167 167
168 virtual void emitCode(GrGLShaderBuilder*, 168 virtual void emitCode(GrGLShaderBuilder*,
169 const GrDrawEffect&, 169 const GrDrawEffect&,
170 const GrEffectKey&, 170 const GrEffectKey&,
171 const char* outputColor, 171 const char* outputColor,
172 const char* inputColor, 172 const char* inputColor,
173 const TransformedCoordsArray&, 173 const TransformedCoordsArray&,
174 const TextureSamplerArray&) SK_OVERRIDE; 174 const TextureSamplerArray&) SK_OVERRIDE;
175 175
176 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 176 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE;
177 177
178 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 178 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*);
179 179
180 private: 180 private:
181 GrTextureDomain::GLDomain fGLDomain; 181 GrTextureDomain::GLDomain fGLDomain;
182 typedef GrGLEffect INHERITED; 182 typedef GrGLEffect INHERITED;
183 }; 183 };
184 184
185 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory, 185 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory,
186 const GrDrawEffect&) 186 const GrDrawEffect&)
187 : INHERITED(factory) { 187 : INHERITED(factory) {
188 } 188 }
189 189
190 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, 190 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
191 const GrDrawEffect& drawEffect, 191 const GrDrawEffect& drawEffect,
192 const GrEffectKey& key, 192 const GrEffectKey& key,
193 const char* outputColor, 193 const char* outputColor,
194 const char* inputColor, 194 const char* inputColor,
195 const TransformedCoordsArray& coords, 195 const TransformedCoordsArray& coords,
196 const TextureSamplerArray& samplers) { 196 const TextureSamplerArray& samplers) {
197 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 197 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>();
198 const GrTextureDomain& domain = effect.textureDomain(); 198 const GrTextureDomain& domain = effect.textureDomain();
199 199
200 SkString coords2D = builder->ensureFSCoords2D(coords, 0); 200 SkString coords2D = builder->ensureFSCoords2D(coords, 0);
201 fGLDomain.sampleTexture(builder, domain, outputColor, coords2D, samplers[0], inputColor); 201 fGLDomain.sampleTexture(builder, domain, outputColor, coords2D, samplers[0], inputColor);
202 } 202 }
203 203
204 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, 204 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman,
205 const GrDrawEffect& drawEffect) { 205 const GrDrawEffect& drawEffect) {
206 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>(); 206 const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainE ffect>();
207 const GrTextureDomain& domain = effect.textureDomain(); 207 const GrTextureDomain& domain = effect.textureDomain();
208 fGLDomain.setData(uman, domain, effect.texture(0)->origin()); 208 fGLDomain.setData(pdman, domain, effect.texture(0)->origin());
209 } 209 }
210 210
211 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&, 211 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&,
212 GrEffectKeyBuilder* b) { 212 GrEffectKeyBuilder* b) {
213 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain(); 213 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain();
214 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 214 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
215 } 215 }
216 216
217 217
218 /////////////////////////////////////////////////////////////////////////////// 218 ///////////////////////////////////////////////////////////////////////////////
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 292 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
293 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse; 293 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse;
294 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet; 294 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet;
295 return GrTextureDomainEffect::Create(textures[texIdx], 295 return GrTextureDomainEffect::Create(textures[texIdx],
296 matrix, 296 matrix,
297 domain, 297 domain,
298 mode, 298 mode,
299 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 299 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
300 coords); 300 coords);
301 } 301 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.h ('k') | src/gpu/gl/GrGLEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698