From 8ab8ff072cbfb539f594425233a3805367733e42 Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Thu, 26 Feb 2009 23:18:22 +0000 Subject: Linux: support displays without Xrender support. VNC servers don't support Xrender. For this use case, we implement a slow fallback which byte-fiddles the Skia bitmaps as needed to support 32 and 24 bit visuals. Review URL: http://codereview.chromium.org/27227 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10523 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/x11_util.cc | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'chrome/common/x11_util.cc') diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc index 264ab9c..d10c320 100644 --- a/chrome/common/x11_util.cc +++ b/chrome/common/x11_util.cc @@ -82,6 +82,22 @@ bool QuerySharedMemorySupport(Display* dpy) { return shared_memory_support; } +bool QueryRenderSupport(Display* dpy) { + static bool render_supported = false; + static bool render_supported_cached = false; + + if (render_supported_cached) + return render_supported; + + // We don't care about the version of Xrender since all the features which + // we use are included in every version. + int dummy; + render_supported = XRenderQueryExtension(dpy, &dummy, &dummy); + render_supported_cached = true; + + return render_supported; +} + XID GetX11RootWindow() { return GDK_WINDOW_XID(gdk_get_default_root_window()); } @@ -94,14 +110,30 @@ void* GetVisualFromGtkWidget(GtkWidget* widget) { return GDK_VISUAL_XVISUAL(gtk_widget_get_visual(widget)); } +int BitsPerPixelForPixmapDepth(Display* dpy, int depth) { + int count; + XPixmapFormatValues* formats = XListPixmapFormats(dpy, &count); + if (!formats) + return -1; + + int bits_per_pixel = -1; + for (int i = 0; i < count; ++i) { + if (formats[i].depth == depth) { + bits_per_pixel = formats[i].bits_per_pixel; + break; + } + } + + XFree(formats); + return bits_per_pixel; +} + XRenderPictFormat* GetRenderVisualFormat(Display* dpy, Visual* visual) { static XRenderPictFormat* pictformat = NULL; if (pictformat) return pictformat; - int dummy; - if (!XRenderQueryExtension(dpy, &dummy, &dummy)) - CHECK(false) << "XRENDER not supported on display"; + DCHECK(QueryRenderSupport(dpy)); pictformat = XRenderFindVisualFormat(dpy, visual); CHECK(pictformat) << "XRENDER does not support default visual"; -- cgit v1.1