Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Unified Diff: ui/base/x/x11_util.cc

Issue 1429083002: gl_surface_egl: ensure off and on screen surfaces use the same EGLConfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | ui/base/x/x11_util_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/x/x11_util.cc
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index f36aa0101cebfc17d925b5d7a2c1fd764f98e6c1..b253a778b79bba0667d4f8f161559244cd90d92b 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -53,6 +53,11 @@
#include "ui/gfx/skia_util.h"
#include "ui/gfx/x/x11_error_tracker.h"
+#if !defined(OS_CHROMEOS)
+#include "base/command_line.h"
+#include "ui/gfx/x/x11_switches.h"
+#endif
+
#if defined(OS_FREEBSD)
#include <sys/sysctl.h>
#include <sys/types.h>
@@ -1409,6 +1414,64 @@ void LogErrorEventDescription(XDisplay* dpy,
<< " (" << request_str << ")";
}
+#if !defined(OS_CHROMEOS)
+void ChooseVisualForWindow(Visual** visual, int* depth) {
+ static Visual* s_visual = NULL;
+ static int s_depth = 0;
+
+ if (!s_visual) {
+ XDisplay* display = gfx::GetXDisplay();
+ XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False);
+
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableTransparentVisuals) &&
+ XGetSelectionOwner(display, NET_WM_CM_S0) != None) {
+ // Choose the first ARGB8888 visual
+ XVisualInfo visual_template;
+ visual_template.screen = 0;
+
+ int visuals_len;
+ gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo(
+ display, VisualScreenMask, &visual_template, &visuals_len));
+ for (int i = 0; i < visuals_len; ++i) {
+ // Why support only 8888 ARGB? Because it's all that GTK+ supports. In
+ // gdkvisual-x11.cc, they look for this specific visual and use it for
+ // all their alpha channel using needs.
+ //
+ // TODO(erg): While the following does find a valid visual, some GL
+ // drivers
+ // don't believe that this has an alpha channel. According to marcheu@,
+ // this should work on open source driver though. (It doesn't work with
+ // NVidia's binaries currently.) http://crbug.com/369209
+ const XVisualInfo& info = visual_list[i];
+ if (info.depth == 32 && info.visual->red_mask == 0xff0000 &&
+ info.visual->green_mask == 0x00ff00 &&
+ info.visual->blue_mask == 0x0000ff) {
+ s_visual = info.visual;
+ s_depth = info.depth;
+ break;
+ }
+ }
+ } else {
+ XWindowAttributes windowAttribs;
+ Window root = XDefaultRootWindow(display);
+ Status status = XGetWindowAttributes(display, root, &windowAttribs);
+ DCHECK(status != 0);
+ s_visual = windowAttribs.visual;
+ s_depth = windowAttribs.depth;
+ }
+ } // !s_visual
+
+ DCHECK(s_visual);
+ DCHECK(s_depth > 0);
+
+ if (visual)
+ *visual = s_visual;
+ if (depth)
+ *depth = s_depth;
+}
+#endif
+
// ----------------------------------------------------------------------------
// End of x11_util_internal.h
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | ui/base/x/x11_util_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698