| 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/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 10 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 SkColorTypeToUIResourceFormat(skbitmap.colorType())); | 59 SkColorTypeToUIResourceFormat(skbitmap.colorType())); |
| 60 | 60 |
| 61 SetOpaque(skbitmap.isOpaque()); | 61 SetOpaque(skbitmap.isOpaque()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) { | 64 UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) { |
| 65 SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 65 SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 66 SkImageInfo info = | 66 SkImageInfo info = |
| 67 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); | 67 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); |
| 68 skia::RefPtr<SkPixelRef> pixel_ref = skia::AdoptRef( | 68 skia::RefPtr<SkPixelRef> pixel_ref = skia::AdoptRef( |
| 69 SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NULL)); | 69 SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), nullptr)); |
| 70 pixel_ref->setImmutable(); | 70 pixel_ref->setImmutable(); |
| 71 Create(pixel_ref, size, UIResourceBitmap::RGBA8); | 71 Create(pixel_ref, size, UIResourceBitmap::RGBA8); |
| 72 SetOpaque(is_opaque); | 72 SetOpaque(is_opaque); |
| 73 } | 73 } |
| 74 | 74 |
| 75 UIResourceBitmap::UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref, | 75 UIResourceBitmap::UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref, |
| 76 const gfx::Size& size) { | 76 const gfx::Size& size) { |
| 77 Create(pixel_ref, size, UIResourceBitmap::ETC1); | 77 Create(pixel_ref, size, UIResourceBitmap::ETC1); |
| 78 } | 78 } |
| 79 | 79 |
| 80 UIResourceBitmap::~UIResourceBitmap() {} | 80 UIResourceBitmap::~UIResourceBitmap() {} |
| 81 | 81 |
| 82 AutoLockUIResourceBitmap::AutoLockUIResourceBitmap( | 82 AutoLockUIResourceBitmap::AutoLockUIResourceBitmap( |
| 83 const UIResourceBitmap& bitmap) : bitmap_(bitmap) { | 83 const UIResourceBitmap& bitmap) : bitmap_(bitmap) { |
| 84 bitmap_.pixel_ref_->lockPixels(); | 84 bitmap_.pixel_ref_->lockPixels(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() { | 87 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() { |
| 88 bitmap_.pixel_ref_->unlockPixels(); | 88 bitmap_.pixel_ref_->unlockPixels(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const { | 91 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const { |
| 92 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels()); | 92 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace cc | 95 } // namespace cc |
| OLD | NEW |