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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 wrap_mode_ = CLAMP_TO_EDGE; | 47 wrap_mode_ = CLAMP_TO_EDGE; |
48 opaque_ = (format == ETC1); | 48 opaque_ = (format == ETC1); |
49 } | 49 } |
50 | 50 |
51 UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) { | 51 UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) { |
52 DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels()); | 52 DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels()); |
53 DCHECK(skbitmap.isImmutable()); | 53 DCHECK(skbitmap.isImmutable()); |
54 | 54 |
55 skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef()); | 55 skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef()); |
56 const SkImageInfo& info = pixel_ref->info(); | 56 const SkImageInfo& info = pixel_ref->info(); |
57 Create(pixel_ref, | 57 Create(pixel_ref, gfx::Size(info.width(), info.height()), |
58 gfx::Size(info.fWidth, info.fHeight), | |
59 SkColorTypeToUIResourceFormat(skbitmap.colorType())); | 58 SkColorTypeToUIResourceFormat(skbitmap.colorType())); |
60 | 59 |
61 SetOpaque(skbitmap.isOpaque()); | 60 SetOpaque(skbitmap.isOpaque()); |
62 } | 61 } |
63 | 62 |
64 UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) { | 63 UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) { |
65 SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 64 SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
66 SkImageInfo info = | 65 SkImageInfo info = |
67 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); | 66 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); |
68 skia::RefPtr<SkPixelRef> pixel_ref = skia::AdoptRef( | 67 skia::RefPtr<SkPixelRef> pixel_ref = skia::AdoptRef( |
(...skipping 17 matching lines...) Expand all Loading... |
86 | 85 |
87 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() { | 86 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() { |
88 bitmap_.pixel_ref_->unlockPixels(); | 87 bitmap_.pixel_ref_->unlockPixels(); |
89 } | 88 } |
90 | 89 |
91 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const { | 90 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const { |
92 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels()); | 91 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels()); |
93 } | 92 } |
94 | 93 |
95 } // namespace cc | 94 } // namespace cc |
OLD | NEW |