OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_GFX_X_X11_UTIL_H_ | 5 #ifndef UI_GFX_X_X11_UTIL_H_ |
6 #define UI_GFX_X_X11_UTIL_H_ | 6 #define UI_GFX_X_X11_UTIL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "ui/gfx/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
10 | 11 |
11 typedef unsigned long XAtom; | 12 typedef unsigned long XAtom; |
12 typedef unsigned long XID; | 13 typedef unsigned long XID; |
13 typedef struct _XImage XImage; | 14 typedef struct _XImage XImage; |
14 typedef struct _XGC *GC; | 15 typedef struct _XGC *GC; |
15 typedef struct _XDisplay XDisplay; | 16 typedef struct _XDisplay XDisplay; |
16 | 17 |
| 18 extern "C" { |
| 19 int XFree(void*); |
| 20 } |
| 21 |
17 namespace gfx { | 22 namespace gfx { |
18 | 23 |
| 24 template <class T, class R, R (*F)(T*)> |
| 25 struct XObjectDeleter { |
| 26 inline void operator()(void* ptr) const { F(static_cast<T*>(ptr)); } |
| 27 }; |
| 28 |
| 29 template <class T, class D = XObjectDeleter<void, int, XFree>> |
| 30 using XScopedPtr = scoped_ptr<T, D>; |
| 31 |
19 // TODO(oshima|evan): This assume there is one display and doesn't work | 32 // TODO(oshima|evan): This assume there is one display and doesn't work |
20 // undef multiple displays/monitor environment. Remove this and change the | 33 // undef multiple displays/monitor environment. Remove this and change the |
21 // chrome codebase to get the display from window. | 34 // chrome codebase to get the display from window. |
22 GFX_EXPORT XDisplay* GetXDisplay(); | 35 GFX_EXPORT XDisplay* GetXDisplay(); |
23 | 36 |
24 // This opens a new X11 XDisplay*, taking command line arguments into account. | 37 // This opens a new X11 XDisplay*, taking command line arguments into account. |
25 GFX_EXPORT XDisplay* OpenNewXDisplay(); | 38 GFX_EXPORT XDisplay* OpenNewXDisplay(); |
26 | 39 |
27 // Return the number of bits-per-pixel for a pixmap of the given depth | 40 // Return the number of bits-per-pixel for a pixmap of the given depth |
28 GFX_EXPORT int BitsPerPixelForPixmapDepth(XDisplay* display, int depth); | 41 GFX_EXPORT int BitsPerPixelForPixmapDepth(XDisplay* display, int depth); |
(...skipping 18 matching lines...) Expand all Loading... |
47 const uint8* data, | 60 const uint8* data, |
48 int data_width, int data_height, | 61 int data_width, int data_height, |
49 int src_x, int src_y, | 62 int src_x, int src_y, |
50 int dst_x, int dst_y, | 63 int dst_x, int dst_y, |
51 int copy_width, int copy_height); | 64 int copy_width, int copy_height); |
52 | 65 |
53 } // namespace gfx | 66 } // namespace gfx |
54 | 67 |
55 #endif // UI_GFX_X_X11_UTIL_H_ | 68 #endif // UI_GFX_X_X11_UTIL_H_ |
56 | 69 |
OLD | NEW |