diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-04-21 12:20:33 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-04-23 16:36:35 +0200 |
commit | cfa250caa24593b24e13290bf7c6216b871b8c7a (patch) | |
tree | 2f7ef4788f1a7a0eec51dd35a67bfb07f52c3c1f /client | |
parent | 2d6fbde89b08b7dd4a2050c71fe6663ea8e9c2d9 (diff) | |
download | spice-cfa250caa24593b24e13290bf7c6216b871b8c7a.tar.gz spice-cfa250caa24593b24e13290bf7c6216b871b8c7a.tar.xz spice-cfa250caa24593b24e13290bf7c6216b871b8c7a.zip |
Add XPlatform::get_screen_format for X11
Diffstat (limited to 'client')
-rw-r--r-- | client/x11/platform.cpp | 26 | ||||
-rw-r--r-- | client/x11/x_platform.h | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp index dba276de..5f6c1fed 100644 --- a/client/x11/platform.cpp +++ b/client/x11/platform.cpp @@ -67,6 +67,7 @@ static Display* x_display = NULL; static bool x_shm_avail = false; static XVisualInfo **vinfo = NULL; +static RedDrawable::Format *screen_format = NULL; static GLXFBConfig **fb_config = NULL; static XIM x_input_method = NULL; static XIC x_input_context = NULL; @@ -202,6 +203,11 @@ XVisualInfo** XPlatform::get_vinfo() return vinfo; } +RedDrawable::Format XPlatform::get_screen_format(int screen) +{ + return screen_format[screen]; +} + GLXFBConfig** XPlatform::get_fbconfig() { return fb_config; @@ -2194,6 +2200,8 @@ void Platform::init() memset(vinfo, 0, sizeof(XVisualInfo *) * ScreenCount(x_display)); fb_config = new GLXFBConfig *[ScreenCount(x_display)]; memset(fb_config, 0, sizeof(GLXFBConfig *) * ScreenCount(x_display)); + screen_format = new RedDrawable::Format[ScreenCount(x_display)]; + memset(screen_format, 0, sizeof(RedDrawable::Format) * ScreenCount(x_display)); if (threads_enable && glXQueryExtension(x_display, &err, &ev)) { int num_configs; @@ -2235,6 +2243,24 @@ void Platform::init() if (vinfo[i] == NULL) { THROW("Unable to find a visual for screen"); } + if ((vinfo[i]->depth == 32 || vinfo[i]->depth == 24) && + vinfo[i]->red_mask == 0xff0000 && + vinfo[i]->green_mask == 0x00ff00 && + vinfo[i]->blue_mask == 0x0000ff) { + screen_format[i] = RedDrawable::RGB32; + } else if (vinfo[i]->depth == 16 && + vinfo[i]->red_mask == 0xf800 && + vinfo[i]->green_mask == 0x7e0 && + vinfo[i]->blue_mask == 0x1f) { + screen_format[i] = RedDrawable::RGB16_565; + } else if (vinfo[i]->depth == 15 && + vinfo[i]->red_mask == 0x7c00 && + vinfo[i]->green_mask == 0x3e0 && + vinfo[i]->blue_mask == 0x1f) { + screen_format[i] = RedDrawable::RGB16_555; + } else { + THROW("Unsupported visual for screen"); + } } XSetErrorHandler(x_error_handler); diff --git a/client/x11/x_platform.h b/client/x11/x_platform.h index 12d20f1c..575ee2d4 100644 --- a/client/x11/x_platform.h +++ b/client/x11/x_platform.h @@ -18,10 +18,14 @@ #ifndef _H_XPLATFORM #define _H_XPLATFORM +#include "red_drawable.h" +#include <X11/extensions/XShm.h> + class XPlatform { public: static Display* get_display(); static XVisualInfo** get_vinfo(); + static RedDrawable::Format get_screen_format(int screen); static GLXFBConfig** get_fbconfig(); static XIC get_input_context(); |