Chromium Code Reviews| Index: cc/resources/ui_resource_bitmap.cc |
| diff --git a/cc/resources/ui_resource_bitmap.cc b/cc/resources/ui_resource_bitmap.cc |
| index 8bbfb37deee70a1ebaede084bea89fcc1361064d..852b6c0db1acdea293c72a21a6d3bcf3367ddf94 100644 |
| --- a/cc/resources/ui_resource_bitmap.cc |
| +++ b/cc/resources/ui_resource_bitmap.cc |
| @@ -4,7 +4,9 @@ |
| #include "cc/resources/ui_resource_bitmap.h" |
| +#include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| namespace cc { |
| @@ -12,6 +14,9 @@ scoped_refptr<UIResourceBitmap> |
| UIResourceBitmap::Create(uint8_t* pixels, |
| UIResourceFormat format, |
| gfx::Size size) { |
| + // Check for a non-empty bitmap. |
| + DCHECK(size.width() && size.height()); |
| + |
| scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap(); |
| ret->pixels_ = scoped_ptr<uint8_t[]>(pixels); |
| ret->format_ = format; |
| @@ -21,6 +26,18 @@ UIResourceBitmap::Create(uint8_t* pixels, |
| } |
| UIResourceBitmap::UIResourceBitmap() {} |
| + |
| UIResourceBitmap::~UIResourceBitmap() {} |
| +scoped_refptr<UIResourceBitmap> UIResourceBitmap::CreateFromSkBitmap( |
| + const SkBitmap& skbitmap) { |
| + DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config); |
| + |
| + gfx::Size size(skbitmap.width(), skbitmap.height()); |
| + uint8_t* dst_pixels = new uint8_t[size.GetArea() * 4]; |
| + uint8_t* src_pixels = static_cast<uint8_t*>(skbitmap.getPixels()); |
| + memcpy(dst_pixels, src_pixels, size.GetArea() * 4); |
|
aelias_OOO_until_Jul13
2013/08/30 06:20:41
This isn't correct because there may be unused pix
aelias_OOO_until_Jul13
2013/09/04 03:29:32
You didn't address this comment in your last updat
powei
2013/09/05 18:16:46
Done. Sorry about the delay. Got lost in the fol
|
| + return UIResourceBitmap::Create(dst_pixels, UIResourceBitmap::RGBA8, size); |
| +} |
| + |
| } // namespace cc |