From 5b3bdb5546f1aa83b7f3c060beabc191d5de428d Mon Sep 17 00:00:00 2001 From: "pkotwicz@chromium.org" Date: Tue, 9 Oct 2012 04:41:03 +0000 Subject: [PATCH] This CL removes ResourceBundle::GetBitmapNamed() and ThemeProvider::GetBitmapNamed() BUG=153180 Test=Compiles R=sail,erg TBR=sky Review URL: https://chromiumcodereview.appspot.com/11015007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160789 0039d316-1c4b-4281-b951-d872f2087c98 --- .../extensions/extension_icon_manager.cc | 4 +- chrome/browser/themes/browser_theme_pack.cc | 11 ------ chrome/browser/themes/browser_theme_pack.h | 6 --- chrome/browser/themes/theme_service.cc | 8 ---- chrome/browser/themes/theme_service.h | 1 - chrome/browser/themes/theme_service_gtk.cc | 5 ++- .../bookmark_bar_controller_unittest.mm | 1 - .../ui/cocoa/download/background_theme.h | 1 - .../ui/cocoa/download/background_theme.mm | 4 -- .../infobars/extension_infobar_controller.mm | 8 ++-- chrome/browser/ui/gtk/browser_titlebar.cc | 6 +-- chrome/browser/ui/gtk/browser_toolbar_gtk.cc | 2 +- chrome/browser/ui/gtk/custom_button.cc | 10 +++-- chrome/browser/ui/gtk/custom_button.h | 8 +++- .../ui/gtk/download/download_shelf_gtk.cc | 5 ++- chrome/browser/ui/gtk/find_bar_gtk.cc | 4 +- chrome/browser/ui/gtk/gtk_theme_service.cc | 15 ++------ chrome/browser/ui/gtk/gtk_theme_service.h | 3 +- .../ui/gtk/notifications/balloon_view_gtk.cc | 7 ++-- .../browser/ui/gtk/tabs/tab_renderer_gtk.cc | 38 +++++++++---------- chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc | 7 ++-- chrome/browser/ui/gtk/task_manager_gtk.cc | 4 +- .../ui/gtk/titlebar_throb_animation.cc | 8 ++-- chrome/browser/ui/libgtk2ui/gtk2_ui.cc | 32 ++++++++-------- .../chrome_content_renderer_client.cc | 3 +- ui/base/resource/resource_bundle.cc | 5 --- ui/base/resource/resource_bundle.h | 7 ---- ui/base/theme_provider.h | 6 --- ui/views/widget/default_theme_provider.cc | 4 -- ui/views/widget/default_theme_provider.h | 1 - 30 files changed, 86 insertions(+), 138 deletions(-) diff --git a/chrome/browser/extensions/extension_icon_manager.cc b/chrome/browser/extensions/extension_icon_manager.cc index fea156f9cf4ccc..381db4d54e7a15 100644 --- a/chrome/browser/extensions/extension_icon_manager.cc +++ b/chrome/browser/extensions/extension_icon_manager.cc @@ -100,8 +100,8 @@ void ExtensionIconManager::OnImageLoaded(const gfx::Image& image, void ExtensionIconManager::EnsureDefaultIcon() { if (default_icon_.empty()) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - SkBitmap* src = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); - default_icon_ = ApplyTransforms(*src); + SkBitmap src = rb.GetImageNamed(IDR_EXTENSIONS_SECTION).AsBitmap(); + default_icon_ = ApplyTransforms(src); } } diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index c470ebd0a89ca0..73f930587a99a5 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -594,17 +594,6 @@ bool BrowserThemePack::GetDisplayProperty(int id, int* result) const { return false; } -SkBitmap* BrowserThemePack::GetBitmapNamed(int idr_id) const { - const gfx::Image* image = GetImageNamed(idr_id); - if (!image) - return NULL; - - // TODO(sail): This cast should be removed. Currently we use this const_cast - // to avoid changing the BrowserThemePack::GetBitmapNamed API. Once we - // switch to using gfx::Image everywhere this can be removed. - return const_cast(image->ToSkBitmap()); -} - const gfx::Image* BrowserThemePack::GetImageNamed(int idr_id) const { int prs_id = GetPersistentIDByIDR(idr_id); if (prs_id == -1) diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h index ea9ccc60fcd406..d15aeb592441e8 100644 --- a/chrome/browser/themes/browser_theme_pack.h +++ b/chrome/browser/themes/browser_theme_pack.h @@ -84,12 +84,6 @@ class BrowserThemePack : public base::RefCountedThreadSafe< bool GetColor(int id, SkColor* color) const; bool GetDisplayProperty(int id, int* result) const; - // Returns a bitmap if we have a custom image for |id|, otherwise NULL. Note - // that this is separate from HasCustomImage() which returns whether a custom - // image |id| was included in the unprocessed theme and is used as a proxy - // for making layout decisions in the interface. - SkBitmap* GetBitmapNamed(int id) const; - // Returns an image if we have a custom image for |id|, otherwise NULL. const gfx::Image* GetImageNamed(int id) const; diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc index 9249fe736a5cad..526e8d075fdccf 100644 --- a/chrome/browser/themes/theme_service.cc +++ b/chrome/browser/themes/theme_service.cc @@ -260,14 +260,6 @@ gfx::Image ThemeService::GetImageNamed(int id) const { return image ? *image : gfx::Image(); } -SkBitmap* ThemeService::GetBitmapNamed(int id) const { - gfx::Image image = GetImageNamed(id); - if (image.IsEmpty()) - return NULL; - - return const_cast(image.ToSkBitmap()); -} - gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { gfx::Image image = GetImageNamed(id); if (image.IsEmpty()) diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h index 980befcbe7e803..424b86b7d21ce1 100644 --- a/chrome/browser/themes/theme_service.h +++ b/chrome/browser/themes/theme_service.h @@ -164,7 +164,6 @@ class ThemeService : public base::NonThreadSafe, virtual gfx::Image GetImageNamed(int id) const; // Overridden from ui::ThemeProvider: - virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE; virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; virtual SkColor GetColor(int id) const OVERRIDE; virtual bool GetDisplayProperty(int id, int* result) const OVERRIDE; diff --git a/chrome/browser/themes/theme_service_gtk.cc b/chrome/browser/themes/theme_service_gtk.cc index 4cd16df22393ec..8338313889b54b 100644 --- a/chrome/browser/themes/theme_service_gtk.cc +++ b/chrome/browser/themes/theme_service_gtk.cc @@ -11,6 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/gtk_util.h" +#include "ui/gfx/image/image.h" GdkPixbuf* ThemeService::GetRTLEnabledPixbufNamed(int id) const { return GetPixbufImpl(id, true); @@ -26,8 +27,8 @@ GdkPixbuf* ThemeService::GetPixbufImpl(int id, bool rtl_enabled) const { if (pixbufs_iter != gdk_pixbufs_.end()) return pixbufs_iter->second; - SkBitmap* bitmap = GetBitmapNamed(id); - GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(*bitmap); + SkBitmap bitmap = GetImageNamed(id).AsBitmap(); + GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap); // We loaded successfully. Cache the pixbuf. if (pixbuf) { diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm index cbb7bc87610d85..f5b99fdaeb2f44 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm @@ -191,7 +191,6 @@ - (void)setDragDataNode:(const BookmarkNode*)node { FakeTheme(NSColor* color) : color_(color) {} scoped_nsobject color_; - virtual SkBitmap* GetBitmapNamed(int id) const { return NULL; } virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const { return NULL; } virtual SkColor GetColor(int id) const { return SkColor(); } virtual bool GetDisplayProperty(int id, int* result) const { return false; } diff --git a/chrome/browser/ui/cocoa/download/background_theme.h b/chrome/browser/ui/cocoa/download/background_theme.h index 224f2eb6619e8a..7751965a2af3c8 100644 --- a/chrome/browser/ui/cocoa/download/background_theme.h +++ b/chrome/browser/ui/cocoa/download/background_theme.h @@ -16,7 +16,6 @@ class BackgroundTheme : public ui::ThemeProvider { virtual ~BackgroundTheme(); // Overridden from ui::ThemeProvider: - virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE; virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; virtual SkColor GetColor(int id) const OVERRIDE; virtual bool GetDisplayProperty(int id, int* result) const OVERRIDE; diff --git a/chrome/browser/ui/cocoa/download/background_theme.mm b/chrome/browser/ui/cocoa/download/background_theme.mm index dd7b16f429f8e4..1d596ccf267a86 100644 --- a/chrome/browser/ui/cocoa/download/background_theme.mm +++ b/chrome/browser/ui/cocoa/download/background_theme.mm @@ -27,10 +27,6 @@ BackgroundTheme::~BackgroundTheme() {} -SkBitmap* BackgroundTheme::GetBitmapNamed(int id) const { - return NULL; -} - gfx::ImageSkia* BackgroundTheme::GetImageSkiaNamed(int id) const { return NULL; } diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index d779b7f13e4b72..4010e9e0c21440 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -94,13 +94,13 @@ virtual void OnImageLoaded(const gfx::Image& image, ResourceBundle& rb = ResourceBundle::GetSharedInstance(); // Fall back on the default extension icon on failure. - const SkBitmap* icon; + const gfx::ImageSkia* icon; if (image.IsEmpty()) - icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); + icon = rb.GetImageSkiaNamed(IDR_EXTENSIONS_SECTION); else - icon = image.ToSkBitmap(); + icon = image.ToImageSkia(); - SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); + gfx::ImageSkia* drop_image = rb.GetImageSkiaNamed(IDR_APP_DROPARROW); const int image_size = extension_misc::EXTENSION_ICON_BITTY; scoped_ptr canvas( diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc index f675b865c5c607..ce9a3ca88519fc 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.cc +++ b/chrome/browser/ui/gtk/browser_titlebar.cc @@ -550,8 +550,8 @@ void BrowserTitlebar::GetButtonResources(const std::string& button_name, void BrowserTitlebar::UpdateButtonBackground(CustomDrawButton* button) { SkColor color = theme_service_->GetColor( ThemeService::COLOR_BUTTON_BACKGROUND); - SkBitmap* background = - theme_service_->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND); + SkBitmap background = theme_service_->GetImageNamed( + IDR_THEME_WINDOW_CONTROL_BACKGROUND).AsBitmap(); // TODO(erg): For now, we just use a completely black mask and we can get // away with this in the short term because our buttons are rectangles. We @@ -564,7 +564,7 @@ void BrowserTitlebar::UpdateButtonBackground(CustomDrawButton* button) { mask.allocPixels(); mask.eraseColor(SK_ColorBLACK); - button->SetBackground(color, background, &mask); + button->SetBackground(color, background, mask); } void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index 383b2a1706292e..0579c037ae3b7a 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -694,7 +694,7 @@ gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, gtk_widget_get_allocation(sender, &allocation); // Draw the chrome app menu icon onto the canvas. - const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); + const gfx::ImageSkia* badge = theme_service_->GetImageSkiaNamed(resource_id); gfx::CanvasSkiaPaint canvas(expose, false); int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); int y_offset = 0; diff --git a/chrome/browser/ui/gtk/custom_button.cc b/chrome/browser/ui/gtk/custom_button.cc index 8a98c042ce9b8e..2b41351df5ae1d 100644 --- a/chrome/browser/ui/gtk/custom_button.cc +++ b/chrome/browser/ui/gtk/custom_button.cc @@ -139,14 +139,15 @@ gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, } void CustomDrawButtonBase::SetBackground(SkColor color, - SkBitmap* image, SkBitmap* mask) { - if (!image || !mask) { + const SkBitmap& image, + const SkBitmap& mask) { + if (image.isNull() || mask.isNull()) { if (background_image_->valid()) { background_image_->UsePixbuf(NULL); } } else { SkBitmap img = - SkBitmapOperations::CreateButtonBackground(color, *image, *mask); + SkBitmapOperations::CreateButtonBackground(color, image, mask); GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(img); background_image_->UsePixbuf(pixbuf); @@ -336,7 +337,8 @@ void CustomDrawButton::UnsetPaintOverride() { } void CustomDrawButton::SetBackground(SkColor color, - SkBitmap* image, SkBitmap* mask) { + const SkBitmap& image, + const SkBitmap& mask) { button_base_.SetBackground(color, image, mask); } diff --git a/chrome/browser/ui/gtk/custom_button.h b/chrome/browser/ui/gtk/custom_button.h index 62018df0142c9b..cf9b07606f821e 100644 --- a/chrome/browser/ui/gtk/custom_button.h +++ b/chrome/browser/ui/gtk/custom_button.h @@ -57,7 +57,9 @@ class CustomDrawButtonBase : public content::NotificationObserver { int paint_override() const { return paint_override_; } // Set the background details. - void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); + void SetBackground(SkColor color, + const SkBitmap& image, + const SkBitmap& mask); // Provide content::NotificationObserver implementation. virtual void Observe(int type, @@ -186,7 +188,9 @@ class CustomDrawButton : public content::NotificationObserver { void UnsetPaintOverride(); // Set the background details. - void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); + void SetBackground(SkColor color, + const SkBitmap& image, + const SkBitmap& mask); // content::NotificationObserver implementation. virtual void Observe(int type, diff --git a/chrome/browser/ui/gtk/download/download_shelf_gtk.cc b/chrome/browser/ui/gtk/download/download_shelf_gtk.cc index ebdb1b5c61b240..054a9dccf5046e 100644 --- a/chrome/browser/ui/gtk/download/download_shelf_gtk.cc +++ b/chrome/browser/ui/gtk/download/download_shelf_gtk.cc @@ -25,6 +25,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "grit/ui_resources.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -267,8 +268,8 @@ void DownloadShelfGtk::Observe(int type, ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetBackground( theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), - rb.GetBitmapNamed(IDR_CLOSE_BAR), - rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); + rb.GetImageNamed(IDR_CLOSE_BAR).AsBitmap(), + rb.GetImageNamed(IDR_CLOSE_BAR_MASK).AsBitmap()); } } diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc index 0b49418960268e..7895cfcec6dfed 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.cc +++ b/chrome/browser/ui/gtk/find_bar_gtk.cc @@ -541,8 +541,8 @@ void FindBarGtk::Observe(int type, ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetBackground( theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), - rb.GetBitmapNamed(IDR_CLOSE_BAR), - rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); + rb.GetImageNamed(IDR_CLOSE_BAR).AsBitmap(), + rb.GetImageNamed(IDR_CLOSE_BAR_MASK).AsBitmap()); } UpdateMatchLabelAppearance(match_label_failure_); diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index 2519e3fb1f7fa5..814c53584a7dc8 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service.cc @@ -202,7 +202,7 @@ void BuildIconFromIDRWithColor(int id, GtkIconSet* icon_set) { SkColor color = gfx::GdkColorToSkColor(style->fg[state]); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - SkBitmap original = *rb.GetBitmapNamed(id); + SkBitmap original = rb.GetImageNamed(id).AsBitmap(); SkBitmap fill_color; fill_color.setConfig(SkBitmap::kARGB_8888_Config, @@ -296,13 +296,6 @@ void GtkThemeService::Init(Profile* profile) { ThemeService::Init(profile); } -SkBitmap* GtkThemeService::GetBitmapNamed(int id) const { - // TODO(erg): Remove this const cast. The gfx::Image interface returns its - // images const. GetBitmapNamed() also should but doesn't and has a million - // callsites. - return const_cast(GetImageNamed(id).ToSkBitmap()); -} - gfx::ImageSkia* GtkThemeService::GetImageSkiaNamed(int id) const { // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns // its images const. GetImageSkiaNamed() also should but has many callsites. @@ -1050,9 +1043,9 @@ SkBitmap GtkThemeService::GenerateFrameImage( } SkBitmap GtkThemeService::GenerateTabImage(int base_id) const { - SkBitmap* base_image = GetBitmapNamed(base_id); + SkBitmap base_image = GetImageNamed(base_id).AsBitmap(); SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( - *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); + base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); return SkBitmapOperations::CreateTiledBitmap( bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); } @@ -1062,7 +1055,7 @@ SkBitmap GtkThemeService::GenerateTintedIcon( const color_utils::HSL& tint) const { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); return SkBitmapOperations::CreateHSLShiftedBitmap( - *rb.GetBitmapNamed(base_id), tint); + rb.GetImageNamed(base_id).AsBitmap(), tint); } void GtkThemeService::GetNormalButtonTintHSL( diff --git a/chrome/browser/ui/gtk/gtk_theme_service.h b/chrome/browser/ui/gtk/gtk_theme_service.h index 5d2b9ce621c7f2..bf2576b79d03e9 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service.h +++ b/chrome/browser/ui/gtk/gtk_theme_service.h @@ -67,7 +67,6 @@ class GtkThemeService : public ThemeService { // Sets that we aren't using the system theme, then calls // ThemeService's implementation. virtual void Init(Profile* profile) OVERRIDE; - virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE; virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; virtual gfx::Image GetImageNamed(int id) const OVERRIDE; virtual SkColor GetColor(int id) const OVERRIDE; @@ -295,7 +294,7 @@ class GtkThemeService : public ThemeService { GtkIconSet* fullscreen_icon_set_; // Image cache of lazily created images, created when requested by - // GetBitmapNamed(). + // GetImageNamed(). mutable ImageCache gtk_images_; PrefChangeRegistrar registrar_; diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc index d8896fc6079901..90c0c56070f105 100644 --- a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc +++ b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc @@ -283,9 +283,10 @@ void BalloonViewImpl::Show(Balloon* balloon) { IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE)); - close_button_->SetBackground(SK_ColorBLACK, - rb.GetBitmapNamed(IDR_TAB_CLOSE), - rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); + close_button_->SetBackground( + SK_ColorBLACK, + rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(), + rb.GetImageNamed(IDR_TAB_CLOSE_MASK).AsBitmap()); gtk_widget_set_tooltip_text(close_button_->widget(), dismiss_text.c_str()); g_signal_connect(close_button_->widget(), "clicked", G_CALLBACK(OnCloseButtonThunk), this); diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc index aead804a616a50..568bd51690eec2 100644 --- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc @@ -112,23 +112,23 @@ TabRendererGtk::LoadingAnimation::Data::Data( GtkThemeService* theme_service) { // The loading animation image is a strip of states. Each state must be // square, so the height must divide the width evenly. - SkBitmap* loading_animation_frames = - theme_service->GetBitmapNamed(IDR_THROBBER); - DCHECK(loading_animation_frames); - DCHECK_EQ(loading_animation_frames->width() % - loading_animation_frames->height(), 0); + SkBitmap loading_animation_frames = + theme_service->GetImageNamed(IDR_THROBBER).AsBitmap(); + DCHECK(!loading_animation_frames.isNull()); + DCHECK_EQ(loading_animation_frames.width() % + loading_animation_frames.height(), 0); loading_animation_frame_count = - loading_animation_frames->width() / - loading_animation_frames->height(); - - SkBitmap* waiting_animation_frames = - theme_service->GetBitmapNamed(IDR_THROBBER_WAITING); - DCHECK(waiting_animation_frames); - DCHECK_EQ(waiting_animation_frames->width() % - waiting_animation_frames->height(), 0); + loading_animation_frames.width() / + loading_animation_frames.height(); + + SkBitmap waiting_animation_frames = + theme_service->GetImageNamed(IDR_THROBBER_WAITING).AsBitmap(); + DCHECK(!waiting_animation_frames.isNull()); + DCHECK_EQ(waiting_animation_frames.width() % + waiting_animation_frames.height(), 0); waiting_animation_frame_count = - waiting_animation_frames->width() / - waiting_animation_frames->height(); + waiting_animation_frames.width() / + waiting_animation_frames.height(); waiting_to_loading_frame_count_ratio = waiting_animation_frame_count / @@ -394,8 +394,8 @@ void TabRendererGtk::UpdateData(WebContents* contents, // will eventually be chromium-themable and this code will go away. data_.is_default_favicon = (data_.favicon.pixelRef() == - ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_DEFAULT_FAVICON)->pixelRef()); + ui::ResourceBundle::GetSharedInstance().GetImageNamed( + IDR_DEFAULT_FAVICON).AsBitmap().pixelRef()); } // Loading state also involves whether we show the favicon, since that's where @@ -759,8 +759,8 @@ void TabRendererGtk::Layout() { close_button_color_ = tab_text_color; ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetBackground(close_button_color_, - rb.GetBitmapNamed(IDR_TAB_CLOSE), - rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); + rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(), + rb.GetImageNamed(IDR_TAB_CLOSE_MASK).AsBitmap()); } } } else { diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc index bafceafdb001d6..52742ce33177d6 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc @@ -2269,8 +2269,9 @@ CustomDrawButton* TabStripGtk::MakeNewTabButton() { void TabStripGtk::SetNewTabButtonBackground() { SkColor color = theme_service_->GetColor( ThemeService::COLOR_BUTTON_BACKGROUND); - SkBitmap* background = theme_service_->GetBitmapNamed( - IDR_THEME_WINDOW_CONTROL_BACKGROUND); - SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); + SkBitmap background = theme_service_->GetImageNamed( + IDR_THEME_WINDOW_CONTROL_BACKGROUND).AsBitmap(); + SkBitmap mask = theme_service_->GetImageNamed( + IDR_NEWTAB_BUTTON_MASK).AsBitmap(); newtab_button_->SetBackground(color, background, mask); } diff --git a/chrome/browser/ui/gtk/task_manager_gtk.cc b/chrome/browser/ui/gtk/task_manager_gtk.cc index ebd5c2a55e82a2..c2f5567742e7c7 100644 --- a/chrome/browser/ui/gtk/task_manager_gtk.cc +++ b/chrome/browser/ui/gtk/task_manager_gtk.cc @@ -747,8 +747,8 @@ std::string TaskManagerGtk::GetModelText(int row, int col_id) { GdkPixbuf* TaskManagerGtk::GetModelIcon(int row) { SkBitmap icon = *model_->GetResourceIcon(row).bitmap(); if (icon.pixelRef() == - ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_DEFAULT_FAVICON)->pixelRef()) { + ui::ResourceBundle::GetSharedInstance().GetImageNamed( + IDR_DEFAULT_FAVICON).AsBitmap().pixelRef()) { return static_cast(g_object_ref( GtkThemeService::GetDefaultFavicon(true).ToGdkPixbuf())); } diff --git a/chrome/browser/ui/gtk/titlebar_throb_animation.cc b/chrome/browser/ui/gtk/titlebar_throb_animation.cc index 4b90974cde44d8..538aa847a57b95 100644 --- a/chrome/browser/ui/gtk/titlebar_throb_animation.cc +++ b/chrome/browser/ui/gtk/titlebar_throb_animation.cc @@ -18,16 +18,16 @@ std::vector* g_throbber_waiting_frames = NULL; // square GdkPixbufs that get stored in |frames|. void MakeThrobberFrames(int resource_id, std::vector* frames) { ui::ResourceBundle &rb = ui::ResourceBundle::GetSharedInstance(); - SkBitmap* frame_strip = rb.GetBitmapNamed(resource_id); + SkBitmap frame_strip = rb.GetImageNamed(resource_id).AsBitmap(); // Each frame of the animation is a square, so we use the height as the // frame size. - int frame_size = frame_strip->height(); - size_t num_frames = frame_strip->width() / frame_size; + int frame_size = frame_strip.height(); + size_t num_frames = frame_strip.width() / frame_size; // Make a separate GdkPixbuf for each frame of the animation. for (size_t i = 0; i < num_frames; ++i) { - SkBitmap frame = SkBitmapOperations::CreateTiledBitmap(*frame_strip, + SkBitmap frame = SkBitmapOperations::CreateTiledBitmap(frame_strip, i * frame_size, 0, frame_size, frame_size); frames->push_back(gfx::GdkPixbufFromSkBitmap(frame)); } diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc index 874ccbb833e76f..2886e462de182a 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc @@ -791,7 +791,7 @@ SkBitmap Gtk2UI::GenerateTintedIcon( const color_utils::HSL& tint) const { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); return SkBitmapOperations::CreateHSLShiftedBitmap( - *rb.GetBitmapNamed(base_id), tint); + rb.GetImageNamed(base_id).AsBitmap(), tint); } SkBitmap Gtk2UI::GenerateGTKIcon(int base_id) const { @@ -807,13 +807,13 @@ SkBitmap Gtk2UI::GenerateGTKIcon(int base_id) const { DCHECK(stock_id); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - SkBitmap* default_bitmap = rb.GetBitmapNamed(base_id); + SkBitmap default_bitmap = rb.GetImageNamed(base_id).AsBitmap(); gtk_widget_ensure_style(fake_frame_); GtkStyle* style = gtk_widget_get_style(fake_frame_); GtkIconSet* icon_set = gtk_style_lookup_icon_set(style, stock_id); if (!icon_set) - return *default_bitmap; + return default_bitmap; // Ask GTK to render the icon to a buffer, which we will steal from. GdkPixbuf* gdk_icon = gtk_icon_set_render_icon( @@ -829,13 +829,13 @@ SkBitmap Gtk2UI::GenerateGTKIcon(int base_id) const { // This can theoretically happen if an icon theme doesn't provide a // specific image. This should realistically never happen, but I bet there // are some theme authors who don't reliably provide all icons. - return *default_bitmap; + return default_bitmap; } SkBitmap retval; retval.setConfig(SkBitmap::kARGB_8888_Config, - default_bitmap->width(), - default_bitmap->height()); + default_bitmap.width(), + default_bitmap.height()); retval.allocPixels(); retval.eraseColor(0); @@ -846,25 +846,25 @@ SkBitmap Gtk2UI::GenerateGTKIcon(int base_id) const { if (gtk_state == GTK_STATE_ACTIVE || gtk_state == GTK_STATE_PRELIGHT) { SkBitmap border = DrawGtkButtonBorder(gtk_state, - default_bitmap->width(), - default_bitmap->height()); + default_bitmap.width(), + default_bitmap.height()); canvas.drawBitmap(border, 0, 0); } canvas.drawBitmap(icon, - (default_bitmap->width() / 2) - (icon.width() / 2), - (default_bitmap->height() / 2) - (icon.height() / 2)); + (default_bitmap.width() / 2) - (icon.width() / 2), + (default_bitmap.height() / 2) - (icon.height() / 2)); return retval; } SkBitmap Gtk2UI::GenerateWrenchIcon(int base_id) const { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - SkBitmap* default_bitmap = rb.GetBitmapNamed(IDR_TOOLS); + SkBitmap default_bitmap = rb.GetImageNamed(IDR_TOOLS).AsBitmap(); // Part 1: Tint the wrench icon according to the button tint. SkBitmap shifted = SkBitmapOperations::CreateHSLShiftedBitmap( - *default_bitmap, button_tint_); + default_bitmap, button_tint_); // The unhighlighted icon doesn't need to have a border composed onto it. if (base_id == IDR_TOOLS) @@ -872,16 +872,16 @@ SkBitmap Gtk2UI::GenerateWrenchIcon(int base_id) const { SkBitmap retval; retval.setConfig(SkBitmap::kARGB_8888_Config, - default_bitmap->width(), - default_bitmap->height()); + default_bitmap.width(), + default_bitmap.height()); retval.allocPixels(); retval.eraseColor(0); SkCanvas canvas(retval); SkBitmap border = DrawGtkButtonBorder( base_id == IDR_TOOLS_H ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE, - default_bitmap->width(), - default_bitmap->height()); + default_bitmap.width(), + default_bitmap.height()); canvas.drawBitmap(border, 0, 0); canvas.drawBitmap(shifted, 0, 0); diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 003ac3edfe58d2..4b35e07134ae26 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -294,7 +294,8 @@ void ChromeContentRendererClient::SetNumberOfViews(int number_of_views) { } SkBitmap* ChromeContentRendererClient::GetSadPluginBitmap() { - return ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SAD_PLUGIN); + return const_cast(ResourceBundle::GetSharedInstance(). + GetImageNamed(IDR_SAD_PLUGIN).ToSkBitmap()); } std::string ChromeContentRendererClient::GetDefaultEncoding() { diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index f5fe3df4d5057a..5a77c12a1d8516 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -318,11 +318,6 @@ std::string ResourceBundle::ReloadLocaleResources( return LoadLocaleResources(pref_locale); } -SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) { - const SkBitmap* bitmap = GetImageNamed(resource_id).ToSkBitmap(); - return const_cast(bitmap); -} - gfx::ImageSkia* ResourceBundle::GetImageSkiaNamed(int resource_id) { const gfx::ImageSkia* image = GetImageNamed(resource_id).ToImageSkia(); return const_cast(image); diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h index fcc07dbe81c8f4..ef22f675357d99 100644 --- a/ui/base/resource/resource_bundle.h +++ b/ui/base/resource/resource_bundle.h @@ -165,13 +165,6 @@ class UI_EXPORT ResourceBundle { // on another thread. std::string ReloadLocaleResources(const std::string& pref_locale); - // Gets the bitmap with the specified resource_id from the current module - // data. Returns a pointer to a shared instance of the SkBitmap. This shared - // bitmap is owned by the resource bundle and should not be freed. - // - // !! THIS IS DEPRECATED. PLEASE USE THE METHOD BELOW. !! - SkBitmap* GetBitmapNamed(int resource_id); - // Gets image with the specified resource_id from the current module data. // Returns a pointer to a shared instance of gfx::ImageSkia. This shared // instance is owned by the resource bundle and should not be freed. diff --git a/ui/base/theme_provider.h b/ui/base/theme_provider.h index f5d1b05edfda12..007094f88cab12 100644 --- a/ui/base/theme_provider.h +++ b/ui/base/theme_provider.h @@ -50,12 +50,6 @@ class UI_EXPORT ThemeProvider { public: virtual ~ThemeProvider(); - // Get the bitmap specified by |id|. An implementation of ThemeProvider should - // have its own source of ids (e.g. an enum, or external resource bundle). - // TODO(pkotwicz): Get rid of GetBitmapNamed once all code uses - // GetImageSkiaNamed. - virtual SkBitmap* GetBitmapNamed(int id) const = 0; - // Get the image specified by |id|. An implementation of ThemeProvider should // have its own source of ids (e.g. an enum, or external resource bundle). virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const = 0; diff --git a/ui/views/widget/default_theme_provider.cc b/ui/views/widget/default_theme_provider.cc index 3cbf6fe0805ec7..a04b5bf135fc81 100644 --- a/ui/views/widget/default_theme_provider.cc +++ b/ui/views/widget/default_theme_provider.cc @@ -17,10 +17,6 @@ DefaultThemeProvider::DefaultThemeProvider() {} DefaultThemeProvider::~DefaultThemeProvider() {} -SkBitmap* DefaultThemeProvider::GetBitmapNamed(int id) const { - return ResourceBundle::GetSharedInstance().GetBitmapNamed(id); -} - gfx::ImageSkia* DefaultThemeProvider::GetImageSkiaNamed(int id) const { return ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); } diff --git a/ui/views/widget/default_theme_provider.h b/ui/views/widget/default_theme_provider.h index d69f37eec224f4..f4befb08ee59b7 100644 --- a/ui/views/widget/default_theme_provider.h +++ b/ui/views/widget/default_theme_provider.h @@ -25,7 +25,6 @@ class VIEWS_EXPORT DefaultThemeProvider : public ui::ThemeProvider { virtual ~DefaultThemeProvider(); // Overridden from ui::ThemeProvider: - virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE; virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; virtual SkColor GetColor(int id) const OVERRIDE; virtual bool GetDisplayProperty(int id, int* result) const OVERRIDE;