Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/resources/ui_resource_bitmap.h" | 5 #include "cc/resources/ui_resource_bitmap.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | |
| 7 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | |
| 8 | 10 |
| 9 namespace cc { | 11 namespace cc { |
| 10 | 12 |
| 11 scoped_refptr<UIResourceBitmap> | 13 scoped_refptr<UIResourceBitmap> |
| 12 UIResourceBitmap::Create(uint8_t* pixels, | 14 UIResourceBitmap::Create(uint8_t* pixels, |
| 13 UIResourceFormat format, | 15 UIResourceFormat format, |
| 14 gfx::Size size) { | 16 gfx::Size size) { |
| 17 // Check for a non-empty bitmap. | |
| 18 DCHECK(size.width() && size.height()); | |
| 19 | |
| 15 scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap(); | 20 scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap(); |
| 16 ret->pixels_ = scoped_ptr<uint8_t[]>(pixels); | 21 ret->pixels_ = scoped_ptr<uint8_t[]>(pixels); |
| 17 ret->format_ = format; | 22 ret->format_ = format; |
| 18 ret->size_ = size; | 23 ret->size_ = size; |
| 19 | 24 |
| 20 return ret; | 25 return ret; |
| 21 } | 26 } |
| 22 | 27 |
| 23 UIResourceBitmap::UIResourceBitmap() {} | 28 UIResourceBitmap::UIResourceBitmap() {} |
| 29 | |
| 24 UIResourceBitmap::~UIResourceBitmap() {} | 30 UIResourceBitmap::~UIResourceBitmap() {} |
| 25 | 31 |
| 32 scoped_refptr<UIResourceBitmap> UIResourceBitmap::CreateFromSkBitmap( | |
| 33 const SkBitmap& skbitmap) { | |
| 34 DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config); | |
| 35 | |
| 36 gfx::Size size(skbitmap.width(), skbitmap.height()); | |
| 37 uint8_t* dst_pixels = new uint8_t[size.GetArea() * 4]; | |
| 38 uint8_t* src_pixels = static_cast<uint8_t*>(skbitmap.getPixels()); | |
| 39 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
| |
| 40 return UIResourceBitmap::Create(dst_pixels, UIResourceBitmap::RGBA8, size); | |
| 41 } | |
| 42 | |
| 26 } // namespace cc | 43 } // namespace cc |
| OLD | NEW |