diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 23:18:22 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 23:18:22 +0000 |
commit | 8ab8ff072cbfb539f594425233a3805367733e42 (patch) | |
tree | 4e55550442aca6b6a3729ca0b121864ca9710735 /chrome/common/x11_util.cc | |
parent | 76d2816ad27088432ce9d946facfaa091151dcf6 (diff) | |
download | chromium_src-8ab8ff072cbfb539f594425233a3805367733e42.zip chromium_src-8ab8ff072cbfb539f594425233a3805367733e42.tar.gz chromium_src-8ab8ff072cbfb539f594425233a3805367733e42.tar.bz2 |
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
Diffstat (limited to 'chrome/common/x11_util.cc')
-rw-r--r-- | chrome/common/x11_util.cc | 38 |
1 files changed, 35 insertions, 3 deletions
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"; |