chiark / gitweb /
Optimised copyout from XImage for 24-deep 32bpp RGB LE XImages
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Jul 2009 14:14:27 +0000 (15:14 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Jul 2009 14:14:27 +0000 (15:14 +0100)
pctb/pages.c
pctb/x.gdb

index fcee3d5845eaae1c47f97aa2d965bf623b820ca0..433ea36bfcbf9900385a86414a434a0e85dfdab2 100644 (file)
@@ -225,6 +225,8 @@ static void compute_shift_mask(ShMask *sm, unsigned long ximage_mask) {
   }
   assert(sm->lshift < LONG_BIT);
   assert(sm->rshift < LONG_BIT);
+  debugf("SHIFTMASK %p={.lshift=%d, .rshift=%d} image_mask=%lx\n",
+        sm, sm->lshift, sm->rshift, ximage_mask);
 }
 
 static void rtimestamp(double *t, const char *wh) {
@@ -273,13 +275,31 @@ static void snapshot(Snapshot **output) {
   int x,y,i;
   unsigned char *op= (*output)->data;
   for (y=0; y<wheight; y++) {
-    for (x=0; x<wwidth; x++) {
-      long xrgb= XGetPixel(im_use,x,y);
-      for (i=0; i<3; i++) {
-       unsigned long sample=
-         ((xrgb << shiftmasks[i].lshift) >> shiftmasks[i].rshift)
-         & SAMPLEMASK;
-       *op++= sample;
+    if (im_use->xoffset == 0 &&
+       im_use->format == ZPixmap &&
+       im_use->byte_order == LSBFirst &&
+       im_use->depth == 24 &&
+       im_use->bits_per_pixel == 32 &&
+       im_use->red_mask   == 0x0000ffU &&
+       im_use->green_mask == 0x00ff00U &&
+       im_use->blue_mask  == 0xff0000U) {
+      const char *p= im_use->data + y * im_use->bytes_per_line;
+//      debugf("optimised copy y=%d",y);
+      for (x=0; x<wwidth; x++) {
+       *op++ = *p++;
+       *op++ = *p++;
+       *op++ = *p++;
+       p++;
+      }
+    } else {
+      for (x=0; x<wwidth; x++) {
+       long xrgb= XGetPixel(im_use,x,y);
+       for (i=0; i<3; i++) {
+         unsigned long sample=
+           ((xrgb << shiftmasks[i].lshift) >> shiftmasks[i].rshift)
+           & SAMPLEMASK;
+         *op++= sample;
+       }
       }
     }
   }
index 208882594ddd660df747f93373dd47a29c6a826a..9c71346a88a4995fd7bec6895ed93a7095b8b4c8 100644 (file)
@@ -1,4 +1,4 @@
 file ypp-commodities
-set args --same --test-servers --raw-tsv
-break findchar
+set args --screenshot-only --test-servers --single-page
+break pages.c:277
 run