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

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

Issue 1110033004: Make XPFragmentBuilder only Builder with access to DstCopy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 "SkPath.h" 10 #include "SkPath.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const AARectEffect& aare = fp.cast<AARectEffect>(); 115 const AARectEffect& aare = fp.cast<AARectEffect>();
116 const char *rectName; 116 const char *rectName;
117 // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bot tom - 0.5), 117 // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bot tom - 0.5),
118 // respectively. 118 // respectively.
119 fRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 119 fRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
120 kVec4f_GrSLType, 120 kVec4f_GrSLType,
121 kDefault_GrSLPrecision, 121 kDefault_GrSLPrecision,
122 "rect", 122 "rect",
123 &rectName); 123 &rectName);
124 124
125 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 125 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
126 const char* fragmentPos = fsBuilder->fragmentPosition(); 126 const char* fragmentPos = fsBuilder->fragmentPosition();
127 if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) { 127 if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) {
128 // The amount of coverage removed in x and y by the edges is computed as a pair of negative 128 // The amount of coverage removed in x and y by the edges is computed as a pair of negative
129 // numbers, xSub and ySub. 129 // numbers, xSub and ySub.
130 fsBuilder->codeAppend("\t\tfloat xSub, ySub;\n"); 130 fsBuilder->codeAppend("\t\tfloat xSub, ySub;\n");
131 fsBuilder->codeAppendf("\t\txSub = min(%s.x - %s.x, 0.0);\n", fragmentPo s, rectName); 131 fsBuilder->codeAppendf("\t\txSub = min(%s.x - %s.x, 0.0);\n", fragmentPo s, rectName);
132 fsBuilder->codeAppendf("\t\txSub += min(%s.z - %s.x, 0.0);\n", rectName, fragmentPos); 132 fsBuilder->codeAppendf("\t\txSub += min(%s.z - %s.x, 0.0);\n", rectName, fragmentPos);
133 fsBuilder->codeAppendf("\t\tySub = min(%s.y - %s.y, 0.0);\n", fragmentPo s, rectName); 133 fsBuilder->codeAppendf("\t\tySub = min(%s.y - %s.y, 0.0);\n", fragmentPo s, rectName);
134 fsBuilder->codeAppendf("\t\tySub += min(%s.w - %s.y, 0.0);\n", rectName, fragmentPos); 134 fsBuilder->codeAppendf("\t\tySub += min(%s.w - %s.y, 0.0);\n", rectName, fragmentPos);
135 // Now compute coverage in x and y and multiply them to get the fraction of the pixel 135 // Now compute coverage in x and y and multiply them to get the fraction of the pixel
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const TextureSamplerArray& samplers) { 209 const TextureSamplerArray& samplers) {
210 const GrConvexPolyEffect& cpe = fp.cast<GrConvexPolyEffect>(); 210 const GrConvexPolyEffect& cpe = fp.cast<GrConvexPolyEffect>();
211 211
212 const char *edgeArrayName; 212 const char *edgeArrayName;
213 fEdgeUniform = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibi lity, 213 fEdgeUniform = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibi lity,
214 kVec3f_GrSLType, 214 kVec3f_GrSLType,
215 kDefault_GrSLPrecision, 215 kDefault_GrSLPrecision,
216 "edges", 216 "edges",
217 cpe.getEdgeCount(), 217 cpe.getEdgeCount(),
218 &edgeArrayName); 218 &edgeArrayName);
219 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 219 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
220 fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); 220 fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
221 fsBuilder->codeAppend("\t\tfloat edge;\n"); 221 fsBuilder->codeAppend("\t\tfloat edge;\n");
222 const char* fragmentPos = fsBuilder->fragmentPosition(); 222 const char* fragmentPos = fsBuilder->fragmentPosition();
223 for (int i = 0; i < cpe.getEdgeCount(); ++i) { 223 for (int i = 0; i < cpe.getEdgeCount(); ++i) {
224 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n", 224 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n",
225 edgeArrayName, i, fragmentPos, fragmentPos); 225 edgeArrayName, i, fragmentPos, fragmentPos);
226 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { 226 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
227 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); 227 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n");
228 } else { 228 } else {
229 fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); 229 fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n");
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 372 }
373 373
374 GrFragmentProcessor* fp; 374 GrFragmentProcessor* fp;
375 do { 375 do {
376 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 376 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
377 random->nextULessThan(kGrProcessorEdgeTy peCnt)); 377 random->nextULessThan(kGrProcessorEdgeTy peCnt));
378 fp = GrConvexPolyEffect::Create(edgeType, count, edges); 378 fp = GrConvexPolyEffect::Create(edgeType, count, edges);
379 } while (NULL == fp); 379 } while (NULL == fp);
380 return fp; 380 return fp;
381 } 381 }
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