OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_LINUX_UTIL_H_ |
| 6 #define UI_GFX_LINUX_UTIL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <glib-object.h> |
| 10 #include <stdint.h> |
| 11 |
| 12 #include <string> |
| 13 #include <vector> |
| 14 |
| 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "ui/base/ui_export.h" |
| 17 |
| 18 typedef struct _PangoContext PangoContext; |
| 19 |
| 20 class SkBitmap; |
| 21 |
| 22 namespace gfx { |
| 23 |
| 24 class Rect; |
| 25 |
| 26 // Creates and returns a PangoContext. The caller owns the context. |
| 27 PangoContext* GetPangoContext(); |
| 28 |
| 29 // Returns the resolution (DPI) used by pango. A negative values means the |
| 30 // resolution hasn't been set. |
| 31 double GetPangoResolution(); |
| 32 |
| 33 // Change windows accelerator style to GTK style. (GTK uses _ for |
| 34 // accelerators. Windows uses & with && as an escape for &.) |
| 35 UI_EXPORT std::string ConvertAcceleratorsFromWindowsStyle( |
| 36 const std::string& label); |
| 37 |
| 38 // Removes the "&" accelerators from a Windows label. |
| 39 UI_EXPORT std::string RemoveWindowsStyleAccelerators(const std::string& label); |
| 40 |
| 41 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA. |
| 42 // The caller is responsible for free()ing the data. If |stride| is 0, it's |
| 43 // assumed to be 4 * |width|. |
| 44 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride); |
| 45 |
| 46 } // namespace gfx |
| 47 |
| 48 // It's not legal C++ to have a templatized typedefs, so we wrap it in a |
| 49 // struct. When using this, you need to include ::Type. E.g., |
| 50 // ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); |
| 51 template<class T> |
| 52 struct ScopedGObject { |
| 53 // A helper class that will g_object_unref |p| when it goes out of scope. |
| 54 // This never adds a ref, it only unrefs. |
| 55 template<class U> |
| 56 struct GObjectUnrefer { |
| 57 void operator()(U* ptr) const { |
| 58 if (ptr) |
| 59 g_object_unref(ptr); |
| 60 } |
| 61 }; |
| 62 |
| 63 typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; |
| 64 }; |
| 65 |
| 66 #endif // UI_GFX_LINUX_UTIL_H_ |
OLD | NEW |