From 843778ed1f2f0f1c83014fafb800625c9bb55623 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 7 Dec 2024 19:32:02 +0000 Subject: [PATCH] Bug 1933668 - Undo half-pixel shift from WGR when using AA-Stroke. r=aosmond, a=dmeehan Differential Revision: https://phabricator.services.mozilla.com/D231471 --- dom/canvas/DrawTargetWebgl.cpp | 7 ++++++- .../canvas/element/path-objects/2d.path.open.arc.html.ini | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 testing/web-platform/meta/html/canvas/element/path-objects/2d.path.open.arc.html.ini diff --git a/dom/canvas/DrawTargetWebgl.cpp b/dom/canvas/DrawTargetWebgl.cpp index f6362ab0da569..bbeda4f347467 100644 --- a/dom/canvas/DrawTargetWebgl.cpp +++ b/dom/canvas/DrawTargetWebgl.cpp @@ -3096,7 +3096,12 @@ static inline AAStroke::LineCap ToAAStrokeLineCap(CapStyle aCap) { } static inline Point WGRPointToPoint(const WGR::Point& aPoint) { - return Point(IntPoint(aPoint.x, aPoint.y)) * (1.0f / 16.0f); + // WGR points are 28.4 fixed-point where (0.0, 0.0) is assumed to be a pixel + // center, as opposed to (0.5, 0.5) in canvas device space. WGR thus shifts + // each point by (-0.5, -0.5). To undo this, transform from fixed-point back + // to floating-point, and reverse the pixel shift by adding back (0.5, 0.5). + return Point(IntPoint(aPoint.x, aPoint.y)) * (1.0f / 16.0f) + + Point(0.5f, 0.5f); } // Generates a vertex buffer for a stroked path using aa-stroke. diff --git a/testing/web-platform/meta/html/canvas/element/path-objects/2d.path.open.arc.html.ini b/testing/web-platform/meta/html/canvas/element/path-objects/2d.path.open.arc.html.ini deleted file mode 100644 index 0632738fba088..0000000000000 --- a/testing/web-platform/meta/html/canvas/element/path-objects/2d.path.open.arc.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[2d.path.open.arc.html] - [line caps should be drawn on open arcs] - expected: FAIL