Index: chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc |
diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc |
index f8e98273d8facf3b0f05ec2de3abf1f446a660ed..7d16ab570d53e9b7ca2999330fa3d13062852aae 100644 |
--- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc |
+++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc |
@@ -502,23 +502,8 @@ void TabRendererGtk::PaintFaviconArea(GtkWidget* widget, cairo_t* cr) { |
cairo_matrix_init_translate(&cairo_matrix, x(), y()); |
cairo_set_matrix(cr, &cairo_matrix); |
- // Which background should we be painting? |
- int theme_id; |
- int offset_y = 0; |
- if (IsActive()) { |
- theme_id = IDR_THEME_TOOLBAR; |
- } else { |
- theme_id = data_.incognito ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : |
- IDR_THEME_TAB_BACKGROUND; |
- |
- if (!theme_service_->HasCustomImage(theme_id)) |
- offset_y = background_offset_y_; |
- } |
- |
// 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); |
- cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
+ SetTabBackgroundImageAsSource(cr, widget, favicon_bounds_); |
cairo_rectangle(cr, |
favicon_bounds_.x(), favicon_bounds_.y(), |
favicon_bounds_.width(), favicon_bounds_.height()); |
@@ -957,17 +942,6 @@ void TabRendererGtk::PaintIcon(GtkWidget* widget, cairo_t* cr) { |
cairo_paint(cr); |
} else if (data_.capture_state == RECORDING) { |
// Add mask around the recording overlay image (red dot). |
- gfx::CairoCachedSurface* tab_bg; |
- if (IsActive()) { |
- tab_bg = theme_service_->GetImageNamed(IDR_THEME_TOOLBAR).ToCairo(); |
- } else { |
- int theme_id = data_.incognito ? |
- IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
- tab_bg = theme_service_->GetImageNamed(theme_id).ToCairo(); |
- } |
- tab_bg->SetSource(cr, widget, -background_offset_x_, 0); |
- cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
- |
gfx::CairoCachedSurface* recording_mask = |
theme_service_->GetImageNamed(IDR_TAB_RECORDING_MASK).ToCairo(); |
int offset_from_right = data_.cairo_overlay.Width() + |
@@ -978,6 +952,9 @@ void TabRendererGtk::PaintIcon(GtkWidget* widget, cairo_t* cr) { |
(recording_mask->Height() - data_.cairo_overlay.Height()) / 2; |
int favicon_y = favicon_bounds_.y() + favicon_hiding_offset_ + |
favicon_bounds_.height() - offset_from_bottom; |
+ SetTabBackgroundImageAsSource(cr, widget, |
+ gfx::Rect(favicon_x, favicon_y, recording_mask->Width(), |
+ recording_mask->Height())); |
recording_mask->MaskSource(cr, widget, favicon_x, favicon_y); |
if (!IsActive()) { |
@@ -1026,15 +1003,56 @@ void TabRendererGtk::PaintTabBackground(GtkWidget* widget, cairo_t* cr) { |
} |
} |
-void TabRendererGtk::DrawTabBackground( |
- cairo_t* cr, |
- GtkWidget* widget, |
- const gfx::Image& tab_bg, |
- int offset_x, |
- int offset_y) { |
- tab_bg.ToCairo()->SetSource(cr, widget, -offset_x, -offset_y); |
+void TabRendererGtk::SetTabBackgroundImageAsSource(cairo_t* cr, |
+ GtkWidget* widget, |
+ const gfx::Rect& bounds) { |
+ int tab_bg_id = 0; |
+ int tab_bg_offset_y = 0; |
+ int tab_bg_overlay_id = 0; |
+ if (IsActive()) { |
+ tab_bg_id = IDR_THEME_TOOLBAR; |
+ |
+ // The image at |tab_bg_id| is aligned with the top of the tab. |
+ tab_bg_offset_y = 0; |
+ } else { |
+ tab_bg_id = data_.incognito ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : |
+ IDR_THEME_TAB_BACKGROUND; |
+ // |tab_bg_id| is the tinted frame image. Set |tab_bg_offset_y_| so that |
+ // the image is aligned with the top of the frame. |
+ tab_bg_offset_y = background_offset_y_; |
+ |
+ tab_bg_overlay_id = data_.incognito ? |
+ IDR_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY : |
+ IDR_THEME_TAB_BACKGROUND_OVERLAY; |
+ } |
+ gfx::Image tab_bg = theme_service_->GetImageNamed(tab_bg_id); |
+ tab_bg.ToCairo()->SetSource(cr, widget, -background_offset_x_, |
+ -tab_bg_offset_y); |
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
+ // The default theme does not provide overlay images. |
+ if (tab_bg_overlay_id != 0 && |
+ theme_service_->HasCustomImage(tab_bg_overlay_id)) { |
+ cairo_push_group(cr); |
+ cairo_rectangle(cr, bounds.x(), bounds.y(), bounds.width(), |
+ bounds.height()); |
+ cairo_fill_preserve(cr); |
+ |
+ gfx::Image tab_bg_overlay = |
+ theme_service_->GetImageNamed(tab_bg_overlay_id); |
+ // |tab_bg_overlay| is aligned with the top of the tab. |
+ tab_bg_overlay.ToCairo()->SetSource(cr, widget, -background_offset_x_, 0); |
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
+ cairo_fill(cr); |
+ |
+ cairo_pop_group_to_source(cr); |
+ } |
+} |
+ |
+void TabRendererGtk::DrawTabBackground(cairo_t* cr, GtkWidget* widget) { |
+ SetTabBackgroundImageAsSource(cr, widget, |
+ gfx::Rect(0, 0, width(), tab_inactive_l_height_)); |
+ |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
// Draw left edge |
@@ -1084,28 +1102,14 @@ void TabRendererGtk::DrawTabShadow(cairo_t* cr, |
void TabRendererGtk::PaintInactiveTabBackground(GtkWidget* widget, |
cairo_t* cr) { |
- int theme_id = data_.incognito ? |
- IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
- |
- 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 |
- // image is a composited foreground + frame image. |
- int offset_y = theme_service_->HasCustomImage(theme_id) ? |
- 0 : background_offset_y_; |
- |
- DrawTabBackground(cr, widget, tab_bg, background_offset_x_, offset_y); |
- |
+ DrawTabBackground(cr, widget); |
DrawTabShadow(cr, widget, IDR_TAB_INACTIVE_LEFT, IDR_TAB_INACTIVE_CENTER, |
IDR_TAB_INACTIVE_RIGHT); |
} |
void TabRendererGtk::PaintActiveTabBackground(GtkWidget* widget, |
cairo_t* cr) { |
- gfx::Image tab_bg = theme_service_->GetImageNamed(IDR_THEME_TOOLBAR); |
- |
- DrawTabBackground(cr, widget, tab_bg, background_offset_x_, 0); |
+ DrawTabBackground(cr, widget); |
DrawTabShadow(cr, widget, IDR_TAB_ACTIVE_LEFT, IDR_TAB_ACTIVE_CENTER, |
IDR_TAB_ACTIVE_RIGHT); |
} |