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

Unified Diff: ui/gl/gl_visual_picker_glx.h

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: auto* Created 4 years, 3 months 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 | « ui/gl/gl_surface_glx.cc ('k') | ui/gl/gl_visual_picker_glx.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_visual_picker_glx.h
diff --git a/ui/gl/gl_visual_picker_glx.h b/ui/gl/gl_visual_picker_glx.h
new file mode 100644
index 0000000000000000000000000000000000000000..bc0ca1780d318e150f6e926004b6132687858f0d
--- /dev/null
+++ b/ui/gl/gl_visual_picker_glx.h
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GL_GL_VISUAL_PICKER_GLX_H_
+#define UI_GL_GL_VISUAL_PICKER_GLX_H_
+
+#include <X11/Xutil.h>
+
+#include <vector>
+
+#include "base/macros.h"
+#include "ui/gfx/x/x11_types.h"
+#include "ui/gl/gl_export.h"
+
+namespace base {
+template <typename T>
+struct DefaultSingletonTraits;
+}
+
+namespace gl {
+
+// Picks the best X11 visuals to use for GL. This class is adapted from GTK's
+// pick_better_visual_for_gl. Tries to find visuals that
+// 1. Support GL
+// 2. Support double buffer
+// 3. Have an alpha channel only if we want one
+class GL_EXPORT GLVisualPickerGLX {
+ public:
+ static GLVisualPickerGLX* GetInstance();
+
+ ~GLVisualPickerGLX();
+
+ const XVisualInfo& system_visual() { return system_visual_; };
+
+ const XVisualInfo& rgba_visual() { return rgba_visual_; };
+
+ private:
+ friend struct base::DefaultSingletonTraits<GLVisualPickerGLX>;
+
+ XVisualInfo PickBestGlVisual(const std::vector<XVisualInfo>& visuals,
+ bool want_alpha) const;
+
+ XVisualInfo PickBestSystemVisual(
+ const std::vector<XVisualInfo>& visuals) const;
+
+ XVisualInfo PickBestRgbaVisual(const std::vector<XVisualInfo>& visuals) const;
+
+ XDisplay* display_;
+
+ bool has_glx_visual_rating_;
+ bool has_glx_multisample_;
+
+ XVisualInfo system_visual_;
+ XVisualInfo rgba_visual_;
+
+ GLVisualPickerGLX();
+
+ DISALLOW_COPY_AND_ASSIGN(GLVisualPickerGLX);
+};
+
+} // namespace gl
+
+#endif // UI_GL_GL_VISUAL_PICKER_GLX_H_
« no previous file with comments | « ui/gl/gl_surface_glx.cc ('k') | ui/gl/gl_visual_picker_glx.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698