Skip to content
Permalink
Browse files

Fix aliasing issues in Assistant UI on veyron-speedy board.

Merge to release branch.

The text in the Assistant UI is drawn with anti-aliasing. Since the
background info isn't available when drawing text on a layer, it can
cause aliasing issues.

To fix this we set the label's background to solid white.

(cherry picked from commit 5c298ed)

Bug: chromium:1016006
Test: manual
Change-Id: Ib9fb3db78d30964dd45cc9d665f379044751d177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959345
Commit-Queue: Jeroen Dhollander <jeroendh@google.com>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#723188}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959935
Cr-Commit-Position: refs/branch-heads/3945@{#930}
Cr-Branched-From: e4635ff-refs/heads/master@{#706915}
  • Loading branch information
Jeroen Dhollander Commit Bot
Jeroen Dhollander authored and Commit Bot committed Dec 10, 2019
1 parent 98da865 commit edf65a7a7b6d5c789822d6e9c8e55bc3c26aed19
@@ -24,6 +24,7 @@
#include "ui/compositor/layer_animator.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
@@ -152,24 +153,14 @@ views::View* AppListAssistantMainStage::CreateContentLayoutContainer() {
// The content layout container stacks two views.
// On top is a main content container including the line separator, progress
// indicator query view and |ui_element_container_|.
// |greeting_label_| is laid out beneath of the main content container. As
// such, it appears underneath and does not cause repositioning to any of
// content layout's underlying views.
// |greeting_label_| is laid out above of the main content container. As
// such, it floats above and does not cause repositioning to any of content
// layout's underlying views.
views::View* content_layout_container = new views::View();

InitGreetingLabel();
content_layout_container->AddChildView(greeting_label_);
auto* stack_layout = content_layout_container->SetLayoutManager(
std::make_unique<ash::StackLayout>());

// We need to stretch |greeting_label_| to match its parent so that it
// won't use heuristics in Label to infer line breaking, which seems to cause
// text clipping with DPI adjustment. See b/112843496.
stack_layout->SetRespectDimensionForView(
greeting_label_, ash::StackLayout::RespectDimension::kHeight);
stack_layout->SetVerticalAlignmentForView(
greeting_label_, ash::StackLayout::VerticalAlignment::kCenter);

auto* main_content_layout_container = CreateMainContentLayoutContainer();
content_layout_container->AddChildView(main_content_layout_container);

@@ -179,6 +170,17 @@ views::View* AppListAssistantMainStage::CreateContentLayoutContainer() {
main_content_layout_container,
ash::StackLayout::RespectDimension::kWidth);

InitGreetingLabel();
content_layout_container->AddChildView(greeting_label_);

// We need to stretch |greeting_label_| to match its parent so that it
// won't use heuristics in Label to infer line breaking, which seems to cause
// text clipping with DPI adjustment. See b/112843496.
stack_layout->SetRespectDimensionForView(
greeting_label_, ash::StackLayout::RespectDimension::kHeight);
stack_layout->SetVerticalAlignmentForView(
greeting_label_, ash::StackLayout::VerticalAlignment::kCenter);

return content_layout_container;
}

@@ -196,7 +198,7 @@ void AppListAssistantMainStage::InitGreetingLabel() {
gfx::HorizontalAlignment::ALIGN_CENTER);
greeting_label_->SetMultiLine(true);
greeting_label_->SetPaintToLayer();
greeting_label_->layer()->SetFillsBoundsOpaquely(false);
greeting_label_->SetBackground(views::CreateSolidBackground(SK_ColorWHITE));
}

views::View* AppListAssistantMainStage::CreateMainContentLayoutContainer() {
@@ -214,7 +216,7 @@ views::View* AppListAssistantMainStage::CreateMainContentLayoutContainer() {
// Query view. Will be animated on its own layer.
query_view_ = new ash::AssistantQueryView();
query_view_->SetPaintToLayer();
query_view_->layer()->SetFillsBoundsOpaquely(false);
query_view_->SetBackground(views::CreateSolidBackground(SK_ColorWHITE));
query_view_->AddObserver(this);
content_layout_container->AddChildView(query_view_);

@@ -15,6 +15,7 @@
#include "ash/strings/grit/ash_strings.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/background.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"

@@ -89,6 +90,7 @@ void AssistantMiniView::InitLayout() {
.DeriveWithWeight(gfx::Font::Weight::MEDIUM));
label_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
label_->SetLineHeight(kLineHeightDip);
label_->SetBackground(views::CreateSolidBackground(SK_ColorWHITE));
AddChildView(label_);

// Initialize the prompt.
@@ -26,6 +26,7 @@
#include "ui/compositor/callback_layer_animation_observer.h"
#include "ui/compositor/layer_animation_element.h"
#include "ui/compositor/layer_animator.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
@@ -267,7 +268,7 @@ void AssistantMainStage::InitOverlayLayoutContainer() {

// The greeting label will be animated on its own layer.
greeting_label_->SetPaintToLayer();
greeting_label_->layer()->SetFillsBoundsOpaquely(false);
greeting_label_->SetBackground(views::CreateSolidBackground(SK_ColorWHITE));

overlay_layout_container_->AddChildView(greeting_label_);

@@ -13,6 +13,7 @@
#include "net/base/escape.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/layout/box_layout.h"

namespace ash {
@@ -81,6 +82,7 @@ void AssistantQueryView::InitLayout() {
label_->SetAutoColorReadabilityEnabled(false);
label_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER);
label_->SetLineHeight(kLineHeightDip);
label_->SetBackground(views::CreateSolidBackground(SK_ColorWHITE));
AddChildView(label_);
}

@@ -7,6 +7,7 @@
#include "ash/assistant/model/assistant_ui_element.h"
#include "ash/assistant/ui/assistant_ui_constants.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/views/background.h"

namespace ash {

@@ -22,6 +23,7 @@ AssistantTextElementView::AssistantTextElementView(
.DeriveWithWeight(gfx::Font::Weight::MEDIUM));
SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
SetMultiLine(true);
SetBackground(views::CreateSolidBackground(SK_ColorWHITE));
}

AssistantTextElementView::~AssistantTextElementView() = default;

0 comments on commit edf65a7

Please sign in to comment.
You can’t perform that action at this time.