aboutsummaryrefslogtreecommitdiff
path: root/qemu-pixman.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-11-01 11:14:39 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-11-01 11:14:39 -0500
commit4ba79505f43bd0ace35c3fe42197eb02e7e0478e (patch)
treeeb1ecd216c1134a88ac0e2d3bc7185319c82fb95 /qemu-pixman.c
parentd971919f08ca300e7b3595a4c5ddaea2ce8fc3ba (diff)
parent64f735920ad319aee860e56bb9bad6cfccf4ad40 (diff)
Merge remote-tracking branch 'kraxel/pixman.v3' into staging
* kraxel/pixman.v3: (22 commits) pixman: drop obsolete fields from DisplaySurface pixman/vnc: remove dead code. pixman/vnc: remove rgb_prepare_row* functions pixman/vnc: use pixman images in vnc. pixman: switch screendump function. vga: stop direct access to DisplaySurface fields. qxl: stop direct access to DisplaySurface fields. console: don't set PixelFormat alpha fields for 32bpp console: make qemu_alloc_display static pixman: add pixman image to DisplaySurface pixman: helper functions pixman: windup in configure & makefiles pixman: add submodule console: remove DisplayAllocator console: remove dpy_gfx_fill vga: fix text mode updating console: init displaychangelisteners on register console: untangle gfx & txt updates console: s/TextConsole/QemuConsole/ console: move set_mouse + cursor_define callbacks ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-pixman.c')
-rw-r--r--qemu-pixman.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/qemu-pixman.c b/qemu-pixman.c
new file mode 100644
index 0000000000..7547ed74c1
--- /dev/null
+++ b/qemu-pixman.c
@@ -0,0 +1,60 @@
+#include "qemu-pixman.h"
+
+int qemu_pixman_get_type(int rshift, int gshift, int bshift)
+{
+ int type = PIXMAN_TYPE_OTHER;
+
+ if (rshift > gshift && gshift > bshift) {
+ if (bshift == 0) {
+ type = PIXMAN_TYPE_ARGB;
+ } else {
+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0, 21, 8)
+ type = PIXMAN_TYPE_RGBA;
+#endif
+ }
+ } else if (rshift < gshift && gshift < bshift) {
+ if (rshift == 0) {
+ type = PIXMAN_TYPE_ABGR;
+ } else {
+ type = PIXMAN_TYPE_BGRA;
+ }
+ }
+ return type;
+}
+
+pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf)
+{
+ pixman_format_code_t format;
+ int type;
+
+ type = qemu_pixman_get_type(pf->rshift, pf->gshift, pf->bshift);
+ format = PIXMAN_FORMAT(pf->bits_per_pixel, type,
+ pf->abits, pf->rbits, pf->gbits, pf->bbits);
+ if (!pixman_format_supported_source(format)) {
+ return 0;
+ }
+ return format;
+}
+
+pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
+ int width)
+{
+ pixman_image_t *image = pixman_image_create_bits(format, width, 1, NULL, 0);
+ assert(image != NULL);
+ return image;
+}
+
+void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
+ int width, int y)
+{
+ pixman_image_composite(PIXMAN_OP_SRC, fb, NULL, linebuf,
+ 0, y, 0, 0, 0, 0, width, 1);
+}
+
+void qemu_pixman_image_unref(pixman_image_t *image)
+{
+ if (image == NULL) {
+ return;
+ }
+ pixman_image_unref(image);
+}