Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8070)

Unified Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 18486007: Fix the misalignment on CrOS of the tab background images (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a99257db1107b4e8d8db7022588d26e15df8780d..789f3534fc5840e0e126620cacfee087dd36d86f 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
+#include "chrome/browser/ui/views/tabs/tab_paint_util.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/touch_uma/touch_uma.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;
@@ -450,25 +456,20 @@ 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 = TabPaintUtil::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;

Powered by Google App Engine
This is Rietveld 408576698