OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_folder_item.h" | 5 #include "ui/app_list/app_list_folder_item.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
9 #include "ui/app_list/app_list_item_list.h" | 9 #include "ui/app_list/app_list_item_list.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 DCHECK(icons.size() <= kNumFolderTopItems); | 29 DCHECK(icons.size() <= kNumFolderTopItems); |
30 } | 30 } |
31 | 31 |
32 virtual ~FolderImageSource() {} | 32 virtual ~FolderImageSource() {} |
33 | 33 |
34 private: | 34 private: |
35 void DrawIcon(gfx::Canvas* canvas, | 35 void DrawIcon(gfx::Canvas* canvas, |
36 const gfx::ImageSkia& icon, | 36 const gfx::ImageSkia& icon, |
37 const gfx::Size icon_size, | 37 const gfx::Size icon_size, |
38 int x, int y) { | 38 int x, int y) { |
| 39 if (icon.isNull()) |
| 40 return; |
| 41 |
39 gfx::ImageSkia resized( | 42 gfx::ImageSkia resized( |
40 gfx::ImageSkiaOperations::CreateResizedImage( | 43 gfx::ImageSkiaOperations::CreateResizedImage( |
41 icon, skia::ImageOperations::RESIZE_BEST, icon_size)); | 44 icon, skia::ImageOperations::RESIZE_BEST, icon_size)); |
42 canvas->DrawImageInt(resized, 0, 0, resized.width(), resized.height(), | 45 canvas->DrawImageInt(resized, 0, 0, resized.width(), resized.height(), |
43 x, y, resized.width(), resized.height(), true); | 46 x, y, resized.width(), resized.height(), true); |
44 } | 47 } |
45 | 48 |
46 // gfx::CanvasImageSource overrides: | 49 // gfx::CanvasImageSource overrides: |
47 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { | 50 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { |
48 // Draw folder circle. | 51 // Draw folder circle. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 for (size_t i = 0; | 250 for (size_t i = 0; |
248 i < kNumFolderTopItems && i < item_list_->item_count(); ++i) { | 251 i < kNumFolderTopItems && i < item_list_->item_count(); ++i) { |
249 AppListItem* item = item_list_->item_at(i); | 252 AppListItem* item = item_list_->item_at(i); |
250 item->AddObserver(this); | 253 item->AddObserver(this); |
251 top_items_.push_back(item); | 254 top_items_.push_back(item); |
252 } | 255 } |
253 UpdateIcon(); | 256 UpdateIcon(); |
254 } | 257 } |
255 | 258 |
256 } // namespace app_list | 259 } // namespace app_list |
OLD | NEW |