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

Side by Side Diff: src/gpu/GrAARectRenderer.cpp

Issue 23754003: Isolate VertexBuilder from GrGLShaderBuilder (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« 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 "GrRefCnt.h" 9 #include "GrRefCnt.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(GrGLShaderBuilder* builder, 47 virtual void emitCode(GrGLShaderBuilder* builder,
48 const GrDrawEffect& drawEffect, 48 const GrDrawEffect& drawEffect,
49 EffectKey key, 49 EffectKey key,
50 const char* outputColor, 50 const char* outputColor,
51 const char* inputColor, 51 const char* inputColor,
52 const TextureSamplerArray& samplers) SK_OVERRIDE { 52 const TextureSamplerArray& samplers) SK_OVERRIDE {
53 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertex Builder();
54 SkASSERT(NULL != vertexBuilder);
55
53 // setup the varying for the Axis aligned rect effect 56 // setup the varying for the Axis aligned rect effect
54 // xy -> interpolated offset 57 // xy -> interpolated offset
55 // zw -> w/2+0.5, h/2+0.5 58 // zw -> w/2+0.5, h/2+0.5
56 const char *vsRectName, *fsRectName; 59 const char *vsRectName, *fsRectName;
57 builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectNam e); 60 vertexBuilder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsR ectName);
58 const SkString* attr0Name = 61 const SkString* attr0Name =
59 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[0]); 62 vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttrib Indices()[0]);
60 builder->vsCodeAppendf("\t%s = %s;\n", vsRectName, attr0Name->c_str( )); 63 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsRectName, attr0Name-> c_str());
61 64
62 // TODO: compute all these offsets, spans, and scales in the VS 65 // TODO: compute all these offsets, spans, and scales in the VS
63 builder->fsCodeAppendf("\tfloat insetW = min(1.0, %s.z) - 0.5;\n", f sRectName); 66 builder->fsCodeAppendf("\tfloat insetW = min(1.0, %s.z) - 0.5;\n", f sRectName);
64 builder->fsCodeAppendf("\tfloat insetH = min(1.0, %s.w) - 0.5;\n", f sRectName); 67 builder->fsCodeAppendf("\tfloat insetH = min(1.0, %s.w) - 0.5;\n", f sRectName);
65 builder->fsCodeAppend("\tfloat outset = 0.5;\n"); 68 builder->fsCodeAppend("\tfloat outset = 0.5;\n");
66 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects 69 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects
67 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. 70 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range.
68 builder->fsCodeAppend("\tfloat spanW = insetW + outset;\n"); 71 builder->fsCodeAppend("\tfloat spanW = insetW + outset;\n");
69 builder->fsCodeAppend("\tfloat spanH = insetH + outset;\n"); 72 builder->fsCodeAppend("\tfloat spanH = insetH + outset;\n");
70 // For rects < 1 pixel wide or tall, these scale factors are used to cap the maximum 73 // For rects < 1 pixel wide or tall, these scale factors are used to cap the maximum
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 public: 163 public:
161 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) 164 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
162 : INHERITED (factory) {} 165 : INHERITED (factory) {}
163 166
164 virtual void emitCode(GrGLShaderBuilder* builder, 167 virtual void emitCode(GrGLShaderBuilder* builder,
165 const GrDrawEffect& drawEffect, 168 const GrDrawEffect& drawEffect,
166 EffectKey key, 169 EffectKey key,
167 const char* outputColor, 170 const char* outputColor,
168 const char* inputColor, 171 const char* inputColor,
169 const TextureSamplerArray& samplers) SK_OVERRIDE { 172 const TextureSamplerArray& samplers) SK_OVERRIDE {
173 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertex Builder();
174 SkASSERT(NULL != vertexBuilder);
175
170 // setup the varying for the center point and the unit vector 176 // setup the varying for the center point and the unit vector
171 // that points down the height of the rect 177 // that points down the height of the rect
172 const char *vsRectEdgeName, *fsRectEdgeName; 178 const char *vsRectEdgeName, *fsRectEdgeName;
173 builder->addVarying(kVec4f_GrSLType, "RectEdge", 179 vertexBuilder->addVarying(kVec4f_GrSLType, "RectEdge",
174 &vsRectEdgeName, &fsRectEdgeName); 180 &vsRectEdgeName, &fsRectEdgeName);
175 const SkString* attr0Name = 181 const SkString* attr0Name =
176 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[0]); 182 vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttrib Indices()[0]);
177 builder->vsCodeAppendf("\t%s = %s;\n", vsRectEdgeName, attr0Name->c_ str()); 183 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsRectEdgeName, attr0Na me->c_str());
178 184
179 // setup the varying for width/2+.5 and height/2+.5 185 // setup the varying for width/2+.5 and height/2+.5
180 const char *vsWidthHeightName, *fsWidthHeightName; 186 const char *vsWidthHeightName, *fsWidthHeightName;
181 builder->addVarying(kVec2f_GrSLType, "WidthHeight", 187 vertexBuilder->addVarying(kVec2f_GrSLType, "WidthHeight",
182 &vsWidthHeightName, &fsWidthHeightName); 188 &vsWidthHeightName, &fsWidthHeightName);
183 const SkString* attr1Name = 189 const SkString* attr1Name =
184 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[1]); 190 vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttrib Indices()[1]);
185 builder->vsCodeAppendf("\t%s = %s;\n", vsWidthHeightName, attr1Name- >c_str()); 191 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsWidthHeightName, attr 1Name->c_str());
186 192
187 // TODO: compute all these offsets, spans, and scales in the VS 193 // TODO: compute all these offsets, spans, and scales in the VS
188 builder->fsCodeAppendf("\tfloat insetW = min(1.0, %s.x) - 0.5;\n", f sWidthHeightName); 194 builder->fsCodeAppendf("\tfloat insetW = min(1.0, %s.x) - 0.5;\n", f sWidthHeightName);
189 builder->fsCodeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", f sWidthHeightName); 195 builder->fsCodeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", f sWidthHeightName);
190 builder->fsCodeAppend("\tfloat outset = 0.5;\n"); 196 builder->fsCodeAppend("\tfloat outset = 0.5;\n");
191 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects 197 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects
192 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. 198 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range.
193 builder->fsCodeAppend("\tfloat spanW = insetW + outset;\n"); 199 builder->fsCodeAppend("\tfloat spanW = insetW + outset;\n");
194 builder->fsCodeAppend("\tfloat spanH = insetH + outset;\n"); 200 builder->fsCodeAppend("\tfloat spanH = insetH + outset;\n");
195 // For rects < 1 pixel wide or tall, these scale factors are used to cap the maximum 201 // For rects < 1 pixel wide or tall, these scale factors are used to cap the maximum
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 // can't call mapRect for devInside since it calls sort 809 // can't call mapRect for devInside since it calls sort
804 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ; 810 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ;
805 811
806 if (devInside.isEmpty()) { 812 if (devInside.isEmpty()) {
807 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage); 813 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage);
808 return; 814 return;
809 } 815 }
810 816
811 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove rage); 817 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove rage);
812 } 818 }
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