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

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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 domain); 105 domain);
106 builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", i nCoords.c_str(), 106 builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", i nCoords.c_str(),
107 domain); 107 domain);
108 builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0. 0) : ", outColor); 108 builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0. 0) : ", outColor);
109 builder->fsAppendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str()); 109 builder->fsAppendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str());
110 builder->fsCodeAppend(";\n"); 110 builder->fsCodeAppend(";\n");
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 void GrTextureDomain::GLDomain::setData(const GrGLUniformManager& uman, 115 void GrTextureDomain::GLDomain::setData(const GrGLProgramResourceManager& prman,
116 const GrTextureDomain& textureDomain, 116 const GrTextureDomain& textureDomain,
117 GrSurfaceOrigin textureOrigin) { 117 GrSurfaceOrigin textureOrigin) {
118 SkASSERT(textureDomain.mode() == fMode); 118 SkASSERT(textureDomain.mode() == fMode);
119 if (kIgnore_Mode != textureDomain.mode()) { 119 if (kIgnore_Mode != textureDomain.mode()) {
120 GrGLfloat values[4] = { 120 GrGLfloat values[4] = {
121 SkScalarToFloat(textureDomain.domain().left()), 121 SkScalarToFloat(textureDomain.domain().left()),
122 SkScalarToFloat(textureDomain.domain().top()), 122 SkScalarToFloat(textureDomain.domain().top()),
123 SkScalarToFloat(textureDomain.domain().right()), 123 SkScalarToFloat(textureDomain.domain().right()),
124 SkScalarToFloat(textureDomain.domain().bottom()) 124 SkScalarToFloat(textureDomain.domain().bottom())
125 }; 125 };
126 // vertical flip if necessary 126 // vertical flip if necessary
127 if (kBottomLeft_GrSurfaceOrigin == textureOrigin) { 127 if (kBottomLeft_GrSurfaceOrigin == textureOrigin) {
128 values[1] = 1.0f - values[1]; 128 values[1] = 1.0f - values[1];
129 values[3] = 1.0f - values[3]; 129 values[3] = 1.0f - values[3];
130 // The top and bottom were just flipped, so correct the ordering 130 // The top and bottom were just flipped, so correct the ordering
131 // of elements so that values = (l, t, r, b). 131 // of elements so that values = (l, t, r, b).
132 SkTSwap(values[1], values[3]); 132 SkTSwap(values[1], values[3]);
133 } 133 }
134 if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) { 134 if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) {
135 uman.set4fv(fDomainUni, 1, values); 135 prman.set4fv(fDomainUni, 1, values);
136 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat)); 136 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat));
137 } 137 }
138 } 138 }
139 } 139 }
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 const GrEffectKey&, 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 GrGLProgramResourceManager&, const GrDrawEffect&) SK_OVERRIDE;
157 157
158 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 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 const GrEffectKey& 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 GrGLProgramResourceManager& prman,
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(prman, domain, effect.texture(0)->origin());
189 } 189 }
190 190
191 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&, 191 void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLC aps&,
192 GrEffectKeyBuilder* b) { 192 GrEffectKeyBuilder* b) {
193 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain(); 193 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect> ().textureDomain();
194 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 194 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
195 } 195 }
196 196
197 197
198 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
(...skipping 71 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

Powered by Google App Engine
This is Rietveld 408576698