OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_LIBGTK2UI_SKIA_UTILS_GTK2_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK2_H_ |
6 #define CHROME_BROWSER_UI_LIBGTK2UI_SKIA_UTILS_GTK2_H_ | 6 #define CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK2_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
11 | 11 |
12 typedef struct _GdkColor GdkColor; | 12 typedef struct _GdkColor GdkColor; |
13 typedef struct _GdkPixbuf GdkPixbuf; | 13 typedef struct _GdkPixbuf GdkPixbuf; |
14 | 14 |
15 class SkBitmap; | 15 class SkBitmap; |
16 | 16 |
17 // Define a macro for creating GdkColors from RGB values. This is a macro to | 17 // Define a macro for creating GdkColors from RGB values. This is a macro to |
18 // allow static construction of literals, etc. Use this like: | 18 // allow static construction of literals, etc. Use this like: |
19 // GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff); | 19 // GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff); |
20 #define GDK_COLOR_RGB(r, g, b) {0, r * ::libgtk2ui::kSkiaToGDKMultiplier, \ | 20 #define GDK_COLOR_RGB(r, g, b) {0, r * ::libgtkui::kSkiaToGDKMultiplier, \ |
21 g * ::libgtk2ui::kSkiaToGDKMultiplier, \ | 21 g * ::libgtkui::kSkiaToGDKMultiplier, \ |
22 b * ::libgtk2ui::kSkiaToGDKMultiplier} | 22 b * ::libgtkui::kSkiaToGDKMultiplier} |
23 | 23 |
24 namespace libgtk2ui { | 24 namespace libgtkui { |
25 | 25 |
26 // Multiply uint8_t color components by this. | 26 // Multiply uint8_t color components by this. |
27 const int kSkiaToGDKMultiplier = 257; | 27 const int kSkiaToGDKMultiplier = 257; |
28 | 28 |
29 // Converts GdkColors to the ARGB layout Skia expects. | 29 // Converts GdkColors to the ARGB layout Skia expects. |
30 SkColor GdkColorToSkColor(GdkColor color); | 30 SkColor GdkColorToSkColor(GdkColor color); |
31 | 31 |
32 // Converts ARGB to GdkColor. | 32 // Converts ARGB to GdkColor. |
33 GdkColor SkColorToGdkColor(SkColor color); | 33 GdkColor SkColorToGdkColor(SkColor color); |
34 | 34 |
35 const SkBitmap GdkPixbufToImageSkia(GdkPixbuf* pixbuf); | 35 const SkBitmap GdkPixbufToImageSkia(GdkPixbuf* pixbuf); |
36 | 36 |
37 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so | 37 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so |
38 // it is an expensive operation. The returned GdkPixbuf will have a refcount of | 38 // it is an expensive operation. The returned GdkPixbuf will have a refcount of |
39 // 1, and the caller is responsible for unrefing it when done. | 39 // 1, and the caller is responsible for unrefing it when done. |
40 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap); | 40 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap); |
41 | 41 |
42 } // namespace libgtk2ui | 42 } // namespace libgtkui |
43 | 43 |
44 #endif // CHROME_BROWSER_UI_LIBGTK2UI_SKIA_UTILS_GTK2_H_ | 44 #endif // CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK2_H_ |
OLD | NEW |