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

Side by Side Diff: ui/app_list/app_list_item_view.cc

Issue 10820049: Load 2x resources on demand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For preview Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/app_list/app_list_item_view.h" 5 #include "ui/app_list/app_list_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 void ResizeAndGenerateShadow() { 99 void ResizeAndGenerateShadow() {
100 if (cancel_flag_.IsSet()) 100 if (cancel_flag_.IsSet())
101 return; 101 return;
102 102
103 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(image_, 103 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(image_,
104 skia::ImageOperations::RESIZE_BEST, size_)); 104 skia::ImageOperations::RESIZE_BEST, size_));
105 gfx::ImageSkia shadow( 105 gfx::ImageSkia shadow(
106 gfx::ImageSkiaOperations::CreateImageWithDropShadow(resized, shadows_)); 106 gfx::ImageSkiaOperations::CreateImageWithDropShadow(resized, shadows_));
107
108 // The following statement causes shadowed image being generated for all
109 // existing image reps in |image_|. This is needed so that expensive shadow
110 // generation does not run on UI thread.
111 gfx::ImageSkia::ImageSkiaReps image_reps = image_.image_reps();
112 for (gfx::ImageSkia::ImageSkiaReps::const_iterator it = image_reps.begin();
113 it != image_reps.end(); ++it) {
114 shadow.GetRepresentation(it->scale_factor());
115 }
116 image_ = shadow; 107 image_ = shadow;
108 // Make sure that the image contains ImageSkiaReps for supported
109 // scale factors.
110 image_.EnsureRepsForSupportedScaleFactors();
111 // All images are generated. Remove source and mark it as read only.
112 image_.DeleteSource();
113 image_.SetReadOnly();
117 } 114 }
118 115
119 void Cancel() { 116 void Cancel() {
120 cancel_flag_.Set(); 117 cancel_flag_.Set();
121 } 118 }
122 119
123 const gfx::ImageSkia& image() const { 120 const gfx::ImageSkia& image() const {
124 return image_; 121 return image_;
125 } 122 }
126 123
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 apps_grid_view_->SetSelectedItem(this); 305 apps_grid_view_->SetSelectedItem(this);
309 title_->SetEnabledColor(kTitleHoverColor); 306 title_->SetEnabledColor(kTitleHoverColor);
310 } else { 307 } else {
311 apps_grid_view_->ClearSelectedItem(this); 308 apps_grid_view_->ClearSelectedItem(this);
312 model_->SetHighlighted(false); 309 model_->SetHighlighted(false);
313 title_->SetEnabledColor(kTitleColor); 310 title_->SetEnabledColor(kTitleColor);
314 } 311 }
315 } 312 }
316 313
317 } // namespace app_list 314 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698