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

Unified Diff: chrome/browser/ui/views/infobars/infobar_background.cc

Issue 1826653002: Draw infobar arrow border with width of 1px on any scale factor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also deal with bottom separator Created 4 years, 9 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/infobars/infobar_background.cc
diff --git a/chrome/browser/ui/views/infobars/infobar_background.cc b/chrome/browser/ui/views/infobars/infobar_background.cc
index 7e9fe105f810af8ee28893f3064b0fc34bf69ece..2bd8da7d21763429c95df7292cfc2d26b3b1b3c9 100644
--- a/chrome/browser/ui/views/infobars/infobar_background.cc
+++ b/chrome/browser/ui/views/infobars/infobar_background.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/ui/views/infobars/infobar_view.h"
#include "components/infobars/core/infobar.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/views/view.h"
@@ -30,20 +31,22 @@ void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
gradient_points[1].iset(0, view->height());
SkColor gradient_colors[2] = { top_color_, bottom_color_ };
SkPaint paint;
- paint.setStrokeWidth(
- SkIntToScalar(InfoBarContainerDelegate::kSeparatorLineHeight));
paint.setStyle(SkPaint::kFill_Style);
- paint.setStrokeCap(SkPaint::kRound_Cap);
paint.setShader(SkGradientShader::MakeLinear(
- gradient_points, gradient_colors, NULL, 2, SkShader::kClamp_TileMode));
+ gradient_points, gradient_colors, nullptr, 2, SkShader::kClamp_TileMode));
InfoBarView* infobar = static_cast<InfoBarView*>(view);
SkCanvas* canvas_skia = canvas->sk_canvas();
canvas_skia->drawPath(infobar->fill_path(), paint);
- paint.setShader(NULL);
+ paint.setShader(nullptr);
Peter Kasting 2016/03/23 00:28:17 Nit: Rather than reset this, let's just use two di
paint.setColor(SkColorSetA(separator_color_,
SkColorGetA(gradient_colors[0])));
+ paint.setStrokeCap(SkPaint::kRound_Cap);
Peter Kasting 2016/03/22 23:39:18 Why do we need to set the cap for a hairline?
+ paint.setStrokeWidth(
+ ui::MaterialDesignController::IsModeMaterial()
+ ? 0
+ : SkIntToScalar(InfoBarContainerDelegate::kSeparatorLineHeight));
paint.setStyle(SkPaint::kStroke_Style);
// Anti-alias the path so it doesn't look goofy when the edges are not at 45
// degree angles, but don't anti-alias anything else, especially not the fill,
@@ -53,9 +56,7 @@ void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
paint.setAntiAlias(false);
// Now draw the separator at the bottom.
- canvas->FillRect(
- gfx::Rect(0,
- view->height() - InfoBarContainerDelegate::kSeparatorLineHeight,
- view->width(), InfoBarContainerDelegate::kSeparatorLineHeight),
- separator_color_);
+ paint.setColor(separator_color_);
+ SkScalar bottom = SkIntToScalar(view->height()) - SK_ScalarHalf;
Peter Kasting 2016/03/23 00:28:17 This seems wrong at >1x. It really wants to move
Evan Stade 2016/03/23 00:35:46 You're right, it does have bugs at >2x scales. I'l
+ canvas_skia->drawLine(0, bottom, SkIntToScalar(view->width()), bottom, paint);
}
« no previous file with comments | « no previous file | chrome/browser/ui/views/infobars/infobar_view.cc » ('j') | chrome/browser/ui/views/infobars/infobar_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698