Index: chrome/browser/ui/views/tabs/tab_strip.cc |
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc |
index e0356c8cc2fc3cf955c40c86c119c24503db4a4c..a20757e5750900a16fefb25e0df63af5413b161e 100644 |
--- a/chrome/browser/ui/views/tabs/tab_strip.cc |
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc |
@@ -25,6 +25,7 @@ |
#include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h" |
#include "chrome/browser/ui/views/tabs/tab_strip_observer.h" |
+#include "chrome/browser/ui/views/tabs/tab_util.h" |
#include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
#include "content/public/browser/user_metrics.h" |
#include "grit/generated_resources.h" |
@@ -413,16 +414,21 @@ gfx::ImageSkia NewTabButton::GetBackgroundImage( |
views::CustomButton::ButtonState state, |
ui::ScaleFactor scale_factor) const { |
int background_id = 0; |
+ int background_overlay_id = 0; |
if (ShouldUseNativeFrame()) { |
background_id = IDR_THEME_TAB_BACKGROUND_V; |
+ background_overlay_id = IDR_THEME_TAB_BACKGROUND_V_OVERLAY; |
} else if (tab_strip_->controller()->IsIncognito()) { |
background_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; |
+ background_overlay_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY; |
#if defined(OS_WIN) |
} else if (win8::IsSingleWindowMetroMode()) { |
background_id = IDR_THEME_TAB_BACKGROUND_V; |
+ background_overlay_id = IDR_THEME_TAB_BACKGROUND_V_OVERLAY; |
#endif |
} else { |
background_id = IDR_THEME_TAB_BACKGROUND; |
+ background_overlay_id = IDR_THEME_TAB_BACKGROUND_OVERLAY; |
} |
int alpha = 0; |
@@ -443,6 +449,9 @@ gfx::ImageSkia NewTabButton::GetBackgroundImage( |
GetThemeProvider()->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK); |
int height = mask->height(); |
int width = mask->width(); |
+ // This method assumes that the button is |width|x|height|. |
+ DCHECK_EQ(width, NewTabButton::width()); |
+ DCHECK_EQ(height, NewTabButton::height()); |
// The canvas and mask has to use the same scale factor. |
if (!mask->HasRepresentation(scale_factor)) |
@@ -450,25 +459,21 @@ gfx::ImageSkia NewTabButton::GetBackgroundImage( |
gfx::Canvas canvas(gfx::Size(width, height), scale_factor, false); |
- // For custom images the background starts at the top of the tab strip. |
- // Otherwise the background starts at the top of the frame. |
- gfx::ImageSkia* background = |
- GetThemeProvider()->GetImageSkiaNamed(background_id); |
- int offset_y = GetThemeProvider()->HasCustomImage(background_id) ? |
- 0 : background_offset_.y(); |
- // The new tab background is mirrored in RTL mode, but the theme background |
- // should never be mirrored. Mirror it here to compensate. |
- float x_scale = 1.0f; |
- int x = GetMirroredX() + background_offset_.x(); |
+ // The new tab button is mirrored in RTL mode, but the button's background |
+ // should never be mirrored. |
if (base::i18n::IsRTL()) { |
- x_scale = -1.0f; |
- // Offset by |width| such that the same region is painted as if there was no |
- // flip. |
- x += width; |
+ // Translate by |width| such that the same region is painted as if there was |
+ // no flip. |
+ canvas.Translate(gfx::Vector2d(width, 0)); |
+ canvas.Scale(-1, 1); |
} |
- canvas.TileImageInt(*background, x, newtab_button_v_offset() + offset_y, |
- x_scale, 1.0f, 0, 0, width, height); |
+ |
+ int x = GetMirroredX() + background_offset_.x(); |
+ gfx::ImageSkia tiled_background = TabUtil::CreateTiledInactiveBackground( |
+ GetThemeProvider(), background_id, background_overlay_id, |
+ background_offset_.y(), x, newtab_button_v_offset(), width, height); |
+ canvas.DrawImageInt(tiled_background, 0, 0); |
if (alpha != 255) { |
SkPaint paint; |