diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 51: Support source pixmaps of any format for pixman compositing.

Message ID 20110719160224.10139.89213.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org July 19, 2011, 4:02 p.m. UTC
------------------------------------------------------------
revno: 51
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Tue 2011-07-19 19:01:23 +0300
message:
  Support source pixmaps of any format for pixman compositing.
modified:
  src/composite-window-pixman.cc


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/composite-window-pixman.cc'
--- src/composite-window-pixman.cc	2011-07-18 16:26:56 +0000
+++ src/composite-window-pixman.cc	2011-07-19 16:01:23 +0000
@@ -146,17 +146,34 @@ 
     return true;
 }
 
+static unsigned int
+count_bits(unsigned long n)
+{
+    unsigned int c;
+    for (c = 0; n; c++)
+        n &= n - 1;
+    return c;
+}
+
 bool
 CompositeWindowPixman::ensure_pixman_image()
 {
     if (pixman_image_)
         return true;
 
+    unsigned int red_bits = count_bits(ximage_->red_mask);
+    unsigned int green_bits = count_bits(ximage_->green_mask);
+    unsigned int blue_bits = count_bits(ximage_->blue_mask);
+    unsigned int alpha_bits = ximage_->depth - (red_bits + green_bits + blue_bits);
+
     pixman_format_code_t format =
         static_cast<pixman_format_code_t>(
-            PIXMAN_FORMAT(ximage_->bits_per_pixel,
-                          PIXMAN_TYPE_ARGB,
-                          ximage_->depth - 24, 8, 8, 8));
+                PIXMAN_FORMAT(ximage_->bits_per_pixel,
+                              PIXMAN_TYPE_ARGB,
+                              alpha_bits, red_bits, green_bits, blue_bits));
+
+    Log::debug("Creating pixman image with bpp: %u format: a%ur%ug%ub%u\n",
+               ximage_->bits_per_pixel, alpha_bits, red_bits, green_bits, blue_bits);
 
     if (!pixman_format_supported_source(format)) {
         Log::debug("Source pixmap format is not supported by pixman!");
@@ -164,7 +181,7 @@ 
     else {
         pixman_image_ = pixman_image_create_bits(format, width_, height_,
                                                  reinterpret_cast<uint32_t *>(ximage_->data),
-                                                 width_ * 4);
+                                                 ximage_->bytes_per_line);
     }
 
     return pixman_image_ != 0;