| 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/libgtkui/skia_utils_gtk.h" | 5 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.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" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 NOTREACHED(); | 81 NOTREACHED(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 return ret; | 84 return ret; |
| 85 } | 85 } |
| 86 | 86 |
| 87 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) { | 87 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) { |
| 88 if (bitmap.isNull()) | 88 if (bitmap.isNull()) |
| 89 return nullptr; | 89 return nullptr; |
| 90 | 90 |
| 91 SkAutoLockPixels lock_pixels(bitmap); | |
| 92 | |
| 93 int width = bitmap.width(); | 91 int width = bitmap.width(); |
| 94 int height = bitmap.height(); | 92 int height = bitmap.height(); |
| 95 | 93 |
| 96 GdkPixbuf* pixbuf = | 94 GdkPixbuf* pixbuf = |
| 97 gdk_pixbuf_new(GDK_COLORSPACE_RGB, // The only colorspace gtk supports. | 95 gdk_pixbuf_new(GDK_COLORSPACE_RGB, // The only colorspace gtk supports. |
| 98 TRUE, // There is an alpha channel. | 96 TRUE, // There is an alpha channel. |
| 99 8, width, height); | 97 8, width, height); |
| 100 | 98 |
| 101 // SkBitmaps are premultiplied, we need to unpremultiply them. | 99 // SkBitmaps are premultiplied, we need to unpremultiply them. |
| 102 const int kBytesPerPixel = 4; | 100 const int kBytesPerPixel = 4; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 divided[i + 3] = alpha; | 118 divided[i + 3] = alpha; |
| 121 } | 119 } |
| 122 i += kBytesPerPixel; | 120 i += kBytesPerPixel; |
| 123 } | 121 } |
| 124 } | 122 } |
| 125 | 123 |
| 126 return pixbuf; | 124 return pixbuf; |
| 127 } | 125 } |
| 128 | 126 |
| 129 } // namespace libgtkui | 127 } // namespace libgtkui |
| OLD | NEW |