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

Unified Diff: src/gpu/effects/GrConvexPolyEffect.cpp

Issue 877473005: Add device space "nudge" to gpu draws Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix 'f' again Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkClipStack.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrConvexPolyEffect.cpp
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 7035094fa6a57794c7a7f48b27747c18d2ffb613..d494bf2467715e77383b991f56cdf013f41e3133 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -137,10 +137,14 @@ void GLAARectEffect::emitCode(GrGLFPBuilder* builder,
fsBuilder->codeAppendf("\t\tfloat alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n");
} else {
fsBuilder->codeAppendf("\t\tfloat alpha = 1.0;\n");
- fsBuilder->codeAppendf("\t\talpha *= (%s.x - %s.x) > -0.5 ? 1.0 : 0.0;\n", fragmentPos, rectName);
- fsBuilder->codeAppendf("\t\talpha *= (%s.z - %s.x) > -0.5 ? 1.0 : 0.0;\n", rectName, fragmentPos);
- fsBuilder->codeAppendf("\t\talpha *= (%s.y - %s.y) > -0.5 ? 1.0 : 0.0;\n", fragmentPos, rectName);
- fsBuilder->codeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n", rectName, fragmentPos);
+ fsBuilder->codeAppendf("\t\talpha *= (%s.x - %s.x) > -0.5 ? 1.0 : 0.0;\n",
+ fragmentPos, rectName);
+ fsBuilder->codeAppendf("\t\talpha *= (%s.z - %s.x) > -0.5 ? 1.0 : 0.0;\n",
+ rectName, fragmentPos);
+ fsBuilder->codeAppendf("\t\talpha *= (%s.y - %s.y) > -0.5 ? 1.0 : 0.0;\n",
+ fragmentPos, rectName);
+ fsBuilder->codeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n",
+ rectName, fragmentPos);
}
if (GrProcessorEdgeTypeIsInverseFill(aare.getEdgeType())) {
@@ -154,8 +158,10 @@ void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrProces
const AARectEffect& aare = processor.cast<AARectEffect>();
const SkRect& rect = aare.getRect();
if (rect != fPrevRect) {
- pdman.set4f(fRectUniform, rect.fLeft + 0.5f, rect.fTop + 0.5f,
- rect.fRight - 0.5f, rect.fBottom - 0.5f);
+ // Add a device space "nudge" of 0.003f, 0.003f to match raster's rounding behavior for
+ // BW clipping/drawing
+ pdman.set4f(fRectUniform, rect.fLeft + 0.503f, rect.fTop + 0.503f,
+ rect.fRight - 0.497f, rect.fBottom - 0.497f);
fPrevRect = rect;
}
}
@@ -221,7 +227,10 @@ void GrGLConvexPolyEffect::emitCode(GrGLFPBuilder* builder,
fsBuilder->codeAppend("\t\tfloat edge;\n");
const char* fragmentPos = fsBuilder->fragmentPosition();
for (int i = 0; i < cpe.getEdgeCount(); ++i) {
- fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n",
+ // Add a device space "nudge" of 0.003f, 0.003f to match raster's rounding behavior for
+ // BW clipping/drawing. Since we are "nudging" fragment positions we have to go in
+ // the opposite direction.
+ fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x - 0.003, %s.y - 0.003, 1));\n",
edgeArrayName, i, fragmentPos, fragmentPos);
if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n");
« 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