=== modified file 'src/composite-window-pixman.cc'
@@ -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;