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

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

Issue 1709153002: Add more specialized fragment builders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make MSVC happy Created 4 years, 10 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/GrConstColorProcessor.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 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "SkPathPriv.h" 10 #include "SkPathPriv.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 const AARectEffect& aare = args.fFp.cast<AARectEffect>(); 103 const AARectEffect& aare = args.fFp.cast<AARectEffect>();
104 const char *rectName; 104 const char *rectName;
105 // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bot tom - 0.5), 105 // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bot tom - 0.5),
106 // respectively. 106 // respectively.
107 fRectUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, 107 fRectUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
108 kVec4f_GrSLType, 108 kVec4f_GrSLType,
109 kDefault_GrSLPrecision, 109 kDefault_GrSLPrecision,
110 "rect", 110 "rect",
111 &rectName); 111 &rectName);
112 112
113 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 113 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
114 const char* fragmentPos = fragBuilder->fragmentPosition(); 114 const char* fragmentPos = fragBuilder->fragmentPosition();
115 if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) { 115 if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) {
116 // The amount of coverage removed in x and y by the edges is computed as a pair of negative 116 // The amount of coverage removed in x and y by the edges is computed as a pair of negative
117 // numbers, xSub and ySub. 117 // numbers, xSub and ySub.
118 fragBuilder->codeAppend("\t\tfloat xSub, ySub;\n"); 118 fragBuilder->codeAppend("\t\tfloat xSub, ySub;\n");
119 fragBuilder->codeAppendf("\t\txSub = min(%s.x - %s.x, 0.0);\n", fragment Pos, rectName); 119 fragBuilder->codeAppendf("\t\txSub = min(%s.x - %s.x, 0.0);\n", fragment Pos, rectName);
120 fragBuilder->codeAppendf("\t\txSub += min(%s.z - %s.x, 0.0);\n", rectNam e, fragmentPos); 120 fragBuilder->codeAppendf("\t\txSub += min(%s.z - %s.x, 0.0);\n", rectNam e, fragmentPos);
121 fragBuilder->codeAppendf("\t\tySub = min(%s.y - %s.y, 0.0);\n", fragment Pos, rectName); 121 fragBuilder->codeAppendf("\t\tySub = min(%s.y - %s.y, 0.0);\n", fragment Pos, rectName);
122 fragBuilder->codeAppendf("\t\tySub += min(%s.w - %s.y, 0.0);\n", rectNam e, fragmentPos); 122 fragBuilder->codeAppendf("\t\tySub += min(%s.w - %s.y, 0.0);\n", rectNam e, fragmentPos);
123 // Now compute coverage in x and y and multiply them to get the fraction of the pixel 123 // Now compute coverage in x and y and multiply them to get the fraction of the pixel
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void GrGLConvexPolyEffect::emitCode(EmitArgs& args) { 187 void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
188 const GrConvexPolyEffect& cpe = args.fFp.cast<GrConvexPolyEffect>(); 188 const GrConvexPolyEffect& cpe = args.fFp.cast<GrConvexPolyEffect>();
189 189
190 const char *edgeArrayName; 190 const char *edgeArrayName;
191 fEdgeUniform = args.fUniformHandler->addUniformArray(kFragment_GrShaderFlag, 191 fEdgeUniform = args.fUniformHandler->addUniformArray(kFragment_GrShaderFlag,
192 kVec3f_GrSLType, 192 kVec3f_GrSLType,
193 kDefault_GrSLPrecision, 193 kDefault_GrSLPrecision,
194 "edges", 194 "edges",
195 cpe.getEdgeCount(), 195 cpe.getEdgeCount(),
196 &edgeArrayName); 196 &edgeArrayName);
197 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 197 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
198 fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); 198 fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
199 fragBuilder->codeAppend("\t\tfloat edge;\n"); 199 fragBuilder->codeAppend("\t\tfloat edge;\n");
200 const char* fragmentPos = fragBuilder->fragmentPosition(); 200 const char* fragmentPos = fragBuilder->fragmentPosition();
201 for (int i = 0; i < cpe.getEdgeCount(); ++i) { 201 for (int i = 0; i < cpe.getEdgeCount(); ++i) {
202 fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n ", 202 fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n ",
203 edgeArrayName, i, fragmentPos, fragmentPos); 203 edgeArrayName, i, fragmentPos, fragmentPos);
204 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { 204 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
205 fragBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); 205 fragBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n");
206 } else { 206 } else {
207 fragBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); 207 fragBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n");
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 344
345 GrFragmentProcessor* fp; 345 GrFragmentProcessor* fp;
346 do { 346 do {
347 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 347 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
348 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); 348 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
349 fp = GrConvexPolyEffect::Create(edgeType, count, edges); 349 fp = GrConvexPolyEffect::Create(edgeType, count, edges);
350 } while (nullptr == fp); 350 } while (nullptr == fp);
351 return fp; 351 return fp;
352 } 352 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConstColorProcessor.cpp ('k') | src/gpu/effects/GrConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698