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

Side by Side Diff: src/gpu/effects/GrConvexPolyEffect.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/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConvolutionEffect.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 2014 Google Inc. 2 * Copyright 2014 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 "GrConvexPolyEffect.h" 8 #include "GrConvexPolyEffect.h"
9 9
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 virtual void emitCode(GrGLShaderBuilder* builder, 92 virtual void emitCode(GrGLShaderBuilder* builder,
93 const GrDrawEffect& drawEffect, 93 const GrDrawEffect& drawEffect,
94 const GrEffectKey& key, 94 const GrEffectKey& key,
95 const char* outputColor, 95 const char* outputColor,
96 const char* inputColor, 96 const char* inputColor,
97 const TransformedCoordsArray&, 97 const TransformedCoordsArray&,
98 const TextureSamplerArray&) SK_OVERRIDE; 98 const TextureSamplerArray&) SK_OVERRIDE;
99 99
100 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 100 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*);
101 101
102 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 102 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE;
103 103
104 private: 104 private:
105 GrGLUniformManager::UniformHandle fRectUniform; 105 GrGLProgramDataManager::UniformHandle fRectUniform;
106 SkRect fPrevRect; 106 SkRect fPrevRect;
107 typedef GrGLEffect INHERITED; 107 typedef GrGLEffect INHERITED;
108 }; 108 };
109 109
110 GLAARectEffect::GLAARectEffect(const GrBackendEffectFactory& factory, 110 GLAARectEffect::GLAARectEffect(const GrBackendEffectFactory& factory,
111 const GrDrawEffect& drawEffect) 111 const GrDrawEffect& drawEffect)
112 : INHERITED (factory) { 112 : INHERITED (factory) {
113 fPrevRect.fLeft = SK_ScalarNaN; 113 fPrevRect.fLeft = SK_ScalarNaN;
114 } 114 }
115 115
116 void GLAARectEffect::emitCode(GrGLShaderBuilder* builder, 116 void GLAARectEffect::emitCode(GrGLShaderBuilder* builder,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 builder->fsCodeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n ", rectName, fragmentPos); 148 builder->fsCodeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n ", rectName, fragmentPos);
149 } 149 }
150 150
151 if (GrEffectEdgeTypeIsInverseFill(aare.getEdgeType())) { 151 if (GrEffectEdgeTypeIsInverseFill(aare.getEdgeType())) {
152 builder->fsCodeAppend("\t\talpha = 1.0 - alpha;\n"); 152 builder->fsCodeAppend("\t\talpha = 1.0 - alpha;\n");
153 } 153 }
154 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, 154 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor,
155 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r()); 155 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r());
156 } 156 }
157 157
158 void GLAARectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) { 158 void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEf fect& drawEffect) {
159 const AARectEffect& aare = drawEffect.castEffect<AARectEffect>(); 159 const AARectEffect& aare = drawEffect.castEffect<AARectEffect>();
160 const SkRect& rect = aare.getRect(); 160 const SkRect& rect = aare.getRect();
161 if (rect != fPrevRect) { 161 if (rect != fPrevRect) {
162 uman.set4f(fRectUniform, rect.fLeft + 0.5f, rect.fTop + 0.5f, 162 pdman.set4f(fRectUniform, rect.fLeft + 0.5f, rect.fTop + 0.5f,
163 rect.fRight - 0.5f, rect.fBottom - 0.5f); 163 rect.fRight - 0.5f, rect.fBottom - 0.5f);
164 fPrevRect = rect; 164 fPrevRect = rect;
165 } 165 }
166 } 166 }
167 167
168 void GLAARectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, 168 void GLAARectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
169 GrEffectKeyBuilder* b) { 169 GrEffectKeyBuilder* b) {
170 const AARectEffect& aare = drawEffect.castEffect<AARectEffect>(); 170 const AARectEffect& aare = drawEffect.castEffect<AARectEffect>();
171 b->add32(aare.getEdgeType()); 171 b->add32(aare.getEdgeType());
172 } 172 }
(...skipping 11 matching lines...) Expand all
184 virtual void emitCode(GrGLShaderBuilder* builder, 184 virtual void emitCode(GrGLShaderBuilder* builder,
185 const GrDrawEffect& drawEffect, 185 const GrDrawEffect& drawEffect,
186 const GrEffectKey& key, 186 const GrEffectKey& key,
187 const char* outputColor, 187 const char* outputColor,
188 const char* inputColor, 188 const char* inputColor,
189 const TransformedCoordsArray&, 189 const TransformedCoordsArray&,
190 const TextureSamplerArray&) SK_OVERRIDE; 190 const TextureSamplerArray&) SK_OVERRIDE;
191 191
192 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 192 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*);
193 193
194 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 194 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE;
195 195
196 private: 196 private:
197 GrGLUniformManager::UniformHandle fEdgeUniform; 197 GrGLProgramDataManager::UniformHandle fEdgeUniform;
198 SkScalar fPrevEdges[3 * GrConvexPolyEffect::kMaxE dges]; 198 SkScalar fPrevEdges[3 * GrConvexPolyEffect::kMa xEdges];
199 typedef GrGLEffect INHERITED; 199 typedef GrGLEffect INHERITED;
200 }; 200 };
201 201
202 GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendEffectFactory& factory , 202 GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendEffectFactory& factory ,
203 const GrDrawEffect& drawEffect) 203 const GrDrawEffect& drawEffect)
204 : INHERITED (factory) { 204 : INHERITED (factory) {
205 fPrevEdges[0] = SK_ScalarNaN; 205 fPrevEdges[0] = SK_ScalarNaN;
206 } 206 }
207 207
208 void GrGLConvexPolyEffect::emitCode(GrGLShaderBuilder* builder, 208 void GrGLConvexPolyEffect::emitCode(GrGLShaderBuilder* builder,
(...skipping 30 matching lines...) Expand all
239 builder->fsCodeAppend("\t\tif (-1.0 == alpha) {\n\t\t\tdiscard;\n\t\t}\n "); 239 builder->fsCodeAppend("\t\tif (-1.0 == alpha) {\n\t\t\tdiscard;\n\t\t}\n ");
240 } 240 }
241 241
242 if (GrEffectEdgeTypeIsInverseFill(cpe.getEdgeType())) { 242 if (GrEffectEdgeTypeIsInverseFill(cpe.getEdgeType())) {
243 builder->fsCodeAppend("\talpha = 1.0 - alpha;\n"); 243 builder->fsCodeAppend("\talpha = 1.0 - alpha;\n");
244 } 244 }
245 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 245 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
246 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r()); 246 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r());
247 } 247 }
248 248
249 void GrGLConvexPolyEffect::setData(const GrGLUniformManager& uman, const GrDrawE ffect& drawEffect) { 249 void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const Gr DrawEffect& drawEffect) {
250 const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>(); 250 const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>();
251 size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar); 251 size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar);
252 if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) { 252 if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) {
253 uman.set3fv(fEdgeUniform, cpe.getEdgeCount(), cpe.getEdges()); 253 pdman.set3fv(fEdgeUniform, cpe.getEdgeCount(), cpe.getEdges());
254 memcpy(fPrevEdges, cpe.getEdges(), byteSize); 254 memcpy(fPrevEdges, cpe.getEdges(), byteSize);
255 } 255 }
256 } 256 }
257 257
258 void GrGLConvexPolyEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps &, 258 void GrGLConvexPolyEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps &,
259 GrEffectKeyBuilder* b) { 259 GrEffectKeyBuilder* b) {
260 const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>(); 260 const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>();
261 GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8); 261 GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
262 uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType(); 262 uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType();
263 b->add32(key); 263 b->add32(key);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 GrEffect* effect; 371 GrEffect* effect;
372 do { 372 do {
373 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( 373 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
374 random->nextULessThan(kGrEffectEdgeTypeC nt)); 374 random->nextULessThan(kGrEffectEdgeTypeC nt));
375 effect = GrConvexPolyEffect::Create(edgeType, count, edges); 375 effect = GrConvexPolyEffect::Create(edgeType, count, edges);
376 } while (NULL == effect); 376 } while (NULL == effect);
377 return effect; 377 return effect;
378 } 378 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698