summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/gtk_theme_provider.h
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-14 20:48:07 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-14 20:48:07 +0000
commitf017cc9f926a81638e324b51bd418ac7f7feeee0 (patch)
tree8db77306164b5d4498eac4ae729753095430a2e5 /chrome/browser/gtk/gtk_theme_provider.h
parent3396dc0d719aeca9d4593dfe0f1ab62cdac1629f (diff)
downloadchromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.zip
chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.tar.gz
chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.tar.bz2
Try 2: Completely redo how themes are stored on disk and processed at install time.
Same as previous patch, except we now have a BrowserThemeProvider::GetDefaultDisplayProperty() so we don't have UMRs in ntp_resource_cache.cc. BUG=24493,21121 TEST=All the new unit tests pass. All the complex theme startup tests go faster. Previous Review URL: http://codereview.chromium.org/460050 Review URL: http://codereview.chromium.org/499004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/gtk_theme_provider.h')
-rw-r--r--chrome/browser/gtk/gtk_theme_provider.h44
1 files changed, 30 insertions, 14 deletions
diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h
index 60d72e7..44fed99 100644
--- a/chrome/browser/gtk/gtk_theme_provider.h
+++ b/chrome/browser/gtk/gtk_theme_provider.h
@@ -40,6 +40,9 @@ class GtkThemeProvider : public BrowserThemeProvider,
// Sets that we aren't using the system theme, then calls
// BrowserThemeProvider's implementation.
virtual void Init(Profile* profile);
+ virtual SkBitmap* GetBitmapNamed(int id) const;
+ virtual SkColor GetColor(int id) const;
+ virtual bool HasCustomImage(int id) const;
virtual void SetTheme(Extension* extension);
virtual void UseDefaultTheme();
virtual void SetNativeTheme();
@@ -86,24 +89,17 @@ class GtkThemeProvider : public BrowserThemeProvider,
static GdkPixbuf* GetFolderIcon(bool native);
static GdkPixbuf* GetDefaultFavicon(bool native);
- protected:
- // Possibly creates a theme specific version of theme_toolbar_default.
- // (minimally acceptable version right now, which is just a fill of the bg
- // color; this should instead invoke gtk_draw_box(...) for complex theme
- // engines.)
- virtual SkBitmap* LoadThemeBitmap(int id) const;
-
private:
+ typedef std::map<int, SkColor> ColorMap;
+ typedef std::map<int, color_utils::HSL> TintMap;
+ typedef std::map<int, SkBitmap*> ImageCache;
+
// Load theme data from preferences, possibly picking colors from GTK.
virtual void LoadThemePrefs();
// Let all the browser views know that themes have changed.
virtual void NotifyThemeChanged();
- // If use_gtk_ is true, completely ignores this call. Otherwise passes it to
- // the superclass.
- virtual void SaveThemeBitmap(const std::string resource_name, int id) const;
-
// Additionally frees the CairoCachedSurfaces.
virtual void FreePlatformCaches();
@@ -115,9 +111,10 @@ class GtkThemeProvider : public BrowserThemeProvider,
void LoadGtkValues();
// Sets the underlying theme colors/tints from a GTK color.
- void SetThemeColorFromGtk(const char* id, GdkColor* color);
- void SetThemeTintFromGtk(const char* id, GdkColor* color,
- const color_utils::HSL& default_tint);
+ void SetThemeColorFromGtk(int id, GdkColor* color);
+ void SetThemeTintFromGtk(int id, GdkColor* color);
+ void BuildTintedFrameColor(int color_id, int tint_id);
+ void SetTintToExactColor(int id, GdkColor* color);
// Split out from FreePlatformCaches so it can be called in our destructor;
// FreePlatformCaches() is called from the BrowserThemeProvider's destructor,
@@ -125,6 +122,16 @@ class GtkThemeProvider : public BrowserThemeProvider,
// points to GtkThemeProvider's version.
void FreePerDisplaySurfaces();
+ // Lazily generates each bitmap used in the gtk theme.
+ SkBitmap* GenerateGtkThemeBitmap(int id) const;
+
+ // Tints IDR_THEME_FRAME based based on |tint_id|. Used during lazy
+ // generation of the gtk theme bitmaps.
+ SkBitmap* GenerateFrameImage(int tint_id) const;
+
+ // Takes the base frame image |base_id| and tints it with |tint_id|.
+ SkBitmap* GenerateTabImage(int base_id) const;
+
// A notification from the GtkChromeButton GObject destructor that we should
// remove it from our internal list.
static void OnDestroyChromeButton(GtkWidget* button,
@@ -142,6 +149,15 @@ class GtkThemeProvider : public BrowserThemeProvider,
// them of theme changes.
std::vector<GtkWidget*> chrome_buttons_;
+ // Tints and colors calculated by LoadGtkValues() that are given to the
+ // caller while |use_gtk_| is true.
+ ColorMap colors_;
+ TintMap tints_;
+
+ // Image cache of lazily created images, created when requested by
+ // GetBitmapNamed().
+ mutable ImageCache gtk_images_;
+
// Cairo surfaces for each GdkDisplay.
typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap;
typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap;