Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / ui / libgtk2ui / skia_utils_gtk2.cc
blob726b70ab1f766233d3865f0fb1d890b7c8592609
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.
5 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h"
7 #include <gdk/gdk.h>
9 namespace libgtk2ui {
11 const int kSkiaToGDKMultiplier = 257;
13 // GDK_COLOR_RGB multiplies by 257 (= 0x10001) to distribute the bits evenly
14 // See: http://www.mindcontrol.org/~hplus/graphics/expand-bits.html
15 // To get back, we can just right shift by eight
16 // (or, formulated differently, i == (i*257)/256 for all i < 256).
18 SkColor GdkColorToSkColor(GdkColor color) {
19 return SkColorSetRGB(color.red >> 8, color.green >> 8, color.blue >> 8);
22 GdkColor SkColorToGdkColor(SkColor color) {
23 GdkColor gdk_color = {
25 SkColorGetR(color) * kSkiaToGDKMultiplier,
26 SkColorGetG(color) * kSkiaToGDKMultiplier,
27 SkColorGetB(color) * kSkiaToGDKMultiplier
29 return gdk_color;
32 } // namespace libgtk2ui