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