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

Unified Diff: ui/gfx/canvas.cc

Issue 2714753002: Improve appearance of focus rings at fractional scales. (Closed)
Patch Set: rebase 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 | « ui/gfx/canvas.h ('k') | ui/views/controls/slider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index ed9cea122815fb411d68469ee87438dfd8ab3131..00e186f0e636edff1d7634cb4488f6aceb33a739 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -373,12 +373,14 @@ void Canvas::DrawFocusRect(const RectF& rect) {
DrawDashedRect(rect, SK_ColorGRAY);
}
-void Canvas::DrawSolidFocusRect(RectF rect, SkColor color, float thickness) {
+void Canvas::DrawSolidFocusRect(RectF rect, SkColor color, int thickness) {
cc::PaintFlags flags;
flags.setColor(color);
- flags.setStrokeWidth(SkFloatToScalar(thickness));
+ const float adjusted_thickness =
+ std::floor(thickness * image_scale_) / image_scale_;
+ flags.setStrokeWidth(SkFloatToScalar(adjusted_thickness));
flags.setStyle(cc::PaintFlags::kStroke_Style);
- rect.Inset(gfx::InsetsF(thickness / 2));
+ rect.Inset(gfx::InsetsF(adjusted_thickness / 2));
DrawRect(rect, flags);
}
« no previous file with comments | « ui/gfx/canvas.h ('k') | ui/views/controls/slider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698