summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-08 02:31:16 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-08 02:31:16 +0000
commite7c81140a626691a25db715646102ea017a17f3e (patch)
treeabe55a144be410cd94a4ee513bdd7c996c5f90a5
parent20f656fa24a2c96bf28d9889dc226dbc6eba1011 (diff)
downloadchromium_src-e7c81140a626691a25db715646102ea017a17f3e.zip
chromium_src-e7c81140a626691a25db715646102ea017a17f3e.tar.gz
chromium_src-e7c81140a626691a25db715646102ea017a17f3e.tar.bz2
GTK: Fix gtk-theme mode: implement GtkThemeService::GetImageNamed().
GtkThemeService injects themed images into SkBitmaps for theming. When I started moving to the gfx::Image returning GetImageNamed() interface, I didn't implement it at the GtkThemeService level. BUG=106597,106060 TEST=No blue tabs in gtk-theme mode. Review URL: http://codereview.chromium.org/8771052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113536 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/themes/theme_service.h7
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.cc16
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.h3
3 files changed, 16 insertions, 10 deletions
diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h
index a6c01c4..e06b450 100644
--- a/chrome/browser/themes/theme_service.h
+++ b/chrome/browser/themes/theme_service.h
@@ -146,10 +146,9 @@ class ThemeService : public base::NonThreadSafe,
// Returns a cross platform image for an id.
//
- // TODO(erg): Make this a virtual, exposed through ui::ThemeProvider and the
- // main way to get theme properties out of the theme provider since it's
- // cross platform.
- const gfx::Image* GetImageNamed(int id) const;
+ // 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;
// ui::ThemeProvider implementation.
virtual void Init(Profile* profile) OVERRIDE;
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc
index 9b26388..177a2cc 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.cc
+++ b/chrome/browser/ui/gtk/gtk_theme_service.cc
@@ -303,19 +303,25 @@ void GtkThemeService::Init(Profile* 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<SkBitmap*>(GetImageNamed(id)->ToSkBitmap());
+}
+
+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;
if (use_gtk_ && IsOverridableImage(id)) {
- // We haven't built this image yet:
- SkBitmap* bitmap = GenerateGtkThemeBitmap(id);
- gtk_images_[id] = bitmap;
- return bitmap;
+ gfx::Image* image = new gfx::Image(GenerateGtkThemeBitmap(id));
+ gtk_images_[id] = image;
+ return image;
}
- return ThemeService::GetBitmapNamed(id);
+ return ThemeService::GetImageNamed(id);
}
SkColor GtkThemeService::GetColor(int id) const {
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.h b/chrome/browser/ui/gtk/gtk_theme_service.h
index 96538e8..3b9df3c 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.h
+++ b/chrome/browser/ui/gtk/gtk_theme_service.h
@@ -64,6 +64,7 @@ class GtkThemeService : public ThemeService {
// ThemeService's implementation.
virtual void Init(Profile* profile) OVERRIDE;
virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE;
+ virtual const 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 Extension* extension) OVERRIDE;
@@ -170,7 +171,7 @@ class GtkThemeService : public ThemeService {
private:
typedef std::map<int, SkColor> ColorMap;
typedef std::map<int, color_utils::HSL> TintMap;
- typedef std::map<int, SkBitmap*> ImageCache;
+ typedef std::map<int, gfx::Image*> ImageCache;
typedef std::map<int, gfx::CairoCachedSurface*> CairoCachedSurfaceMap;
typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap;