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

Unified Diff: ui/views/controls/focusable_border.cc

Issue 2693943003: Improve appearance of FocusableBorder at fractional scale factors by (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/focusable_border.cc
diff --git a/ui/views/controls/focusable_border.cc b/ui/views/controls/focusable_border.cc
index a63629c0ef3444a5e10b78cfc928d3f66b5d37e1..6f388e9ec4c415e44a3e4f28ed730864ae486bbe 100644
--- a/ui/views/controls/focusable_border.cc
+++ b/ui/views/controls/focusable_border.cc
@@ -43,27 +43,28 @@ void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) {
flags.setStyle(cc::PaintFlags::kStroke_Style);
flags.setColor(GetCurrentColor(view));
+ gfx::ScopedCanvas scoped(canvas);
+ float dsf = canvas->UndoDeviceScaleFactor();
+
+ const int stroke_width_px =
+ ui::MaterialDesignController::IsSecondaryUiMaterial() ? 1 : dsf;
Peter Kasting 2017/02/14 00:30:32 It seems like the old pre-Harmony code was trying
Evan Stade 2017/02/14 00:37:47 That was just a hacky way to get a 1dip border. 1d
Peter Kasting 2017/02/14 00:45:59 I see. Why was the old code producing poorer-look
+ flags.setStrokeWidth(SkIntToScalar(stroke_width_px));
+
+ // Scale the rect and snap to pixel boundaries.
+ gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf));
+ rect.Inset(gfx::InsetsF(stroke_width_px / 2.0f));
+
+ SkPath path;
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
- gfx::ScopedCanvas scoped(canvas);
- float dsf = canvas->UndoDeviceScaleFactor();
- // Scale the rect and snap to pixel boundaries.
- gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf));
- rect.Inset(gfx::InsetsF(0.5f));
- SkPath path;
+ flags.setAntiAlias(true);
float corner_radius_px = kCornerRadiusDp * dsf;
path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px,
corner_radius_px);
- const int kStrokeWidthPx = 1;
- flags.setStrokeWidth(SkIntToScalar(kStrokeWidthPx));
- flags.setAntiAlias(true);
- canvas->DrawPath(path, flags);
} else {
- SkPath path;
- path.addRect(gfx::RectToSkRect(view.GetLocalBounds()),
- SkPath::kCW_Direction);
- flags.setStrokeWidth(SkIntToScalar(2));
- canvas->DrawPath(path, flags);
+ path.addRect(gfx::RectFToSkRect(rect), SkPath::kCW_Direction);
}
+
+ canvas->DrawPath(path, flags);
}
gfx::Insets FocusableBorder::GetInsets() const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698