|
@@ -6,6 +6,62 @@
|
|
|
#include "qemu-common.h"
|
|
|
#include "ui/console.h"
|
|
|
|
|
|
+PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format)
|
|
|
+{
|
|
|
+ PixelFormat pf;
|
|
|
+ uint8_t bpp;
|
|
|
+
|
|
|
+ bpp = pf.bits_per_pixel = PIXMAN_FORMAT_BPP(format);
|
|
|
+ pf.bytes_per_pixel = PIXMAN_FORMAT_BPP(format) / 8;
|
|
|
+ pf.depth = PIXMAN_FORMAT_DEPTH(format);
|
|
|
+
|
|
|
+ pf.abits = PIXMAN_FORMAT_A(format);
|
|
|
+ pf.rbits = PIXMAN_FORMAT_R(format);
|
|
|
+ pf.gbits = PIXMAN_FORMAT_G(format);
|
|
|
+ pf.bbits = PIXMAN_FORMAT_B(format);
|
|
|
+
|
|
|
+ switch (PIXMAN_FORMAT_TYPE(format)) {
|
|
|
+ case PIXMAN_TYPE_ARGB:
|
|
|
+ pf.ashift = pf.bbits + pf.gbits + pf.rbits;
|
|
|
+ pf.rshift = pf.bbits + pf.gbits;
|
|
|
+ pf.gshift = pf.bbits;
|
|
|
+ pf.bshift = 0;
|
|
|
+ break;
|
|
|
+ case PIXMAN_TYPE_ABGR:
|
|
|
+ pf.ashift = pf.rbits + pf.gbits + pf.bbits;
|
|
|
+ pf.bshift = pf.rbits + pf.gbits;
|
|
|
+ pf.gshift = pf.rbits;
|
|
|
+ pf.rshift = 0;
|
|
|
+ break;
|
|
|
+ case PIXMAN_TYPE_BGRA:
|
|
|
+ pf.bshift = bpp - pf.bbits;
|
|
|
+ pf.gshift = bpp - (pf.bbits + pf.gbits);
|
|
|
+ pf.rshift = bpp - (pf.bbits + pf.gbits + pf.rbits);
|
|
|
+ pf.ashift = 0;
|
|
|
+ break;
|
|
|
+ case PIXMAN_TYPE_RGBA:
|
|
|
+ pf.rshift = bpp - pf.rbits;
|
|
|
+ pf.gshift = bpp - (pf.rbits + pf.gbits);
|
|
|
+ pf.bshift = bpp - (pf.rbits + pf.gbits + pf.bbits);
|
|
|
+ pf.ashift = 0;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ g_assert_not_reached();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pf.amax = (1 << pf.abits) - 1;
|
|
|
+ pf.rmax = (1 << pf.rbits) - 1;
|
|
|
+ pf.gmax = (1 << pf.gbits) - 1;
|
|
|
+ pf.bmax = (1 << pf.bbits) - 1;
|
|
|
+ pf.amask = pf.amax << pf.ashift;
|
|
|
+ pf.rmask = pf.rmax << pf.rshift;
|
|
|
+ pf.gmask = pf.gmax << pf.gshift;
|
|
|
+ pf.bmask = pf.bmax << pf.bshift;
|
|
|
+
|
|
|
+ return pf;
|
|
|
+}
|
|
|
+
|
|
|
int qemu_pixman_get_type(int rshift, int gshift, int bshift)
|
|
|
{
|
|
|
int type = PIXMAN_TYPE_OTHER;
|