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

Side by Side Diff: src/gpu/GrAARectRenderer.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/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrOvalRenderer.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 "GrAARectRenderer.h" 8 #include "GrAARectRenderer.h"
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 28 matching lines...) Expand all
39 return GrTBackendEffectFactory<GrAlignedRectEffect>::getInstance(); 39 return GrTBackendEffectFactory<GrAlignedRectEffect>::getInstance();
40 } 40 }
41 41
42 class GLEffect : public GrGLVertexEffect { 42 class GLEffect : public GrGLVertexEffect {
43 public: 43 public:
44 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) 44 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
45 : INHERITED (factory) {} 45 : INHERITED (factory) {}
46 46
47 virtual void emitCode(GrGLFullShaderBuilder* builder, 47 virtual void emitCode(GrGLFullShaderBuilder* builder,
48 const GrDrawEffect& drawEffect, 48 const GrDrawEffect& drawEffect,
49 EffectKey key, 49 const GrEffectKey& key,
50 const char* outputColor, 50 const char* outputColor,
51 const char* inputColor, 51 const char* inputColor,
52 const TransformedCoordsArray&, 52 const TransformedCoordsArray&,
53 const TextureSamplerArray& samplers) SK_OVERRIDE { 53 const TextureSamplerArray& samplers) SK_OVERRIDE {
54 // setup the varying for the Axis aligned rect effect 54 // setup the varying for the Axis aligned rect effect
55 // xy -> interpolated offset 55 // xy -> interpolated offset
56 // zw -> w/2+0.5, h/2+0.5 56 // zw -> w/2+0.5, h/2+0.5
57 const char *vsRectName, *fsRectName; 57 const char *vsRectName, *fsRectName;
58 builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectNam e); 58 builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectNam e);
59 const SkString* attr0Name = 59 const SkString* attr0Name =
(...skipping 21 matching lines...) Expand all
81 // Compute the coverage for the rect's height and merge with the wid th 81 // Compute the coverage for the rect's height and merge with the wid th
82 builder->fsCodeAppendf( 82 builder->fsCodeAppendf(
83 "\tcoverage = coverage*scaleH*clamp((%s.w-abs(%s.y))/spanH, 0.0, 1.0);\n", 83 "\tcoverage = coverage*scaleH*clamp((%s.w-abs(%s.y))/spanH, 0.0, 1.0);\n",
84 fsRectName, fsRectName); 84 fsRectName, fsRectName);
85 85
86 86
87 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 87 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
88 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str()); 88 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str());
89 } 89 }
90 90
91 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 91 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {}
92 return 0;
93 }
94 92
95 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {} 93 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {}
96 94
97 private: 95 private:
98 typedef GrGLVertexEffect INHERITED; 96 typedef GrGLVertexEffect INHERITED;
99 }; 97 };
100 98
101 99
102 private: 100 private:
103 GrAlignedRectEffect() : GrVertexEffect() { 101 GrAlignedRectEffect() : GrVertexEffect() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return GrTBackendEffectFactory<GrRectEffect>::getInstance(); 155 return GrTBackendEffectFactory<GrRectEffect>::getInstance();
158 } 156 }
159 157
160 class GLEffect : public GrGLVertexEffect { 158 class GLEffect : public GrGLVertexEffect {
161 public: 159 public:
162 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) 160 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
163 : INHERITED (factory) {} 161 : INHERITED (factory) {}
164 162
165 virtual void emitCode(GrGLFullShaderBuilder* builder, 163 virtual void emitCode(GrGLFullShaderBuilder* builder,
166 const GrDrawEffect& drawEffect, 164 const GrDrawEffect& drawEffect,
167 EffectKey key, 165 const GrEffectKey& key,
168 const char* outputColor, 166 const char* outputColor,
169 const char* inputColor, 167 const char* inputColor,
170 const TransformedCoordsArray&, 168 const TransformedCoordsArray&,
171 const TextureSamplerArray& samplers) SK_OVERRIDE { 169 const TextureSamplerArray& samplers) SK_OVERRIDE {
172 // setup the varying for the center point and the unit vector 170 // setup the varying for the center point and the unit vector
173 // that points down the height of the rect 171 // that points down the height of the rect
174 const char *vsRectEdgeName, *fsRectEdgeName; 172 const char *vsRectEdgeName, *fsRectEdgeName;
175 builder->addVarying(kVec4f_GrSLType, "RectEdge", 173 builder->addVarying(kVec4f_GrSLType, "RectEdge",
176 &vsRectEdgeName, &fsRectEdgeName); 174 &vsRectEdgeName, &fsRectEdgeName);
177 const SkString* attr0Name = 175 const SkString* attr0Name =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 fsRectEdgeName); 212 fsRectEdgeName);
215 builder->fsCodeAppendf( 213 builder->fsCodeAppendf(
216 "\tcoverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0. 0, 1.0);\n", 214 "\tcoverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0. 0, 1.0);\n",
217 fsWidthHeightName); 215 fsWidthHeightName);
218 216
219 217
220 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 218 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
221 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str()); 219 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str());
222 } 220 }
223 221
224 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 222 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {}
225 return 0;
226 }
227 223
228 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {} 224 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {}
229 225
230 private: 226 private:
231 typedef GrGLVertexEffect INHERITED; 227 typedef GrGLVertexEffect INHERITED;
232 }; 228 };
233 229
234 230
235 private: 231 private:
236 GrRectEffect() : GrVertexEffect() { 232 GrRectEffect() : GrVertexEffect() {
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ; 920 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ;
925 921
926 if (devInside.isEmpty()) { 922 if (devInside.isEmpty()) {
927 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage); 923 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage);
928 return; 924 return;
929 } 925 }
930 926
931 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, 927 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist,
932 devInside, useVertexCoverage, true); 928 devInside, useVertexCoverage, true);
933 } 929 }
OLDNEW
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698