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

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

Issue 890433003: Revert of Add device space "nudge" to gpu draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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/core/SkClipStack.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
136 // covered. 136 // covered.
137 fsBuilder->codeAppendf("\t\tfloat alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n"); 137 fsBuilder->codeAppendf("\t\tfloat alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n");
138 } else { 138 } else {
139 fsBuilder->codeAppendf("\t\tfloat alpha = 1.0;\n"); 139 fsBuilder->codeAppendf("\t\tfloat alpha = 1.0;\n");
140 fsBuilder->codeAppendf("\t\talpha *= (%s.x - %s.x) > -0.5 ? 1.0 : 0.0;\n ", 140 fsBuilder->codeAppendf("\t\talpha *= (%s.x - %s.x) > -0.5 ? 1.0 : 0.0;\n ", fragmentPos, rectName);
141 fragmentPos, rectName); 141 fsBuilder->codeAppendf("\t\talpha *= (%s.z - %s.x) > -0.5 ? 1.0 : 0.0;\n ", rectName, fragmentPos);
142 fsBuilder->codeAppendf("\t\talpha *= (%s.z - %s.x) > -0.5 ? 1.0 : 0.0;\n ", 142 fsBuilder->codeAppendf("\t\talpha *= (%s.y - %s.y) > -0.5 ? 1.0 : 0.0;\n ", fragmentPos, rectName);
143 rectName, fragmentPos); 143 fsBuilder->codeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n ", rectName, fragmentPos);
144 fsBuilder->codeAppendf("\t\talpha *= (%s.y - %s.y) > -0.5 ? 1.0 : 0.0;\n ",
145 fragmentPos, rectName);
146 fsBuilder->codeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n ",
147 rectName, fragmentPos);
148 } 144 }
149 145
150 if (GrProcessorEdgeTypeIsInverseFill(aare.getEdgeType())) { 146 if (GrProcessorEdgeTypeIsInverseFill(aare.getEdgeType())) {
151 fsBuilder->codeAppend("\t\talpha = 1.0 - alpha;\n"); 147 fsBuilder->codeAppend("\t\talpha = 1.0 - alpha;\n");
152 } 148 }
153 fsBuilder->codeAppendf("\t\t%s = %s;\n", outputColor, 149 fsBuilder->codeAppendf("\t\t%s = %s;\n", outputColor,
154 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r()); 150 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r());
155 } 151 }
156 152
157 void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrProces sor& processor) { 153 void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrProces sor& processor) {
158 const AARectEffect& aare = processor.cast<AARectEffect>(); 154 const AARectEffect& aare = processor.cast<AARectEffect>();
159 const SkRect& rect = aare.getRect(); 155 const SkRect& rect = aare.getRect();
160 if (rect != fPrevRect) { 156 if (rect != fPrevRect) {
161 // Add a device space "nudge" of 0.05f, 0.05f to match raster's rounding behavior for 157 pdman.set4f(fRectUniform, rect.fLeft + 0.5f, rect.fTop + 0.5f,
162 // BW clipping/drawing 158 rect.fRight - 0.5f, rect.fBottom - 0.5f);
163 pdman.set4f(fRectUniform, rect.fLeft + 0.55f, rect.fTop + 0.55f,
164 rect.fRight - 0.45f, rect.fBottom - 0.45f);
165 fPrevRect = rect; 159 fPrevRect = rect;
166 } 160 }
167 } 161 }
168 162
169 void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, 163 void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
170 GrProcessorKeyBuilder* b) { 164 GrProcessorKeyBuilder* b) {
171 const AARectEffect& aare = processor.cast<AARectEffect>(); 165 const AARectEffect& aare = processor.cast<AARectEffect>();
172 b->add32(aare.getEdgeType()); 166 b->add32(aare.getEdgeType());
173 } 167 }
174 168
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 kVec3f_GrSLType, 214 kVec3f_GrSLType,
221 kDefault_GrSLPrecision, 215 kDefault_GrSLPrecision,
222 "edges", 216 "edges",
223 cpe.getEdgeCount(), 217 cpe.getEdgeCount(),
224 &edgeArrayName); 218 &edgeArrayName);
225 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 219 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
226 fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); 220 fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
227 fsBuilder->codeAppend("\t\tfloat edge;\n"); 221 fsBuilder->codeAppend("\t\tfloat edge;\n");
228 const char* fragmentPos = fsBuilder->fragmentPosition(); 222 const char* fragmentPos = fsBuilder->fragmentPosition();
229 for (int i = 0; i < cpe.getEdgeCount(); ++i) { 223 for (int i = 0; i < cpe.getEdgeCount(); ++i) {
230 // Add a device space "nudge" of 0.05f, 0.05f to match raster's rounding behavior for 224 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n",
231 // BW clipping/drawing. Since we are "nudging" fragment positions we hav e to go in
232 // the opposite direction.
233 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x - 0.05f, %s.y - 0.05f, 1));\n",
234 edgeArrayName, i, fragmentPos, fragmentPos); 225 edgeArrayName, i, fragmentPos, fragmentPos);
235 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { 226 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
236 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); 227 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n");
237 } else { 228 } else {
238 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");
239 } 230 }
240 fsBuilder->codeAppend("\t\talpha *= edge;\n"); 231 fsBuilder->codeAppend("\t\talpha *= edge;\n");
241 } 232 }
242 233
243 // Woe is me. See skbug.com/2149. 234 // Woe is me. See skbug.com/2149.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 372 }
382 373
383 GrFragmentProcessor* fp; 374 GrFragmentProcessor* fp;
384 do { 375 do {
385 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 376 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
386 random->nextULessThan(kGrProcessorEdgeTy peCnt)); 377 random->nextULessThan(kGrProcessorEdgeTy peCnt));
387 fp = GrConvexPolyEffect::Create(edgeType, count, edges); 378 fp = GrConvexPolyEffect::Create(edgeType, count, edges);
388 } while (NULL == fp); 379 } while (NULL == fp);
389 return fp; 380 return fp;
390 } 381 }
OLDNEW
« no previous file with comments | « src/core/SkClipStack.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698