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

Side by Side Diff: ui/app_list/views/app_list_main_view.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new usage of scale in FastShowPickler Created 7 years, 2 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
« no previous file with comments | « ui/app_list/views/app_list_item_view.cc ('k') | ui/app_list/views/cached_label.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_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/callback.h" 10 #include "base/callback.h"
(...skipping 25 matching lines...) Expand all
36 36
37 } // namespace 37 } // namespace
38 38
39 //////////////////////////////////////////////////////////////////////////////// 39 ////////////////////////////////////////////////////////////////////////////////
40 // AppListMainView::IconLoader 40 // AppListMainView::IconLoader
41 41
42 class AppListMainView::IconLoader : public AppListItemModelObserver { 42 class AppListMainView::IconLoader : public AppListItemModelObserver {
43 public: 43 public:
44 IconLoader(AppListMainView* owner, 44 IconLoader(AppListMainView* owner,
45 AppListItemModel* item, 45 AppListItemModel* item,
46 ui::ScaleFactor scale_factor) 46 float scale)
47 : owner_(owner), 47 : owner_(owner),
48 item_(item) { 48 item_(item) {
49 item_->AddObserver(this); 49 item_->AddObserver(this);
50 50
51 // Triggers icon loading for given |scale_factor|. 51 // Triggers icon loading for given |scale_factor|.
52 item_->icon().GetRepresentation(scale_factor); 52 item_->icon().GetRepresentation(scale);
53 } 53 }
54 54
55 virtual ~IconLoader() { 55 virtual ~IconLoader() {
56 item_->RemoveObserver(this); 56 item_->RemoveObserver(this);
57 } 57 }
58 58
59 private: 59 private:
60 // AppListItemModelObserver overrides: 60 // AppListItemModelObserver overrides:
61 virtual void ItemIconChanged() OVERRIDE { 61 virtual void ItemIconChanged() OVERRIDE {
62 owner_->OnItemIconLoaded(this); 62 owner_->OnItemIconLoaded(this);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ApplicationDragAndDropHost* drag_and_drop_host) { 140 ApplicationDragAndDropHost* drag_and_drop_host) {
141 contents_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 141 contents_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
142 } 142 }
143 143
144 void AppListMainView::PreloadIcons(PaginationModel* pagination_model, 144 void AppListMainView::PreloadIcons(PaginationModel* pagination_model,
145 gfx::NativeView parent) { 145 gfx::NativeView parent) {
146 ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P; 146 ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P;
147 if (parent) 147 if (parent)
148 scale_factor = ui::GetScaleFactorForNativeView(parent); 148 scale_factor = ui::GetScaleFactorForNativeView(parent);
149 149
150 float scale = ui::GetImageScale(scale_factor);
150 // |pagination_model| could have -1 as the initial selected page and 151 // |pagination_model| could have -1 as the initial selected page and
151 // assumes first page (i.e. index 0) will be used in this case. 152 // assumes first page (i.e. index 0) will be used in this case.
152 const int selected_page = std::max(0, pagination_model->selected_page()); 153 const int selected_page = std::max(0, pagination_model->selected_page());
153 154
154 const int tiles_per_page = kPreferredCols * kPreferredRows; 155 const int tiles_per_page = kPreferredCols * kPreferredRows;
155 const int start_model_index = selected_page * tiles_per_page; 156 const int start_model_index = selected_page * tiles_per_page;
156 const int end_model_index = std::min( 157 const int end_model_index = std::min(
157 static_cast<int>(model_->apps()->item_count()), 158 static_cast<int>(model_->apps()->item_count()),
158 start_model_index + tiles_per_page); 159 start_model_index + tiles_per_page);
159 160
160 pending_icon_loaders_.clear(); 161 pending_icon_loaders_.clear();
161 for (int i = start_model_index; i < end_model_index; ++i) { 162 for (int i = start_model_index; i < end_model_index; ++i) {
162 AppListItemModel* item = model_->apps()->GetItemAt(i); 163 AppListItemModel* item = model_->apps()->GetItemAt(i);
163 if (item->icon().HasRepresentation(scale_factor)) 164 if (item->icon().HasRepresentation(scale))
164 continue; 165 continue;
165 166
166 pending_icon_loaders_.push_back(new IconLoader(this, item, scale_factor)); 167 pending_icon_loaders_.push_back(new IconLoader(this, item, scale));
167 } 168 }
168 } 169 }
169 170
170 void AppListMainView::OnIconLoadingWaitTimer() { 171 void AppListMainView::OnIconLoadingWaitTimer() {
171 GetWidget()->Show(); 172 GetWidget()->Show();
172 } 173 }
173 174
174 void AppListMainView::OnItemIconLoaded(IconLoader* loader) { 175 void AppListMainView::OnItemIconLoaded(IconLoader* loader) {
175 ScopedVector<IconLoader>::iterator it = std::find( 176 ScopedVector<IconLoader>::iterator it = std::find(
176 pending_icon_loaders_.begin(), pending_icon_loaders_.end(), loader); 177 pending_icon_loaders_.begin(), pending_icon_loaders_.end(), loader);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // Resubmit the query via a posted task so that all observers for the 235 // Resubmit the query via a posted task so that all observers for the
235 // uninstall notification are notified. 236 // uninstall notification are notified.
236 base::MessageLoop::current()->PostTask( 237 base::MessageLoop::current()->PostTask(
237 FROM_HERE, 238 FROM_HERE,
238 base::Bind(&AppListMainView::QueryChanged, 239 base::Bind(&AppListMainView::QueryChanged,
239 weak_ptr_factory_.GetWeakPtr(), 240 weak_ptr_factory_.GetWeakPtr(),
240 search_box_view_)); 241 search_box_view_));
241 } 242 }
242 243
243 } // namespace app_list 244 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_item_view.cc ('k') | ui/app_list/views/cached_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698