Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/browser/android/thumbnail/thumbnail.cc

Issue 1128113010: Allow retrieval of updated bitmaps in thumbnails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 ui_resource_provider_(ui_resource_provider), 47 ui_resource_provider_(ui_resource_provider),
48 thumbnail_delegate_(thumbnail_delegate) { 48 thumbnail_delegate_(thumbnail_delegate) {
49 } 49 }
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 ClearUIResourceId(); 58 ClearUIResourceId();
58 scaled_content_size_ = 59 scaled_content_size_ =
59 gfx::ScaleSize(gfx::Size(bitmap.width(), bitmap.height()), 1.f / scale_); 60 gfx::ScaleSize(gfx::Size(bitmap.width(), bitmap.height()), 1.f / scale_);
60 scaled_data_size_ = scaled_content_size_; 61 scaled_data_size_ = scaled_content_size_;
61 bitmap_ = cc::UIResourceBitmap(bitmap); 62 bitmap_ = cc::UIResourceBitmap(bitmap);
62 } 63 }
63 64
64 void Thumbnail::SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap, 65 void Thumbnail::SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap,
65 const gfx::Size& content_size) { 66 const gfx::Size& content_size) {
66 DCHECK(compressed_bitmap); 67 DCHECK(compressed_bitmap);
67 DCHECK(!content_size.IsEmpty()); 68 DCHECK(!content_size.IsEmpty());
69 retrieved_ = false;
68 ClearUIResourceId(); 70 ClearUIResourceId();
69 gfx::Size data_size(compressed_bitmap->info().width(), 71 gfx::Size data_size(compressed_bitmap->info().width(),
70 compressed_bitmap->info().height()); 72 compressed_bitmap->info().height());
71 scaled_content_size_ = gfx::ScaleSize(content_size, 1.f / scale_); 73 scaled_content_size_ = gfx::ScaleSize(content_size, 1.f / scale_);
72 scaled_data_size_ = gfx::ScaleSize(data_size, 1.f / scale_); 74 scaled_data_size_ = gfx::ScaleSize(data_size, 1.f / scale_);
73 bitmap_ = cc::UIResourceBitmap(compressed_bitmap, data_size); 75 bitmap_ = cc::UIResourceBitmap(compressed_bitmap, data_size);
74 } 76 }
75 77
76 void Thumbnail::CreateUIResource() { 78 void Thumbnail::CreateUIResource() {
77 DCHECK(ui_resource_provider_); 79 DCHECK(ui_resource_provider_);
(...skipping 18 matching lines...) Expand all
96 ui_resource_id_ = 0; 98 ui_resource_id_ = 0;
97 if (thumbnail_delegate_) 99 if (thumbnail_delegate_)
98 thumbnail_delegate_->InvalidateCachedThumbnail(this); 100 thumbnail_delegate_->InvalidateCachedThumbnail(this);
99 } 101 }
100 102
101 void Thumbnail::ClearUIResourceId() { 103 void Thumbnail::ClearUIResourceId() {
102 if (ui_resource_id_ && ui_resource_provider_) 104 if (ui_resource_id_ && ui_resource_provider_)
103 ui_resource_provider_->DeleteUIResource(ui_resource_id_); 105 ui_resource_provider_->DeleteUIResource(ui_resource_id_);
104 ui_resource_id_ = 0; 106 ui_resource_id_ = 0;
105 } 107 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698