OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 9 |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 int y = min(kBadgeBottomY, icon.height() - bottom_right_badge->height()); | 692 int y = min(kBadgeBottomY, icon.height() - bottom_right_badge->height()); |
693 canvas.DrawBitmapInt(*bottom_right_badge, x, y); | 693 canvas.DrawBitmapInt(*bottom_right_badge, x, y); |
694 } | 694 } |
695 | 695 |
696 return canvas.ExtractBitmap(); | 696 return canvas.ExtractBitmap(); |
697 } | 697 } |
698 | 698 |
699 // We blend connecting icons with a black image to generate a faded icon. | 699 // We blend connecting icons with a black image to generate a faded icon. |
700 const SkBitmap NetworkMenuIcon::GenerateConnectingBitmap( | 700 const SkBitmap NetworkMenuIcon::GenerateConnectingBitmap( |
701 const SkBitmap& source) { | 701 const SkBitmap& source) { |
702 static SkBitmap empty_badge; | 702 CR_DEFINE_STATIC_LOCAL(SkBitmap, empty_badge, ()); |
703 if (empty_badge.empty()) { | 703 if (empty_badge.empty()) { |
704 empty_badge.setConfig(SkBitmap::kARGB_8888_Config, | 704 empty_badge.setConfig(SkBitmap::kARGB_8888_Config, |
705 source.width(), source.height(), 0); | 705 source.width(), source.height(), 0); |
706 empty_badge.allocPixels(); | 706 empty_badge.allocPixels(); |
707 empty_badge.eraseARGB(0, 0, 0, 0); | 707 empty_badge.eraseARGB(0, 0, 0, 0); |
708 } | 708 } |
709 DCHECK(empty_badge.width() == source.width()); | 709 DCHECK(empty_badge.width() == source.width()); |
710 DCHECK(empty_badge.height() == source.height()); | 710 DCHECK(empty_badge.height() == source.height()); |
711 return SkBitmapOperations::CreateBlendedBitmap( | 711 return SkBitmapOperations::CreateBlendedBitmap( |
712 empty_badge, source, kConnectingImageAlpha); | 712 empty_badge, source, kConnectingImageAlpha); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 | 795 |
796 const SkBitmap NetworkMenuIcon::GetConnectedBitmap(BitmapType type) { | 796 const SkBitmap NetworkMenuIcon::GetConnectedBitmap(BitmapType type) { |
797 return GetBitmap(type, NumBitmaps(type) - 1); | 797 return GetBitmap(type, NumBitmaps(type) - 1); |
798 } | 798 } |
799 | 799 |
800 int NetworkMenuIcon::NumBitmaps(BitmapType type) { | 800 int NetworkMenuIcon::NumBitmaps(BitmapType type) { |
801 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; | 801 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; |
802 } | 802 } |
803 | 803 |
804 } // chromeos | 804 } // chromeos |
OLD | NEW |