OLD | NEW |
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_GFX_GTK_UTIL_H_ | 5 #ifndef UI_GFX_GTK_UTIL_H_ |
6 #define UI_GFX_GTK_UTIL_H_ | 6 #define UI_GFX_GTK_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <glib-object.h> | 9 #include <glib-object.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "ui/base/ui_export.h" | 16 #include "ui/base/ui_export.h" |
17 | 17 |
18 typedef struct _GdkPixbuf GdkPixbuf; | 18 typedef struct _GdkPixbuf GdkPixbuf; |
19 typedef struct _GdkRegion GdkRegion; | 19 typedef struct _GdkRegion GdkRegion; |
20 typedef struct _GdkCursor GdkCursor; | 20 typedef struct _GdkCursor GdkCursor; |
21 | 21 |
| 22 typedef struct _PangoContext PangoContext; |
| 23 |
22 class CommandLine; | 24 class CommandLine; |
23 class SkBitmap; | 25 class SkBitmap; |
24 | 26 |
25 namespace gfx { | 27 namespace gfx { |
26 | 28 |
27 class Rect; | 29 class Rect; |
28 | 30 |
29 // Call gtk_init() using the argc and argv from command_line. | 31 // Call gtk_init() using the argc and argv from command_line. |
30 // gtk_init() wants an argc and argv that it can mutate; we provide those, | 32 // gtk_init() wants an argc and argv that it can mutate; we provide those, |
31 // but leave the original CommandLine unaltered. | 33 // but leave the original CommandLine unaltered. |
32 UI_EXPORT void GtkInitFromCommandLine(const CommandLine& command_line); | 34 UI_EXPORT void GtkInitFromCommandLine(const CommandLine& command_line); |
33 | 35 |
34 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so | 36 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so |
35 // it is an expensive operation. The returned GdkPixbuf will have a refcount of | 37 // it is an expensive operation. The returned GdkPixbuf will have a refcount of |
36 // 1, and the caller is responsible for unrefing it when done. | 38 // 1, and the caller is responsible for unrefing it when done. |
37 UI_EXPORT GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); | 39 UI_EXPORT GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); |
38 | 40 |
39 // Modify the given region by subtracting the given rectangles. | 41 // Modify the given region by subtracting the given rectangles. |
40 UI_EXPORT void SubtractRectanglesFromRegion(GdkRegion* region, | 42 UI_EXPORT void SubtractRectanglesFromRegion(GdkRegion* region, |
41 const std::vector<Rect>& cutouts); | 43 const std::vector<Rect>& cutouts); |
42 | 44 |
| 45 // Creates and returns a PangoContext. The caller owns the context. |
| 46 PangoContext* GetPangoContext(); |
| 47 |
43 // Returns the resolution (DPI) used by pango. A negative values means the | 48 // Returns the resolution (DPI) used by pango. A negative values means the |
44 // resolution hasn't been set. | 49 // resolution hasn't been set. |
45 double GetPangoResolution(); | 50 double GetPangoResolution(); |
46 | 51 |
47 // Returns a static instance of a GdkCursor* object, sharable across the | 52 // Returns a static instance of a GdkCursor* object, sharable across the |
48 // process. Caller must gdk_cursor_ref() it if they want to assume ownership. | 53 // process. Caller must gdk_cursor_ref() it if they want to assume ownership. |
49 UI_EXPORT GdkCursor* GetCursor(int type); | 54 UI_EXPORT GdkCursor* GetCursor(int type); |
50 | 55 |
51 // Change windows accelerator style to GTK style. (GTK uses _ for | 56 // Change windows accelerator style to GTK style. (GTK uses _ for |
52 // accelerators. Windows uses & with && as an escape for &.) | 57 // accelerators. Windows uses & with && as an escape for &.) |
(...skipping 22 matching lines...) Expand all Loading... |
75 void operator()(U* ptr) const { | 80 void operator()(U* ptr) const { |
76 if (ptr) | 81 if (ptr) |
77 g_object_unref(ptr); | 82 g_object_unref(ptr); |
78 } | 83 } |
79 }; | 84 }; |
80 | 85 |
81 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; | 86 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; |
82 }; | 87 }; |
83 | 88 |
84 #endif // UI_GFX_GTK_UTIL_H_ | 89 #endif // UI_GFX_GTK_UTIL_H_ |
OLD | NEW |