pixman: add qemu_pixman_color()
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 6 Mar 2013 13:14:17 +0000 (14:14 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 16 Apr 2013 07:03:47 +0000 (09:03 +0200)
Helper function to map qemu colors (32bit integer + matching PixelFormat)
into pixman_color_t.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
include/ui/qemu-pixman.h
ui/qemu-pixman.c

index b032f529aa73b0190230fe9bae92863b140d9389..b0f09b587fb13103cd7bad6386ab93be6325dc86 100644 (file)
@@ -43,4 +43,6 @@ pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
                                           pixman_image_t *image);
 void qemu_pixman_image_unref(pixman_image_t *image);
 
+pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color);
+
 #endif /* QEMU_PIXMAN_H */
index 6dcbe905468de5152665e59abcf150d5480486e0..be551e09edd7f4122865b8a5609c39d454a6d37b 100644 (file)
@@ -79,3 +79,14 @@ void qemu_pixman_image_unref(pixman_image_t *image)
     }
     pixman_image_unref(image);
 }
+
+pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color)
+{
+    pixman_color_t c;
+
+    c.red   = ((color & pf->rmask) >> pf->rshift) << (16 - pf->rbits);
+    c.green = ((color & pf->gmask) >> pf->gshift) << (16 - pf->gbits);
+    c.blue  = ((color & pf->bmask) >> pf->bshift) << (16 - pf->bbits);
+    c.alpha = ((color & pf->amask) >> pf->ashift) << (16 - pf->abits);
+    return c;
+}