Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 107 |
| 108 // The following statement causes shadowed image being generated for all | 108 // The following statement causes shadowed image being generated for all |
| 109 // existing image reps in |image_|. This is needed so that expensive shadow | 109 // existing image reps in |image_|. This is needed so that expensive shadow |
| 110 // generation does not run on UI thread. | 110 // generation does not run on UI thread. |
|
tbarzic
2012/08/25 01:46:39
I'm a bit concerned about this part..
I don't thin
xiyuan
2012/08/28 17:31:21
As we have discussed, the icon cache is keyed by t
| |
| 111 gfx::ImageSkia::ImageSkiaReps image_reps = image_.image_reps(); | 111 gfx::ImageSkia::ImageSkiaReps image_reps = image_.image_reps(); |
| 112 for (gfx::ImageSkia::ImageSkiaReps::const_iterator it = image_reps.begin(); | 112 for (gfx::ImageSkia::ImageSkiaReps::const_iterator it = image_reps.begin(); |
| 113 it != image_reps.end(); ++it) { | 113 it != image_reps.end(); ++it) { |
| 114 shadow.GetRepresentation(it->scale_factor()); | 114 shadow.GetRepresentation(it->scale_factor()); |
| 115 } | 115 } |
| 116 image_ = shadow; | 116 image_ = shadow; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void Cancel() { | 119 void Cancel() { |
| 120 cancel_flag_.Set(); | 120 cancel_flag_.Set(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 | 177 |
| 178 icon_size_ = size; | 178 icon_size_ = size; |
| 179 UpdateIcon(); | 179 UpdateIcon(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void AppListItemView::UpdateIcon() { | 182 void AppListItemView::UpdateIcon() { |
| 183 // Skip if |icon_size_| has not been determined. | 183 // Skip if |icon_size_| has not been determined. |
| 184 if (icon_size_.IsEmpty()) | 184 if (icon_size_.IsEmpty()) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 gfx::ImageSkia icon = model_->icon(); | 187 const gfx::ImageSkia& icon = model_->icon(); |
| 188 // Clear icon and bail out if model icon is empty. | 188 // Use empty model icon and bail out. OnPaint should trigger image |
| 189 if (icon.isNull()) { | 189 // representation fetching and if there is an icon, UpdateIcon should be |
| 190 icon_->SetImage(NULL); | 190 // called again with the updated image. |
| 191 if (icon.isNull() || icon.image_reps().size() == 0) { | |
| 192 icon_->SetImage(icon); | |
| 191 return; | 193 return; |
| 192 } | 194 } |
| 193 | 195 |
| 194 CancelPendingIconOperation(); | 196 CancelPendingIconOperation(); |
| 195 | 197 |
| 196 gfx::ImageSkia shadow; | 198 gfx::ImageSkia shadow; |
| 197 if (IconCache::GetInstance()->Get(icon, icon_size_, &shadow)) { | 199 if (IconCache::GetInstance()->Get(icon, icon_size_, &shadow)) { |
| 198 icon_->SetImage(shadow); | 200 icon_->SetImage(shadow); |
| 199 } else { | 201 } else { |
| 200 // Schedule resize and shadow generation. | 202 // Schedule resize and shadow generation. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 apps_grid_view_->SetSelectedItem(this); | 310 apps_grid_view_->SetSelectedItem(this); |
| 309 title_->SetEnabledColor(kTitleHoverColor); | 311 title_->SetEnabledColor(kTitleHoverColor); |
| 310 } else { | 312 } else { |
| 311 apps_grid_view_->ClearSelectedItem(this); | 313 apps_grid_view_->ClearSelectedItem(this); |
| 312 model_->SetHighlighted(false); | 314 model_->SetHighlighted(false); |
| 313 title_->SetEnabledColor(kTitleColor); | 315 title_->SetEnabledColor(kTitleColor); |
| 314 } | 316 } |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace app_list | 319 } // namespace app_list |
| OLD | NEW |