Skip to content

Commit

Permalink
M68 merge: LogoView: Fix setting alpha
Browse files Browse the repository at this point in the history
This cl fixes a bug to set logo view alpha value.

TBR=xiyuan@chromium.org, xiaohuic@chromium.org

Bug: b/80430044, 847609
Test: manual.
Change-Id: I25a6e3d64d062f44da48154af42caf3431e14904
Reviewed-on: https://chromium-review.googlesource.com/1077267
Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Tao Wu <wutao@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#562632}(cherry picked from commit d7c083c)
Reviewed-on: https://chromium-review.googlesource.com/1079855
Reviewed-by: Tao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/branch-heads/3440@{#54}
Cr-Branched-From: 010ddcf-refs/heads/master@{#561733}
  • Loading branch information
wutao committed May 30, 2018
1 parent 839e351 commit 559b106
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ash/assistant/ui/logo_view/logo_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ int64_t TimeTicksToMs(const base::TimeTicks& timestamp) {
return (timestamp - base::TimeTicks()).InMilliseconds();
}

int32_t GetLogoAlpha(const LogoView::Logo& logo) {
return logo.GetAlpha() * 255;
}

} // namespace

LogoView::LogoView()
Expand Down Expand Up @@ -93,8 +97,6 @@ void LogoView::DrawDots(gfx::Canvas* canvas) {
// we need to find out why the Mic parts are overlapping in the first place.
for (auto iter = logo_.dots().rbegin(); iter != logo_.dots().rend(); ++iter)
DrawDot(canvas, (*iter).get());

layer()->SetOpacity(logo_.GetAlpha());
}

void LogoView::DrawDot(gfx::Canvas* canvas, Dot* dot) {
Expand Down Expand Up @@ -127,6 +129,7 @@ void LogoView::DrawShape(gfx::Canvas* canvas, Shape* shape, SkColor color) {
cc::PaintFlags paint_flags;
paint_flags.setAntiAlias(true);
paint_flags.setColor(color);
paint_flags.setAlpha(GetLogoAlpha(logo_));
paint_flags.setStyle(cc::PaintFlags::kStroke_Style);
paint_flags.setStrokeCap(shape->cap());

Expand All @@ -142,6 +145,7 @@ void LogoView::DrawLine(gfx::Canvas* canvas, Dot* dot, float x, float y) {
cc::PaintFlags paint_flags;
paint_flags.setAntiAlias(true);
paint_flags.setColor(dot->color());
paint_flags.setAlpha(GetLogoAlpha(logo_));
paint_flags.setStrokeWidth(stroke_width);
paint_flags.setStyle(cc::PaintFlags::kStroke_Style);
paint_flags.setStrokeCap(cc::PaintFlags::kRound_Cap);
Expand All @@ -159,6 +163,7 @@ void LogoView::DrawCircle(gfx::Canvas* canvas, Dot* dot, float x, float y) {
cc::PaintFlags paint_flags;
paint_flags.setAntiAlias(true);
paint_flags.setColor(dot->color());
paint_flags.setAlpha(GetLogoAlpha(logo_));
paint_flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawCircle(gfx::PointF(x * dots_scale_, y * dots_scale_),
radius * dots_scale_, paint_flags);
Expand Down

0 comments on commit 559b106

Please sign in to comment.