diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 20:19:20 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 20:19:20 +0000 |
commit | 64b549cd85a086dcc713b6d5240114ada0b4120c (patch) | |
tree | d07f1fcb332a7fb99ebadeb5ee651b3f8523db20 /chrome/browser | |
parent | ff58b6b0e4a3774fb1e0b7c177529dc39651055b (diff) | |
download | chromium_src-64b549cd85a086dcc713b6d5240114ada0b4120c.zip chromium_src-64b549cd85a086dcc713b6d5240114ada0b4120c.tar.gz chromium_src-64b549cd85a086dcc713b6d5240114ada0b4120c.tar.bz2 |
Remove an unnecessary image using auto-mirroring.
BUG=none
TEST=Find bar still looks right in RTL mode
Review URL: http://codereview.chromium.org/3162017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.cc | 71 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.h | 20 |
3 files changed, 58 insertions, 40 deletions
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 937db3f..71c4081 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -869,10 +869,9 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, GtkAllocation border_allocation = bar->border_bin_->allocation; // Blit the left part of the background image once on the left. - bool rtl = base::i18n::IsRTL(); - CairoCachedSurface* background_left = bar->theme_provider_->GetSurfaceNamed( - rtl ? IDR_FIND_BOX_BACKGROUND_LEFT_RTL : IDR_FIND_BOX_BACKGROUND_LEFT, - widget); + CairoCachedSurface* background_left = + bar->theme_provider_->GetRTLEnabledSurfaceNamed( + IDR_FIND_BOX_BACKGROUND_LEFT, widget); background_left->SetSource(cr, border_allocation.x, border_allocation.y); cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); cairo_rectangle(cr, border_allocation.x, border_allocation.y, diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 3ffaae5..1df6d39 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -481,42 +481,29 @@ void GtkThemeProvider::GetScrollbarColors(GdkColor* thumb_active_color, } CairoCachedSurface* GtkThemeProvider::GetSurfaceNamed( - int id, GtkWidget* widget_on_display) { - GdkDisplay* display = gtk_widget_get_display(widget_on_display); - CairoCachedSurfaceMap& surface_map = per_display_surfaces_[display]; - - // Check to see if we already have the pixbuf in the cache. - CairoCachedSurfaceMap::const_iterator found = surface_map.find(id); - if (found != surface_map.end()) - return found->second; - - GdkPixbuf* pixbuf = GetPixbufNamed(id); - CairoCachedSurface* surface = new CairoCachedSurface; - surface->UsePixbuf(pixbuf); - - surface_map[id] = surface; + int id, + GtkWidget* widget_on_display) { + return GetSurfaceNamedImpl(id, GetPixbufNamed(id), widget_on_display); +} - return surface; +CairoCachedSurface* GtkThemeProvider::GetRTLEnabledSurfaceNamed( + int id, + GtkWidget* widget_on_display) { + // We flip the sign of |id| when passing it to GetSurfaceNamedImpl() for the + // same reason that BrowserThemeProvider::GetPixbufImpl() does: so that if one + // location calls this function with a resource ID, and another place calls + // GetSurfaceNamed() with the same ID, they'll correctly get different + // surfaces in RTL mode. + return GetSurfaceNamedImpl(-id, GetRTLEnabledPixbufNamed(id), + widget_on_display); } CairoCachedSurface* GtkThemeProvider::GetUnthemedSurfaceNamed( - int id, GtkWidget* widget_on_display) { - GdkDisplay* display = gtk_widget_get_display(widget_on_display); - CairoCachedSurfaceMap& surface_map = per_display_unthemed_surfaces_[display]; - - // Check to see if we already have the pixbuf in the cache. - CairoCachedSurfaceMap::const_iterator found = surface_map.find(id); - if (found != surface_map.end()) - return found->second; - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - GdkPixbuf* pixbuf = rb.GetPixbufNamed(id); - CairoCachedSurface* surface = new CairoCachedSurface; - surface->UsePixbuf(pixbuf); - - surface_map[id] = surface; - - return surface; + int id, + GtkWidget* widget_on_display) { + return GetSurfaceNamedImpl(id, + ResourceBundle::GetSharedInstance().GetPixbufNamed(id), + widget_on_display); } // static @@ -997,6 +984,26 @@ void GtkThemeProvider::GetSelectedEntryForegroundHSL( color_utils::SkColorToHSL(GdkToSkColor(&color), tint); } +CairoCachedSurface* GtkThemeProvider::GetSurfaceNamedImpl( + int id, + GdkPixbuf* pixbuf, + GtkWidget* widget_on_display) { + GdkDisplay* display = gtk_widget_get_display(widget_on_display); + CairoCachedSurfaceMap& surface_map = per_display_surfaces_[display]; + + // Check to see if we already have the pixbuf in the cache. + CairoCachedSurfaceMap::const_iterator found = surface_map.find(id); + if (found != surface_map.end()) + return found->second; + + CairoCachedSurface* surface = new CairoCachedSurface; + surface->UsePixbuf(pixbuf); + + surface_map[id] = surface; + + return surface; +} + void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button) { std::vector<GtkWidget*>::iterator it = find(chrome_buttons_.begin(), chrome_buttons_.end(), button); diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index 6c1f59b..c78aaa3 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -97,10 +97,17 @@ class GtkThemeProvider : public BrowserThemeProvider, // to send the image to the server on each expose. CairoCachedSurface* GetSurfaceNamed(int id, GtkWidget* widget_on_display); - // Returns a CairoCachedSurface for a particular Display for an image - // resource that's unthemed. - CairoCachedSurface* GetUnthemedSurfaceNamed( - int id, GtkWidget* widget_on_display); + // Same as above, but auto-mirrors the underlying pixbuf in RTL mode. + CairoCachedSurface* GetRTLEnabledSurfaceNamed(int id, + GtkWidget* widget_on_display); + + // Same as above, but gets the resource from the ResourceBundle instead of the + // BrowserThemeProvider. + // NOTE: Never call this with resource IDs that are ever passed to the above + // two functions! Depending on which call comes first, all callers will + // either get the themed or the unthemed version. + CairoCachedSurface* GetUnthemedSurfaceNamed(int id, + GtkWidget* widget_on_display); // Returns colors that we pass to webkit to match the system theme. const SkColor& get_focus_ring_color() const { return focus_ring_color_; } @@ -201,6 +208,11 @@ class GtkThemeProvider : public BrowserThemeProvider, // entry. void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; + // Implements GetXXXSurfaceNamed(), given the appropriate pixbuf to use. + CairoCachedSurface* GetSurfaceNamedImpl(int id, + GdkPixbuf* pixbuf, + GtkWidget* widget_on_display); + // Handles signal from GTK that our theme has been changed. CHROMEGTK_CALLBACK_1(GtkThemeProvider, void, OnStyleSet, GtkStyle*); |