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

Side by Side Diff: ui/gfx/gtk_util.h

Issue 7328011: Introduce ui.dll / libui.so for the component build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
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_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/ui_api.h"
16 17
17 typedef struct _GdkPixbuf GdkPixbuf; 18 typedef struct _GdkPixbuf GdkPixbuf;
18 typedef struct _GdkRegion GdkRegion; 19 typedef struct _GdkRegion GdkRegion;
19 typedef struct _GdkCursor GdkCursor; 20 typedef struct _GdkCursor GdkCursor;
20 21
21 class CommandLine; 22 class CommandLine;
22 class SkBitmap; 23 class SkBitmap;
23 24
24 namespace gfx { 25 namespace gfx {
25 26
26 class Rect; 27 class Rect;
27 28
28 // Call gtk_init() using the argc and argv from command_line. 29 // Call gtk_init() using the argc and argv from command_line.
29 // gtk_init() wants an argc and argv that it can mutate; we provide those, 30 // gtk_init() wants an argc and argv that it can mutate; we provide those,
30 // but leave the original CommandLine unaltered. 31 // but leave the original CommandLine unaltered.
31 void GtkInitFromCommandLine(const CommandLine& command_line); 32 UI_API void GtkInitFromCommandLine(const CommandLine& command_line);
32 33
33 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so 34 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
34 // it is an expensive operation. The returned GdkPixbuf will have a refcount of 35 // it is an expensive operation. The returned GdkPixbuf will have a refcount of
35 // 1, and the caller is responsible for unrefing it when done. 36 // 1, and the caller is responsible for unrefing it when done.
36 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); 37 UI_API GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap);
37 38
38 // Modify the given region by subtracting the given rectangles. 39 // Modify the given region by subtracting the given rectangles.
39 void SubtractRectanglesFromRegion(GdkRegion* region, 40 UI_API void SubtractRectanglesFromRegion(GdkRegion* region,
40 const std::vector<Rect>& cutouts); 41 const std::vector<Rect>& cutouts);
41 42
42 // Returns the resolution (DPI) used by pango. A negative values means the 43 // Returns the resolution (DPI) used by pango. A negative values means the
43 // resolution hasn't been set. 44 // resolution hasn't been set.
44 double GetPangoResolution(); 45 double GetPangoResolution();
45 46
46 // Returns a static instance of a GdkCursor* object, sharable across the 47 // Returns a static instance of a GdkCursor* object, sharable across the
47 // process. Caller must gdk_cursor_ref() it if they want to assume ownership. 48 // process. Caller must gdk_cursor_ref() it if they want to assume ownership.
48 GdkCursor* GetCursor(int type); 49 UI_API GdkCursor* GetCursor(int type);
49 50
50 // Change windows accelerator style to GTK style. (GTK uses _ for 51 // Change windows accelerator style to GTK style. (GTK uses _ for
51 // accelerators. Windows uses & with && as an escape for &.) 52 // accelerators. Windows uses & with && as an escape for &.)
52 std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label); 53 UI_API std::string ConvertAcceleratorsFromWindowsStyle(
54 const std::string& label);
53 55
54 // Removes the "&" accelerators from a Windows label. 56 // Removes the "&" accelerators from a Windows label.
55 std::string RemoveWindowsStyleAccelerators(const std::string& label); 57 UI_API std::string RemoveWindowsStyleAccelerators(const std::string& label);
56 58
57 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA. 59 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
58 // The caller is responsible for free()ing the data. If |stride| is 0, it's 60 // The caller is responsible for free()ing the data. If |stride| is 0, it's
59 // assumed to be 4 * |width|. 61 // assumed to be 4 * |width|.
60 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride); 62 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
61 63
62 } // namespace gfx 64 } // namespace gfx
63 65
64 // It's not legal C++ to have a templatized typedefs, so we wrap it in a 66 // It's not legal C++ to have a templatized typedefs, so we wrap it in a
65 // struct. When using this, you need to include ::Type. E.g., 67 // struct. When using this, you need to include ::Type. E.g.,
66 // ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); 68 // ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
67 template<class T> 69 template<class T>
68 struct ScopedGObject { 70 struct ScopedGObject {
69 // A helper class that will g_object_unref |p| when it goes out of scope. 71 // A helper class that will g_object_unref |p| when it goes out of scope.
70 // This never adds a ref, it only unrefs. 72 // This never adds a ref, it only unrefs.
71 template<class U> 73 template<class U>
72 struct GObjectUnrefer { 74 struct GObjectUnrefer {
73 void operator()(U* ptr) const { 75 void operator()(U* ptr) const {
74 if (ptr) 76 if (ptr)
75 g_object_unref(ptr); 77 g_object_unref(ptr);
76 } 78 }
77 }; 79 };
78 80
79 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; 81 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type;
80 }; 82 };
81 83
82 #endif // UI_GFX_GTK_UTIL_H_ 84 #endif // UI_GFX_GTK_UTIL_H_
OLDNEW
« no previous file with comments | « ui/gfx/gtk_preserve_window.h ('k') | ui/gfx/icon_util.h » ('j') | ui/ui.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698