From 4c0e526c0bfedcaf66c055bfec8976978c34fbb5 Mon Sep 17 00:00:00 2001 From: Walter Werner SCHNEIDER Date: Tue, 29 Jul 2025 15:33:18 +0300 Subject: [PATCH] gpu/clip: fix vertex corner positions Fixes the 1px overlap of curve quads. Without this patch the rendered quads were skewed vertically and were 2 pixels shorter in height. The NorthWest pixels were moved to the SouthWest instead of NorthWest and the SouthEast pixels were moved to the NorthEast instead of SouthEast. References: https://todo.sr.ht/~eliasnaur/gio/339 Signed-off-by: Walter Werner SCHNEIDER Signed-off-by: Elias Naur --- gpu/clip.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gpu/clip.go b/gpu/clip.go index 3ba61d00..34d89e44 100644 --- a/gpu/clip.go +++ b/gpu/clip.go @@ -19,10 +19,10 @@ type quadSplitter struct { func encodeQuadTo(data []byte, meta uint32, from, ctrl, to f32.Point) { // inlined code: - // encodeVertex(data, meta, -1, 1, from, ctrl, to) + // encodeVertex(data, meta, 1, -1, from, ctrl, to) // encodeVertex(data[vertStride:], meta, 1, 1, from, ctrl, to) // encodeVertex(data[vertStride*2:], meta, -1, -1, from, ctrl, to) - // encodeVertex(data[vertStride*3:], meta, 1, -1, from, ctrl, to) + // encodeVertex(data[vertStride*3:], meta, -1, 1, from, ctrl, to) // this code needs to stay in sync with `vertex.encode`. bo := binary.LittleEndian @@ -48,10 +48,10 @@ func encodeQuadTo(data []byte, meta uint32, from, ctrl, to f32.Point) { } const ( - nwCorner = 1*0.25 + 0*0.5 - neCorner = 1*0.25 + 1*0.5 - swCorner = 0*0.25 + 0*0.5 - seCorner = 0*0.25 + 1*0.5 + nwCorner = 1*0.5 + 0*0.25 + neCorner = 1*0.5 + 1*0.25 + swCorner = 0*0.5 + 0*0.25 + seCorner = 0*0.5 + 1*0.25 ) func encodeVertex(data []byte, meta uint32, cornerx, cornery int16, from, ctrl, to f32.Point) {