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

Side by Side Diff: ui/base/x/x11_util_internal.h

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: auto* Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/base/x/x11_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_X_X11_UTIL_INTERNAL_H_ 5 #ifndef UI_BASE_X_X11_UTIL_INTERNAL_H_
6 #define UI_BASE_X_X11_UTIL_INTERNAL_H_ 6 #define UI_BASE_X_X11_UTIL_INTERNAL_H_
7 7
8 // This file declares utility functions for X11 (Linux only). 8 // This file declares utility functions for X11 (Linux only).
9 // 9 //
10 // These functions require the inclusion of the Xlib headers. Since the Xlib 10 // These functions require the inclusion of the Xlib headers. Since the Xlib
11 // headers pollute so much of the namespace, this should only be included 11 // headers pollute so much of the namespace, this should only be included
12 // when needed. 12 // when needed.
13 13
14 extern "C" { 14 extern "C" {
15 #include <X11/extensions/Xrender.h> 15 #include <X11/extensions/Xrender.h>
16 #include <X11/extensions/XShm.h> 16 #include <X11/extensions/XShm.h>
17 #include <X11/Xatom.h> 17 #include <X11/Xatom.h>
18 #include <X11/Xlib.h> 18 #include <X11/Xlib.h>
19 } 19 }
20 20
21 #include <memory>
22 #include <unordered_map>
23
24 #include "base/macros.h"
21 #include "build/build_config.h" 25 #include "build/build_config.h"
22 #include "ui/base/x/ui_base_x_export.h" 26 #include "ui/base/x/ui_base_x_export.h"
27 #include "ui/gfx/x/x11_types.h"
28
29 namespace base {
30 template <typename T>
31 struct DefaultSingletonTraits;
32 }
23 33
24 namespace ui { 34 namespace ui {
25 35
26 // -------------------------------------------------------------------------- 36 // --------------------------------------------------------------------------
27 // NOTE: these functions cache the results and must be called from the UI 37 // NOTE: these functions cache the results and must be called from the UI
28 // thread. 38 // thread.
29 // Get the XRENDER format id for ARGB32 (Skia's format). 39 // Get the XRENDER format id for ARGB32 (Skia's format).
30 // 40 //
31 // NOTE:Currently this don't support multiple screens/displays. 41 // NOTE:Currently this don't support multiple screens/displays.
32 UI_BASE_X_EXPORT XRenderPictFormat* GetRenderARGB32Format(Display* dpy); 42 UI_BASE_X_EXPORT XRenderPictFormat* GetRenderARGB32Format(Display* dpy);
33 43
34 // -------------------------------------------------------------------------- 44 // --------------------------------------------------------------------------
35 // X11 error handling. 45 // X11 error handling.
36 // Sets the X Error Handlers. Passing NULL for either will enable the default 46 // Sets the X Error Handlers. Passing NULL for either will enable the default
37 // error handler, which if called will log the error and abort the process. 47 // error handler, which if called will log the error and abort the process.
38 UI_BASE_X_EXPORT void SetX11ErrorHandlers(XErrorHandler error_handler, 48 UI_BASE_X_EXPORT void SetX11ErrorHandlers(XErrorHandler error_handler,
39 XIOErrorHandler io_error_handler); 49 XIOErrorHandler io_error_handler);
40 50
41 // NOTE: This function should not be called directly from the 51 // NOTE: This function should not be called directly from the
42 // X11 Error handler because it queries the server to decode the 52 // X11 Error handler because it queries the server to decode the
43 // error message, which may trigger other errors. A suitable workaround 53 // error message, which may trigger other errors. A suitable workaround
44 // is to post a task in the error handler to call this function. 54 // is to post a task in the error handler to call this function.
45 UI_BASE_X_EXPORT void LogErrorEventDescription(Display* dpy, 55 UI_BASE_X_EXPORT void LogErrorEventDescription(Display* dpy,
46 const XErrorEvent& error_event); 56 const XErrorEvent& error_event);
47 57
48 // -------------------------------------------------------------------------- 58 // --------------------------------------------------------------------------
49 // Selects a visual with a preference for alpha support on compositing window 59 // Selects a visual with a preference for alpha support on compositing window
50 // managers. The caller must compare depth to 32 to know if the returned visual 60 // managers.
51 // supports transparency. NULL parameters are allowed to install or query the
52 // cached visual and depth.
53 #if !defined(OS_CHROMEOS) 61 #if !defined(OS_CHROMEOS)
54 UI_BASE_X_EXPORT void ChooseVisualForWindow(bool enable_transparent_visuals, 62 class UI_BASE_X_EXPORT XVisualManager {
55 Visual** visual, 63 public:
56 int* depth); 64 static XVisualManager* GetInstance();
65
66 void ChooseVisualForWindow(bool want_argb_visual,
67 Visual** visual,
68 int* depth,
69 Colormap* colormap,
70 bool* using_argb_visual);
71
72 // Called by GpuDataManagerImplPrivate when GPUInfo becomes available. It is
73 // necessary for the GPU process to find out which visuals are best for GL
74 // because we don't want to load GL in the browser process. Returns false iff
75 // |default_visual_id| or |transparent_visual_id| are invalid.
76 bool OnGPUInfoChanged(bool software_rendering,
77 VisualID default_visual_id,
78 VisualID transparent_visual_id);
79
80 ~XVisualManager();
81
82 private:
83 friend struct base::DefaultSingletonTraits<XVisualManager>;
84
85 class XVisualData {
86 public:
87 explicit XVisualData(XVisualInfo visual_info);
88 ~XVisualData();
89
90 Colormap GetColormap();
91
92 const XVisualInfo visual_info;
93
94 private:
95 Colormap colormap_;
96 };
97
98 XVisualManager();
99
100 std::unordered_map<VisualID, std::unique_ptr<XVisualData>> visuals_;
101
102 XDisplay* display_;
103
104 VisualID system_visual_id_;
105 VisualID transparent_visual_id_;
106
107 bool using_compositing_wm_;
108 bool using_software_rendering_;
109 bool have_gpu_argb_visual_;
110
111 DISALLOW_COPY_AND_ASSIGN(XVisualManager);
112 };
57 #endif 113 #endif
58 114
59 } // namespace ui 115 } // namespace ui
60 116
61 #endif // UI_BASE_X_X11_UTIL_INTERNAL_H_ 117 #endif // UI_BASE_X_X11_UTIL_INTERNAL_H_
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/base/x/x11_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698