aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-01-30 11:24:50 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-30 11:24:50 -0800
commitb9329991426d0b77ea194a380d72d73fb855308a (patch)
tree6af899a575ba954883f30c34563a00b4528ca38e /src/gpu/gl
parent022afb8384019b448c7c1c62a9ff63fa9e477737 (diff)
Add device space "nudge" to gpu draws
This CL nudges all the GPU draws and clips slightly to match raster's round behavior for BW draws. We assume the effect will be negligible and do it for AA draws too. BUG=423834 Committed: https://skia.googlesource.com/skia/+/2d55d07501c56310f97d2092d789a2bc9fa01b78 Review URL: https://codereview.chromium.org/877473005
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
index f17e741169..f0b645ee42 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
@@ -47,13 +47,15 @@ void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posV
// Transform from Skia's device coords to GL's normalized device coords. Note that
// because we want to "nudge" the device space positions we are converting to
// non-homogeneous NDC.
+ // The "0.05" nudge serves to match the raster path's rounding for bw draws.
+ // For aa draws we just assume the impact will be minimal - so we always perform the nudge.
if (kVec3f_GrSLType == posVar.getType()) {
- this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy)/%s.z, dot(%s.yz, %s.zw)/%s.z, 0, 1);",
- posVar.c_str(), fRtAdjustName, posVar.c_str(),
- posVar.c_str(), fRtAdjustName, posVar.c_str());
+ this->codeAppendf("gl_Position = vec4((dot(%s.xz, %s.xy)/%s.z) + 0.05 * %s.x, (dot(%s.yz, %s.zw)/%s.z) + 0.05 * %s.z, 0, 1);",
+ posVar.c_str(), fRtAdjustName, posVar.c_str(), fRtAdjustName,
+ posVar.c_str(), fRtAdjustName, posVar.c_str(), fRtAdjustName);
} else {
SkASSERT(kVec2f_GrSLType == posVar.getType());
- this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
+ this->codeAppendf("gl_Position = vec4((%s.x + 0.05) * %s.x + %s.y, (%s.y + 0.05) * %s.z + %s.w, 0, 1);",
posVar.c_str(), fRtAdjustName, fRtAdjustName,
posVar.c_str(), fRtAdjustName, fRtAdjustName);
}