From 2ef7538593b1c844c52171f643a2d1dafd739ee3 Mon Sep 17 00:00:00 2001 From: Royce Mitchell III Date: Sat, 16 Aug 2003 21:17:20 +0000 Subject: [PATCH] fixed line back-tracking in Polygon to match forward-tracking. No overlap occurs between line and fill if pen width <= 1. svn path=/trunk/; revision=5606 --- reactos/apps/tests/polytest/polytest.cpp | 18 ++++++++++++------ reactos/subsys/win32k/objects/polyfill.c | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/reactos/apps/tests/polytest/polytest.cpp b/reactos/apps/tests/polytest/polytest.cpp index bb9dae9b0f8..cebf77b54d1 100644 --- a/reactos/apps/tests/polytest/polytest.cpp +++ b/reactos/apps/tests/polytest/polytest.cpp @@ -268,6 +268,10 @@ POLYGONFILL_MakeEdge(POINT From, POINT To) rc->ToX = From.x; rc->ToY = From.y; rc->YDirection = -1; + + // lines that go up get walked backwards, so need to be offset + // by -1 in order to make the walk identically on a pixel-level + rc->Error = -1; } else { @@ -276,6 +280,8 @@ POLYGONFILL_MakeEdge(POINT From, POINT To) rc->ToX = To.x; rc->ToY = To.y; rc->YDirection = 1; + + rc->Error = 0; } rc->x = rc->FromX; @@ -289,7 +295,7 @@ POLYGONFILL_MakeEdge(POINT From, POINT To) rc->ErrorMax = MAX(rc->absdx,rc->absdy); - rc->Error = rc->ErrorMax / 2; + rc->Error += rc->ErrorMax / 2; rc->XDirection = (rc->dx < 0)?(-1):(1); @@ -556,8 +562,8 @@ POLYGONFILL_FillScanLineAlternate( while ( NULL != pRight ) { - int x1 = pLeft->XIntercept[1]; - int x2 = pRight->XIntercept[0]+1; + int x1 = pLeft->XIntercept[1]+1; + int x2 = pRight->XIntercept[0]; if ( x2 > x1 ) { RECTL BoundRect; @@ -606,8 +612,8 @@ POLYGONFILL_FillScanLineWinding( while ( NULL != pRight ) { - int x1 = pLeft->XIntercept[1]; - int x2 = pRight->XIntercept[0]+1; + int x1 = pLeft->XIntercept[1]+1; + int x2 = pRight->XIntercept[0]; if ( winding && x2 > x1 ) { RECTL BoundRect; @@ -808,7 +814,7 @@ void main() const int pts_count = sizeof(pts)/sizeof(pts[0]); // use ALTERNATE or WINDING for 3rd param - Polygon ( pts, pts_count, ALTERNATE ); + Polygon ( pts, pts_count, WINDING ); // print out our "screen" for ( int y = 0; y < SCREENY; y++ ) diff --git a/reactos/subsys/win32k/objects/polyfill.c b/reactos/subsys/win32k/objects/polyfill.c index eaaf5adf4d8..1ac125424c0 100644 --- a/reactos/subsys/win32k/objects/polyfill.c +++ b/reactos/subsys/win32k/objects/polyfill.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: polyfill.c,v 1.9 2003/08/16 05:12:37 royce Exp $ +/* $Id: polyfill.c,v 1.10 2003/08/16 21:17:20 royce Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -145,6 +145,10 @@ POLYGONFILL_MakeEdge(POINT From, POINT To) rc->ToX = From.x; rc->ToY = From.y; rc->YDirection = -1; + + // lines that go up get walked backwards, so need to be offset + // by -1 in order to make the walk identically on a pixel-level + rc->Error = -1; } else { @@ -153,6 +157,8 @@ POLYGONFILL_MakeEdge(POINT From, POINT To) rc->ToX = To.x; rc->ToY = To.y; rc->YDirection = 1; + + rc->Error = 0; } rc->x = rc->FromX; @@ -166,7 +172,7 @@ POLYGONFILL_MakeEdge(POINT From, POINT To) rc->ErrorMax = MAX(rc->absdx,rc->absdy); - rc->Error = rc->ErrorMax / 2; + rc->Error += rc->ErrorMax / 2; rc->XDirection = (rc->dx < 0)?(-1):(1); @@ -433,8 +439,8 @@ POLYGONFILL_FillScanLineAlternate( while ( NULL != pRight ) { - int x1 = pLeft->XIntercept[1]; - int x2 = pRight->XIntercept[0]+1; + int x1 = pLeft->XIntercept[1]+1; + int x2 = pRight->XIntercept[0]; if ( x2 > x1 ) { RECTL BoundRect; @@ -483,8 +489,8 @@ POLYGONFILL_FillScanLineWinding( while ( NULL != pRight ) { - int x1 = pLeft->XIntercept[1]; - int x2 = pRight->XIntercept[0]+1; + int x1 = pLeft->XIntercept[1]+1; + int x2 = pRight->XIntercept[0]; if ( winding && x2 > x1 ) { RECTL BoundRect;