diff options
63 files changed, 495 insertions, 454 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc index 5b2562e..a173098 100644 --- a/ash/desktop_background/desktop_background_controller.cc +++ b/ash/desktop_background/desktop_background_controller.cc @@ -42,7 +42,7 @@ class DesktopBackgroundController::WallpaperOperation if (cancel_flag_.IsSet()) return; wallpaper_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed( - GetWallpaperInfo(index_).id).ToSkBitmap(); + GetWallpaperInfo(index_).id).ToImageSkia(); if (cancel_flag_.IsSet()) return; layout_ = GetWallpaperInfo(index_).layout; @@ -52,7 +52,7 @@ class DesktopBackgroundController::WallpaperOperation cancel_flag_.Set(); } - const SkBitmap* wallpaper() { + const gfx::ImageSkia* wallpaper() { return wallpaper_; } @@ -70,7 +70,7 @@ class DesktopBackgroundController::WallpaperOperation base::CancellationFlag cancel_flag_; - const SkBitmap* wallpaper_; + const gfx::ImageSkia* wallpaper_; WallpaperLayout layout_; int index_; @@ -103,8 +103,9 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index) { true /* task_is_slow */); } -void DesktopBackgroundController::SetCustomWallpaper(const SkBitmap& wallpaper, - WallpaperLayout layout) { +void DesktopBackgroundController::SetCustomWallpaper( + const gfx::ImageSkia& wallpaper, + WallpaperLayout layout) { internal::RootWindowLayoutManager* root_window_layout = Shell::GetInstance()->root_window_layout(); root_window_layout->SetBackgroundLayer(NULL); @@ -170,7 +171,7 @@ void DesktopBackgroundController::OnWallpaperLoadCompleted( } void DesktopBackgroundController::CreateEmptyWallpaper() { - SkBitmap dummy; + gfx::ImageSkia dummy; internal::CreateDesktopBackground(dummy, CENTER); desktop_background_mode_ = BACKGROUND_IMAGE; } diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h index a531001..0b80157 100644 --- a/ash/desktop_background/desktop_background_controller.h +++ b/ash/desktop_background/desktop_background_controller.h @@ -11,7 +11,9 @@ #include "base/basictypes.h" #include "base/memory/weak_ptr.h" -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace ash { @@ -53,7 +55,8 @@ class ASH_EXPORT DesktopBackgroundController { // Sets the user selected custom wallpaper. Called when user selected a file // from file system or changed the layout of wallpaper. - void SetCustomWallpaper(const SkBitmap& wallpaper, WallpaperLayout layout); + void SetCustomWallpaper(const gfx::ImageSkia& wallpaper, + WallpaperLayout layout); // Cancels the current wallpaper loading operation. void CancelPendingWallpaperOperation(); diff --git a/ash/desktop_background/desktop_background_resources.cc b/ash/desktop_background/desktop_background_resources.cc index e5cf675..76dc091 100644 --- a/ash/desktop_background/desktop_background_resources.cc +++ b/ash/desktop_background/desktop_background_resources.cc @@ -9,7 +9,6 @@ #include "grit/ui_resources.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" -#include "third_party/skia/include/core/SkBitmap.h" namespace { diff --git a/ash/desktop_background/desktop_background_resources.h b/ash/desktop_background/desktop_background_resources.h index 4b48e9d..1de8762 100644 --- a/ash/desktop_background/desktop_background_resources.h +++ b/ash/desktop_background/desktop_background_resources.h @@ -7,8 +7,6 @@ #include "ash/ash_export.h" -class SkBitmap; - namespace ash { enum WallpaperLayout { diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index c1c08d8..bedd737 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -60,11 +60,10 @@ static int RoundPositive(double x) { //////////////////////////////////////////////////////////////////////////////// // DesktopBackgroundView, public: -DesktopBackgroundView::DesktopBackgroundView(const SkBitmap& wallpaper, +DesktopBackgroundView::DesktopBackgroundView(const gfx::ImageSkia& wallpaper, WallpaperLayout wallpaper_layout) { wallpaper_ = wallpaper; wallpaper_layout_ = wallpaper_layout; - wallpaper_.buildMipMap(false); } DesktopBackgroundView::~DesktopBackgroundView() { @@ -127,7 +126,7 @@ void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) { Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), event.location()); } -void CreateDesktopBackground(const SkBitmap& wallpaper, +void CreateDesktopBackground(const gfx::ImageSkia& wallpaper, WallpaperLayout wallpaper_layout) { views::Widget* desktop_widget = new views::Widget; views::Widget::InitParams params( diff --git a/ash/desktop_background/desktop_background_view.h b/ash/desktop_background/desktop_background_view.h index 4a5b676..16164e4 100644 --- a/ash/desktop_background/desktop_background_view.h +++ b/ash/desktop_background/desktop_background_view.h @@ -7,7 +7,7 @@ #pragma once #include "ash/desktop_background/desktop_background_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/view.h" #include "ui/views/widget/widget_delegate.h" @@ -16,7 +16,7 @@ namespace internal { class DesktopBackgroundView : public views::WidgetDelegateView { public: - DesktopBackgroundView(const SkBitmap& wallpaper, + DesktopBackgroundView(const gfx::ImageSkia& wallpaper, WallpaperLayout wallpaper_layout); virtual ~DesktopBackgroundView(); @@ -26,7 +26,7 @@ class DesktopBackgroundView : public views::WidgetDelegateView { virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; - SkBitmap wallpaper_; + gfx::ImageSkia wallpaper_; WallpaperLayout wallpaper_layout_; DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundView); diff --git a/ash/shell.cc b/ash/shell.cc index ebf4a19..a9f9d42 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -65,7 +65,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/env.h" #include "ui/aura/focus_manager.h" @@ -78,6 +77,7 @@ #include "ui/aura/window.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/monitor.h" #include "ui/gfx/screen.h" #include "ui/gfx/size.h" @@ -276,7 +276,7 @@ class DummySystemTrayDelegate : public SystemTrayDelegate { return "über@tray"; } - virtual const SkBitmap& GetUserImage() const OVERRIDE { + virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE { return null_image_; } @@ -505,7 +505,7 @@ class DummySystemTrayDelegate : public SystemTrayDelegate { bool bluetooth_enabled_; float volume_; bool caps_lock_enabled_; - SkBitmap null_image_; + gfx::ImageSkia null_image_; DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); }; diff --git a/ash/shell.h b/ash/shell.h index 7d162b4..237c4945 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -17,11 +17,10 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" -#include "ui/gfx/size.h" #include "ui/gfx/insets.h" +#include "ui/gfx/size.h" class CommandLine; -class SkBitmap; namespace aura { class EventFilter; @@ -39,6 +38,7 @@ class BrowserContext; } namespace gfx { +class ImageSkia; class Point; class Rect; } diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc index b9d1174..4e5cb06 100644 --- a/ash/shell/app_list.cc +++ b/ash/shell/app_list.cc @@ -5,9 +5,9 @@ #include <string> #include "ash/shell.h" -#include "ash/shell_delegate.h" #include "ash/shell/example_factory.h" #include "ash/shell/toplevel_window.h" +#include "ash/shell_delegate.h" #include "base/basictypes.h" #include "base/i18n/case_conversion.h" #include "base/i18n/string_search.h" @@ -46,7 +46,7 @@ class WindowTypeLauncherItem : public app_list::AppListItemModel { SetTitle(GetTitle(type)); } - static SkBitmap GetIcon(Type type) { + static gfx::ImageSkia GetIcon(Type type) { static const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, @@ -60,7 +60,7 @@ class WindowTypeLauncherItem : public app_list::AppListItemModel { icon.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize); icon.allocPixels(); icon.eraseColor(kColors[static_cast<int>(type) % arraysize(kColors)]); - return icon; + return gfx::ImageSkia(icon); } // The text below is not localized as this is an example code. @@ -199,7 +199,7 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate { } } - SkBitmap CreateSearchBoxIcon() { + gfx::ImageSkia CreateSearchBoxIcon() { const string16 icon_text = ASCIIToUTF16("ash"); const gfx::Size icon_size(32, 32); @@ -212,7 +212,7 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate { gfx::Canvas::TEXT_VALIGN_MIDDLE | gfx::Canvas::NO_SUBPIXEL_RENDERING); - return canvas.ExtractBitmap(); + return gfx::ImageSkia(canvas.ExtractBitmap()); } void DecorateSearchBox(app_list::SearchBoxModel* search_box_model) { diff --git a/ash/shell_factory.h b/ash/shell_factory.h index c1ebf51e..7e60116 100644 --- a/ash/shell_factory.h +++ b/ash/shell_factory.h @@ -9,7 +9,9 @@ #include "ash/ash_export.h" #include "ash/desktop_background/desktop_background_resources.h" -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace views { class View; @@ -21,7 +23,7 @@ class Widget; namespace ash { namespace internal { -void CreateDesktopBackground(const SkBitmap& wallpaper, +void CreateDesktopBackground(const gfx::ImageSkia& wallpaper, WallpaperLayout wallpaper_layout); ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents); } // namespace internal diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc index a3224a5..e9c9a25 100644 --- a/ash/system/date/tray_date.cc +++ b/ash/system/date/tray_date.cc @@ -16,10 +16,10 @@ #include "base/timer.h" #include "base/utf_string_conversions.h" #include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkRect.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/size.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/button/text_button.h" diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 632d595..95823ca 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -448,7 +448,7 @@ class NetworkDetailedView : public TrayDetailsView, HoverHighlightView* container = new HoverHighlightView(this); container->set_fixed_height(kTrayPopupItemHeight); container->AddIconAndLabel( - *rb.GetImageNamed(IDR_AURA_UBER_TRAY_NETWORK_AIRPLANE).ToSkBitmap(), + *rb.GetImageNamed(IDR_AURA_UBER_TRAY_NETWORK_AIRPLANE).ToImageSkia(), rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_AIRPLANE_MODE), gfx::Font::NORMAL); AddChildView(container); diff --git a/ash/system/power/tray_power.cc b/ash/system/power/tray_power.cc index 4d7b8ae..48b206e 100644 --- a/ash/system/power/tray_power.cc +++ b/ash/system/power/tray_power.cc @@ -17,12 +17,12 @@ #include "base/utf_string_conversions.h" #include "grit/ash_strings.h" #include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkRect.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/size.h" -#include "ui/base/l10n/l10n_util.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/button/text_button.h" #include "ui/views/controls/image_view.h" @@ -58,9 +58,9 @@ enum IconSet { ICON_DARK }; -SkBitmap GetBatteryImage(const PowerSupplyStatus& supply_status, +gfx::ImageSkia GetBatteryImage(const PowerSupplyStatus& supply_status, IconSet icon_set) { - SkBitmap image; + gfx::ImageSkia image; gfx::Image all = ui::ResourceBundle::GetSharedInstance().GetImageNamed( icon_set == ICON_DARK ? IDR_AURA_UBER_TRAY_POWER_SMALL_DARK : IDR_AURA_UBER_TRAY_POWER_SMALL); @@ -83,7 +83,7 @@ SkBitmap GetBatteryImage(const PowerSupplyStatus& supply_status, (supply_status.line_power_on ? kBatteryImageWidth : 0) + 2, image_index * kBatteryImageHeight, kBatteryImageWidth - 2, kBatteryImageHeight); - all.ToSkBitmap()->extractSubset(&image, region); + all.ToImageSkia()->extractSubset(&image, region); return image; } diff --git a/ash/system/status_area_widget_delegate.h b/ash/system/status_area_widget_delegate.h index ffba10d..35228d4 100644 --- a/ash/system/status_area_widget_delegate.h +++ b/ash/system/status_area_widget_delegate.h @@ -7,7 +7,7 @@ #pragma once #include "ash/ash_export.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/accessible_pane_view.h" #include "ui/views/layout/box_layout.h" #include "ui/views/widget/widget_delegate.h" diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index 3b9284f..d8d48ff 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -10,12 +10,11 @@ #include <vector> #include "ash/ash_export.h" -#include "ash/system/user/login_status.h" #include "ash/system/power/power_supply_status.h" +#include "ash/system/user/login_status.h" #include "base/file_path.h" #include "base/i18n/time_formatting.h" #include "base/string16.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image_skia.h" namespace ash { @@ -107,7 +106,7 @@ class SystemTrayDelegate { // Gets information about the logged in user. virtual const std::string GetUserDisplayName() const = 0; virtual const std::string GetUserEmail() const = 0; - virtual const SkBitmap& GetUserImage() const = 0; + virtual const gfx::ImageSkia& GetUserImage() const = 0; virtual user::LoginStatus GetUserLoginStatus() const = 0; // Returns whether a system upgrade is available. diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index 5418fa3..664f987b 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -5,7 +5,6 @@ #include "ash/system/tray/tray_views.h" #include "ash/system/tray/tray_constants.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "grit/ash_strings.h" #include "grit/ui_resources.h" #include "grit/ui_resources_standard.h" @@ -13,6 +12,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/border.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/label.h" @@ -125,7 +125,7 @@ HoverHighlightView::HoverHighlightView(ViewClickListener* listener) HoverHighlightView::~HoverHighlightView() { } -void HoverHighlightView::AddIconAndLabel(const SkBitmap& image, +void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, const string16& text, gfx::Font::FontStyle style) { SetLayoutManager(new views::BoxLayout( @@ -412,7 +412,7 @@ void SpecialPopupRow::SetTextLabel(int string_id, ViewClickListener* listener) { container->set_text_default_color(kHeaderTextColorNormal); container->AddIconAndLabel( - *rb.GetImageNamed(IDR_AURA_UBER_TRAY_LESS).ToSkBitmap(), + *rb.GetImageNamed(IDR_AURA_UBER_TRAY_LESS).ToImageSkia(), rb.GetLocalizedString(string_id), gfx::Font::BOLD); @@ -528,7 +528,7 @@ void TrayNotificationView::InitView(views::View* contents) { layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); } -void TrayNotificationView::SetIconImage(const SkBitmap& image) { +void TrayNotificationView::SetIconImage(const gfx::ImageSkia& image) { icon_->SetImage(image); SchedulePaint(); } @@ -542,7 +542,7 @@ void TrayNotificationView::UpdateView(views::View* new_contents) { } void TrayNotificationView::UpdateViewAndImage(views::View* new_contents, - const SkBitmap& image) { + const gfx::ImageSkia& image) { RemoveAllChildViews(true); InitView(new_contents); icon_->SetImage(image); diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index f6173b2..2eff8bb 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -16,9 +16,12 @@ #include "ui/views/controls/slider.h" #include "ui/views/view.h" -class SkBitmap; typedef unsigned int SkColor; +namespace gfx { +class ImageSkia; +} + namespace views { class Label; class BoxLayout; @@ -96,7 +99,7 @@ class HoverHighlightView : public ActionableView { // Convenience function for adding an icon and a label. This also sets the // accessible name. - void AddIconAndLabel(const SkBitmap& image, + void AddIconAndLabel(const gfx::ImageSkia& image, const string16& text, gfx::Font::FontStyle style); @@ -266,13 +269,14 @@ class TrayNotificationView : public views::View, void InitView(views::View* contents); // Sets/updates the icon image. - void SetIconImage(const SkBitmap& image); + void SetIconImage(const gfx::ImageSkia& image); // Replaces the contents view. void UpdateView(views::View* new_contents); // Replaces the contents view and updates the icon image. - void UpdateViewAndImage(views::View* new_contents, const SkBitmap& image); + void UpdateViewAndImage(views::View* new_contents, + const gfx::ImageSkia& image); // Overridden from ButtonListener. virtual void ButtonPressed(views::Button* sender, diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 07fb61e..d894335 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -53,10 +53,10 @@ class RoundedImageView : public views::View { virtual ~RoundedImageView() { } - // Set the bitmap that should be displayed from a pointer. The pointer - // contents is copied in the receiver's bitmap. - void SetImage(const SkBitmap& bm, const gfx::Size& size) { - image_ = bm; + // Set the image that should be displayed from a pointer. The pointer + // contents is copied in the receiver's image. + void SetImage(const gfx::ImageSkia& img, const gfx::Size& size) { + image_ = img; image_size_ = size; // Try to get the best image quality for the avatar. @@ -99,8 +99,8 @@ class RoundedImageView : public views::View { } private: - SkBitmap image_; - SkBitmap resized_; + gfx::ImageSkia image_; + gfx::ImageSkia resized_; gfx::Size image_size_; int corner_radius_; diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc index 49cca635..3132e7f 100644 --- a/ash/wm/custom_frame_view_ash.cc +++ b/ash/wm/custom_frame_view_ash.cc @@ -121,13 +121,13 @@ void CustomFrameViewAsh::Layout() { void CustomFrameViewAsh::OnPaint(gfx::Canvas* canvas) { bool paint_as_active = ShouldPaintAsActive(); - int theme_bitmap_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : + int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; frame_painter_->PaintHeader( this, canvas, paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE, - theme_bitmap_id, + theme_image_id, NULL); frame_painter_->PaintTitleBar(this, canvas, GetTitleFont()); frame_painter_->PaintHeaderContentSeparator(this, canvas); diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc index f35db43..076af87 100644 --- a/ash/wm/frame_painter.cc +++ b/ash/wm/frame_painter.cc @@ -76,7 +76,7 @@ const int kButtonOverlap = 1; // we need to copy the theme image for the window header from a few pixels // inset to preserve alignment with the NTP image, or else we'll break a bunch // of existing themes. We do something similar on OS X for the same reason. -const int kThemeFrameBitmapOffsetX = 5; +const int kThemeFrameImageOffsetX = 5; // Duration of crossfade animation for activating and deactivating frame. const int kActivationCrossfadeDurationMs = 200; // Alpha/opacity value for fully-opaque headers. @@ -87,14 +87,14 @@ const int kFullyOpaque = 255; void TileRoundRect(gfx::Canvas* canvas, int x, int y, int w, int h, SkPaint* paint, - const SkBitmap& bitmap, + const gfx::ImageSkia& image, int corner_radius, - int bitmap_offset_x) { + int image_offset_x) { // To get the shader to sample the image |inset_y| pixels in but tile across // the whole image, we adjust the target rectangle for the shader to the right // and translate the canvas left to compensate. SkRect rect; - rect.iset(x + bitmap_offset_x, y, x + bitmap_offset_x + w, y + h); + rect.iset(x + image_offset_x, y, x + image_offset_x + w, y + h); const SkScalar kRadius = SkIntToScalar(corner_radius); SkScalar radii[8] = { kRadius, kRadius, // top-left @@ -104,7 +104,7 @@ void TileRoundRect(gfx::Canvas* canvas, SkPath path; path.addRoundRect(rect, radii, SkPath::kCW_Direction); - SkShader* shader = SkShader::CreateBitmapShader(bitmap, + SkShader* shader = SkShader::CreateBitmapShader(image, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); paint->setShader(shader); @@ -113,9 +113,9 @@ void TileRoundRect(gfx::Canvas* canvas, shader->unref(); // Adjust canvas to compensate for image sampling offset, draw, then adjust // back. This is cheaper than pushing/popping the entire canvas state. - canvas->sk_canvas()->translate(SkIntToScalar(-bitmap_offset_x), 0); + canvas->sk_canvas()->translate(SkIntToScalar(-image_offset_x), 0); canvas->DrawPath(path, *paint); - canvas->sk_canvas()->translate(SkIntToScalar(bitmap_offset_x), 0); + canvas->sk_canvas()->translate(SkIntToScalar(image_offset_x), 0); } // Returns true if |window| is a visible, normal window. @@ -189,17 +189,17 @@ void FramePainter::Init(views::Widget* frame, // Window frame image parts. ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); button_separator_ = - rb.GetImageNamed(IDR_AURA_WINDOW_BUTTON_SEPARATOR).ToSkBitmap(); + rb.GetImageNamed(IDR_AURA_WINDOW_BUTTON_SEPARATOR).ToImageSkia(); top_left_corner_ = - rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_LEFT).ToSkBitmap(); + rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_LEFT).ToImageSkia(); top_edge_ = - rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP).ToSkBitmap(); + rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP).ToImageSkia(); top_right_corner_ = - rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_RIGHT).ToSkBitmap(); + rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_RIGHT).ToImageSkia(); header_left_edge_ = - rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_LEFT).ToSkBitmap(); + rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_LEFT).ToImageSkia(); header_right_edge_ = - rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_RIGHT).ToSkBitmap(); + rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_RIGHT).ToImageSkia(); window_ = frame->GetNativeWindow(); // Ensure we get resize cursors for a few pixels outside our bounds. @@ -306,7 +306,7 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view, gfx::Canvas* canvas, HeaderMode header_mode, int theme_frame_id, - const SkBitmap* theme_frame_overlay) { + const gfx::ImageSkia* theme_frame_overlay) { if (previous_theme_frame_id_ != 0 && previous_theme_frame_id_ != theme_frame_id) { crossfade_animation_.reset(new ui::SlideAnimation(this)); @@ -319,15 +319,16 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view, int opacity = GetHeaderOpacity(header_mode, theme_frame_id, theme_frame_overlay); ui::ThemeProvider* theme_provider = frame_->GetThemeProvider(); - SkBitmap* theme_frame = theme_provider->GetBitmapNamed(theme_frame_id); + gfx::ImageSkia* theme_frame = theme_provider->GetImageSkiaNamed( + theme_frame_id); header_frame_bounds_ = gfx::Rect(0, 0, view->width(), theme_frame->height()); const int kCornerRadius = 2; SkPaint paint; if (crossfade_animation_.get() && crossfade_animation_->is_animating()) { - SkBitmap* crossfade_theme_frame = - theme_provider->GetBitmapNamed(crossfade_theme_frame_id_); + gfx::ImageSkia* crossfade_theme_frame = + theme_provider->GetImageSkiaNamed(crossfade_theme_frame_id_); if (crossfade_theme_frame) { double current_value = crossfade_animation_->GetCurrentValue(); int old_alpha = (1 - current_value) * crossfade_opacity_; @@ -341,7 +342,7 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view, &paint, *crossfade_theme_frame, kCornerRadius, - kThemeFrameBitmapOffsetX); + kThemeFrameImageOffsetX); paint.setAlpha(new_alpha); } else { @@ -358,7 +359,7 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view, &paint, *theme_frame, kCornerRadius, - kThemeFrameBitmapOffsetX); + kThemeFrameImageOffsetX); previous_theme_frame_id_ = theme_frame_id; previous_opacity_ = opacity; @@ -564,16 +565,16 @@ void FramePainter::AnimationProgressed(const ui::Animation* animation) { // FramePainter, private: void FramePainter::SetButtonImages(views::ImageButton* button, - int normal_bitmap_id, - int hot_bitmap_id, - int pushed_bitmap_id) { + int normal_image_id, + int hot_image_id, + int pushed_image_id) { ui::ThemeProvider* theme_provider = frame_->GetThemeProvider(); button->SetImage(views::CustomButton::BS_NORMAL, - theme_provider->GetImageSkiaNamed(normal_bitmap_id)); + theme_provider->GetImageSkiaNamed(normal_image_id)); button->SetImage(views::CustomButton::BS_HOT, - theme_provider->GetImageSkiaNamed(hot_bitmap_id)); + theme_provider->GetImageSkiaNamed(hot_image_id)); button->SetImage(views::CustomButton::BS_PUSHED, - theme_provider->GetImageSkiaNamed(pushed_bitmap_id)); + theme_provider->GetImageSkiaNamed(pushed_image_id)); } int FramePainter::GetTitleOffsetX() const { @@ -584,7 +585,7 @@ int FramePainter::GetTitleOffsetX() const { int FramePainter::GetHeaderOpacity(HeaderMode header_mode, int theme_frame_id, - const SkBitmap* theme_frame_overlay) { + const gfx::ImageSkia* theme_frame_overlay) { // User-provided themes are painted fully opaque. if (frame_->GetThemeProvider()->HasCustomImage(theme_frame_id)) return kFullyOpaque; diff --git a/ash/wm/frame_painter.h b/ash/wm/frame_painter.h index 883d671..2d21203 100644 --- a/ash/wm/frame_painter.h +++ b/ash/wm/frame_painter.h @@ -13,17 +13,17 @@ #include "base/compiler_specific.h" // OVERRIDE #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" +#include "ui/aura/window_observer.h" #include "ui/base/animation/animation_delegate.h" #include "ui/gfx/rect.h" -#include "ui/aura/window_observer.h" -class SkBitmap; namespace aura { class Window; } namespace gfx { class Canvas; class Font; +class ImageSkia; class Point; class Size; } @@ -86,7 +86,7 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, gfx::Canvas* canvas, HeaderMode header_mode, int theme_frame_id, - const SkBitmap* theme_frame_overlay); + const gfx::ImageSkia* theme_frame_overlay); // Paints the header/content separator line. Exists as a separate function // because some windows with complex headers (e.g. browsers with tab strips) @@ -124,9 +124,9 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, // Sets the images for a button base on IDs from the |frame_| theme provider. void SetButtonImages(views::ImageButton* button, - int normal_bitmap_id, - int hot_bitmap_id, - int pushed_bitmap_id); + int normal_image_id, + int hot_image_id, + int pushed_image_id); // Returns the offset between window left edge and title string. int GetTitleOffsetX() const; @@ -134,7 +134,7 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, // Returns the opacity value used to paint the header. int GetHeaderOpacity(HeaderMode header_mode, int theme_frame_id, - const SkBitmap* theme_frame_overlay); + const gfx::ImageSkia* theme_frame_overlay); // Returns true if there is exactly one visible, normal-type window using // a header painted by this class, in which case we should paint a transparent @@ -156,18 +156,18 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, aura::Window* window_; // Window frame header/caption parts. - const SkBitmap* button_separator_; - const SkBitmap* top_left_corner_; - const SkBitmap* top_edge_; - const SkBitmap* top_right_corner_; - const SkBitmap* header_left_edge_; - const SkBitmap* header_right_edge_; - - // Bitmap id and opacity last used for painting header. + const gfx::ImageSkia* button_separator_; + const gfx::ImageSkia* top_left_corner_; + const gfx::ImageSkia* top_edge_; + const gfx::ImageSkia* top_right_corner_; + const gfx::ImageSkia* header_left_edge_; + const gfx::ImageSkia* header_right_edge_; + + // Image id and opacity last used for painting header. int previous_theme_frame_id_; int previous_opacity_; - // Bitmap id and opacity we are crossfading from. + // Image id and opacity we are crossfading from. int crossfade_theme_frame_id_; int crossfade_opacity_; diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc index 234d11f..57ae977 100644 --- a/ash/wm/frame_painter_unittest.cc +++ b/ash/wm/frame_painter_unittest.cc @@ -164,7 +164,7 @@ TEST_F(FramePainterTest, GetHeaderOpacity) { NULL)); // Custom overlay image is drawn completely opaque. - SkBitmap custom_overlay; + gfx::ImageSkia custom_overlay; EXPECT_EQ(255, p1.GetHeaderOpacity(FramePainter::ACTIVE, IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, diff --git a/ash/wm/image_grid.cc b/ash/wm/image_grid.cc index f5a1c46..c4fec2a 100644 --- a/ash/wm/image_grid.cc +++ b/ash/wm/image_grid.cc @@ -6,12 +6,12 @@ #include <algorithm> +#include "third_party/skia/include/core/SkColor.h" +#include "third_party/skia/include/core/SkXfermode.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" #include "ui/gfx/rect.h" #include "ui/gfx/transform.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkXfermode.h" using std::max; using std::min; @@ -227,7 +227,7 @@ void ImageGrid::ImagePainter::SetClipRect(const gfx::Rect& clip_rect, void ImageGrid::ImagePainter::OnPaintLayer(gfx::Canvas* canvas) { if (!clip_rect_.IsEmpty()) canvas->ClipRect(clip_rect_); - canvas->DrawBitmapInt(*(image_->ToSkBitmap()), 0, 0); + canvas->DrawBitmapInt(*(image_->ToImageSkia()), 0, 0); } void ImageGrid::ImagePainter::OnDeviceScaleFactorChanged( @@ -238,7 +238,7 @@ void ImageGrid::ImagePainter::OnDeviceScaleFactorChanged( // static gfx::Size ImageGrid::GetImageSize(const gfx::Image* image) { return image ? - gfx::Size(image->ToSkBitmap()->width(), image->ToSkBitmap()->height()) : + gfx::Size(image->ToImageSkia()->width(), image->ToImageSkia()->height()) : gfx::Size(); } diff --git a/ash/wm/panel_frame_view.cc b/ash/wm/panel_frame_view.cc index f0cdba9..e0d93e2 100644 --- a/ash/wm/panel_frame_view.cc +++ b/ash/wm/panel_frame_view.cc @@ -63,13 +63,13 @@ int PanelFrameView::NonClientHitTest(const gfx::Point& point) { void PanelFrameView::OnPaint(gfx::Canvas* canvas) { bool paint_as_active = ShouldPaintAsActive(); - int theme_bitmap_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : + int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; frame_painter_->PaintHeader( this, canvas, paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE, - theme_bitmap_id, + theme_image_id, NULL); frame_painter_->PaintHeaderContentSeparator(this, canvas); } diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc index 0d83ec3..ec986ed 100644 --- a/ash/wm/workspace/frame_maximize_button.cc +++ b/ash/wm/workspace/frame_maximize_button.cc @@ -4,10 +4,10 @@ #include "ash/wm/workspace/frame_maximize_button.h" +#include "ash/launcher/launcher.h" #include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/property_util.h" -#include "ash/launcher/launcher.h" #include "ash/wm/workspace/phantom_window_controller.h" #include "ash/wm/workspace/snap_sizer.h" #include "grit/ash_strings.h" @@ -217,7 +217,7 @@ gfx::ImageSkia FrameMaximizeButton::GetImageToPaint() { NOTREACHED(); } } - return *ResourceBundle::GetSharedInstance().GetImageNamed(id).ToSkBitmap(); + return *ResourceBundle::GetSharedInstance().GetImageNamed(id).ToImageSkia(); } // Hot and pressed states handled by regular ImageButton. return ImageButton::GetImageToPaint(); diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc index 053a646..9219027 100644 --- a/ash/wm/workspace/multi_window_resize_controller.cc +++ b/ash/wm/workspace/multi_window_resize_controller.cc @@ -67,7 +67,7 @@ class MultiWindowResizeController::ResizeView : public views::View { int image_id = direction == TOP_BOTTOM ? IDR_AURA_MULTI_WINDOW_RESIZE_H : IDR_AURA_MULTI_WINDOW_RESIZE_V; - image_ = rb.GetImageNamed(image_id).ToSkBitmap(); + image_ = rb.GetImageNamed(image_id).ToImageSkia(); } // views::View overrides: @@ -105,7 +105,7 @@ class MultiWindowResizeController::ResizeView : public views::View { private: MultiWindowResizeController* controller_; const Direction direction_; - const SkBitmap* image_; + const gfx::ImageSkia* image_; DISALLOW_COPY_AND_ASSIGN(ResizeView); }; diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 9735799..eee8d39 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -67,9 +67,9 @@ #include "chrome/browser/ui/media_stream_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" -#include "chrome/browser/view_type_utils.h" #include "chrome/browser/user_style_sheet_watcher.h" #include "chrome/browser/user_style_sheet_watcher_factory.h" +#include "chrome/browser/view_type_utils.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -855,9 +855,9 @@ std::string ChromeContentBrowserClient::GetAcceptLangs( return profile->GetPrefs()->GetString(prefs::kAcceptLanguages); } -SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() { +gfx::ImageSkia* ChromeContentBrowserClient::GetDefaultFavicon() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); + return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); } bool ChromeContentBrowserClient::AllowAppCache( diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index ab87162..b5a2153 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -66,7 +66,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { virtual std::string GetApplicationLocale() OVERRIDE; virtual std::string GetAcceptLangs( content::BrowserContext* context) OVERRIDE; - virtual SkBitmap* GetDefaultFavicon() OVERRIDE; + virtual gfx::ImageSkia* GetDefaultFavicon() OVERRIDE; virtual bool AllowAppCache(const GURL& manifest_url, const GURL& first_party, content::ResourceContext* context) OVERRIDE; diff --git a/chrome/browser/chromeos/login/default_user_images.cc b/chrome/browser/chromeos/login/default_user_images.cc index 055a5b8..e015c5a 100644 --- a/chrome/browser/chromeos/login/default_user_images.cc +++ b/chrome/browser/chromeos/login/default_user_images.cc @@ -11,8 +11,8 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image_skia.h" namespace chromeos { @@ -96,10 +96,10 @@ bool IsDefaultImageUrl(const std::string url, int* image_id) { return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); } -const SkBitmap& GetDefaultImage(int index) { +const gfx::ImageSkia& GetDefaultImage(int index) { DCHECK(index >= 0 && index < kDefaultImagesCount); return *ResourceBundle::GetSharedInstance(). - GetBitmapNamed(kDefaultImageResources[index]); + GetImageSkiaNamed(kDefaultImageResources[index]); } // Resource IDs of default user images. diff --git a/chrome/browser/chromeos/login/default_user_images.h b/chrome/browser/chromeos/login/default_user_images.h index 1950a23..8d5270a 100644 --- a/chrome/browser/chromeos/login/default_user_images.h +++ b/chrome/browser/chromeos/login/default_user_images.h @@ -9,7 +9,9 @@ #include <cstddef> // for size_t #include <string> -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace chromeos { @@ -31,7 +33,7 @@ std::string GetDefaultImageUrl(int index); bool IsDefaultImageUrl(const std::string url, int* image_id); // Returns bitmap of default user image with specified index. -const SkBitmap& GetDefaultImage(int index); +const gfx::ImageSkia& GetDefaultImage(int index); // Resource IDs of default user images. extern const int kDefaultImageResources[]; diff --git a/chrome/browser/chromeos/login/message_bubble.cc b/chrome/browser/chromeos/login/message_bubble.cc index 15eaccb..91083ab 100644 --- a/chrome/browser/chromeos/login/message_bubble.cc +++ b/chrome/browser/chromeos/login/message_bubble.cc @@ -29,7 +29,7 @@ namespace chromeos { MessageBubble::MessageBubble(views::View* anchor_view, views::BubbleBorder::ArrowLocation arrow_location, - SkBitmap* image, + gfx::ImageSkia* image, const string16& text, const std::vector<string16>& links) : BubbleDelegateView(anchor_view, arrow_location), diff --git a/chrome/browser/chromeos/login/message_bubble.h b/chrome/browser/chromeos/login/message_bubble.h index e506aab..aa5a797 100644 --- a/chrome/browser/chromeos/login/message_bubble.h +++ b/chrome/browser/chromeos/login/message_bubble.h @@ -15,7 +15,9 @@ #include "ui/views/controls/link_listener.h" #include "ui/views/view.h" -class SkBitmap; +namespace gfx { +class ImageSkia; +} namespace views { class ImageButton; @@ -37,7 +39,7 @@ class MessageBubble : public views::BubbleDelegateView, public: MessageBubble(views::View* anchor_view, views::BubbleBorder::ArrowLocation arrow_location, - SkBitmap* image, + gfx::ImageSkia* image, const string16& text, const std::vector<string16>& links); @@ -60,7 +62,7 @@ class MessageBubble : public views::BubbleDelegateView, virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; private: - SkBitmap* image_; + gfx::ImageSkia* image_; string16 text_; views::ImageButton* close_button_; std::vector<views::Link*> help_links_; diff --git a/chrome/browser/chromeos/login/take_photo_view.cc b/chrome/browser/chromeos/login/take_photo_view.cc index a9cb1c4..c583d36 100644 --- a/chrome/browser/chromeos/login/take_photo_view.cc +++ b/chrome/browser/chromeos/login/take_photo_view.cc @@ -256,7 +256,7 @@ void TakePhotoView::ShowCameraError() { user_image_->SetErrorState(); } -const SkBitmap& TakePhotoView::GetImage() const { +const gfx::ImageSkia& TakePhotoView::GetImage() const { return user_image_->GetImage(); } diff --git a/chrome/browser/chromeos/login/take_photo_view.h b/chrome/browser/chromeos/login/take_photo_view.h index 33e7d21..9afc028 100644 --- a/chrome/browser/chromeos/login/take_photo_view.h +++ b/chrome/browser/chromeos/login/take_photo_view.h @@ -15,12 +15,12 @@ class SkBitmap; namespace gfx { class ImageSkia; -} // namespace gfx +} namespace views { class ImageButton; class Label; -} // namespace views +} namespace chromeos { @@ -60,7 +60,7 @@ class TakePhotoView : public views::View, void ShowCameraError(); // Returns the currently selected image. - const SkBitmap& GetImage() const; + const gfx::ImageSkia& GetImage() const; // Sets the image indicating that the view is used only for image preview. void SetImage(gfx::ImageSkia* image); diff --git a/chrome/browser/chromeos/login/user.cc b/chrome/browser/chromeos/login/user.cc index 0d27050..e6b65dd 100644 --- a/chrome/browser/chromeos/login/user.cc +++ b/chrome/browser/chromeos/login/user.cc @@ -30,7 +30,7 @@ std::string GetUserName(const std::string& email) { User::User(const std::string& email, bool is_guest) : email_(email), - user_image_(*ResourceBundle::GetSharedInstance().GetBitmapNamed( + user_image_(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( kDefaultImageResources[0])), oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), image_index_(kInvalidImageIndex), @@ -55,7 +55,7 @@ void User::SetImage(const UserImage& user_image, int image_index) { } void User::SetStubImage(int image_index) { - user_image_.SetImage(*ResourceBundle::GetSharedInstance().GetBitmapNamed( + user_image_.SetImage(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( kStubImageResourceID)); image_index_ = image_index; image_is_stub_ = true; diff --git a/chrome/browser/chromeos/login/user.h b/chrome/browser/chromeos/login/user.h index 8b3f7dc..ebd32e8 100644 --- a/chrome/browser/chromeos/login/user.h +++ b/chrome/browser/chromeos/login/user.h @@ -12,6 +12,7 @@ #include "base/basictypes.h" #include "chrome/browser/chromeos/login/user_image.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" // The demo user is represented by a domainless username. const char kDemoUser[] = "demouser"; @@ -63,7 +64,7 @@ class User { bool NeedsNameTooltip() const; // The image for this user. - const SkBitmap& image() const { return user_image_.image(); } + const gfx::ImageSkia& image() const { return user_image_.image(); } int image_index() const { return image_index_; } bool has_animated_image() const { return user_image_.has_animated_image(); } diff --git a/chrome/browser/chromeos/login/user_image.cc b/chrome/browser/chromeos/login/user_image.cc index ecbae9e..cf8fbcf 100644 --- a/chrome/browser/chromeos/login/user_image.cc +++ b/chrome/browser/chromeos/login/user_image.cc @@ -21,13 +21,13 @@ bool IsAnimatedImage(const UserImage::RawImage& data) { } // namespace -UserImage::UserImage(const SkBitmap& image) +UserImage::UserImage(const gfx::ImageSkia& image) : image_(image), has_raw_image_(false), has_animated_image_(false) { } -UserImage::UserImage(const SkBitmap& image, +UserImage::UserImage(const gfx::ImageSkia& image, const RawImage& raw_image) : image_(image), has_raw_image_(true), @@ -37,7 +37,7 @@ UserImage::UserImage(const SkBitmap& image, UserImage::~UserImage() {} -void UserImage::SetImage(const SkBitmap& image) { +void UserImage::SetImage(const gfx::ImageSkia& image) { image_ = image; has_raw_image_ = false; has_animated_image_ = false; diff --git a/chrome/browser/chromeos/login/user_image.h b/chrome/browser/chromeos/login/user_image.h index 5edbd7f..9fa2965 100644 --- a/chrome/browser/chromeos/login/user_image.h +++ b/chrome/browser/chromeos/login/user_image.h @@ -8,7 +8,7 @@ #include <vector> -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" namespace chromeos { @@ -21,25 +21,25 @@ class UserImage { // Constructs UserImage from bitmap. Should be used where only // static image is needed (e.g. wallpapers). - explicit UserImage(const SkBitmap& image); + explicit UserImage(const gfx::ImageSkia& image); // Constructs UserImage from raw image and bitmap that should // represent single frame from that one. Can be used for wrapping // animated images. - UserImage(const SkBitmap& image, const RawImage& raw_image); + UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); virtual ~UserImage(); // Replaces already stored image to new |image|. Note, that // |raw_image| will be reset after that operation. - void SetImage(const SkBitmap& image); - const SkBitmap& image() const { return image_; } + void SetImage(const gfx::ImageSkia& image); + const gfx::ImageSkia& image() const { return image_; } bool has_raw_image() const { return has_raw_image_; } bool has_animated_image() const { return has_animated_image_; } const RawImage& raw_image() const { return raw_image_; } private: - SkBitmap image_; + gfx::ImageSkia image_; bool has_raw_image_; bool has_animated_image_; RawImage raw_image_; diff --git a/chrome/browser/chromeos/login/user_image_screen.cc b/chrome/browser/chromeos/login/user_image_screen.cc index 25d7e59..b1d73a3 100644 --- a/chrome/browser/chromeos/login/user_image_screen.cc +++ b/chrome/browser/chromeos/login/user_image_screen.cc @@ -19,6 +19,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image_skia.h" namespace chromeos { @@ -108,7 +109,7 @@ void UserImageScreen::StopCamera() { camera_controller_.Stop(); } -void UserImageScreen::OnPhotoTaken(const SkBitmap& image) { +void UserImageScreen::OnPhotoTaken(const gfx::ImageSkia& image) { UserManager* user_manager = UserManager::Get(); user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), UserImage(image)); @@ -165,7 +166,7 @@ void UserImageScreen::Observe(int type, // We've got a new profile image. if (actor_) actor_->AddProfileImage( - *content::Details<const SkBitmap>(details).ptr()); + *content::Details<const gfx::ImageSkia>(details).ptr()); break; } case chrome::NOTIFICATION_PROFILE_IMAGE_UPDATE_FAILED: { diff --git a/chrome/browser/chromeos/login/user_image_screen.h b/chrome/browser/chromeos/login/user_image_screen.h index e22b506..608c543 100644 --- a/chrome/browser/chromeos/login/user_image_screen.h +++ b/chrome/browser/chromeos/login/user_image_screen.h @@ -36,7 +36,7 @@ class UserImageScreen: public WizardScreen, // UserImageScreenActor::Delegate implementation: virtual void StartCamera() OVERRIDE; virtual void StopCamera() OVERRIDE; - virtual void OnPhotoTaken(const SkBitmap& image) OVERRIDE; + virtual void OnPhotoTaken(const gfx::ImageSkia& image) OVERRIDE; virtual void OnProfileImageSelected() OVERRIDE; virtual void OnDefaultImageSelected(int index) OVERRIDE; virtual void OnActorDestroyed(UserImageScreenActor* actor) OVERRIDE; diff --git a/chrome/browser/chromeos/login/user_image_screen_actor.h b/chrome/browser/chromeos/login/user_image_screen_actor.h index 8530005..cd84c19 100644 --- a/chrome/browser/chromeos/login/user_image_screen_actor.h +++ b/chrome/browser/chromeos/login/user_image_screen_actor.h @@ -8,6 +8,10 @@ class SkBitmap; +namespace gfx { +class ImageSkia; +} + namespace chromeos { // Interface for dependency injection between UserImageScreen and its actual @@ -23,7 +27,7 @@ class UserImageScreenActor { // Called when UI needs to start video capture. virtual void StartCamera() = 0; // Called when user accepts photo as login user image. - virtual void OnPhotoTaken(const SkBitmap& image) = 0; + virtual void OnPhotoTaken(const gfx::ImageSkia& image) = 0; // Called when user accepts Profile image as login user image. virtual void OnProfileImageSelected() = 0; // Called when user accepts one of the default images as login user @@ -66,7 +70,7 @@ class UserImageScreenActor { virtual bool IsCapturing() const = 0; // Inserts profile image in the list for user to select. - virtual void AddProfileImage(const SkBitmap& image) {} + virtual void AddProfileImage(const gfx::ImageSkia& image) {} // Indicates that there is no custom profile image for the user. virtual void OnProfileImageAbsent() {} diff --git a/chrome/browser/chromeos/options/take_photo_dialog.h b/chrome/browser/chromeos/options/take_photo_dialog.h index 6a509dc..22e83c5 100644 --- a/chrome/browser/chromeos/options/take_photo_dialog.h +++ b/chrome/browser/chromeos/options/take_photo_dialog.h @@ -31,7 +31,7 @@ class TakePhotoDialog : public views::DialogDelegateView, virtual ~Delegate() {} // Called when user accepts the photo. - virtual void OnPhotoAccepted(const SkBitmap& photo) = 0; + virtual void OnPhotoAccepted(const gfx::ImageSkia& photo) = 0; }; explicit TakePhotoDialog(Delegate* delegate); diff --git a/chrome/browser/chromeos/status/data_promo_notification.cc b/chrome/browser/chromeos/status/data_promo_notification.cc index 0fe399e..b2cf615 100644 --- a/chrome/browser/chromeos/status/data_promo_notification.cc +++ b/chrome/browser/chromeos/status/data_promo_notification.cc @@ -203,7 +203,8 @@ void DataPromoNotification::ShowOptionalMobileDataPromoNotification( mobile_data_bubble_ = new MessageBubble( host, views::BubbleBorder::TOP_RIGHT, - ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_NOTIFICATION_3G), + ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + IDR_NOTIFICATION_3G), message, links); mobile_data_bubble_->set_link_listener(listener); diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index 1b5ce7b..6542391 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -31,11 +31,11 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "net/base/escape.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/menu_model.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/skbitmap_operations.h" #include "ui/views/controls/menu/menu_item_view.h" #include "ui/views/controls/menu/menu_model_adapter.h" @@ -118,7 +118,7 @@ class NetworkMenuModel : public ui::MenuModel { sub_menu_model(NULL), flags(0) { } - MenuItem(ui::MenuModel::ItemType type, string16 label, SkBitmap icon, + MenuItem(ui::MenuModel::ItemType type, string16 label, gfx::ImageSkia icon, const std::string& service_path, int flags) : type(type), label(label), @@ -127,7 +127,7 @@ class NetworkMenuModel : public ui::MenuModel { sub_menu_model(NULL), flags(flags) { } - MenuItem(ui::MenuModel::ItemType type, string16 label, SkBitmap icon, + MenuItem(ui::MenuModel::ItemType type, string16 label, gfx::ImageSkia icon, NetworkMenuModel* sub_menu_model, int flags) : type(type), label(label), @@ -138,7 +138,7 @@ class NetworkMenuModel : public ui::MenuModel { ui::MenuModel::ItemType type; string16 label; - SkBitmap icon; + gfx::ImageSkia icon; std::string service_path; NetworkMenuModel* sub_menu_model; // Weak ptr. int flags; @@ -578,7 +578,7 @@ void MainMenuModel::AddWirelessNetworkMenuItem( flag |= FLAG_DISABLED; if (ShouldHighlightNetwork(wifi_network)) flag |= FLAG_ASSOCIATED; - const SkBitmap icon = NetworkMenuIcon::GetBitmap(wifi_network, + const gfx::ImageSkia icon = NetworkMenuIcon::GetImage(wifi_network, NetworkMenuIcon::COLOR_DARK); menu_items_.push_back( MenuItem(ui::MenuModel::TYPE_COMMAND, @@ -596,7 +596,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { menu_items_.push_back( MenuItem(ui::MenuModel::TYPE_COMMAND, l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_LOCKED), - SkBitmap(), std::string(), FLAG_DISABLED)); + gfx::ImageSkia(), std::string(), FLAG_DISABLED)); return; } @@ -622,9 +622,9 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { int flag = FLAG_ETHERNET; if (ShouldHighlightNetwork(ethernet_network)) flag |= FLAG_ASSOCIATED; - SkBitmap icon; - icon = NetworkMenuIcon::GetBitmap(ethernet_network, - NetworkMenuIcon::COLOR_DARK); + gfx::ImageSkia icon; + icon = NetworkMenuIcon::GetImage(ethernet_network, + NetworkMenuIcon::COLOR_DARK); menu_items_.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, label, icon, std::string(), flag)); } @@ -646,8 +646,8 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { menu_items_.push_back(MenuItem( ui::MenuModel::TYPE_COMMAND, l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_OTHER_WIFI_NETWORKS), - NetworkMenuIcon::GetConnectedBitmap(NetworkMenuIcon::ARCS, - NetworkMenuIcon::COLOR_DARK), + NetworkMenuIcon::GetConnectedImage(NetworkMenuIcon::ARCS, + NetworkMenuIcon::COLOR_DARK), std::string(), FLAG_ADD_WIFI)); } @@ -722,7 +722,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { active_cellular && active_cellular->SupportsDataPlan(); if (isActive) flag |= FLAG_ASSOCIATED; - const SkBitmap icon = NetworkMenuIcon::GetBitmap(cell_networks[i], + const gfx::ImageSkia icon = NetworkMenuIcon::GetImage(cell_networks[i], NetworkMenuIcon::COLOR_DARK); menu_items_.push_back( MenuItem(ui::MenuModel::TYPE_COMMAND, @@ -740,7 +740,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { if (label.length()) { menu_items_.push_back( MenuItem(ui::MenuModel::TYPE_COMMAND, - label, SkBitmap(), + label, gfx::ImageSkia(), std::string(), FLAG_DISABLED)); } } @@ -759,8 +759,8 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { ui::MenuModel::TYPE_COMMAND, l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_OTHER_CELLULAR_NETWORKS), - NetworkMenuIcon::GetDisconnectedBitmap(NetworkMenuIcon::BARS, - NetworkMenuIcon::COLOR_DARK), + NetworkMenuIcon::GetDisconnectedImage(NetworkMenuIcon::BARS, + NetworkMenuIcon::COLOR_DARK), std::string(), FLAG_ADD_CELLULAR)); } } @@ -771,7 +771,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { label = l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_MENU_ITEM_INDENT, l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE)); menu_items_.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, label, - SkBitmap(), std::string(), FLAG_DISABLED)); + gfx::ImageSkia(), std::string(), FLAG_DISABLED)); } bool show_wifi_scanning = wifi_available && cros->wifi_scanning(); @@ -789,7 +789,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { // Add 'Scanning...' label = l10n_util::GetStringUTF16(IDS_STATUSBAR_WIFI_SCANNING_MESSAGE); menu_items_.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, label, - SkBitmap(), std::string(), FLAG_DISABLED)); + gfx::ImageSkia(), std::string(), FLAG_DISABLED)); } if (show_toggle_wifi) { @@ -801,7 +801,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { if (cros->wifi_busy()) flag |= FLAG_DISABLED; menu_items_.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, label, - SkBitmap(), std::string(), flag)); + gfx::ImageSkia(), std::string(), flag)); } if (show_toggle_mobile) { @@ -821,9 +821,9 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { id = IDS_STATUSBAR_NETWORK_DEVICE_ENABLE; label = l10n_util::GetStringFUTF16(id, l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR)); - SkBitmap icon; + gfx::ImageSkia icon; if (is_locked) { - icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE); + icon = *rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_SECURE); } int flag = FLAG_TOGGLE_MOBILE; if (cros->mobile_busy()) @@ -838,7 +838,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { // menu_items_.push_back(MenuItem(cros->offline_mode() ? // ui::MenuModel::TYPE_CHECK : ui::MenuModel::TYPE_COMMAND, // l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_OFFLINE_MODE), - // SkBitmap(), std::string(), FLAG_TOGGLE_OFFLINE)); + // ImageSkia(), std::string(), FLAG_TOGGLE_OFFLINE)); // Additional links like: // * Network settings; @@ -850,7 +850,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) { menu_items_.push_back(MenuItem( ui::MenuModel::TYPE_SUBMENU, l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_MORE), - SkBitmap(), more_menu_model_.get(), FLAG_NONE)); + gfx::ImageSkia(), more_menu_model_.get(), FLAG_NONE)); } } @@ -890,7 +890,7 @@ void VPNMenuModel::InitMenuItems(bool should_open_button_options) { flag |= FLAG_DISABLED; if (ShouldHighlightNetwork(vpn)) flag |= FLAG_ASSOCIATED; - const SkBitmap icon = NetworkMenuIcon::GetBitmap(vpn, + const gfx::ImageSkia icon = NetworkMenuIcon::GetImage(vpn, NetworkMenuIcon::COLOR_DARK); menu_items_.push_back( MenuItem(ui::MenuModel::TYPE_COMMAND, @@ -906,14 +906,14 @@ void VPNMenuModel::InitMenuItems(bool should_open_button_options) { menu_items_.push_back(MenuItem( ui::MenuModel::TYPE_COMMAND, l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_ADD_VPN), - SkBitmap(), std::string(), FLAG_ADD_VPN)); + gfx::ImageSkia(), std::string(), FLAG_ADD_VPN)); } // Show disconnect if we have an active VPN. if (active_vpn) { menu_items_.push_back(MenuItem( ui::MenuModel::TYPE_COMMAND, l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DISCONNECT_VPN), - SkBitmap(), std::string(), FLAG_DISCONNECT_VPN)); + gfx::ImageSkia(), std::string(), FLAG_DISCONNECT_VPN)); } } @@ -941,14 +941,16 @@ void MoreMenuModel::InitMenuItems(bool should_open_button_options) { if (message_id != -1) { link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, l10n_util::GetStringUTF16(message_id), - SkBitmap(), std::string(), FLAG_OPTIONS)); + gfx::ImageSkia(), + std::string(), + FLAG_OPTIONS)); } if (connected) { std::string ip_address = cros->IPAddress(); if (!ip_address.empty()) { address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, - ASCIIToUTF16(cros->IPAddress()), SkBitmap(), std::string(), + ASCIIToUTF16(cros->IPAddress()), gfx::ImageSkia(), std::string(), FLAG_DISABLED)); } } @@ -962,7 +964,7 @@ void MoreMenuModel::InitMenuItems(bool should_open_button_options) { std::string label = l10n_util::GetStringUTF8( IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET) + " " + hardware_address; address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, - UTF8ToUTF16(label), SkBitmap(), std::string(), FLAG_DISABLED)); + UTF8ToUTF16(label), gfx::ImageSkia(), std::string(), FLAG_DISABLED)); } } @@ -976,7 +978,8 @@ void MoreMenuModel::InitMenuItems(bool should_open_button_options) { std::string label = l10n_util::GetStringUTF8( IDS_STATUSBAR_NETWORK_DEVICE_WIFI) + " " + hardware_address; address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, - UTF8ToUTF16(label), SkBitmap(), std::string(), FLAG_DISABLED)); + UTF8ToUTF16(label), gfx::ImageSkia(), std::string(), + FLAG_DISABLED)); } } } diff --git a/chrome/browser/chromeos/status/network_menu_icon.cc b/chrome/browser/chromeos/status/network_menu_icon.cc index a6b12a9..976b335 100644 --- a/chrome/browser/chromeos/status/network_menu_icon.cc +++ b/chrome/browser/chromeos/status/network_menu_icon.cc @@ -32,13 +32,13 @@ const int kThrobDurationMs = 750; // Images for strength bars for wired networks. const int kNumBarsImages = 5; -SkBitmap* kBarsImagesAnimatingDark[kNumBarsImages - 1]; -SkBitmap* kBarsImagesAnimatingLight[kNumBarsImages - 1]; +gfx::ImageSkia* kBarsImagesAnimatingDark[kNumBarsImages - 1]; +gfx::ImageSkia* kBarsImagesAnimatingLight[kNumBarsImages - 1]; // Imagaes for strength arcs for wireless networks. const int kNumArcsImages = 5; -SkBitmap* kArcsImagesAnimatingDark[kNumArcsImages - 1]; -SkBitmap* kArcsImagesAnimatingLight[kNumArcsImages - 1]; +gfx::ImageSkia* kArcsImagesAnimatingDark[kNumArcsImages - 1]; +gfx::ImageSkia* kArcsImagesAnimatingLight[kNumArcsImages - 1]; // Badge offsets. If a badge is large enough that it won't fit within the icon // when using the right or bottom offset, it gets shifted inwards so it will. @@ -78,7 +78,8 @@ int CellularStrengthIndex(const CellularNetwork* cellular) { return StrengthIndex(cellular->strength(), kNumBarsImages - 1); } -const SkBitmap* BadgeForNetworkTechnology(const CellularNetwork* cellular) { +const gfx::ImageSkia* BadgeForNetworkTechnology( + const CellularNetwork* cellular) { const int kUnknownBadgeType = -1; int id = kUnknownBadgeType; switch (cellular->network_technology()) { @@ -145,7 +146,7 @@ const SkBitmap* BadgeForNetworkTechnology(const CellularNetwork* cellular) { if (id == kUnknownBadgeType) return NULL; else - return ResourceBundle::GetSharedInstance().GetBitmapNamed(id); + return ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); } // Generates a single empty vpn image for blending. @@ -154,7 +155,7 @@ const SkBitmap& GetEmptyVpnBadge() { if (empty_vpn_badge == NULL) { empty_vpn_badge = new SkBitmap(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); + const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); empty_vpn_badge->setConfig(SkBitmap::kARGB_8888_Config, vpn_badge->width(), vpn_badge->height()); @@ -164,13 +165,13 @@ const SkBitmap& GetEmptyVpnBadge() { return *empty_vpn_badge; } -const SkBitmap GetVpnResource(int resource_id) { +const gfx::ImageSkia GetVpnResource(int resource_id) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const SkBitmap* ethernet_icon = rb.GetBitmapNamed(resource_id); + const gfx::ImageSkia* ethernet_icon = rb.GetImageSkiaNamed(resource_id); gfx::Canvas canvas( gfx::Size(ethernet_icon->width(), ethernet_icon->height()), false); canvas.DrawBitmapInt(*ethernet_icon, 0, 0); - const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); + const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); canvas.DrawBitmapInt(*vpn_badge, kBadgeLeftX, kBadgeBottomY); return canvas.ExtractBitmap(); } @@ -181,7 +182,7 @@ const SkBitmap GetVpnResource(int resource_id) { // NetworkIcon // TODO(stevenjb): Separate class implementation from the definition. -// Sets up and generates an SkBitmap for a Network icon. +// Sets up and generates an ImageSkia for a Network icon. class NetworkIcon { public: // Default constructor is used by the status bar icon (NetworkMenuIcon). @@ -219,7 +220,7 @@ class NetworkIcon { // Resets the icon state. void ClearIconAndBadges() { - icon_ = SkBitmap(); + icon_ = gfx::ImageSkia(); top_left_badge_ = NULL; top_right_badge_ = NULL; bottom_left_badge_ = NULL; @@ -249,7 +250,7 @@ class NetworkIcon { } // Determine whether or not we need to update the icon. - bool dirty = bitmap_.empty(); + bool dirty = image_.empty(); // If the network state has changed, the icon needs updating. if (state_ != network->state()) { @@ -278,8 +279,8 @@ class NetworkIcon { if (dirty) { // Set the icon and badges based on the network. UpdateIcon(network); - // Generate the bitmap from the icon. - GenerateBitmap(); + // Generate the image from the icon. + GenerateImage(); } } @@ -289,7 +290,7 @@ class NetworkIcon { switch (network->type()) { case TYPE_ETHERNET: { - icon_ = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED); + icon_ = *rb.GetImageSkiaNamed(IDR_STATUSBAR_WIRED); break; } case TYPE_WIFI: { @@ -297,7 +298,7 @@ class NetworkIcon { static_cast<const WifiNetwork*>(network); if (strength_index_ == -1) strength_index_ = WifiStrengthIndex(wifi); - icon_ = NetworkMenuIcon::GetBitmap( + icon_ = NetworkMenuIcon::GetImage( NetworkMenuIcon::ARCS, strength_index_, resource_color_theme_); break; } @@ -306,7 +307,7 @@ class NetworkIcon { static_cast<const WimaxNetwork*>(network); if (strength_index_ == -1) strength_index_ = WimaxStrengthIndex(wimax); - icon_ = NetworkMenuIcon::GetBitmap( + icon_ = NetworkMenuIcon::GetImage( NetworkMenuIcon::BARS, strength_index_, resource_color_theme_); break; } @@ -315,18 +316,18 @@ class NetworkIcon { static_cast<const CellularNetwork*>(network); if (strength_index_ == -1) strength_index_ = CellularStrengthIndex(cellular); - icon_ = NetworkMenuIcon::GetBitmap( + icon_ = NetworkMenuIcon::GetImage( NetworkMenuIcon::BARS, strength_index_, resource_color_theme_); break; } case TYPE_VPN: { - icon_ = *rb.GetBitmapNamed(IDR_STATUSBAR_VPN); + icon_ = *rb.GetImageSkiaNamed(IDR_STATUSBAR_VPN); break; } default: { LOG(WARNING) << "Request for icon for unsupported type: " << network->type(); - icon_ = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED); + icon_ = *rb.GetImageSkiaNamed(IDR_STATUSBAR_WIRED); break; } } @@ -346,7 +347,7 @@ class NetworkIcon { case TYPE_ETHERNET: { if (network->disconnected()) { bottom_right_badge_ = - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED); + rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED); } break; } @@ -355,11 +356,12 @@ class NetworkIcon { static_cast<const WifiNetwork*>(network); if (wifi->encrypted() && resource_color_theme_ == NetworkMenuIcon::COLOR_DARK) - bottom_right_badge_ = rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE); + bottom_right_badge_ = rb.GetImageSkiaNamed( + IDR_STATUSBAR_NETWORK_SECURE); break; } case TYPE_WIMAX: { - bottom_right_badge_ = rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_4G); + bottom_right_badge_ = rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_4G); break; } case TYPE_CELLULAR: { @@ -368,7 +370,7 @@ class NetworkIcon { if (cellular->roaming_state() == ROAMING_STATE_ROAMING && !cros->IsCellularAlwaysInRoaming()) { // For cellular that always in roaming don't show roaming badge. - top_left_badge_ = rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_ROAMING); + top_left_badge_ = rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_ROAMING); } if (!cellular->connecting()) bottom_right_badge_ = BadgeForNetworkTechnology(cellular); @@ -379,7 +381,7 @@ class NetworkIcon { } // Display warning badge if cros is not loaded. if (is_status_bar_&& !CrosLibrary::Get()->load_error_string().empty()) - top_right_badge_ = rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_WARNING); + top_right_badge_ = rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_WARNING); } // Clears any previous state then sets the base icon and badges. @@ -405,25 +407,25 @@ class NetworkIcon { SetBadges(connected_network); } else { // Use the ethernet icon for VPN when not connected. - icon_ = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED); + icon_ = *rb.GetImageSkiaNamed(IDR_STATUSBAR_WIRED); // We can be connected to a VPN, even when there is no connected // underlying network. In that case, for the status bar, show the // disconnected badge. if (is_status_bar_) { bottom_right_badge_ = - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED); + rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED); } } // Overlay the VPN badge. - bottom_left_badge_ = rb.GetBitmapNamed(kVpnBadgeId); + bottom_left_badge_ = rb.GetImageSkiaNamed(kVpnBadgeId); } - // Generates the bitmap. Call after setting the icon and badges. - void GenerateBitmap() { + // Generates the image. Call after setting the icon and badges. + void GenerateImage() { if (icon_.empty()) return; - bitmap_ = NetworkMenuIcon::GenerateBitmapFromComponents( + image_ = NetworkMenuIcon::GenerateImageFromComponents( icon_, top_left_badge_, top_right_badge_, @@ -431,19 +433,19 @@ class NetworkIcon { bottom_right_badge_); } - const SkBitmap GetBitmap() const { return bitmap_; } + const gfx::ImageSkia GetImage() const { return image_; } - void set_icon(const SkBitmap& icon) { icon_ = icon; } - void set_top_left_badge(const SkBitmap* badge) { + void set_icon(const gfx::ImageSkia& icon) { icon_ = icon; } + void set_top_left_badge(const gfx::ImageSkia* badge) { top_left_badge_ = badge; } - void set_top_right_badge(const SkBitmap* badge) { + void set_top_right_badge(const gfx::ImageSkia* badge) { top_right_badge_ = badge; } - void set_bottom_left_badge(const SkBitmap* badge) { + void set_bottom_left_badge(const gfx::ImageSkia* badge) { bottom_left_badge_ = badge; } - void set_bottom_right_badge(const SkBitmap* badge) { + void set_bottom_right_badge(const gfx::ImageSkia* badge) { bottom_right_badge_ = badge; } @@ -478,7 +480,8 @@ class NetworkIcon { bool dirty = false; const CellularNetwork* cellular = static_cast<const CellularNetwork*>(network); - const SkBitmap* technology_badge = BadgeForNetworkTechnology(cellular); + const gfx::ImageSkia* technology_badge = BadgeForNetworkTechnology( + cellular); if (technology_badge != bottom_right_badge_) { dirty = true; } @@ -493,12 +496,12 @@ class NetworkIcon { ConnectionState state_; NetworkMenuIcon::ResourceColorTheme resource_color_theme_; int strength_index_; - SkBitmap bitmap_; - SkBitmap icon_; - const SkBitmap* top_left_badge_; - const SkBitmap* top_right_badge_; - const SkBitmap* bottom_left_badge_; - const SkBitmap* bottom_right_badge_; + gfx::ImageSkia image_; + gfx::ImageSkia icon_; + const gfx::ImageSkia* top_left_badge_; + const gfx::ImageSkia* top_right_badge_; + const gfx::ImageSkia* bottom_left_badge_; + const gfx::ImageSkia* bottom_right_badge_; bool is_status_bar_; const Network* connected_network_; // weak pointer; used for VPN icons. NetworkRoamingState roaming_state_; @@ -537,12 +540,12 @@ void NetworkMenuIcon::SetResourceColorTheme(ResourceColorTheme color) { icon_.reset(new NetworkIcon(resource_color_theme_)); } -const SkBitmap NetworkMenuIcon::GetIconAndText(string16* text) { +const gfx::ImageSkia NetworkMenuIcon::GetIconAndText(string16* text) { SetIconAndText(); if (text) *text = text_; - icon_->GenerateBitmap(); - return icon_->GetBitmap(); + icon_->GenerateImage(); + return icon_->GetImage(); } void NetworkMenuIcon::AnimationProgressed(const ui::Animation* animation) { @@ -582,17 +585,17 @@ double NetworkMenuIcon::GetAnimation() { // TODO(stevenjb): move below SetIconAndText. void NetworkMenuIcon::SetConnectingIconAndText() { int image_count; - BitmapType bitmap_type; - SkBitmap** images; + ImageType image_type; + gfx::ImageSkia** images; if (connecting_network_->type() == TYPE_WIFI) { image_count = kNumArcsImages - 1; - bitmap_type = ARCS; + image_type = ARCS; images = resource_color_theme_ == COLOR_DARK ? kArcsImagesAnimatingDark : kArcsImagesAnimatingLight; } else { image_count = kNumBarsImages - 1; - bitmap_type = BARS; + image_type = BARS; images = resource_color_theme_ == COLOR_DARK ? kBarsImagesAnimatingDark : kBarsImagesAnimatingLight; } @@ -601,9 +604,10 @@ void NetworkMenuIcon::SetConnectingIconAndText() { // Lazily cache images. if (!images[index]) { - SkBitmap source = GetBitmap(bitmap_type, index + 1, resource_color_theme_); + gfx::ImageSkia source = + GetImage(image_type, index + 1, resource_color_theme_); images[index] = - new SkBitmap(NetworkMenuIcon::GenerateConnectingBitmap(source)); + new gfx::ImageSkia(NetworkMenuIcon::GenerateConnectingBitmap(source)); } icon_->set_icon(*images[index]); icon_->SetBadges(connecting_network_); @@ -660,12 +664,12 @@ void NetworkMenuIcon::SetActiveNetworkIconAndText(const Network* network) { // Overlay the VPN badge if connecting to a VPN. if (network->type() != TYPE_VPN && cros->virtual_network()) { if (cros->virtual_network()->connecting()) { - const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); + const gfx::ImageSkia* vpn_badge = rb.GetImageSkiaNamed(kVpnBadgeId); const double animation = GetAnimation(); animating = true; // Even though this is the only place we use vpn_connecting_badge_, // it is important that this is a member variable since we set a - // pointer to it and access that pointer in icon_->GenerateBitmap(). + // pointer to it and access that pointer in icon_->GenerateImage(). vpn_connecting_badge_ = SkBitmapOperations::CreateBlendedBitmap( GetEmptyVpnBadge(), *vpn_badge, animation); icon_->set_bottom_left_badge(&vpn_connecting_badge_); @@ -699,17 +703,17 @@ void NetworkMenuIcon::SetDisconnectedIconAndText() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); switch (last_network_type_) { case TYPE_ETHERNET: - icon_->set_icon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); + icon_->set_icon(*rb.GetImageSkiaNamed(IDR_STATUSBAR_WIRED)); icon_->set_bottom_right_badge( - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); + rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); break; case TYPE_WIFI: case TYPE_WIMAX: case TYPE_CELLULAR: default: - icon_->set_icon(GetDisconnectedBitmap(BARS, resource_color_theme_)); + icon_->set_icon(GetDisconnectedImage(BARS, resource_color_theme_)); icon_->set_bottom_right_badge( - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); + rb.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); break; } if (mode_ == MENU_MODE) @@ -719,15 +723,15 @@ void NetworkMenuIcon::SetDisconnectedIconAndText() { } //////////////////////////////////////////////////////////////////////////////// -// Static functions for generating network icon bitmaps: +// Static functions for generating network icon images: // This defines how we assemble a network icon. -const SkBitmap NetworkMenuIcon::GenerateBitmapFromComponents( - const SkBitmap& icon, - const SkBitmap* top_left_badge, - const SkBitmap* top_right_badge, - const SkBitmap* bottom_left_badge, - const SkBitmap* bottom_right_badge) { +const gfx::ImageSkia NetworkMenuIcon::GenerateImageFromComponents( + const gfx::ImageSkia& icon, + const gfx::ImageSkia* top_left_badge, + const gfx::ImageSkia* top_right_badge, + const gfx::ImageSkia* bottom_left_badge, + const gfx::ImageSkia* bottom_right_badge) { DCHECK(!icon.empty()); gfx::Canvas canvas(icon, false); @@ -748,12 +752,12 @@ const SkBitmap NetworkMenuIcon::GenerateBitmapFromComponents( canvas.DrawBitmapInt(*bottom_right_badge, x, y); } - return canvas.ExtractBitmap(); + return gfx::ImageSkia(canvas.ExtractBitmap()); } // We blend connecting icons with a black image to generate a faded icon. const SkBitmap NetworkMenuIcon::GenerateConnectingBitmap( - const SkBitmap& source) { + const gfx::ImageSkia& source) { CR_DEFINE_STATIC_LOCAL(SkBitmap, empty_badge, ()); if (empty_badge.empty()) { empty_badge.setConfig(SkBitmap::kARGB_8888_Config, @@ -768,9 +772,9 @@ const SkBitmap NetworkMenuIcon::GenerateConnectingBitmap( empty_badge, source, kConnectingImageAlpha); } -// Generates and caches an icon bitmap for a network's current state. -const SkBitmap NetworkMenuIcon::GetBitmap(const Network* network, - ResourceColorTheme color) { +// Generates and caches an icon image for a network's current state. +const gfx::ImageSkia NetworkMenuIcon::GetImage(const Network* network, + ResourceColorTheme color) { DCHECK(network); // Maintain a static (global) icon map. Note: Icons are never destroyed; // it is assumed that a finite and reasonable number of network icons will be @@ -794,38 +798,38 @@ const SkBitmap NetworkMenuIcon::GetBitmap(const Network* network, } else { icon = iter->second; } - // Update and return the icon's bitmap. + // Update and return the icon's image. icon->Update(); - return icon->GetBitmap(); + return icon->GetImage(); } // Returns an icon for a disconnected VPN. -const SkBitmap NetworkMenuIcon::GetVpnBitmap() { - static SkBitmap* vpn_bitmap = NULL; - if (vpn_bitmap == NULL) - vpn_bitmap = new SkBitmap(GetVpnResource(IDR_STATUSBAR_VPN)); - return *vpn_bitmap; +const gfx::ImageSkia NetworkMenuIcon::GetVpnImage() { + static gfx::ImageSkia* vpn_image = NULL; + if (vpn_image == NULL) + vpn_image = new gfx::ImageSkia(GetVpnResource(IDR_STATUSBAR_VPN)); + return *vpn_image; } -const SkBitmap NetworkMenuIcon::GetBitmap(BitmapType type, - int index, - ResourceColorTheme color) { +const gfx::ImageSkia NetworkMenuIcon::GetImage(ImageType type, + int index, + ResourceColorTheme color) { int width, height; - SkBitmap* images; + gfx::ImageSkia* images; if (type == ARCS) { if (index >= kNumArcsImages) - return SkBitmap(); + return gfx::ImageSkia(); - images = ResourceBundle::GetSharedInstance().GetBitmapNamed( + images = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( color == COLOR_DARK ? IDR_STATUSBAR_NETWORK_ARCS_DARK : IDR_STATUSBAR_NETWORK_ARCS_LIGHT); width = images->width(); height = images->height() / kNumArcsImages; } else { if (index >= kNumBarsImages) - return SkBitmap(); + return gfx::ImageSkia(); - images = ResourceBundle::GetSharedInstance().GetBitmapNamed( + images = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( color == COLOR_DARK ? IDR_STATUSBAR_NETWORK_BARS_DARK : IDR_STATUSBAR_NETWORK_BARS_LIGHT); width = images->width(); @@ -833,23 +837,23 @@ const SkBitmap NetworkMenuIcon::GetBitmap(BitmapType type, } SkIRect subset = SkIRect::MakeXYWH(0, index * height, width, height); - SkBitmap image; + gfx::ImageSkia image; images->extractSubset(&image, subset); return image; } -const SkBitmap NetworkMenuIcon::GetDisconnectedBitmap( - BitmapType type, +const gfx::ImageSkia NetworkMenuIcon::GetDisconnectedImage( + ImageType type, ResourceColorTheme color) { - return GetBitmap(type, 0, color); + return GetImage(type, 0, color); } -const SkBitmap NetworkMenuIcon::GetConnectedBitmap(BitmapType type, - ResourceColorTheme color) { - return GetBitmap(type, NumBitmaps(type) - 1, color); +const gfx::ImageSkia NetworkMenuIcon::GetConnectedImage(ImageType type, + ResourceColorTheme color) { + return GetImage(type, NumImages(type) - 1, color); } -int NetworkMenuIcon::NumBitmaps(BitmapType type) { +int NetworkMenuIcon::NumImages(ImageType type) { return (type == ARCS) ? kNumArcsImages : kNumBarsImages; } diff --git a/chrome/browser/chromeos/status/network_menu_icon.h b/chrome/browser/chromeos/status/network_menu_icon.h index 832b3e1..d4a79a0 100644 --- a/chrome/browser/chromeos/status/network_menu_icon.h +++ b/chrome/browser/chromeos/status/network_menu_icon.h @@ -13,7 +13,7 @@ // class MyIconDelegate : public NetworkMenuIcon::Delegate { // virtual void NetworkMenuIconChanged() OVERRIDE { // string16 tooltip; -// const SkBitmap* bitmap = network_icon_->GetIconAndText(&tooltip); +// const ImageSkia* image = network_icon_->GetIconAndText(&tooltip); // SetIcon(*bitmap); // SetTooltip(tooltip); // SchedulePaint(); @@ -22,7 +22,7 @@ // MyIconDelegate my_delegate; // NetworkMenuIcon icon(&my_delegate, NetworkMenuIcon::MENU_MODE); // -// NetworkMenuIcon also provides static functions for fetching network bitmaps +// NetworkMenuIcon also provides static functions for fetching network images // (e.g. for network entries in the menu or settings). // Example usage: // Network* network = network_library->FindNetworkByPath(my_network_path_); @@ -36,9 +36,9 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/chromeos/cros/network_library.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/throb_animation.h" +#include "ui/gfx/image/image_skia.h" namespace chromeos { @@ -57,7 +57,7 @@ class NetworkMenuIcon : public ui::AnimationDelegate { }; // Used for calls to GetBitmap() and GetNumBitmaps() below. - enum BitmapType { + enum ImageType { ARCS = 0, BARS }; @@ -66,8 +66,8 @@ class NetworkMenuIcon : public ui::AnimationDelegate { public: Delegate() {} virtual ~Delegate() {} - // Called when the bitmap has changed due to animation. The callback should - // trigger a call to GetIconAndText() to generate and retrieve the bitmap. + // Called when the image has changed due to animation. The callback should + // trigger a call to GetIconAndText() to generate and retrieve the image. virtual void NetworkMenuIconChanged() = 0; private: @@ -87,52 +87,52 @@ class NetworkMenuIcon : public ui::AnimationDelegate { // Sets the resource color theme (e.g. light or dark icons). void SetResourceColorTheme(ResourceColorTheme color); - // Generates and returns the icon bitmap. If |text| is not NULL, sets it to + // Generates and returns the icon image. If |text| is not NULL, sets it to // the tooltip or display text to show, based on the value of mode_. - const SkBitmap GetIconAndText(string16* text); + const gfx::ImageSkia GetIconAndText(string16* text); // ui::AnimationDelegate implementation. virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - // Static functions for generating network icon bitmaps: + // Static functions for generating network icon images: - // Composites the bitmaps to generate a network icon. Input parameters are + // Composites the images to generate a network icon. Input parameters are // the icon and badges that are composited to generate |result|. Public // primarily for unit tests. - static const SkBitmap GenerateBitmapFromComponents( - const SkBitmap& icon, - const SkBitmap* top_left_badge, - const SkBitmap* top_right_badge, - const SkBitmap* bottom_left_badge, - const SkBitmap* bottom_right_badge); + static const gfx::ImageSkia GenerateImageFromComponents( + const gfx::ImageSkia& icon, + const gfx::ImageSkia* top_left_badge, + const gfx::ImageSkia* top_right_badge, + const gfx::ImageSkia* bottom_left_badge, + const gfx::ImageSkia* bottom_right_badge); // Returns a modified version of |source| representing the connecting state // of a network. Public for unit tests. - static const SkBitmap GenerateConnectingBitmap(const SkBitmap& source); + static const SkBitmap GenerateConnectingBitmap(const gfx::ImageSkia& source); - // Returns a bitmap associated with |network|, reflecting its current state. - static const SkBitmap GetBitmap(const Network* network, - ResourceColorTheme color); + // Returns an image associated with |network|, reflecting its current state. + static const gfx::ImageSkia GetImage(const Network* network, + ResourceColorTheme color); - // Returns a bitmap representing an unconnected VPN. - static const SkBitmap GetVpnBitmap(); + // Returns an image representing an unconnected VPN. + static const gfx::ImageSkia GetVpnImage(); - // Access a specific bitmap of the specified color theme. If index is out of - // range, an empty bitmap will be returned. - static const SkBitmap GetBitmap(BitmapType type, - int index, - ResourceColorTheme color); + // Access a specific image of the specified color theme. If index is out of + // range, an empty image will be returned. + static const gfx::ImageSkia GetImage(ImageType type, + int index, + ResourceColorTheme color); - // Gets the disconnected bitmap for given type. - static const SkBitmap GetDisconnectedBitmap(BitmapType type, - ResourceColorTheme color); + // Gets the disconnected image for given type. + static const gfx::ImageSkia GetDisconnectedImage(ImageType type, + ResourceColorTheme color); - // Gets the connected bitmap for given type. - static const SkBitmap GetConnectedBitmap(BitmapType type, - ResourceColorTheme color); + // Gets the connected image for given type. + static const gfx::ImageSkia GetConnectedImage(ImageType type, + ResourceColorTheme color); - // Returns total number of bitmaps for given type. - static int NumBitmaps(BitmapType type); + // Returns total number of images for given type. + static int NumImages(ImageType type); protected: // Starts the connection animation if necessary and returns its current value. @@ -158,8 +158,8 @@ class NetworkMenuIcon : public ui::AnimationDelegate { Mode mode_; // A delegate may be specified to receive notifications when this animates. Delegate* delegate_; - // Generated bitmap for connecting to a VPN. - SkBitmap vpn_connecting_badge_; + // Generated image for connecting to a VPN. + gfx::ImageSkia vpn_connecting_badge_; ResourceColorTheme resource_color_theme_; // Animation throbber for animating the icon while conencting. ui::ThrobAnimation animation_connecting_; diff --git a/chrome/browser/chromeos/status/network_menu_icon_unittest.cc b/chrome/browser/chromeos/status/network_menu_icon_unittest.cc index 8e7437e..0504308 100644 --- a/chrome/browser/chromeos/status/network_menu_icon_unittest.cc +++ b/chrome/browser/chromeos/status/network_menu_icon_unittest.cc @@ -12,8 +12,17 @@ namespace { -// Compares each pixel in two bitmaps for testing. -bool CompareTwoBitmaps(const SkBitmap& a, const SkBitmap& b, int log_level) { +// Compares each pixel in the 1x representation of two images for testing. +// TODO(pkotwicz): Compare pixels of all bitmaps contained within image. +bool CompareTwoImages(const gfx::ImageSkia& image_a, + const gfx::ImageSkia& image_b, + int log_level) { + float actual_scale_factor; + SkBitmap a = image_a.GetBitmapForScale(1.0f, 1.0f, &actual_scale_factor); + DCHECK_EQ(1.0f, actual_scale_factor); + SkBitmap b = image_b.GetBitmapForScale(1.0f, 1.0f, &actual_scale_factor); + DCHECK_EQ(1.0f, actual_scale_factor); + CHECK(!a.empty()); CHECK(!b.empty()); if (a.getSize() != b.getSize()) { @@ -67,67 +76,67 @@ class NetworkMenuIconTest : public testing::Test { virtual void SetUp() OVERRIDE { cros_ = CrosLibrary::Get()->GetNetworkLibrary(); // Ethernet connected = WIRED icon, no badges. - ethernet_connected_bitmap_ = NetworkMenuIcon::GenerateBitmapFromComponents( - *rb_.GetBitmapNamed(IDR_STATUSBAR_WIRED), + ethernet_connected_image_ = NetworkMenuIcon::GenerateImageFromComponents( + *rb_.GetImageSkiaNamed(IDR_STATUSBAR_WIRED), NULL, NULL, NULL, NULL); // Ethernet disonnected = WIRED icon + DISCONNECTED badge. - ethernet_disconnected_bitmap_ = - NetworkMenuIcon::GenerateBitmapFromComponents( - *rb_.GetBitmapNamed(IDR_STATUSBAR_WIRED), + ethernet_disconnected_image_ = + NetworkMenuIcon::GenerateImageFromComponents( + *rb_.GetImageSkiaNamed(IDR_STATUSBAR_WIRED), NULL, NULL, NULL, - rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); + rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); // Wifi connected, strength = 100% = ARCS4 icon, no badges. - wifi_connected_100_bitmap_ = NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap( + wifi_connected_100_image_ = NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage( NetworkMenuIcon::ARCS, - NetworkMenuIcon::NumBitmaps(NetworkMenuIcon::ARCS) - 1, + NetworkMenuIcon::NumImages(NetworkMenuIcon::ARCS) - 1, NetworkMenuIcon::COLOR_DARK), NULL, NULL, NULL, NULL); // Wifi connected, strength = 50%, encrypted = ARCS2 icon + SECURE badge. - wifi_encrypted_50_bitmap_ = NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap(NetworkMenuIcon::ARCS, 3, - NetworkMenuIcon::COLOR_DARK), - NULL, NULL, NULL, rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); + wifi_encrypted_50_image_ = NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage(NetworkMenuIcon::ARCS, 3, + NetworkMenuIcon::COLOR_DARK), + NULL, NULL, NULL, rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_SECURE)); // Wifi disconnected (strength = 0%) = ARCS0 icon. - wifi_disconnected_bitmap_ = NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap(NetworkMenuIcon::ARCS, 0, - NetworkMenuIcon::COLOR_DARK), + wifi_disconnected_image_ = NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage(NetworkMenuIcon::ARCS, 0, + NetworkMenuIcon::COLOR_DARK), NULL, NULL, NULL, NULL); // Wifi connecting = IDR_STATUSBAR_NETWORK_ARCS1 (faded). - wifi_connecting_bitmap_ = NetworkMenuIcon::GenerateConnectingBitmap( - NetworkMenuIcon::GetBitmap(NetworkMenuIcon::ARCS, 1, - NetworkMenuIcon::COLOR_DARK)); + wifi_connecting_image_ = NetworkMenuIcon::GenerateConnectingBitmap( + NetworkMenuIcon::GetImage(NetworkMenuIcon::ARCS, 1, + NetworkMenuIcon::COLOR_DARK)); // 4G connected, strength = 50% = BARS4 icon + 4G badge. - wimax_connected_50_bitmap_ = - NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap( + wimax_connected_50_image_ = + NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage( NetworkMenuIcon::BARS, 3, NetworkMenuIcon::COLOR_DARK), - NULL, NULL, NULL, rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_4G)); + NULL, NULL, NULL, rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_4G)); // 3G connected, strength = 100% = BARS4 icon + 3G badge. - cellular_connected_100_bitmap_ = - NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap( + cellular_connected_100_image_ = + NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage( NetworkMenuIcon::BARS, - NetworkMenuIcon::NumBitmaps(NetworkMenuIcon::BARS) - 1, + NetworkMenuIcon::NumImages(NetworkMenuIcon::BARS) - 1, NetworkMenuIcon::COLOR_DARK), - NULL, NULL, NULL, rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G)); + NULL, NULL, NULL, rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_3G)); // 3G connected, strength = 50%, roaming = BARS2 icon + roaming & 3G badges. - cellular_roaming_50_bitmap_ = NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap(NetworkMenuIcon::BARS, 3, - NetworkMenuIcon::COLOR_DARK), - rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_ROAMING), NULL, - NULL, rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G)); + cellular_roaming_50_image_ = NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage(NetworkMenuIcon::BARS, 3, + NetworkMenuIcon::COLOR_DARK), + rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_ROAMING), NULL, + NULL, rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_3G)); // 3G disconnected (strength = 0%) = BARS0 icon + 3G badge. - cellular_disconnected_bitmap_ = - NetworkMenuIcon::GenerateBitmapFromComponents( - NetworkMenuIcon::GetBitmap(NetworkMenuIcon::BARS, 0, - NetworkMenuIcon::COLOR_DARK), - NULL, NULL, NULL, rb_.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G)); + cellular_disconnected_image_ = + NetworkMenuIcon::GenerateImageFromComponents( + NetworkMenuIcon::GetImage(NetworkMenuIcon::BARS, 0, + NetworkMenuIcon::COLOR_DARK), + NULL, NULL, NULL, rb_.GetImageSkiaNamed(IDR_STATUSBAR_NETWORK_3G)); // 3G connecting = IDR_STATUSBAR_NETWORK_BARS1 (faded). - cellular_connecting_bitmap_ = NetworkMenuIcon::GenerateConnectingBitmap( - NetworkMenuIcon::GetBitmap(NetworkMenuIcon::BARS, 1, - NetworkMenuIcon::COLOR_DARK)); + cellular_connecting_image_ = NetworkMenuIcon::GenerateConnectingBitmap( + NetworkMenuIcon::GetImage(NetworkMenuIcon::BARS, 1, + NetworkMenuIcon::COLOR_DARK)); } virtual void TearDown() OVERRIDE { @@ -167,19 +176,19 @@ class NetworkMenuIconTest : public testing::Test { test_network.SetRoamingState(roaming); } - bool CompareBitmaps(const SkBitmap& icon, const SkBitmap& base) { - if (CompareTwoBitmaps(icon, base, 1)) + bool CompareImages(const gfx::ImageSkia& icon, const gfx::ImageSkia& base) { + if (CompareTwoImages(icon, base, 1)) return true; - EXPECT_FALSE(CompareTwoBitmaps(icon, ethernet_connected_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, ethernet_disconnected_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, wifi_connected_100_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, wifi_encrypted_50_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, wifi_disconnected_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, wifi_connecting_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, cellular_connected_100_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, cellular_roaming_50_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, cellular_disconnected_bitmap_, 2)); - EXPECT_FALSE(CompareTwoBitmaps(icon, cellular_connecting_bitmap_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, ethernet_connected_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, ethernet_disconnected_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, wifi_connected_100_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, wifi_encrypted_50_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, wifi_disconnected_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, wifi_connecting_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, cellular_connected_100_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, cellular_roaming_50_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, cellular_disconnected_image_, 2)); + EXPECT_FALSE(CompareTwoImages(icon, cellular_connecting_image_, 2)); return false; } @@ -187,17 +196,17 @@ class NetworkMenuIconTest : public testing::Test { ScopedStubCrosEnabler cros_stub_; NetworkLibrary* cros_; ResourceBundle& rb_; - SkBitmap ethernet_connected_bitmap_; - SkBitmap ethernet_disconnected_bitmap_; - SkBitmap wifi_connected_100_bitmap_; - SkBitmap wifi_encrypted_50_bitmap_; - SkBitmap wifi_disconnected_bitmap_; - SkBitmap wifi_connecting_bitmap_; - SkBitmap wimax_connected_50_bitmap_; - SkBitmap cellular_connected_100_bitmap_; - SkBitmap cellular_roaming_50_bitmap_; - SkBitmap cellular_disconnected_bitmap_; - SkBitmap cellular_connecting_bitmap_; + gfx::ImageSkia ethernet_connected_image_; + gfx::ImageSkia ethernet_disconnected_image_; + gfx::ImageSkia wifi_connected_100_image_; + gfx::ImageSkia wifi_encrypted_50_image_; + gfx::ImageSkia wifi_disconnected_image_; + gfx::ImageSkia wifi_connecting_image_; + gfx::ImageSkia wimax_connected_50_image_; + gfx::ImageSkia cellular_connected_100_image_; + gfx::ImageSkia cellular_roaming_50_image_; + gfx::ImageSkia cellular_disconnected_image_; + gfx::ImageSkia cellular_connecting_image_; }; // Compare icon cache results against expected results fron SetUp(). @@ -205,35 +214,35 @@ TEST_F(NetworkMenuIconTest, EthernetIcon) { Network* network = cros_->FindNetworkByPath("eth1"); ASSERT_NE(static_cast<const Network*>(NULL), network); SetConnected(network, true); - SkBitmap icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, ethernet_connected_bitmap_)); + gfx::ImageSkia icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, ethernet_connected_image_)); SetConnected(network, false); - icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, ethernet_disconnected_bitmap_)); + icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, ethernet_disconnected_image_)); } TEST_F(NetworkMenuIconTest, WifiIcon) { WifiNetwork* network = cros_->FindWifiNetworkByPath("wifi1"); ASSERT_NE(static_cast<const Network*>(NULL), network); - SkBitmap icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, wifi_connected_100_bitmap_)); + gfx::ImageSkia icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, wifi_connected_100_image_)); SetStrength(network, 50); SetEncryption(network, SECURITY_RSN); - icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, wifi_encrypted_50_bitmap_)); + icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, wifi_encrypted_50_image_)); SetConnected(network, false); SetStrength(network, 0); SetEncryption(network, SECURITY_NONE); - icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, wifi_disconnected_bitmap_)); + icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, wifi_disconnected_image_)); } TEST_F(NetworkMenuIconTest, CellularIcon) { @@ -242,22 +251,22 @@ TEST_F(NetworkMenuIconTest, CellularIcon) { SetConnected(network, true); SetStrength(network, 100); SetRoamingState(network, ROAMING_STATE_HOME); - SkBitmap icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, cellular_connected_100_bitmap_)); + gfx::ImageSkia icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, cellular_connected_100_image_)); SetStrength(network, 50); SetRoamingState(network, ROAMING_STATE_ROAMING); - icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, cellular_roaming_50_bitmap_)); + icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, cellular_roaming_50_image_)); SetConnected(network, false); SetStrength(network, 0); SetRoamingState(network, ROAMING_STATE_HOME); - icon = NetworkMenuIcon::GetBitmap(network, - NetworkMenuIcon::COLOR_DARK); - EXPECT_TRUE(CompareBitmaps(icon, cellular_disconnected_bitmap_)); + icon = NetworkMenuIcon::GetImage(network, + NetworkMenuIcon::COLOR_DARK); + EXPECT_TRUE(CompareImages(icon, cellular_disconnected_image_)); } namespace { @@ -302,7 +311,7 @@ class TestNetworkMenuIcon : public NetworkMenuIcon { TEST_F(NetworkMenuIconTest, StatusIconMenuMode) { TestNetworkMenuIcon menu_icon(NetworkMenuIcon::MENU_MODE); - SkBitmap icon; + gfx::ImageSkia icon; // Set cellular1 to connecting. CellularNetwork* cellular1 = cros_->FindCellularNetworkByPath("cellular1"); @@ -312,12 +321,12 @@ TEST_F(NetworkMenuIconTest, StatusIconMenuMode) { // For MENU_MODE, we always display the connecting icon (cellular1). icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, cellular_connecting_bitmap_)); + EXPECT_TRUE(CompareImages(icon, cellular_connecting_image_)); // Set cellular1 to connected; ethernet icon should be shown. SetConnected(cellular1, true); icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, ethernet_connected_bitmap_)); + EXPECT_TRUE(CompareImages(icon, ethernet_connected_image_)); // Set ethernet to inactive/disconnected; wifi icon should be shown. Network* eth1 = cros_->FindNetworkByPath("eth1"); @@ -325,12 +334,12 @@ TEST_F(NetworkMenuIconTest, StatusIconMenuMode) { SetActive(eth1, false); SetConnected(eth1, false); icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, wifi_connected_100_bitmap_)); + EXPECT_TRUE(CompareImages(icon, wifi_connected_100_image_)); } TEST_F(NetworkMenuIconTest, StatusIconDropdownMode) { TestNetworkMenuIcon menu_icon(NetworkMenuIcon::DROPDOWN_MODE); - SkBitmap icon; + gfx::ImageSkia icon; // Set wifi1 to connecting. WifiNetwork* wifi1 = cros_->FindWifiNetworkByPath("wifi1"); @@ -339,7 +348,7 @@ TEST_F(NetworkMenuIconTest, StatusIconDropdownMode) { // For DROPDOWN_MODE, we prioritize the connected network (ethernet). icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, ethernet_connected_bitmap_)); + EXPECT_TRUE(CompareImages(icon, ethernet_connected_image_)); // Set ethernet to inactive/disconnected. Network* ethernet = cros_->FindNetworkByPath("eth1"); @@ -349,19 +358,19 @@ TEST_F(NetworkMenuIconTest, StatusIconDropdownMode) { // Icon should now be cellular connected icon. icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, cellular_connected_100_bitmap_)); + EXPECT_TRUE(CompareImages(icon, cellular_connected_100_image_)); // Set cellular1 to disconnected; Icon should now be wimax icon. CellularNetwork* cellular1 = cros_->FindCellularNetworkByPath("cellular1"); ASSERT_NE(static_cast<const Network*>(NULL), cellular1); SetConnected(cellular1, false); icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, wimax_connected_50_bitmap_)); + EXPECT_TRUE(CompareImages(icon, wimax_connected_50_image_)); // Set wifi1 to connected. Icon should now be wifi connected icon. SetConnected(wifi1, true); icon = menu_icon.GetIconAndText(NULL); - EXPECT_TRUE(CompareBitmaps(icon, wifi_connected_100_bitmap_)); + EXPECT_TRUE(CompareImages(icon, wifi_connected_100_image_)); } } // namespace chromeos diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc index 48fbb57..966989d 100644 --- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc +++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc @@ -90,7 +90,7 @@ ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network, NetworkMenu* network_menu) { ash::NetworkIconInfo info; info.name = UTF8ToUTF16(network->name()); - info.image = network_icon->GetBitmap(network, NetworkMenuIcon::COLOR_DARK); + info.image = network_icon->GetImage(network, NetworkMenuIcon::COLOR_DARK); info.service_path = network->service_path(); info.highlight = network_menu->ShouldHighlightNetwork(network); info.tray_icon_visible = ShouldShowNetworkIconInTray(network); @@ -244,7 +244,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, return UserManager::Get()->GetLoggedInUser().display_email(); } - virtual const SkBitmap& GetUserImage() const OVERRIDE { + virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE { return UserManager::Get()->GetLoggedInUser().image(); } diff --git a/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc index 086d2eb..7ca70d3 100644 --- a/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc +++ b/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc @@ -256,8 +256,8 @@ void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { canvas, ShouldPaintAsActive() ? ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE, - GetThemeFrameBitmapId(), - GetThemeFrameOverlayBitmap()); + GetThemeFrameImageId(), + GetThemeFrameOverlayImage()); if (browser_view()->ShouldShowWindowTitle()) frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); if (browser_view()->IsToolbarVisible()) @@ -344,7 +344,7 @@ bool BrowserNonClientFrameViewAsh::ShouldTabIconViewAnimate() const { gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { views::WidgetDelegate* delegate = frame()->widget_delegate(); if (!delegate) - return SkBitmap(); + return gfx::ImageSkia(); return delegate->GetWindowIcon(); } @@ -395,7 +395,7 @@ bool BrowserNonClientFrameViewAsh::UseShortHeader() const { void BrowserNonClientFrameViewAsh::LayoutAvatar() { DCHECK(avatar_button()); - SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); + gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; @@ -441,7 +441,7 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground( // source y position. If you have to debug this code use an image editor // to paint a diagonal line through the toolbar image and ensure it lines up // across the tab and toolbar. - SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); + gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); canvas->TileImageInt( *theme_toolbar, x, bottom_y - GetHorizontalTabStripVerticalOffset(false), @@ -451,21 +451,22 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground( // The content area line has a shadow that extends a couple of pixels above // the toolbar bounds. const int kContentShadowHeight = 2; - SkBitmap* toolbar_top = - tp->GetBitmapNamed(IDR_TOOLBAR_SHADE_TOP); + gfx::ImageSkia* toolbar_top = + tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); canvas->TileImageInt(*toolbar_top, 0, 0, x, y - kContentShadowHeight, w, split_point + kContentShadowHeight + 1); // Draw the "lightening" shade line around the edges of the toolbar. - SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_TOOLBAR_SHADE_LEFT); + gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT); canvas->TileImageInt(*toolbar_left, 0, 0, x + kClientEdgeThickness, y + kClientEdgeThickness + kContentShadowHeight, toolbar_left->width(), theme_toolbar->height()); - SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_TOOLBAR_SHADE_RIGHT); + gfx::ImageSkia* toolbar_right = + tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); canvas->TileImageInt(*toolbar_right, 0, 0, w - toolbar_right->width() - 2 * kClientEdgeThickness, @@ -486,7 +487,7 @@ void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); } -int BrowserNonClientFrameViewAsh::GetThemeFrameBitmapId() const { +int BrowserNonClientFrameViewAsh::GetThemeFrameImageId() const { bool is_incognito = browser_view()->IsOffTheRecord(); if (browser_view()->IsBrowserTypeNormal()) { // Use the standard resource ids to allow users to theme the frames. @@ -508,13 +509,13 @@ int BrowserNonClientFrameViewAsh::GetThemeFrameBitmapId() const { IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; } -const SkBitmap* -BrowserNonClientFrameViewAsh::GetThemeFrameOverlayBitmap() const { +const gfx::ImageSkia* +BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const { ui::ThemeProvider* tp = GetThemeProvider(); if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && browser_view()->IsBrowserTypeNormal() && !browser_view()->IsOffTheRecord()) { - return tp->GetBitmapNamed(ShouldPaintAsActive() ? + return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); } return NULL; diff --git a/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h b/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h index d2a9e7f..e9318b0 100644 --- a/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h +++ b/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h @@ -81,10 +81,10 @@ class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView, // above the content area. void PaintContentEdge(gfx::Canvas* canvas); - // Returns the correct bitmap id for the frame header based on activation + // Returns the correct image id for the frame header based on activation // state and incognito mode. - int GetThemeFrameBitmapId() const; - const SkBitmap* GetThemeFrameOverlayBitmap() const; + int GetThemeFrameImageId() const; + const gfx::ImageSkia* GetThemeFrameOverlayImage() const; // Window controls. The |size_button_| either toggles maximized or toggles // minimized. The exact behavior is determined by |size_button_minimizes_|. diff --git a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc index cad8a9b..36cd990 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc @@ -149,10 +149,10 @@ void NetworkDropdown::NetworkMenuIconChanged() { void NetworkDropdown::SetNetworkIconAndText() { string16 text; - const SkBitmap icon_bitmap = network_icon_->GetIconAndText(&text); + const gfx::ImageSkia icon_image = network_icon_->GetIconAndText(&text); std::string icon_str = - icon_bitmap.empty() ? - std::string() : web_ui_util::GetImageDataUrl(icon_bitmap); + icon_image.empty() ? + std::string() : web_ui_util::GetImageDataUrl(icon_image); base::StringValue title(text); base::StringValue icon(icon_str); web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", diff --git a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc index 6da2ad4..f7f4fc0 100644 --- a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc @@ -151,7 +151,7 @@ void UserImageScreenHandler::RegisterMessages() { base::Unretained(this))); } -void UserImageScreenHandler::AddProfileImage(const SkBitmap& image) { +void UserImageScreenHandler::AddProfileImage(const gfx::ImageSkia& image) { profile_picture_data_url_ = web_ui_util::GetImageDataUrl(image); SendProfileImage(profile_picture_data_url_); } @@ -173,7 +173,7 @@ void UserImageScreenHandler::OnProfileImageAbsent() { } } -void UserImageScreenHandler::OnPhotoAccepted(const SkBitmap& photo) { +void UserImageScreenHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) { user_photo_ = photo; user_photo_data_url_ = web_ui_util::GetImageDataUrl(user_photo_); selected_image_ = User::kExternalImageIndex; diff --git a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h index c8035f5..5392c77 100644 --- a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h @@ -12,6 +12,7 @@ #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" namespace base { @@ -46,14 +47,14 @@ class UserImageScreenHandler : public UserImageScreenActor, virtual void ShowCameraInitializing() OVERRIDE; virtual void CheckCameraPresence() OVERRIDE; virtual bool IsCapturing() const OVERRIDE; - virtual void AddProfileImage(const SkBitmap& image) OVERRIDE; + virtual void AddProfileImage(const gfx::ImageSkia& image) OVERRIDE; virtual void OnProfileImageAbsent() OVERRIDE; // WebUIMessageHandler implementation: virtual void RegisterMessages() OVERRIDE; // TakePhotoDialog::Delegate implementation. - virtual void OnPhotoAccepted(const SkBitmap& photo) OVERRIDE; + virtual void OnPhotoAccepted(const gfx::ImageSkia& photo) OVERRIDE; private: // Sends profile image as a data URL to the page. @@ -83,7 +84,7 @@ class UserImageScreenHandler : public UserImageScreenActor, int selected_image_; // Last user photo, if taken. - SkBitmap user_photo_; + gfx::ImageSkia user_photo_; // Data URL for |user_photo_|. std::string user_photo_data_url_; diff --git a/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc index 8836814..65b555d 100644 --- a/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc @@ -28,7 +28,6 @@ #include "content/public/common/url_constants.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/views/widget/widget.h" @@ -218,7 +217,7 @@ void ChangePictureOptionsHandler::SendSelectedImage() { } } -void ChangePictureOptionsHandler::SendProfileImage(const SkBitmap& image, +void ChangePictureOptionsHandler::SendProfileImage(const gfx::ImageSkia& image, bool should_select) { base::StringValue data_url(web_ui_util::GetImageDataUrl(image)); base::FundamentalValue select(should_select); @@ -303,7 +302,7 @@ void ChangePictureOptionsHandler::FileSelected(const FilePath& path, kHistogramImagesCount); } -void ChangePictureOptionsHandler::OnPhotoAccepted(const SkBitmap& photo) { +void ChangePictureOptionsHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) { UserManager* user_manager = UserManager::Get(); user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), chromeos::UserImage(photo)); @@ -336,7 +335,8 @@ void ChangePictureOptionsHandler::Observe( OptionsPageUIHandler::Observe(type, source, details); if (type == chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED) { // User profile image has been updated. - SendProfileImage(*content::Details<const SkBitmap>(details).ptr(), false); + SendProfileImage(*content::Details<const gfx::ImageSkia>(details).ptr(), + false); } } diff --git a/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.h b/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.h index 7c40516..14561a0 100644 --- a/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.h +++ b/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.h @@ -10,6 +10,7 @@ #include "chrome/browser/ui/select_file_dialog.h" #include "chrome/browser/ui/webui/options2/options_ui2.h" #include "content/public/browser/notification_registrar.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" namespace base { @@ -44,7 +45,7 @@ class ChangePictureOptionsHandler : public ::options2::OptionsPageUIHandler, // Sends the profile image to the page. If |should_select| is true then // the profile image element is selected. - void SendProfileImage(const SkBitmap& image, bool should_select); + void SendProfileImage(const gfx::ImageSkia& image, bool should_select); // Starts profile image update and shows the last downloaded profile image, // if any, on the page. Shouldn't be called before |SendProfileImage|. @@ -80,7 +81,7 @@ class ChangePictureOptionsHandler : public ::options2::OptionsPageUIHandler, int index, void* params) OVERRIDE; // TakePhotoDialog::Delegate implementation. - virtual void OnPhotoAccepted(const SkBitmap& photo) OVERRIDE; + virtual void OnPhotoAccepted(const gfx::ImageSkia& photo) OVERRIDE; // content::NotificationObserver implementation. virtual void Observe(int type, @@ -96,7 +97,7 @@ class ChangePictureOptionsHandler : public ::options2::OptionsPageUIHandler, scoped_refptr<SelectFileDialog> select_file_dialog_; // Previous user image from camera/file and its data URL. - SkBitmap previous_image_; + gfx::ImageSkia previous_image_; std::string previous_image_data_url_; // Index of the previous user image. diff --git a/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc index 60755e4..a74f299 100644 --- a/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc @@ -52,9 +52,9 @@ #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image_skia.h" #include "ui/views/widget/widget.h" namespace { @@ -98,7 +98,7 @@ class NetworkInfoDictionary { void set_service_path(const std::string& service_path) { service_path_ = service_path; } - void set_icon(const SkBitmap& icon) { + void set_icon(const gfx::ImageSkia& icon) { icon_url_ = icon.isNull() ? "" : web_ui_util::GetImageDataUrl(icon); } void set_name(const std::string& name) { @@ -167,7 +167,7 @@ NetworkInfoDictionary::NetworkInfoDictionary() { NetworkInfoDictionary::NetworkInfoDictionary(const chromeos::Network* network) { set_service_path(network->service_path()); - set_icon(chromeos::NetworkMenuIcon::GetBitmap(network, + set_icon(chromeos::NetworkMenuIcon::GetImage(network, chromeos::NetworkMenuIcon::COLOR_DARK)); set_name(network->name()); set_connecting(network->connecting()); @@ -184,7 +184,7 @@ NetworkInfoDictionary::NetworkInfoDictionary( const chromeos::Network* network, const chromeos::Network* remembered) { set_service_path(remembered->service_path()); - set_icon(chromeos::NetworkMenuIcon::GetBitmap( + set_icon(chromeos::NetworkMenuIcon::GetImage( network ? network : remembered, chromeos::NetworkMenuIcon::COLOR_DARK)); set_name(remembered->name()); set_connecting(network ? network->connecting() : false); @@ -1351,7 +1351,7 @@ ListValue* InternetOptionsHandler::GetWirelessList() { NetworkInfoDictionary network_dict; network_dict.set_service_path(kOtherNetworksFakePath); network_dict.set_icon( - chromeos::NetworkMenuIcon::GetDisconnectedBitmap( + chromeos::NetworkMenuIcon::GetDisconnectedImage( chromeos::NetworkMenuIcon::BARS, chromeos::NetworkMenuIcon::COLOR_DARK)); network_dict.set_name( diff --git a/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h b/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h index 3dd15af..60b46da 100644 --- a/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h +++ b/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h @@ -15,7 +15,10 @@ #include "ui/gfx/native_widget_types.h" class Browser; -class SkBitmap; + +namespace gfx { +class ImageSkia; +} namespace views { class WidgetDelegate; diff --git a/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc b/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc index 3f8fe95..73d2d1f 100644 --- a/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc @@ -72,7 +72,7 @@ std::vector<unsigned char> UserImageSource::GetUserImage( return user_image; } gfx::PNGCodec::EncodeBGRASkBitmap( - *ResourceBundle::GetSharedInstance().GetBitmapNamed( + *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_LOGIN_DEFAULT_USER), false, &user_image); diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index b5abf12c..859204f 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -5,7 +5,7 @@ #include "content/public/browser/content_browser_client.h" #include "base/file_path.h" -#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/image/image_skia.h" namespace content { @@ -78,8 +78,8 @@ std::string ContentBrowserClient::GetAcceptLangs(BrowserContext* context) { return std::string(); } -SkBitmap* ContentBrowserClient::GetDefaultFavicon() { - static SkBitmap* empty = new SkBitmap(); +gfx::ImageSkia* ContentBrowserClient::GetDefaultFavicon() { + static gfx::ImageSkia* empty = new gfx::ImageSkia(); return empty; } diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index fcf53c7..54569e7 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -21,7 +21,6 @@ class FilePath; class GURL; class PluginProcessHost; class ResourceDispatcherHost; -class SkBitmap; namespace webkit_glue { struct WebPreferences; @@ -31,6 +30,10 @@ namespace crypto { class CryptoModuleBlockingPasswordDelegate; } +namespace gfx { +class ImageSkia; +} + namespace net { class CookieList; class CookieOptions; @@ -174,7 +177,7 @@ class CONTENT_EXPORT ContentBrowserClient { virtual std::string GetAcceptLangs(BrowserContext* context); // Returns the default favicon. The callee doesn't own the given bitmap. - virtual SkBitmap* GetDefaultFavicon(); + virtual gfx::ImageSkia* GetDefaultFavicon(); // Allow the embedder to control if an AppCache can be used for the given url. // This is called on the IO thread. diff --git a/content/public/browser/favicon_status.cc b/content/public/browser/favicon_status.cc index 2ab0e8a..c9da916 100644 --- a/content/public/browser/favicon_status.cc +++ b/content/public/browser/favicon_status.cc @@ -5,11 +5,12 @@ #include "content/public/browser/favicon_status.h" #include "content/public/browser/content_browser_client.h" +#include "ui/gfx/image/image_skia.h" namespace content { FaviconStatus::FaviconStatus() : valid(false) { - bitmap = *GetContentClient()->browser()->GetDefaultFavicon(); + bitmap = *GetContentClient()->browser()->GetDefaultFavicon()->bitmap(); } } // namespace content diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc index 530fa4a..dca4df0 100644 --- a/content/shell/shell_content_browser_client.cc +++ b/content/shell/shell_content_browser_client.cc @@ -14,7 +14,6 @@ #include "content/shell/shell_resource_dispatcher_host_delegate.h" #include "content/shell/shell_switches.h" #include "googleurl/src/gurl.h" -#include "third_party/skia/include/core/SkBitmap.h" namespace content { diff --git a/ui/views/examples/content_client/examples_content_browser_client.cc b/ui/views/examples/content_client/examples_content_browser_client.cc index fac0d07..0c1f738 100644 --- a/ui/views/examples/content_client/examples_content_browser_client.cc +++ b/ui/views/examples/content_client/examples_content_browser_client.cc @@ -13,7 +13,6 @@ #include "content/shell/shell_resource_dispatcher_host_delegate.h" #include "content/shell/shell_switches.h" #include "googleurl/src/gurl.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/views/examples/content_client/examples_browser_main_parts.h" namespace views { |