OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_COMMON_X11_UTIL_H_ | 5 #ifndef CHROME_COMMON_X11_UTIL_H_ |
6 #define CHROME_COMMON_X11_UTIL_H_ | 6 #define CHROME_COMMON_X11_UTIL_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 do not require the Xlib headers to be included (which is why | 10 // These functions do not require the Xlib headers to be included (which is why |
11 // we use a void* for Visual*). The Xlib headers are highly polluting so we try | 11 // we use a void* for Visual*). The Xlib headers are highly polluting so we try |
12 // hard to limit their spread into the rest of the code. | 12 // hard to limit their spread into the rest of the code. |
13 | 13 |
14 typedef struct _GtkWidget GtkWidget; | 14 typedef struct _GtkWidget GtkWidget; |
15 typedef unsigned long XID; | 15 typedef unsigned long XID; |
16 typedef struct _XDisplay Display; | 16 typedef struct _XDisplay Display; |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class Size; | 19 class Size; |
20 } | 20 } |
21 | 21 |
22 namespace x11_util { | 22 namespace x11_util { |
23 // These functions cache their results and must be called from the UI thread. | 23 // These functions cache their results and must be called from the UI thread. |
24 // Currently they don't support multiple screens/displays. | 24 // Currently they don't support multiple screens/displays. |
25 | 25 |
26 // Return an X11 connection for the current, primary display. | 26 // Return an X11 connection for the current, primary display. |
27 Display* GetXDisplay(); | 27 Display* GetXDisplay(); |
28 // Return true iff the connection supports X shared memory | 28 // Return true iff the connection supports X shared memory |
29 bool QuerySharedMemorySupport(Display* dpy); | 29 bool QuerySharedMemorySupport(Display* dpy); |
| 30 // Return true iff the display supports Xrender |
| 31 bool QueryRenderSupport(Display* dpy); |
30 | 32 |
31 // These functions do not cache their results | 33 // These functions do not cache their results |
32 | 34 |
33 // Get the X window id for the default root window | 35 // Get the X window id for the default root window |
34 XID GetX11RootWindow(); | 36 XID GetX11RootWindow(); |
35 // Get the X window id for the given GTK widget. | 37 // Get the X window id for the given GTK widget. |
36 XID GetX11WindowFromGtkWidget(GtkWidget*); | 38 XID GetX11WindowFromGtkWidget(GtkWidget*); |
37 // Get a Visual from the given widget. Since we don't include the Xlib | 39 // Get a Visual from the given widget. Since we don't include the Xlib |
38 // headers, this is returned as a void*. | 40 // headers, this is returned as a void*. |
39 void* GetVisualFromGtkWidget(GtkWidget*); | 41 void* GetVisualFromGtkWidget(GtkWidget*); |
| 42 // Return the number of bits-per-pixel for a pixmap of the given depth |
| 43 int BitsPerPixelForPixmapDepth(Display*, int depth); |
40 | 44 |
41 // Return a handle to a server side pixmap. |shared_memory_key| is a SysV | 45 // Return a handle to a server side pixmap. |shared_memory_key| is a SysV |
42 // IPC key. The shared memory region must contain 32-bit pixels. | 46 // IPC key. The shared memory region must contain 32-bit pixels. |
43 XID AttachSharedMemory(Display* display, int shared_memory_support); | 47 XID AttachSharedMemory(Display* display, int shared_memory_support); |
44 void DetachSharedMemory(Display* display, XID shmseg); | 48 void DetachSharedMemory(Display* display, XID shmseg); |
45 | 49 |
46 // Return a handle to an XRender picture where |pixmap| is a handle to a | 50 // Return a handle to an XRender picture where |pixmap| is a handle to a |
47 // pixmap containing Skia ARGB data. | 51 // pixmap containing Skia ARGB data. |
48 XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap); | 52 XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap); |
49 | 53 |
50 void FreePicture(Display* display, XID picture); | 54 void FreePicture(Display* display, XID picture); |
51 void FreePixmap(Display* display, XID pixmap); | 55 void FreePixmap(Display* display, XID pixmap); |
52 }; | 56 }; |
53 | 57 |
54 #endif // CHROME_COMMON_X11_UTIL_H_ | 58 #endif // CHROME_COMMON_X11_UTIL_H_ |
OLD | NEW |