Chromium Code Reviews| 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 <pango/pango-layout.h> | |
| 10 #include <stdint.h> | 11 #include <stdint.h> |
| 11 | 12 |
| 12 #include <string> | 13 #include <string> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 16 #include "base/i18n/rtl.h" | |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "ui/base/ui_export.h" | 18 #include "ui/base/ui_export.h" |
| 17 | 19 |
| 18 typedef struct _GdkPixbuf GdkPixbuf; | 20 typedef struct _GdkPixbuf GdkPixbuf; |
| 19 typedef struct _GdkRegion GdkRegion; | 21 typedef struct _GdkRegion GdkRegion; |
| 20 typedef struct _GdkCursor GdkCursor; | 22 typedef struct _GdkCursor GdkCursor; |
| 21 | 23 |
| 22 typedef struct _PangoContext PangoContext; | 24 typedef struct _PangoContext PangoContext; |
| 23 | 25 |
| 24 class CommandLine; | 26 class CommandLine; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 const std::string& label); | 61 const std::string& label); |
| 60 | 62 |
| 61 // Removes the "&" accelerators from a Windows label. | 63 // Removes the "&" accelerators from a Windows label. |
| 62 UI_EXPORT std::string RemoveWindowsStyleAccelerators(const std::string& label); | 64 UI_EXPORT std::string RemoveWindowsStyleAccelerators(const std::string& label); |
| 63 | 65 |
| 64 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA. | 66 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA. |
| 65 // The caller is responsible for free()ing the data. If |stride| is 0, it's | 67 // The caller is responsible for free()ing the data. If |stride| is 0, it's |
| 66 // assumed to be 4 * |width|. | 68 // assumed to be 4 * |width|. |
| 67 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride); | 69 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride); |
| 68 | 70 |
| 71 class Font; | |
|
oshima
2011/08/19 18:44:07
move this before "class Rect"
xji
2011/08/20 00:53:05
Done.
| |
| 72 void SetupPangoLayout(PangoLayout* layout, | |
|
oshima
2011/08/19 18:44:07
please add comment as this is now public API
xji
2011/08/20 00:53:05
Done.
| |
| 73 const string16& text, | |
| 74 const gfx::Font& font, | |
| 75 int width, | |
| 76 base::i18n::TextDirection text_direction, | |
| 77 int flags); | |
| 69 } // namespace gfx | 78 } // namespace gfx |
| 70 | 79 |
| 71 // It's not legal C++ to have a templatized typedefs, so we wrap it in a | 80 // It's not legal C++ to have a templatized typedefs, so we wrap it in a |
| 72 // struct. When using this, you need to include ::Type. E.g., | 81 // struct. When using this, you need to include ::Type. E.g., |
| 73 // ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); | 82 // ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); |
| 74 template<class T> | 83 template<class T> |
| 75 struct ScopedGObject { | 84 struct ScopedGObject { |
| 76 // A helper class that will g_object_unref |p| when it goes out of scope. | 85 // A helper class that will g_object_unref |p| when it goes out of scope. |
| 77 // This never adds a ref, it only unrefs. | 86 // This never adds a ref, it only unrefs. |
| 78 template<class U> | 87 template<class U> |
| 79 struct GObjectUnrefer { | 88 struct GObjectUnrefer { |
| 80 void operator()(U* ptr) const { | 89 void operator()(U* ptr) const { |
| 81 if (ptr) | 90 if (ptr) |
| 82 g_object_unref(ptr); | 91 g_object_unref(ptr); |
| 83 } | 92 } |
| 84 }; | 93 }; |
| 85 | 94 |
| 86 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; | 95 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; |
| 87 }; | 96 }; |
| 88 | 97 |
| 89 #endif // UI_GFX_GTK_UTIL_H_ | 98 #endif // UI_GFX_GTK_UTIL_H_ |
| OLD | NEW |