summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/app_base.gypi4
-rw-r--r--app/gfx/skia_utils_gtk.cc32
-rw-r--r--app/gfx/skia_utils_gtk.h22
3 files changed, 57 insertions, 1 deletions
diff --git a/app/app_base.gypi b/app/app_base.gypi
index 81305aa..9c41cce 100644
--- a/app/app_base.gypi
+++ b/app/app_base.gypi
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -152,6 +152,8 @@
'gfx/skbitmap_operations.h',
'gfx/skia_util.cc',
'gfx/skia_util.h',
+ 'gfx/skia_utils_gtk.cc',
+ 'gfx/skia_utils_gtk.h',
'gfx/text_elider.cc',
'gfx/text_elider.h',
'gtk_dnd_util.cc',
diff --git a/app/gfx/skia_utils_gtk.cc b/app/gfx/skia_utils_gtk.cc
new file mode 100644
index 0000000..3937d46
--- /dev/null
+++ b/app/gfx/skia_utils_gtk.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/gfx/skia_utils_gtk.h"
+
+#include <gdk/gdkcolor.h>
+
+namespace gfx {
+
+const int kSkiaToGDKMultiplier = 257;
+
+// GDK_COLOR_RGB multiplies by 257 (= 0x10001) to distribute the bits evenly
+// See: http://www.mindcontrol.org/~hplus/graphics/expand-bits.html
+// To get back, we can just right shift by eight
+// (or, formulated differently, i == (i*257)/256 for all i < 256).
+
+SkColor GdkColorToSkColor(GdkColor color) {
+ return SkColorSetRGB(color.red >> 8, color.green >> 8, color.blue >> 8);
+}
+
+GdkColor SkColorToGdkColor(SkColor color) {
+ GdkColor gdk_color = {
+ 0,
+ SkColorGetR(color) * kSkiaToGDKMultiplier,
+ SkColorGetG(color) * kSkiaToGDKMultiplier,
+ SkColorGetB(color) * kSkiaToGDKMultiplier
+ };
+ return gdk_color;
+}
+
+} // namespace gfx
diff --git a/app/gfx/skia_utils_gtk.h b/app/gfx/skia_utils_gtk.h
new file mode 100644
index 0000000..df68581
--- /dev/null
+++ b/app/gfx/skia_utils_gtk.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_GFX_SKIA_UTILS_GTK_H_
+#define APP_GFX_SKIA_UTILS_GTK_H_
+
+#include "third_party/skia/include/core/SkColor.h"
+
+typedef struct _GdkColor GdkColor;
+
+namespace gfx {
+
+// Converts GdkColors to the ARGB layout Skia expects.
+SkColor GdkColorToSkColor(GdkColor color);
+
+// Converts ARGB to GdkColor.
+GdkColor SkColorToGdkColor(SkColor color);
+
+} // namespace gfx
+
+#endif // APP_GFX_SKIA_UTILS_GTK_H_