Chromium Code Reviews| 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_LIBGTKUI_SKIA_UTILS_GTK2_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK2_H_ | 6 #define CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK_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 * ::libgtkui::kSkiaToGDKMultiplier, \ | 20 #define GDK_COLOR_RGB(r, g, b) \ |
| 21 g * ::libgtkui::kSkiaToGDKMultiplier, \ | 21 { \ |
| 22 b * ::libgtkui::kSkiaToGDKMultiplier} | 22 0, r* ::libgtkui::kSkiaToGDKMultiplier, \ |
| 23 g* ::libgtkui::kSkiaToGDKMultiplier, \ | |
| 24 b* ::libgtkui::kSkiaToGDKMultiplier \ | |
|
Elliot Glaysher
2016/10/27 17:07:08
please also fix up this case of cl format gone wil
Tom (Use chromium acct)
2016/10/27 17:43:19
Done.
| |
| 25 } | |
| 23 | 26 |
| 24 namespace libgtkui { | 27 namespace libgtkui { |
| 25 | 28 |
| 26 // Multiply uint8_t color components by this. | 29 // Multiply uint8_t color components by this. |
| 27 const int kSkiaToGDKMultiplier = 257; | 30 const int kSkiaToGDKMultiplier = 257; |
| 28 | 31 |
| 29 // Converts GdkColors to the ARGB layout Skia expects. | 32 // Converts GdkColors to the ARGB layout Skia expects. |
| 30 SkColor GdkColorToSkColor(GdkColor color); | 33 SkColor GdkColorToSkColor(GdkColor color); |
| 31 | 34 |
| 32 // Converts ARGB to GdkColor. | 35 // Converts ARGB to GdkColor. |
| 33 GdkColor SkColorToGdkColor(SkColor color); | 36 GdkColor SkColorToGdkColor(SkColor color); |
| 34 | 37 |
| 35 const SkBitmap GdkPixbufToImageSkia(GdkPixbuf* pixbuf); | 38 const SkBitmap GdkPixbufToImageSkia(GdkPixbuf* pixbuf); |
| 36 | 39 |
| 37 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so | 40 // 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 | 41 // 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. | 42 // 1, and the caller is responsible for unrefing it when done. |
| 40 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap); | 43 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap); |
| 41 | 44 |
| 42 } // namespace libgtkui | 45 } // namespace libgtkui |
| 43 | 46 |
| 44 #endif // CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK2_H_ | 47 #endif // CHROME_BROWSER_UI_LIBGTKUI_SKIA_UTILS_GTK_H_ |
| OLD | NEW |