]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
optimize scanning for 0 alpha in FinishBGRA8
authoreihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 4 Apr 2011 21:21:49 +0000 (21:21 +0000)
committereihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 4 Apr 2011 21:21:49 +0000 (21:21 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11022 d7cf8633-e32d-0410-b094-e92efae38249

dpsoftrast.c

index 3b0ec6e02c127a39a5e74da98b8ea70068105d36..4f7fbf34aa53b2933e908ccdc70d20cb71e12d4a 100644 (file)
@@ -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: