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 "chrome/browser/chromeos/status/network_menu_icon.h" | 5 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | |
| 10 #include <utility> | |
| 9 | 11 |
| 10 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 13 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 12 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 13 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 14 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 15 #include "grit/theme_resources_standard.h" | 17 #include "grit/theme_resources_standard.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/image/image_skia_source.h" | |
| 19 #include "ui/gfx/skbitmap_operations.h" | 22 #include "ui/gfx/skbitmap_operations.h" |
| 20 | 23 |
| 21 using std::max; | 24 using std::max; |
| 22 using std::min; | 25 using std::min; |
| 23 | 26 |
| 24 namespace chromeos { | 27 namespace chromeos { |
| 25 | 28 |
| 26 namespace { | 29 namespace { |
| 27 | 30 |
| 28 // Amount to fade icons while connecting. | 31 // Amount to fade icons while connecting. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 break; | 145 break; |
| 143 case NETWORK_TECHNOLOGY_UNKNOWN: | 146 case NETWORK_TECHNOLOGY_UNKNOWN: |
| 144 break; | 147 break; |
| 145 } | 148 } |
| 146 if (id == kUnknownBadgeType) | 149 if (id == kUnknownBadgeType) |
| 147 return NULL; | 150 return NULL; |
| 148 else | 151 else |
| 149 return ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); | 152 return ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); |
| 150 } | 153 } |
| 151 | 154 |
| 152 // Blend source image with a black image to fade the image. | 155 const SkBitmap GetEmptyBitmapOfSameSize(const gfx::ImageSkiaRep& reference) { |
| 153 const gfx::ImageSkia GenerateFadedImage(gfx::ImageSkia source, | 156 typedef std::pair<int, int> SizeKey; |
| 154 gfx::ImageSkia empty_image, | 157 typedef std::map<SizeKey, SkBitmap> SizeBitmapMap; |
| 155 double alpha) { | 158 static SizeBitmapMap* empty_bitmaps_ = new SizeBitmapMap; |
| 156 gfx::ImageSkia faded_image; | 159 |
| 157 std::vector<gfx::ImageSkiaRep> image_reps = source.image_reps(); | 160 SizeKey key(reference.pixel_width(), reference.pixel_height()); |
| 158 for (size_t i = 0; i < image_reps.size(); ++i) { | 161 |
| 159 gfx::ImageSkiaRep image_rep = image_reps[i]; | 162 SizeBitmapMap::iterator iter = empty_bitmaps_->find(key); |
| 160 ui::ScaleFactor scale_factor = image_rep.scale_factor(); | 163 if (iter != empty_bitmaps_->end()) |
| 161 gfx::ImageSkiaRep empty_image_rep = | 164 return iter->second; |
| 162 empty_image.GetRepresentation(scale_factor); | 165 |
| 163 SkBitmap empty_bitmap = empty_image_rep.sk_bitmap(); | 166 SkBitmap empty; |
| 164 if (empty_image_rep.is_null() || | 167 empty.setConfig(SkBitmap::kARGB_8888_Config, key.first, key.second); |
| 165 empty_image_rep.scale_factor() != scale_factor) { | 168 empty.allocPixels(); |
| 166 empty_bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 169 empty.eraseARGB(0, 0, 0, 0); |
| 167 image_rep.pixel_width(), | 170 (*empty_bitmaps_)[key] = empty; |
| 168 image_rep.pixel_height()); | 171 return empty; |
| 169 empty_bitmap.allocPixels(); | |
| 170 empty_bitmap.eraseARGB(0, 0, 0, 0); | |
| 171 empty_image.AddRepresentation(gfx::ImageSkiaRep(empty_bitmap, | |
| 172 scale_factor)); | |
| 173 } | |
| 174 SkBitmap faded_bitmap = SkBitmapOperations::CreateBlendedBitmap( | |
| 175 empty_bitmap, image_rep.sk_bitmap(), alpha); | |
| 176 faded_image.AddRepresentation(gfx::ImageSkiaRep(faded_bitmap, | |
| 177 scale_factor)); | |
| 178 } | |
| 179 return faded_image; | |
| 180 } | 172 } |
| 181 | 173 |
| 182 const SkBitmap GetVpnResource(int resource_id) { | 174 class FadedImageSource : public gfx::ImageSkiaSource { |
| 175 public: | |
| 176 FadedImageSource(const gfx::ImageSkia& source, double alpha) | |
| 177 : source_(source), | |
| 178 alpha_(alpha) { | |
| 179 } | |
| 180 virtual ~FadedImageSource() {} | |
| 181 | |
| 182 virtual gfx::ImageSkiaRep GetImageForScale( | |
| 183 ui::ScaleFactor scale_factor) OVERRIDE { | |
| 184 gfx::ImageSkiaRep image_rep = source_.GetRepresentation(scale_factor); | |
| 185 const SkBitmap empty_bitmap = GetEmptyBitmapOfSameSize(image_rep); | |
| 186 SkBitmap faded_bitmap = SkBitmapOperations::CreateBlendedBitmap( | |
| 187 empty_bitmap, image_rep.sk_bitmap(), alpha_); | |
| 188 return gfx::ImageSkiaRep(faded_bitmap, image_rep.scale_factor()); | |
| 189 } | |
| 190 | |
| 191 private: | |
| 192 const gfx::ImageSkia source_; | |
| 193 const float alpha_; | |
| 194 | |
| 195 DISALLOW_COPY_AND_ASSIGN(FadedImageSource); | |
| 196 }; | |
| 197 | |
| 198 // This defines how we assemble a network icon. | |
| 199 class NetworkIconImageSource : public gfx::ImageSkiaSource { | |
| 200 public: | |
| 201 NetworkIconImageSource(const gfx::ImageSkia& icon, | |
| 202 const gfx::ImageSkia* top_left_badge, | |
| 203 const gfx::ImageSkia* top_right_badge, | |
| 204 const gfx::ImageSkia* bottom_left_badge, | |
| 205 const gfx::ImageSkia* bottom_right_badge) | |
| 206 : icon_(icon), | |
| 207 top_left_badge_(top_left_badge), | |
| 208 top_right_badge_(top_right_badge), | |
| 209 bottom_left_badge_(bottom_left_badge), | |
| 210 bottom_right_badge_(bottom_right_badge) { | |
| 211 } | |
| 212 virtual ~NetworkIconImageSource() {} | |
| 213 | |
| 214 virtual gfx::ImageSkiaRep GetImageForScale( | |
| 215 ui::ScaleFactor scale_factor) OVERRIDE { | |
| 216 gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale_factor); | |
| 217 if (icon_rep.is_null()) | |
| 218 return gfx::ImageSkiaRep(); | |
| 219 gfx::Canvas canvas(icon_rep.sk_bitmap(), false); | |
| 220 canvas.sk_canvas()->scale(icon_rep.GetScale(), icon_rep.GetScale()); | |
| 221 if (top_left_badge_) | |
| 222 canvas.DrawImageInt(*top_left_badge_, kBadgeLeftX, kBadgeTopY); | |
| 223 if (top_right_badge_) | |
| 224 canvas.DrawImageInt(*top_right_badge_, | |
| 225 icon_.width() - top_right_badge_->width(), | |
| 226 kBadgeTopY); | |
| 227 if (bottom_left_badge_) { | |
| 228 canvas.DrawImageInt(*bottom_left_badge_, | |
| 229 kBadgeLeftX, | |
| 230 icon_.height() - bottom_left_badge_->height()); | |
| 231 } | |
| 232 if (bottom_right_badge_) { | |
| 233 canvas.DrawImageInt(*bottom_right_badge_, | |
| 234 icon_.width() - bottom_right_badge_->width(), | |
| 235 icon_.height() - bottom_right_badge_->height()); | |
| 236 } | |
| 237 return gfx::ImageSkiaRep(canvas.ExtractBitmap(), icon_rep.scale_factor()); | |
| 238 } | |
| 239 | |
| 240 private: | |
| 241 const gfx::ImageSkia icon_; | |
| 242 const gfx::ImageSkia *top_left_badge_; | |
| 243 const gfx::ImageSkia *top_right_badge_; | |
| 244 const gfx::ImageSkia *bottom_left_badge_; | |
| 245 const gfx::ImageSkia *bottom_right_badge_; | |
| 246 | |
| 247 DISALLOW_COPY_AND_ASSIGN(NetworkIconImageSource); | |
| 248 }; | |
| 249 | |
| 250 // This defines how we assemble a network menu icon. | |
| 251 class NetworkMenuIconSource : public gfx::ImageSkiaSource { | |
| 252 public: | |
| 253 NetworkMenuIconSource(NetworkMenuIcon::ImageType type, | |
| 254 int index, | |
| 255 NetworkMenuIcon::ResourceColorTheme color) | |
| 256 : type_(type), | |
| 257 index_(index), | |
| 258 color_(color) { | |
| 259 } | |
| 260 virtual ~NetworkMenuIconSource() {} | |
| 261 | |
| 262 virtual gfx::ImageSkiaRep GetImageForScale( | |
| 263 ui::ScaleFactor scale_factor) OVERRIDE { | |
| 264 int width, height; | |
| 265 gfx::ImageSkia* images; | |
| 266 if (type_ == NetworkMenuIcon::ARCS) { | |
| 267 if (index_ >= kNumArcsImages) | |
| 268 return gfx::ImageSkia(); | |
| 269 images = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
| 270 color_ == NetworkMenuIcon::COLOR_DARK ? | |
| 271 IDR_STATUSBAR_NETWORK_ARCS_DARK : IDR_STATUSBAR_NETWORK_ARCS_LIGHT); | |
| 272 width = images->width(); | |
| 273 height = images->height() / kNumArcsImages; | |
| 274 } else { | |
| 275 if (index_ >= kNumBarsImages) | |
| 276 return gfx::ImageSkia(); | |
| 277 | |
| 278 images = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
| 279 color_ == NetworkMenuIcon::COLOR_DARK ? | |
| 280 IDR_STATUSBAR_NETWORK_BARS_DARK : IDR_STATUSBAR_NETWORK_BARS_LIGHT); | |
| 281 width = images->width(); | |
| 282 height = images->height() / kNumBarsImages; | |
| 283 } | |
| 284 gfx::ImageSkiaRep image_rep = images->GetRepresentation(scale_factor); | |
|
stevenjb
2012/07/02 22:31:34
I assume that image_rep will always be scaled appr
oshima
2012/07/02 22:42:06
It may not, and that's why I'm using the image_rep
stevenjb
2012/07/03 16:38:38
Ah, I see, I was confused by scale vs. scale_facto
| |
| 285 | |
| 286 float scale = ui::GetScaleFactorScale(image_rep.scale_factor()); | |
| 287 height *= scale; | |
| 288 width *= scale; | |
| 289 | |
| 290 SkIRect subset = SkIRect::MakeXYWH(0, index_ * height, width, height); | |
| 291 | |
| 292 SkBitmap dst_bitmap; | |
| 293 image_rep.sk_bitmap().extractSubset(&dst_bitmap, subset); | |
| 294 return gfx::ImageSkiaRep(dst_bitmap, image_rep.scale_factor()); | |
| 295 } | |
| 296 | |
| 297 gfx::Size size() const { | |
| 298 // NeworkMenuIcons has the same size in DIP | |
| 299 return ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
| 300 IDR_STATUSBAR_NETWORK_ARCS_DARK)->size(); | |
| 301 } | |
| 302 | |
| 303 private: | |
| 304 const NetworkMenuIcon::ImageType type_; | |
| 305 const int index_; | |
| 306 const NetworkMenuIcon::ResourceColorTheme color_; | |
| 307 | |
| 308 DISALLOW_COPY_AND_ASSIGN(NetworkMenuIconSource); | |
| 309 }; | |
| 310 | |
| 311 gfx::ImageSkia CreateVpnImage() { | |
| 183 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 312 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 184 const gfx::ImageSkia* ethernet_icon = rb.GetImageSkiaNamed(resource_id); | 313 const gfx::ImageSkia* ethernet_icon = rb.GetImageSkiaNamed(IDR_STATUSBAR_VPN); |
| 185 const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); | 314 const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); |
| 186 return NetworkMenuIcon::GenerateImageFromComponents( | 315 return NetworkMenuIcon::GenerateImageFromComponents( |
| 187 *ethernet_icon, NULL, NULL, vpn_badge, NULL); | 316 *ethernet_icon, NULL, NULL, vpn_badge, NULL); |
| 188 } | 317 } |
| 189 | 318 |
| 190 } // namespace | 319 } // namespace |
| 191 | 320 |
| 192 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
| 193 // NetworkIcon | 322 // NetworkIcon |
| 194 // TODO(stevenjb): Separate class implementation from the definition. | 323 // TODO(stevenjb): Separate class implementation from the definition. |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 icon_->UpdateIcon(network); | 810 icon_->UpdateIcon(network); |
| 682 // Overlay the VPN badge if connecting to a VPN. | 811 // Overlay the VPN badge if connecting to a VPN. |
| 683 if (network->type() != TYPE_VPN && cros->virtual_network()) { | 812 if (network->type() != TYPE_VPN && cros->virtual_network()) { |
| 684 if (cros->virtual_network()->connecting()) { | 813 if (cros->virtual_network()->connecting()) { |
| 685 const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); | 814 const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); |
| 686 const double animation = GetAnimation(); | 815 const double animation = GetAnimation(); |
| 687 animating = true; | 816 animating = true; |
| 688 // Even though this is the only place we use vpn_connecting_badge_, | 817 // Even though this is the only place we use vpn_connecting_badge_, |
| 689 // it is important that this is a member variable since we set a | 818 // it is important that this is a member variable since we set a |
| 690 // pointer to it and access that pointer in icon_->GenerateImage(). | 819 // pointer to it and access that pointer in icon_->GenerateImage(). |
| 691 CR_DEFINE_STATIC_LOCAL(gfx::ImageSkia, empty_image, ()); | 820 vpn_connecting_badge_ = gfx::ImageSkia( |
| 692 vpn_connecting_badge_ = GenerateFadedImage(*vpn_badge, empty_image, | 821 new FadedImageSource(*vpn_badge, animation), vpn_badge->size()); |
| 693 animation); | |
| 694 icon_->set_bottom_left_badge(&vpn_connecting_badge_); | 822 icon_->set_bottom_left_badge(&vpn_connecting_badge_); |
| 695 } | 823 } |
| 696 } | 824 } |
| 697 if (!animating) | 825 if (!animating) |
| 698 animation_connecting_.Stop(); | 826 animation_connecting_.Stop(); |
| 699 | 827 |
| 700 // Set the text to display. | 828 // Set the text to display. |
| 701 if (network->type() == TYPE_ETHERNET) { | 829 if (network->type() == TYPE_ETHERNET) { |
| 702 if (mode_ == MENU_MODE) { | 830 if (mode_ == MENU_MODE) { |
| 703 text_ = l10n_util::GetStringFUTF16( | 831 text_ = l10n_util::GetStringFUTF16( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 // Currently we iterate over all the available resolutions in |icon|. This will | 876 // Currently we iterate over all the available resolutions in |icon|. This will |
| 749 // be wrong once we dynamically load image resolutions. | 877 // be wrong once we dynamically load image resolutions. |
| 750 // TODO(pkotwicz): Figure out what to do when a new image resolution becomes | 878 // TODO(pkotwicz): Figure out what to do when a new image resolution becomes |
| 751 // available. | 879 // available. |
| 752 const gfx::ImageSkia NetworkMenuIcon::GenerateImageFromComponents( | 880 const gfx::ImageSkia NetworkMenuIcon::GenerateImageFromComponents( |
| 753 const gfx::ImageSkia& icon, | 881 const gfx::ImageSkia& icon, |
| 754 const gfx::ImageSkia* top_left_badge, | 882 const gfx::ImageSkia* top_left_badge, |
| 755 const gfx::ImageSkia* top_right_badge, | 883 const gfx::ImageSkia* top_right_badge, |
| 756 const gfx::ImageSkia* bottom_left_badge, | 884 const gfx::ImageSkia* bottom_left_badge, |
| 757 const gfx::ImageSkia* bottom_right_badge) { | 885 const gfx::ImageSkia* bottom_right_badge) { |
| 758 DCHECK(!icon.empty()); | 886 return gfx::ImageSkia(new NetworkIconImageSource(icon, |
| 759 gfx::ImageSkia badged; | 887 top_left_badge, |
| 760 int dip_width = icon.width(); | 888 top_right_badge, |
| 761 int dip_height = icon.height(); | 889 bottom_left_badge, |
| 762 std::vector<gfx::ImageSkiaRep> image_reps = icon.image_reps(); | 890 bottom_right_badge), |
| 763 for (std::vector<gfx::ImageSkiaRep>::iterator it = image_reps.begin(); | 891 icon.size()); |
| 764 it != image_reps.end(); ++it) { | |
| 765 gfx::Canvas canvas(*it, false); | |
| 766 if (top_left_badge) | |
| 767 canvas.DrawImageInt(*top_left_badge, kBadgeLeftX, kBadgeTopY); | |
| 768 if (top_right_badge) | |
| 769 canvas.DrawImageInt(*top_right_badge, | |
| 770 dip_width - top_right_badge->width(), | |
| 771 kBadgeTopY); | |
| 772 if (bottom_left_badge) | |
| 773 canvas.DrawImageInt(*bottom_left_badge, | |
| 774 kBadgeLeftX, | |
| 775 dip_height - bottom_left_badge->height()); | |
| 776 if (bottom_right_badge) | |
| 777 canvas.DrawImageInt(*bottom_right_badge, | |
| 778 dip_width - bottom_right_badge->width(), | |
| 779 dip_height - bottom_right_badge->height()); | |
| 780 badged.AddRepresentation(canvas.ExtractImageSkiaRep()); | |
| 781 } | |
| 782 return badged; | |
| 783 } | 892 } |
| 784 | 893 |
| 785 // We blend connecting icons with a black image to generate a faded icon. | 894 // We blend connecting icons with a black image to generate a faded icon. |
| 786 const gfx::ImageSkia NetworkMenuIcon::GenerateConnectingImage( | 895 const gfx::ImageSkia NetworkMenuIcon::GenerateConnectingImage( |
| 787 const gfx::ImageSkia& source) { | 896 const gfx::ImageSkia& source) { |
| 788 CR_DEFINE_STATIC_LOCAL(gfx::ImageSkia, empty_badge, ()); | 897 return gfx::ImageSkia(new FadedImageSource(source, kConnectingImageAlpha), |
| 789 return GenerateFadedImage(source, empty_badge, kConnectingImageAlpha); | 898 source.size()); |
| 790 } | 899 } |
| 791 | 900 |
| 792 // Generates and caches an icon image for a network's current state. | 901 // Generates and caches an icon image for a network's current state. |
| 793 const gfx::ImageSkia NetworkMenuIcon::GetImage(const Network* network, | 902 const gfx::ImageSkia NetworkMenuIcon::GetImage(const Network* network, |
| 794 ResourceColorTheme color) { | 903 ResourceColorTheme color) { |
| 795 DCHECK(network); | 904 DCHECK(network); |
| 796 // Maintain a static (global) icon map. Note: Icons are never destroyed; | 905 // Maintain a static (global) icon map. Note: Icons are never destroyed; |
| 797 // it is assumed that a finite and reasonable number of network icons will be | 906 // it is assumed that a finite and reasonable number of network icons will be |
| 798 // created during a session. | 907 // created during a session. |
| 799 | 908 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 816 } else { | 925 } else { |
| 817 icon = iter->second; | 926 icon = iter->second; |
| 818 } | 927 } |
| 819 // Update and return the icon's image. | 928 // Update and return the icon's image. |
| 820 icon->Update(); | 929 icon->Update(); |
| 821 return icon->GetImage(); | 930 return icon->GetImage(); |
| 822 } | 931 } |
| 823 | 932 |
| 824 // Returns an icon for a disconnected VPN. | 933 // Returns an icon for a disconnected VPN. |
| 825 const gfx::ImageSkia NetworkMenuIcon::GetVpnImage() { | 934 const gfx::ImageSkia NetworkMenuIcon::GetVpnImage() { |
| 826 static gfx::ImageSkia* vpn_image = NULL; | 935 static const gfx::ImageSkia *vpn_image = new gfx::ImageSkia(CreateVpnImage()); |
| 827 if (vpn_image == NULL) | |
| 828 vpn_image = new gfx::ImageSkia(GetVpnResource(IDR_STATUSBAR_VPN)); | |
| 829 return *vpn_image; | 936 return *vpn_image; |
| 830 } | 937 } |
| 831 | 938 |
| 832 const gfx::ImageSkia NetworkMenuIcon::GetImage(ImageType type, | 939 const gfx::ImageSkia NetworkMenuIcon::GetImage(ImageType type, |
| 833 int index, | 940 int index, |
| 834 ResourceColorTheme color) { | 941 ResourceColorTheme color) { |
| 835 int width, height; | 942 NetworkMenuIconSource* source = new NetworkMenuIconSource(type, index, color); |
| 836 gfx::ImageSkia* images; | 943 return gfx::ImageSkia(source, source->size()); |
| 837 if (type == ARCS) { | |
| 838 if (index >= kNumArcsImages) | |
| 839 return gfx::ImageSkia(); | |
| 840 | |
| 841 images = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
| 842 color == COLOR_DARK ? IDR_STATUSBAR_NETWORK_ARCS_DARK : | |
| 843 IDR_STATUSBAR_NETWORK_ARCS_LIGHT); | |
| 844 width = images->width(); | |
| 845 height = images->height() / kNumArcsImages; | |
| 846 } else { | |
| 847 if (index >= kNumBarsImages) | |
| 848 return gfx::ImageSkia(); | |
| 849 | |
| 850 images = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
| 851 color == COLOR_DARK ? IDR_STATUSBAR_NETWORK_BARS_DARK : | |
| 852 IDR_STATUSBAR_NETWORK_BARS_LIGHT); | |
| 853 width = images->width(); | |
| 854 height = images->height() / kNumBarsImages; | |
| 855 } | |
| 856 | |
| 857 SkIRect subset = SkIRect::MakeXYWH(0, index * height, width, height); | |
| 858 gfx::ImageSkia image; | |
| 859 images->extractSubset(&image, subset); | |
| 860 return image; | |
| 861 } | 944 } |
| 862 | 945 |
| 863 const gfx::ImageSkia NetworkMenuIcon::GetDisconnectedImage( | 946 const gfx::ImageSkia NetworkMenuIcon::GetDisconnectedImage( |
| 864 ImageType type, | 947 ImageType type, |
| 865 ResourceColorTheme color) { | 948 ResourceColorTheme color) { |
| 866 return GetImage(type, 0, color); | 949 return GetImage(type, 0, color); |
| 867 } | 950 } |
| 868 | 951 |
| 869 const gfx::ImageSkia NetworkMenuIcon::GetConnectedImage(ImageType type, | 952 const gfx::ImageSkia NetworkMenuIcon::GetConnectedImage(ImageType type, |
| 870 ResourceColorTheme color) { | 953 ResourceColorTheme color) { |
| 871 return GetImage(type, NumImages(type) - 1, color); | 954 return GetImage(type, NumImages(type) - 1, color); |
| 872 } | 955 } |
| 873 | 956 |
| 874 int NetworkMenuIcon::NumImages(ImageType type) { | 957 int NetworkMenuIcon::NumImages(ImageType type) { |
| 875 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; | 958 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; |
| 876 } | 959 } |
| 877 | 960 |
| 878 } // chromeos | 961 } // chromeos |
| OLD | NEW |