implement masking in sp_region_fill()
authorBrian <brian@i915.localnet.net>
Wed, 1 Aug 2007 22:15:30 +0000 (16:15 -0600)
committerBrian <brian@i915.localnet.net>
Wed, 1 Aug 2007 22:15:30 +0000 (16:15 -0600)
src/mesa/pipe/softpipe/sp_region.c

index 34fbcce8ca21ccb9bd86e438160698ef74a07c48..1dbd1609e373b39f0fabb04221521f7a084f452d 100644 (file)
@@ -112,29 +112,66 @@ sp_region_fill(struct pipe_context *pipe,
    case 1:
       {
          GLubyte *row = get_pointer(dst, dstx, dsty);
-         for (i = 0; i < height; i++) {
-            memset(row, value, width);
-            row += dst->pitch;
+         if ((mask & 0xff) == 0xff) {
+            /* no masking */
+            for (i = 0; i < height; i++) {
+               memset(row, value, width);
+               row += dst->pitch;
+            }
+         }
+         else {
+            value &= mask;
+            mask = ~mask;
+            for (i = 0; i < height; i++) {
+               for (j = 0; j < width; j++) {
+                  row[j] = (row[j] & mask) | value;
+               }
+               row += dst->pitch;
+            }
          }
       }
       break;
    case 2:
       {
          GLushort *row = (GLushort *) get_pointer(dst, dstx, dsty);
-         for (i = 0; i < height; i++) {
-            for (j = 0; j < width; j++)
-               row[j] = value;
-            row += dst->pitch;
+         if ((mask & 0xffff) == 0xffff) {
+            /* no masking */
+            for (i = 0; i < height; i++) {
+               for (j = 0; j < width; j++)
+                  row[j] = value;
+               row += dst->pitch;
+            }
+         }
+         else {
+            value &= mask;
+            mask = ~mask;
+            for (i = 0; i < height; i++) {
+               for (j = 0; j < width; j++)
+                  row[j] = (row[j] & mask) | value;
+               row += dst->pitch;
+            }
          }
       }
       break;
    case 4:
       {
          GLuint *row = (GLuint *) get_pointer(dst, dstx, dsty);
-         for (i = 0; i < height; i++) {
-            for (j = 0; j < width; j++)
-               row[j] = value;
-            row += dst->pitch;
+         if (mask == 0xffffffff) {
+            /* no masking */
+            for (i = 0; i < height; i++) {
+               for (j = 0; j < width; j++)
+                  row[j] = value;
+               row += dst->pitch;
+            }
+         }
+         else {
+            value &= mask;
+            mask = ~mask;
+            for (i = 0; i < height; i++) {
+               for (j = 0; j < width; j++)
+                  row[j] = (row[j] & mask) | value;
+               row += dst->pitch;
+            }
          }
       }
       break;