From 1b31df6b230b39e9b0eed0f3f4707486e7d71c47 Mon Sep 17 00:00:00 2001 From: eihrul Date: Mon, 4 Apr 2011 21:21:49 +0000 Subject: [PATCH] optimize scanning for 0 alpha in FinishBGRA8 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11022 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=22669287c86f5c625403e69cacc47a395751f783 --- dpsoftrast.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dpsoftrast.c b/dpsoftrast.c index 3b0ec6e0..4f7fbf34 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -2047,6 +2047,7 @@ void DPSOFTRAST_Draw_Span_FinishBGRA8(DPSOFTRAST_State_Thread *thread, const DPS int x; int startx = span->startx; int endx = span->endx; + int maskx; int subx; const unsigned int * RESTRICT ini = (const unsigned int *)in4ub; unsigned char * RESTRICT pixelmask = span->pixelmask; @@ -2068,9 +2069,25 @@ void DPSOFTRAST_Draw_Span_FinishBGRA8(DPSOFTRAST_State_Thread *thread, const DPS case DPSOFTRAST_BLENDMODE_ALPHA: case DPSOFTRAST_BLENDMODE_ADDALPHA: case DPSOFTRAST_BLENDMODE_SUBALPHA: + maskx = startx; for (x = startx;x < endx;x++) - if (in4ub[x*4+3] < 1) - pixelmask[x] = false; + { + if (in4ub[x*4+3] >= 1) + { + startx = x; + for (;;) + { + while (++x < endx && in4ub[x*4+3] >= 1) ; + maskx = x; + if (x >= endx) break; + ++x; + while (++x < endx && in4ub[x*4+3] < 1) pixelmask[x] = false; + if (x >= endx) break; + } + break; + } + } + endx = maskx; break; case DPSOFTRAST_BLENDMODE_OPAQUE: case DPSOFTRAST_BLENDMODE_ADD: -- 2.39.2