| 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 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" | 5 #include "chrome/browser/ui/libgtkui/skia_utils_gtk2.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "third_party/skia/include/core/SkUnPreMultiply.h" | 11 #include "third_party/skia/include/core/SkUnPreMultiply.h" |
| 12 | 12 |
| 13 namespace libgtk2ui { | 13 namespace libgtkui { |
| 14 | 14 |
| 15 // GDK_COLOR_RGB multiplies by 257 (= 0x10001) to distribute the bits evenly | 15 // GDK_COLOR_RGB multiplies by 257 (= 0x10001) to distribute the bits evenly |
| 16 // See: http://www.mindcontrol.org/~hplus/graphics/expand-bits.html | 16 // See: http://www.mindcontrol.org/~hplus/graphics/expand-bits.html |
| 17 // To get back, we can just right shift by eight | 17 // To get back, we can just right shift by eight |
| 18 // (or, formulated differently, i == (i*257)/256 for all i < 256). | 18 // (or, formulated differently, i == (i*257)/256 for all i < 256). |
| 19 | 19 |
| 20 SkColor GdkColorToSkColor(GdkColor color) { | 20 SkColor GdkColorToSkColor(GdkColor color) { |
| 21 return SkColorSetRGB(color.red >> 8, color.green >> 8, color.blue >> 8); | 21 return SkColorSetRGB(color.red >> 8, color.green >> 8, color.blue >> 8); |
| 22 } | 22 } |
| 23 | 23 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 divided[i + 2] = SkColorGetB(pixel); | 123 divided[i + 2] = SkColorGetB(pixel); |
| 124 divided[i + 3] = alpha; | 124 divided[i + 3] = alpha; |
| 125 } | 125 } |
| 126 i += kBytesPerPixel; | 126 i += kBytesPerPixel; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 return pixbuf; | 130 return pixbuf; |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace libgtk2ui | 133 } // namespace libgtkui |
| OLD | NEW |