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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "chrome/browser/android/thumbnail/thumbnail.h" | 6 #include "chrome/browser/android/thumbnail/thumbnail.h" |
7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "ui/android/resources/ui_resource_provider.h" | 9 #include "ui/android/resources/ui_resource_provider.h" |
10 #include "ui/gfx/geometry/size_conversions.h" | 10 #include "ui/gfx/geometry/size_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 Thumbnail::~Thumbnail() { | 51 Thumbnail::~Thumbnail() { |
52 ClearUIResourceId(); | 52 ClearUIResourceId(); |
53 } | 53 } |
54 | 54 |
55 void Thumbnail::SetBitmap(const SkBitmap& bitmap) { | 55 void Thumbnail::SetBitmap(const SkBitmap& bitmap) { |
56 DCHECK(!bitmap.empty()); | 56 DCHECK(!bitmap.empty()); |
57 retrieved_ = false; | 57 retrieved_ = false; |
58 ClearUIResourceId(); | 58 ClearUIResourceId(); |
59 scaled_content_size_ = | 59 scaled_content_size_ = |
60 gfx::ScaleSize(gfx::Size(bitmap.width(), bitmap.height()), 1.f / scale_); | 60 gfx::ScaleSize(gfx::SizeF(bitmap.width(), bitmap.height()), 1.f / scale_); |
61 scaled_data_size_ = scaled_content_size_; | 61 scaled_data_size_ = scaled_content_size_; |
62 bitmap_ = cc::UIResourceBitmap(bitmap); | 62 bitmap_ = cc::UIResourceBitmap(bitmap); |
63 } | 63 } |
64 | 64 |
65 void Thumbnail::SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap, | 65 void Thumbnail::SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap, |
66 const gfx::Size& content_size) { | 66 const gfx::Size& content_size) { |
67 DCHECK(compressed_bitmap); | 67 DCHECK(compressed_bitmap); |
68 DCHECK(!content_size.IsEmpty()); | 68 DCHECK(!content_size.IsEmpty()); |
69 retrieved_ = false; | 69 retrieved_ = false; |
70 ClearUIResourceId(); | 70 ClearUIResourceId(); |
71 gfx::Size data_size(compressed_bitmap->info().width(), | 71 gfx::Size data_size(compressed_bitmap->info().width(), |
72 compressed_bitmap->info().height()); | 72 compressed_bitmap->info().height()); |
73 scaled_content_size_ = gfx::ScaleSize(content_size, 1.f / scale_); | 73 scaled_content_size_ = gfx::ScaleSize(gfx::SizeF(content_size), 1.f / scale_); |
74 scaled_data_size_ = gfx::ScaleSize(data_size, 1.f / scale_); | 74 scaled_data_size_ = gfx::ScaleSize(gfx::SizeF(data_size), 1.f / scale_); |
75 bitmap_ = cc::UIResourceBitmap(compressed_bitmap, data_size); | 75 bitmap_ = cc::UIResourceBitmap(compressed_bitmap, data_size); |
76 } | 76 } |
77 | 77 |
78 void Thumbnail::CreateUIResource() { | 78 void Thumbnail::CreateUIResource() { |
79 DCHECK(ui_resource_provider_); | 79 DCHECK(ui_resource_provider_); |
80 if (!ui_resource_id_) | 80 if (!ui_resource_id_) |
81 ui_resource_id_ = ui_resource_provider_->CreateUIResource(this); | 81 ui_resource_id_ = ui_resource_provider_->CreateUIResource(this); |
82 } | 82 } |
83 | 83 |
84 cc::UIResourceBitmap Thumbnail::GetBitmap(cc::UIResourceId uid, | 84 cc::UIResourceBitmap Thumbnail::GetBitmap(cc::UIResourceId uid, |
(...skipping 13 matching lines...) Expand all Loading... |
98 ui_resource_id_ = 0; | 98 ui_resource_id_ = 0; |
99 if (thumbnail_delegate_) | 99 if (thumbnail_delegate_) |
100 thumbnail_delegate_->InvalidateCachedThumbnail(this); | 100 thumbnail_delegate_->InvalidateCachedThumbnail(this); |
101 } | 101 } |
102 | 102 |
103 void Thumbnail::ClearUIResourceId() { | 103 void Thumbnail::ClearUIResourceId() { |
104 if (ui_resource_id_ && ui_resource_provider_) | 104 if (ui_resource_id_ && ui_resource_provider_) |
105 ui_resource_provider_->DeleteUIResource(ui_resource_id_); | 105 ui_resource_provider_->DeleteUIResource(ui_resource_id_); |
106 ui_resource_id_ = 0; | 106 ui_resource_id_ = 0; |
107 } | 107 } |
OLD | NEW |