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

Side by Side Diff: ash/system/chromeos/network/network_icon.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 "ash/system/chromeos/network/network_icon.h" 5 #include "ash/system/chromeos/network/network_icon.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/chromeos/network/network_icon_animation.h" 8 #include "ash/system/chromeos/network/network_icon_animation.h"
9 #include "ash/system/chromeos/network/network_icon_animation_observer.h" 9 #include "ash/system/chromeos/network/network_icon_animation_observer.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 (*s_empty_bitmaps)[key] = empty; 189 (*s_empty_bitmaps)[key] = empty;
190 return empty; 190 return empty;
191 } 191 }
192 192
193 class EmptyImageSource: public gfx::ImageSkiaSource { 193 class EmptyImageSource: public gfx::ImageSkiaSource {
194 public: 194 public:
195 explicit EmptyImageSource(const gfx::Size& size) 195 explicit EmptyImageSource(const gfx::Size& size)
196 : size_(size) { 196 : size_(size) {
197 } 197 }
198 198
199 virtual gfx::ImageSkiaRep GetImageForScale( 199 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE {
200 ui::ScaleFactor scale_factor) OVERRIDE { 200 gfx::Size pixel_size = gfx::ToFlooredSize(gfx::ScaleSize(size_, scale));
201 gfx::Size pixel_size = gfx::ToFlooredSize(
202 gfx::ScaleSize(size_, ui::GetScaleFactorScale(scale_factor)));
203 SkBitmap empty_bitmap = GetEmptyBitmap(pixel_size); 201 SkBitmap empty_bitmap = GetEmptyBitmap(pixel_size);
204 return gfx::ImageSkiaRep(empty_bitmap, scale_factor); 202 return gfx::ImageSkiaRep(empty_bitmap, scale);
205 } 203 }
204
206 private: 205 private:
207 const gfx::Size size_; 206 const gfx::Size size_;
208 207
209 DISALLOW_COPY_AND_ASSIGN(EmptyImageSource); 208 DISALLOW_COPY_AND_ASSIGN(EmptyImageSource);
210 }; 209 };
211 210
212 // This defines how we assemble a network icon. 211 // This defines how we assemble a network icon.
213 class NetworkIconImageSource : public gfx::ImageSkiaSource { 212 class NetworkIconImageSource : public gfx::ImageSkiaSource {
214 public: 213 public:
215 NetworkIconImageSource(const gfx::ImageSkia& icon, const Badges& badges) 214 NetworkIconImageSource(const gfx::ImageSkia& icon, const Badges& badges)
216 : icon_(icon), 215 : icon_(icon),
217 badges_(badges) { 216 badges_(badges) {
218 } 217 }
219 virtual ~NetworkIconImageSource() {} 218 virtual ~NetworkIconImageSource() {}
220 219
221 // TODO(pkotwicz): Figure out what to do when a new image resolution becomes 220 // TODO(pkotwicz): Figure out what to do when a new image resolution becomes
222 // available. 221 // available.
223 virtual gfx::ImageSkiaRep GetImageForScale( 222 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE {
224 ui::ScaleFactor scale_factor) OVERRIDE { 223 gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale);
225 gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale_factor);
226 if (icon_rep.is_null()) 224 if (icon_rep.is_null())
227 return gfx::ImageSkiaRep(); 225 return gfx::ImageSkiaRep();
228 gfx::Canvas canvas(icon_rep, false); 226 gfx::Canvas canvas(icon_rep, false);
229 if (badges_.top_left) 227 if (badges_.top_left)
230 canvas.DrawImageInt(*badges_.top_left, 0, 0); 228 canvas.DrawImageInt(*badges_.top_left, 0, 0);
231 if (badges_.top_right) 229 if (badges_.top_right)
232 canvas.DrawImageInt(*badges_.top_right, 230 canvas.DrawImageInt(*badges_.top_right,
233 icon_.width() - badges_.top_right->width(), 0); 231 icon_.width() - badges_.top_right->width(), 0);
234 if (badges_.bottom_left) { 232 if (badges_.bottom_left) {
235 canvas.DrawImageInt(*badges_.bottom_left, 233 canvas.DrawImageInt(*badges_.bottom_left,
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 iter != networks.end(); ++iter) { 837 iter != networks.end(); ++iter) {
840 network_paths.insert((*iter)->path()); 838 network_paths.insert((*iter)->path());
841 } 839 }
842 PurgeIconMap(ICON_TYPE_TRAY, network_paths); 840 PurgeIconMap(ICON_TYPE_TRAY, network_paths);
843 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); 841 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths);
844 PurgeIconMap(ICON_TYPE_LIST, network_paths); 842 PurgeIconMap(ICON_TYPE_LIST, network_paths);
845 } 843 }
846 844
847 } // namespace network_icon 845 } // namespace network_icon
848 } // namespace ash 846 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell/window_watcher.cc ('k') | ash/wm/frame_painter.cc » ('j') | cc/layers/layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698