Commit 0e90c86d authored by mdjones's avatar mdjones Committed by Commit bot

Replace tab switcher borders with single asset

This change replaces the two tab switcher borders that existed
(standard and incognito) with a single white one that can be tinted
to any color it needs to be.

BUG=606612

Review-Url: https://codereview.chromium.org/2045733002
Cr-Commit-Position: refs/heads/master@{#398176}
parent ac40d6ff
......@@ -58,17 +58,18 @@ public class TabListSceneLayer extends SceneLayer {
assert t.isVisible() : "LayoutTab in that list should be visible";
final float decoration = t.getDecorationAlpha();
boolean isDarkTheme = t.isIncognito();
int defaultThemeColor = t.isIncognito()
? ApiCompatibilityUtils.getColor(res, R.color.incognito_primary_color)
: ApiCompatibilityUtils.getColor(res, R.color.default_primary_color);
// If theme colors are enabled in the tab switcher, the theme might require lighter
// text.
boolean isDarkTheme = t.isIncognito();
if (FeatureUtilities.areTabSwitcherThemeColorsEnabled()) {
isDarkTheme |= ColorUtils.shoudUseLightForegroundOnBackground(
t.getToolbarBackgroundColor());
}
int borderResource = t.isIncognito() ? R.drawable.tabswitcher_border_frame_incognito
: R.drawable.tabswitcher_border_frame;
int closeBtnResource = isDarkTheme ? R.drawable.btn_tab_close_white_normal
: R.drawable.btn_tab_close_normal;
int borderColorResource =
......@@ -77,7 +78,8 @@ public class TabListSceneLayer extends SceneLayer {
nativePutTabLayer(mNativePtr, t.getId(), R.id.control_container, closeBtnResource,
R.drawable.tabswitcher_border_frame_shadow,
R.drawable.tabswitcher_border_frame_decoration, R.drawable.logo_card_back,
borderResource, R.drawable.tabswitcher_border_frame_inner_shadow,
R.drawable.tabswitcher_border_frame,
R.drawable.tabswitcher_border_frame_inner_shadow,
t.canUseLiveTexture(), t.getBackgroundColor(),
ApiCompatibilityUtils.getColor(res, borderColorResource), t.isIncognito(),
layout.getOrientation() == Orientation.PORTRAIT, t.getRenderX() * dpToPx,
......@@ -93,10 +95,10 @@ public class TabListSceneLayer extends SceneLayer {
t.getShadowOpacity() * decoration, t.getBorderCloseButtonAlpha() * decoration,
LayoutTab.CLOSE_BUTTON_WIDTH_DP * dpToPx, t.getStaticToViewBlend(),
t.getBorderScale(), t.getSaturation(), t.getBrightness(), t.showToolbar(),
t.getToolbarBackgroundColor(), t.anonymizeToolbar(), R.drawable.textbox,
t.getTextBoxBackgroundColor(), t.getTextBoxAlpha(), t.getToolbarAlpha(),
t.getToolbarYOffset() * dpToPx, t.getSideBorderScale(), true,
t.insetBorderVertical());
defaultThemeColor, t.getToolbarBackgroundColor(), t.anonymizeToolbar(),
R.drawable.textbox, t.getTextBoxBackgroundColor(), t.getTextBoxAlpha(),
t.getToolbarAlpha(), t.getToolbarYOffset() * dpToPx, t.getSideBorderScale(),
true, t.insetBorderVertical());
}
nativeFinishBuildingFrame(mNativePtr);
}
......@@ -143,8 +145,9 @@ public class TabListSceneLayer extends SceneLayer {
float pivotY, float rotationX, float rotationY, float alpha, float borderAlpha,
float borderInnerShadowAlpha, float contourAlpha, float shadowAlpha, float closeAlpha,
float closeBtnWidth, float staticToViewBlend, float borderScale, float saturation,
float brightness, boolean showToolbar, int toolbarBackgroundColor,
boolean anonymizeToolbar, int toolbarTextBoxResource, int toolbarTextBoxBackgroundColor,
float toolbarTextBoxAlpha, float toolbarAlpha, float toolbarYOffset,
float sideBorderScale, boolean attachContent, boolean insetVerticalBorder);
float brightness, boolean showToolbar, int defaultThemeColor,
int toolbarBackgroundColor, boolean anonymizeToolbar, int toolbarTextBoxResource,
int toolbarTextBoxBackgroundColor, float toolbarTextBoxAlpha, float toolbarAlpha,
float toolbarYOffset, float sideBorderScale, boolean attachContent,
boolean insetVerticalBorder);
}
......@@ -134,6 +134,7 @@ void TabLayer::SetProperties(int id,
float view_width,
float view_height,
bool show_toolbar,
int default_theme_color,
int toolbar_background_color,
bool anonymize_toolbar,
int toolbar_textbox_resource_id,
......@@ -479,15 +480,20 @@ void TabLayer::SetProperties(int id,
front_border_->SetOpacity(border_alpha);
front_border_->SetNearestNeighbor(toolbar_visible);
// Colorize the tab decoration.
if (tab_switcher_themes_enabled_ && !incognito_
&& toolbar_background_color != toolbar_background_color_) {
int tab_switcher_color = default_theme_color;
// Colorize the tab decoration if enabled.
if (tab_switcher_themes_enabled_) {
tab_switcher_color = toolbar_background_color;
}
if (toolbar_background_color != toolbar_background_color_) {
toolbar_background_color_ = toolbar_background_color;
cc::FilterOperations filters;
SkScalar colorMatrix[] = {
SkColorGetR(toolbar_background_color) / 255.0f, 0, 0, 0, 0,
0, SkColorGetG(toolbar_background_color) / 255.0f, 0, 0, 0,
0, 0, SkColorGetB(toolbar_background_color) / 255.0f, 0, 0,
SkColorGetR(tab_switcher_color) / 255.0f, 0, 0, 0, 0,
0, SkColorGetG(tab_switcher_color) / 255.0f, 0, 0, 0,
0, 0, SkColorGetB(tab_switcher_color) / 255.0f, 0, 0,
0, 0, 0, 1, 0,
};
filters.Append(cc::FilterOperation::CreateColorMatrixFilter(colorMatrix));
......
......@@ -86,6 +86,7 @@ class TabLayer : public Layer {
float view_width,
float view_height,
bool show_toolbar,
int default_theme_color,
int toolbar_background_color,
bool anonymize_toolbar,
int toolbar_textbox_resource_id,
......
......@@ -114,6 +114,7 @@ void TabListSceneLayer::PutTabLayer(
jfloat saturation,
jfloat brightness,
jboolean show_toolbar,
jint default_theme_color,
jint toolbar_background_color,
jboolean anonymize_toolbar,
jint toolbar_textbox_resource_id,
......@@ -138,7 +139,7 @@ void TabListSceneLayer::PutTabLayer(
contour_alpha, shadow_alpha, close_alpha, border_scale, saturation,
brightness, close_btn_width, static_to_view_blend, content_width,
content_height, content_width, visible_content_height, show_toolbar,
toolbar_background_color, anonymize_toolbar,
default_theme_color, toolbar_background_color, anonymize_toolbar,
toolbar_textbox_resource_id, toolbar_textbox_background_color,
toolbar_textbox_alpha, toolbar_alpha, toolbar_y_offset,
side_border_scale, attach_content, inset_border);
......
......@@ -92,6 +92,7 @@ class TabListSceneLayer : public SceneLayer {
jfloat saturation,
jfloat brightness,
jboolean show_toolbar,
jint default_theme_color,
jint toolbar_background_color,
jboolean anonymize_toolbar,
jint toolbar_textbox_resource_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment