summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-03 06:07:24 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-03 06:07:24 +0000
commitbc091771a0ebd4eaedde7789a67f624b10e19b8c (patch)
tree7d0e45424376ed913ae8ad1b52d87f07ad3425af
parentb6bcd8c0995b6c60a515db642a92fea7808542e9 (diff)
downloadchromium_src-bc091771a0ebd4eaedde7789a67f624b10e19b8c.zip
chromium_src-bc091771a0ebd4eaedde7789a67f624b10e19b8c.tar.gz
chromium_src-bc091771a0ebd4eaedde7789a67f624b10e19b8c.tar.bz2
Remove GetBitmapNamed() part 1.
This CL changes ThemeService::GetImageNamed() to return a gfx::Image instead of a pointer to a gfx::Image. BUG=153180 Test=Compiles Review URL: https://chromiumcodereview.appspot.com/11018006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159855 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/themes/theme_service.cc16
-rw-r--r--chrome/browser/themes/theme_service.h2
-rw-r--r--chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc7
-rw-r--r--chrome/browser/ui/gtk/browser_toolbar_gtk.cc7
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc4
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.cc10
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.h2
-rw-r--r--chrome/browser/ui/gtk/gtk_util.cc4
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc10
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc4
-rw-r--r--chrome/browser/ui/gtk/panels/panel_gtk.cc36
-rw-r--r--chrome/browser/ui/gtk/panels/panel_gtk.h6
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc24
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h2
-rw-r--r--chrome/browser/ui/gtk/throbber_gtk.cc9
-rw-r--r--chrome/browser/ui/gtk/throbber_gtk.h2
16 files changed, 72 insertions, 73 deletions
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 0d0c170..9249fe7 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -240,7 +240,7 @@ void ThemeService::Init(Profile* profile) {
theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
}
-const gfx::Image* ThemeService::GetImageNamed(int id) const {
+gfx::Image ThemeService::GetImageNamed(int id) const {
DCHECK(CalledOnValidThread());
const gfx::Image* image = NULL;
@@ -257,24 +257,24 @@ const gfx::Image* ThemeService::GetImageNamed(int id) const {
if (!image)
image = &rb_.GetNativeImageNamed(id);
- return image;
+ return image ? *image : gfx::Image();
}
SkBitmap* ThemeService::GetBitmapNamed(int id) const {
- const gfx::Image* image = GetImageNamed(id);
- if (!image)
+ gfx::Image image = GetImageNamed(id);
+ if (image.IsEmpty())
return NULL;
- return const_cast<SkBitmap*>(image->ToSkBitmap());
+ return const_cast<SkBitmap*>(image.ToSkBitmap());
}
gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const {
- const gfx::Image* image = GetImageNamed(id);
- if (!image)
+ gfx::Image image = GetImageNamed(id);
+ if (image.IsEmpty())
return NULL;
// TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns
// its images const. GetImageSkiaNamed() also should but has many callsites.
- return const_cast<gfx::ImageSkia*>(image->ToImageSkia());
+ return const_cast<gfx::ImageSkia*>(image.ToImageSkia());
}
SkColor ThemeService::GetColor(int id) const {
diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h
index 7c029b0..980befc 100644
--- a/chrome/browser/themes/theme_service.h
+++ b/chrome/browser/themes/theme_service.h
@@ -161,7 +161,7 @@ class ThemeService : public base::NonThreadSafe,
//
// TODO(erg): Make this part of the ui::ThemeProvider and the main way to get
// theme properties out of the theme provider since it's cross platform.
- virtual const gfx::Image* GetImageNamed(int id) const;
+ virtual gfx::Image GetImageNamed(int id) const;
// Overridden from ui::ThemeProvider:
virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE;
diff --git a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
index e7a13e0..4a777c9 100644
--- a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
+++ b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
@@ -19,6 +19,7 @@
#include "ui/base/gtk/gtk_compat.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/gtk/gtk_windowing.h"
+#include "ui/gfx/image/image.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/pango_util.h"
#include "ui/gfx/rect.h"
@@ -333,7 +334,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
if (CanDelete(autofill_unique_ids()[index])) {
x_align_left += is_rtl ? 0 : -kDeleteIconWidth;
- const gfx::Image* delete_icon;
+ gfx::Image delete_icon;
if (static_cast<int>(index) == selected_line() && delete_icon_selected_)
delete_icon = theme_service_->GetImageNamed(IDR_CLOSE_BAR_H);
else
@@ -345,7 +346,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
gtk_util::DrawFullImage(
cairo_context,
window_,
- *delete_icon,
+ delete_icon,
x_align_left,
entry_rect.y() + ((kRowHeight - kDeleteIconHeight) / 2));
cairo_restore(cairo_context);
@@ -365,7 +366,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
cairo_save(cairo_context);
gtk_util::DrawFullImage(cairo_context,
window_,
- *theme_service_->GetImageNamed(icon),
+ theme_service_->GetImageNamed(icon),
x_align_left,
icon_y);
cairo_restore(cairo_context);
diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
index cbe4a27..383b2a1 100644
--- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
@@ -527,9 +527,8 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget,
area = area.Subtract(right).Subtract(left);
}
- const gfx::Image* background =
- theme_service_->GetImageNamed(IDR_THEME_TOOLBAR);
- background->ToCairo()->SetSource(
+ gfx::Image background = theme_service_->GetImageNamed(IDR_THEME_TOOLBAR);
+ background.ToCairo()->SetSource(
cr, widget, tabstrip_origin.x(), tabstrip_origin.y());
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr, area.x(), area.y(), area.width(), area.height());
@@ -573,7 +572,7 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget,
// Draw the background. CAIRO_OPERATOR_IN uses the existing pixel data as
// an alpha mask.
- background->ToCairo()->SetSource(copy_cr, widget,
+ background.ToCairo()->SetSource(copy_cr, widget,
tabstrip_origin.x(), tabstrip_origin.y());
cairo_set_operator(copy_cr, CAIRO_OPERATOR_IN);
cairo_pattern_set_extend(cairo_get_source(copy_cr), CAIRO_EXTEND_REPEAT);
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index c9f419a..5a81c93 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -539,7 +539,7 @@ void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr,
int image_name = GetThemeFrameResource();
gfx::CairoCachedSurface* surface = theme_provider->GetImageNamed(
- image_name)->ToCairo();
+ image_name).ToCairo();
if (event->area.y < surface->Height()) {
surface->SetSource(cr, widget, 0, GetVerticalOffset());
@@ -554,7 +554,7 @@ void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr,
!browser()->profile()->IsOffTheRecord()) {
gfx::CairoCachedSurface* theme_overlay = theme_provider->GetImageNamed(
IsActive() ? IDR_THEME_FRAME_OVERLAY
- : IDR_THEME_FRAME_OVERLAY_INACTIVE)->ToCairo();
+ : IDR_THEME_FRAME_OVERLAY_INACTIVE).ToCairo();
theme_overlay->SetSource(cr, widget, 0, GetVerticalOffset());
cairo_paint(cr);
}
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc
index e766a72..2519e3f 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.cc
+++ b/chrome/browser/ui/gtk/gtk_theme_service.cc
@@ -300,25 +300,25 @@ 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<SkBitmap*>(GetImageNamed(id)->ToSkBitmap());
+ return const_cast<SkBitmap*>(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.
- return const_cast<gfx::ImageSkia*>(GetImageNamed(id)->ToImageSkia());
+ return const_cast<gfx::ImageSkia*>(GetImageNamed(id).ToImageSkia());
}
-const gfx::Image* GtkThemeService::GetImageNamed(int id) const {
+gfx::Image GtkThemeService::GetImageNamed(int id) const {
// Try to get our cached version:
ImageCache::const_iterator it = gtk_images_.find(id);
if (it != gtk_images_.end())
- return it->second;
+ return *it->second;
if (use_gtk_ && IsOverridableImage(id)) {
gfx::Image* image = new gfx::Image(GenerateGtkThemeBitmap(id));
gtk_images_[id] = image;
- return image;
+ return *image;
}
return ThemeService::GetImageNamed(id);
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.h b/chrome/browser/ui/gtk/gtk_theme_service.h
index 52df2aa..5d2b9ce 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.h
+++ b/chrome/browser/ui/gtk/gtk_theme_service.h
@@ -69,7 +69,7 @@ class GtkThemeService : public ThemeService {
virtual void Init(Profile* profile) OVERRIDE;
virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE;
virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE;
- virtual const gfx::Image* GetImageNamed(int id) const OVERRIDE;
+ virtual gfx::Image GetImageNamed(int id) const OVERRIDE;
virtual SkColor GetColor(int id) const OVERRIDE;
virtual bool HasCustomImage(int id) const OVERRIDE;
virtual void SetTheme(const extensions::Extension* extension) OVERRIDE;
diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc
index 66ba633..1517934 100644
--- a/chrome/browser/ui/gtk/gtk_util.cc
+++ b/chrome/browser/ui/gtk/gtk_util.cc
@@ -728,9 +728,9 @@ void DrawThemedToolbarBackground(GtkWidget* widget,
// The toolbar is supposed to blend in with the active tab, so we have to pass
// coordinates for the IDR_THEME_TOOLBAR bitmap relative to the top of the
// tab strip.
- const gfx::Image* background =
+ const gfx::Image background =
theme_service->GetImageNamed(IDR_THEME_TOOLBAR);
- background->ToCairo()->SetSource(cr, widget,
+ background.ToCairo()->SetSource(cr, widget,
tabstrip_origin.x(), tabstrip_origin.y());
// We tile the toolbar background in both directions.
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 1370c31..9732e23 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -235,7 +235,7 @@ void ContentSettingImageViewGtk::Update(
gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
GtkThemeService::GetFrom(parent_->browser()->profile())->GetImageNamed(
- content_setting_image_model_->get_icon())->ToGdkPixbuf());
+ content_setting_image_model_->get_icon()).ToGdkPixbuf());
gtk_widget_set_tooltip_text(widget(),
content_setting_image_model_->get_tooltip().c_str());
@@ -809,7 +809,7 @@ GtkWidget* LocationBarViewGtk::CreateIconButton(
gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) {
*image = image_id ?
gtk_image_new_from_pixbuf(
- theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) :
+ theme_service_->GetImageNamed(image_id).ToGdkPixbuf()) :
gtk_image_new();
GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
@@ -1239,7 +1239,7 @@ void LocationBarViewGtk::UpdateSiteTypeArea() {
int resource_id = location_entry_->GetIcon();
gtk_image_set_from_pixbuf(
GTK_IMAGE(location_icon_image_),
- theme_service_->GetImageNamed(resource_id)->ToGdkPixbuf());
+ theme_service_->GetImageNamed(resource_id).ToGdkPixbuf());
if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
if (!gtk_util::IsActingAsRoundedWindow(site_type_event_box_)) {
@@ -1584,7 +1584,7 @@ void LocationBarViewGtk::UpdateZoomIcon() {
const int zoom_resource = zoom_controller->GetResourceForZoomLevel();
gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_),
- theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf());
+ theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf());
string16 tooltip = l10n_util::GetStringFUTF16Int(
IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent());
@@ -1609,7 +1609,7 @@ void LocationBarViewGtk::UpdateStarIcon() {
gtk_widget_show_all(star_.get());
int id = starred_ ? IDR_STAR_LIT : IDR_STAR;
gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_),
- theme_service_->GetImageNamed(id)->ToGdkPixbuf());
+ theme_service_->GetImageNamed(id).ToGdkPixbuf());
} else {
gtk_widget_hide_all(star_.get());
}
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
index 96cc14d..cf1c4ce 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
@@ -519,7 +519,7 @@ gfx::Image OmniboxPopupViewGtk::IconForMatch(
}
}
- return *theme_service_->GetImageNamed(icon);
+ return theme_service_->GetImageNamed(icon);
}
void OmniboxPopupViewGtk::GetVisibleMatchForInput(
@@ -718,7 +718,7 @@ gboolean OmniboxPopupViewGtk::HandleExpose(GtkWidget* widget,
kIconLeftPadding;
// Draw the icon for this result.
gtk_util::DrawFullImage(cr, widget,
- *theme_service_->GetImageNamed(
+ theme_service_->GetImageNamed(
is_selected ? IDR_OMNIBOX_TTS_DARK :
IDR_OMNIBOX_TTS),
icon_start_x, line_rect.y() + kIconTopPadding);
diff --git a/chrome/browser/ui/gtk/panels/panel_gtk.cc b/chrome/browser/ui/gtk/panels/panel_gtk.cc
index 268b6fa..359cc3d 100644
--- a/chrome/browser/ui/gtk/panels/panel_gtk.cc
+++ b/chrome/browser/ui/gtk/panels/panel_gtk.cc
@@ -143,36 +143,36 @@ const AcceleratorGtkMap& GetAcceleratorTable() {
return accelerator_table;
}
-gfx::Image* CreateImageForColor(SkColor color) {
+gfx::Image CreateImageForColor(SkColor color) {
gfx::Canvas canvas(gfx::Size(1, 1), ui::SCALE_FACTOR_100P, true);
canvas.DrawColor(color);
- return new gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep()));
+ return gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep()));
}
-const gfx::Image* GetActiveBackgroundDefaultImage() {
- static gfx::Image* image = NULL;
- if (!image)
+const gfx::Image GetActiveBackgroundDefaultImage() {
+ CR_DEFINE_STATIC_LOCAL(gfx::Image, image, ());
+ if (image.IsEmpty())
image = CreateImageForColor(kActiveBackgroundDefaultColor);
return image;
}
-const gfx::Image* GetInactiveBackgroundDefaultImage() {
- static gfx::Image* image = NULL;
- if (!image)
+gfx::Image GetInactiveBackgroundDefaultImage() {
+ CR_DEFINE_STATIC_LOCAL(gfx::Image, image, ());
+ if (image.IsEmpty())
image = CreateImageForColor(kInactiveBackgroundDefaultColor);
return image;
}
-const gfx::Image* GetAttentionBackgroundDefaultImage() {
- static gfx::Image* image = NULL;
- if (!image)
+gfx::Image GetAttentionBackgroundDefaultImage() {
+ CR_DEFINE_STATIC_LOCAL(gfx::Image, image, ());
+ if (image.IsEmpty())
image = CreateImageForColor(kAttentionBackgroundDefaultColor);
return image;
}
-const gfx::Image* GetMinimizeBackgroundDefaultImage() {
- static gfx::Image* image = NULL;
- if (!image)
+gfx::Image GetMinimizeBackgroundDefaultImage() {
+ CR_DEFINE_STATIC_LOCAL(gfx::Image, image, ());
+ if (image.IsEmpty())
image = CreateImageForColor(kMinimizeBackgroundDefaultColor);
return image;
}
@@ -494,12 +494,12 @@ bool PanelGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) const {
return true;
}
-const gfx::Image* PanelGtk::GetFrameBackground() const {
+gfx::Image PanelGtk::GetFrameBackground() const {
return UsingDefaultTheme() ?
GetDefaultFrameBackground() : GetThemedFrameBackground();
}
-const gfx::Image* PanelGtk::GetDefaultFrameBackground() const {
+gfx::Image PanelGtk::GetDefaultFrameBackground() const {
switch (paint_state_) {
case PAINT_AS_INACTIVE:
return GetInactiveBackgroundDefaultImage();
@@ -515,7 +515,7 @@ const gfx::Image* PanelGtk::GetDefaultFrameBackground() const {
}
}
-const gfx::Image* PanelGtk::GetThemedFrameBackground() const {
+gfx::Image PanelGtk::GetThemedFrameBackground() const {
GtkThemeService* theme_provider = GtkThemeService::GetFrom(panel_->profile());
return theme_provider->GetImageNamed(paint_state_ == PAINT_AS_ACTIVE ?
IDR_THEME_TOOLBAR : IDR_THEME_TAB_BACKGROUND);
@@ -540,7 +540,7 @@ gboolean PanelGtk::OnCustomFrameExpose(GtkWidget* widget,
paint_state_ = PAINT_AS_INACTIVE;
// Draw the background.
- gfx::CairoCachedSurface* surface = GetFrameBackground()->ToCairo();
+ gfx::CairoCachedSurface* surface = GetFrameBackground().ToCairo();
surface->SetSource(cr, widget, 0, 0);
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr, event->area.x, event->area.y,
diff --git a/chrome/browser/ui/gtk/panels/panel_gtk.h b/chrome/browser/ui/gtk/panels/panel_gtk.h
index cbb7097..c500410 100644
--- a/chrome/browser/ui/gtk/panels/panel_gtk.h
+++ b/chrome/browser/ui/gtk/panels/panel_gtk.h
@@ -107,9 +107,9 @@ class PanelGtk : public NativePanel,
void DisconnectAccelerators();
// Returns the image to paint the frame.
- const gfx::Image* GetFrameBackground() const;
- const gfx::Image* GetDefaultFrameBackground() const;
- const gfx::Image* GetThemedFrameBackground() const;
+ gfx::Image GetFrameBackground() const;
+ gfx::Image GetDefaultFrameBackground() const;
+ gfx::Image GetThemedFrameBackground() const;
// Animation when panel is first shown.
void RevealPanel();
diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
index 76f22e2..aead804 100644
--- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
@@ -487,8 +487,8 @@ void TabRendererGtk::PaintFaviconArea(GtkWidget* widget, cairo_t* cr) {
}
// Paint the background behind the favicon.
- const gfx::Image* tab_bg = theme_service_->GetImageNamed(theme_id);
- tab_bg->ToCairo()->SetSource(cr, widget, -x(), -offset_y);
+ const gfx::Image tab_bg = theme_service_->GetImageNamed(theme_id);
+ tab_bg.ToCairo()->SetSource(cr, widget, -x(), -offset_y);
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr,
favicon_bounds_.x(), favicon_bounds_.y(),
@@ -499,9 +499,9 @@ void TabRendererGtk::PaintFaviconArea(GtkWidget* widget, cairo_t* cr) {
double throb_value = GetThrobValue();
if (throb_value > 0) {
cairo_push_group(cr);
- const gfx::Image* active_bg =
+ gfx::Image active_bg =
theme_service_->GetImageNamed(IDR_THEME_TOOLBAR);
- active_bg->ToCairo()->SetSource(cr, widget, -x(), 0);
+ active_bg.ToCairo()->SetSource(cr, widget, -x(), 0);
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr,
@@ -864,7 +864,7 @@ void TabRendererGtk::PaintIcon(GtkWidget* widget, cairo_t* cr) {
gfx::CairoCachedSurface* to_display = NULL;
if (should_display_crashed_favicon_) {
- to_display = theme_service_->GetImageNamed(IDR_SAD_FAVICON)->ToCairo();
+ to_display = theme_service_->GetImageNamed(IDR_SAD_FAVICON).ToCairo();
} else if (!data_.favicon.isNull()) {
if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) {
to_display = GtkThemeService::GetDefaultFavicon(true).ToCairo();
@@ -901,10 +901,10 @@ void TabRendererGtk::PaintTabBackground(GtkWidget* widget, cairo_t* cr) {
void TabRendererGtk::DrawTabBackground(
cairo_t* cr,
GtkWidget* widget,
- const gfx::Image* tab_bg,
+ const gfx::Image& tab_bg,
int offset_x,
int offset_y) {
- tab_bg->ToCairo()->SetSource(cr, widget, -offset_x, -offset_y);
+ tab_bg.ToCairo()->SetSource(cr, widget, -offset_x, -offset_y);
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
@@ -959,7 +959,7 @@ void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget,
int theme_id = data_.incognito ?
IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND;
- const gfx::Image* tab_bg = theme_service_->GetImageNamed(theme_id);
+ gfx::Image tab_bg = theme_service_->GetImageNamed(theme_id);
// If the theme is providing a custom background image, then its top edge
// should be at the top of the tab. Otherwise, we assume that the background
@@ -975,7 +975,7 @@ void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget,
void TabRendererGtk::PaintActiveTabBackground(GtkWidget* widget,
cairo_t* cr) {
- const gfx::Image* tab_bg = theme_service_->GetImageNamed(IDR_THEME_TOOLBAR);
+ gfx::Image tab_bg = theme_service_->GetImageNamed(IDR_THEME_TOOLBAR);
DrawTabBackground(cr, widget, tab_bg, background_offset_x_, 0);
DrawTabShadow(cr, widget, IDR_TAB_ACTIVE_LEFT, IDR_TAB_ACTIVE_CENTER,
@@ -986,14 +986,14 @@ void TabRendererGtk::PaintLoadingAnimation(GtkWidget* widget,
cairo_t* cr) {
int id = loading_animation_.animation_state() == ANIMATION_WAITING ?
IDR_THROBBER_WAITING : IDR_THROBBER;
- const gfx::Image* throbber = theme_service_->GetImageNamed(id);
+ gfx::Image throbber = theme_service_->GetImageNamed(id);
- const int image_size = throbber->ToCairo()->Height();
+ const int image_size = throbber.ToCairo()->Height();
const int image_offset = loading_animation_.animation_frame() * image_size;
DCHECK(image_size == favicon_bounds_.height());
DCHECK(image_size == favicon_bounds_.width());
- throbber->ToCairo()->SetSource(cr, widget, favicon_bounds_.x() - image_offset,
+ throbber.ToCairo()->SetSource(cr, widget, favicon_bounds_.x() - image_offset,
favicon_bounds_.y());
cairo_rectangle(cr, favicon_bounds_.x(), favicon_bounds_.y(),
image_size, image_size);
diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h
index a9a5572..bdd842e 100644
--- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h
@@ -305,7 +305,7 @@ class TabRendererGtk : public ui::AnimationDelegate,
// sides for the rounded tab shape.
void DrawTabBackground(cairo_t* cr,
GtkWidget* widget,
- const gfx::Image* tab_bg,
+ const gfx::Image& tab_bg,
int offset_x,
int offset_y);
diff --git a/chrome/browser/ui/gtk/throbber_gtk.cc b/chrome/browser/ui/gtk/throbber_gtk.cc
index 0a71d18..0065a74 100644
--- a/chrome/browser/ui/gtk/throbber_gtk.cc
+++ b/chrome/browser/ui/gtk/throbber_gtk.cc
@@ -22,7 +22,6 @@ const int kThrobberDurationMs = 750;
ThrobberGtk::ThrobberGtk(GtkThemeService* theme_service)
: theme_service_(theme_service),
ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)),
- frames_(NULL),
num_frames_(0) {
DCHECK(theme_service_);
Init();
@@ -64,7 +63,7 @@ gboolean ThrobberGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) {
gtk_widget_get_allocation(widget, &allocation);
cairo_translate(cairo_context, allocation.x, allocation.y);
- gfx::CairoCachedSurface* cairo_frames = frames_->ToCairo();
+ gfx::CairoCachedSurface* cairo_frames = frames_.ToCairo();
const int frame =
static_cast<int>(animation_.GetCurrentValue() * (num_frames_ - 1));
const int image_size = cairo_frames->Height();
@@ -93,9 +92,9 @@ void ThrobberGtk::Init() {
void ThrobberGtk::LoadFrames() {
frames_ = theme_service_->GetImageNamed(IDR_THROBBER);
- DCHECK(frames_);
- const int width = frames_->ToCairo()->Width();
- const int height = frames_->ToCairo()->Height();
+ DCHECK(!frames_.IsEmpty());
+ const int width = frames_.ToCairo()->Width();
+ const int height = frames_.ToCairo()->Height();
DCHECK_EQ(0, width % height);
num_frames_ = width / height;
diff --git a/chrome/browser/ui/gtk/throbber_gtk.h b/chrome/browser/ui/gtk/throbber_gtk.h
index 8d9d777..c13e81d 100644
--- a/chrome/browser/ui/gtk/throbber_gtk.h
+++ b/chrome/browser/ui/gtk/throbber_gtk.h
@@ -63,7 +63,7 @@ class ThrobberGtk : public ui::AnimationDelegate,
ui::SlideAnimation animation_;
// The image containing the throbber frames.
- const gfx::Image* frames_;
+ gfx::Image frames_;
// The number of frames in |frames_|.
int num_frames_;