OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/android/thumbnail/thumbnail.h" | 5 #include "chrome/browser/android/thumbnail/thumbnail.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 void Thumbnail::SetBitmap(const SkBitmap& bitmap) { | 61 void Thumbnail::SetBitmap(const SkBitmap& bitmap) { |
62 DCHECK(!bitmap.empty()); | 62 DCHECK(!bitmap.empty()); |
63 retrieved_ = false; | 63 retrieved_ = false; |
64 ClearUIResourceId(); | 64 ClearUIResourceId(); |
65 scaled_content_size_ = | 65 scaled_content_size_ = |
66 gfx::ScaleSize(gfx::SizeF(bitmap.width(), bitmap.height()), 1.f / scale_); | 66 gfx::ScaleSize(gfx::SizeF(bitmap.width(), bitmap.height()), 1.f / scale_); |
67 scaled_data_size_ = scaled_content_size_; | 67 scaled_data_size_ = scaled_content_size_; |
68 bitmap_ = cc::UIResourceBitmap(bitmap); | 68 bitmap_ = cc::UIResourceBitmap(bitmap); |
69 } | 69 } |
70 | 70 |
71 void Thumbnail::SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap, | 71 void Thumbnail::SetCompressedBitmap(sk_sp<SkPixelRef> compressed_bitmap, |
72 const gfx::Size& content_size) { | 72 const gfx::Size& content_size) { |
73 DCHECK(compressed_bitmap); | 73 DCHECK(compressed_bitmap); |
74 DCHECK(!content_size.IsEmpty()); | 74 DCHECK(!content_size.IsEmpty()); |
75 retrieved_ = false; | 75 retrieved_ = false; |
76 ClearUIResourceId(); | 76 ClearUIResourceId(); |
77 gfx::Size data_size(compressed_bitmap->info().width(), | 77 gfx::Size data_size(compressed_bitmap->info().width(), |
78 compressed_bitmap->info().height()); | 78 compressed_bitmap->info().height()); |
79 scaled_content_size_ = gfx::ScaleSize(gfx::SizeF(content_size), 1.f / scale_); | 79 scaled_content_size_ = gfx::ScaleSize(gfx::SizeF(content_size), 1.f / scale_); |
80 scaled_data_size_ = gfx::ScaleSize(gfx::SizeF(data_size), 1.f / scale_); | 80 scaled_data_size_ = gfx::ScaleSize(gfx::SizeF(data_size), 1.f / scale_); |
81 bitmap_ = cc::UIResourceBitmap(compressed_bitmap, data_size); | 81 bitmap_ = cc::UIResourceBitmap(std::move(compressed_bitmap), data_size); |
82 } | 82 } |
83 | 83 |
84 void Thumbnail::CreateUIResource() { | 84 void Thumbnail::CreateUIResource() { |
85 DCHECK(ui_resource_provider_); | 85 DCHECK(ui_resource_provider_); |
86 if (!ui_resource_id_) | 86 if (!ui_resource_id_) |
87 ui_resource_id_ = ui_resource_provider_->CreateUIResource(this); | 87 ui_resource_id_ = ui_resource_provider_->CreateUIResource(this); |
88 } | 88 } |
89 | 89 |
90 cc::UIResourceBitmap Thumbnail::GetBitmap(cc::UIResourceId uid, | 90 cc::UIResourceBitmap Thumbnail::GetBitmap(cc::UIResourceId uid, |
91 bool resource_lost) { | 91 bool resource_lost) { |
(...skipping 18 matching lines...) Expand all Loading... |
110 void Thumbnail::DoInvalidate() { | 110 void Thumbnail::DoInvalidate() { |
111 if (thumbnail_delegate_) | 111 if (thumbnail_delegate_) |
112 thumbnail_delegate_->InvalidateCachedThumbnail(this); | 112 thumbnail_delegate_->InvalidateCachedThumbnail(this); |
113 } | 113 } |
114 | 114 |
115 void Thumbnail::ClearUIResourceId() { | 115 void Thumbnail::ClearUIResourceId() { |
116 if (ui_resource_id_ && ui_resource_provider_) | 116 if (ui_resource_id_ && ui_resource_provider_) |
117 ui_resource_provider_->DeleteUIResource(ui_resource_id_); | 117 ui_resource_provider_->DeleteUIResource(ui_resource_id_); |
118 ui_resource_id_ = 0; | 118 ui_resource_id_ = 0; |
119 } | 119 } |
OLD | NEW |