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

Unified Diff: ui/views/border.cc

Issue 2694933002: Fix appearance of task manager border at fractional scale factors. (Closed)
Patch Set: inline 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/border.cc
diff --git a/ui/views/border.cc b/ui/views/border.cc
index 14e6d302e20de5e7955465510d7dfdbc2a6cccb9..a53e4a6b46d3a6e07d2bb867650988f1787e712a 100644
--- a/ui/views/border.cc
+++ b/ui/views/border.cc
@@ -12,6 +12,7 @@
#include "cc/paint/paint_flags.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/scoped_canvas.h"
#include "ui/views/painter.h"
#include "ui/views/view.h"
@@ -42,18 +43,18 @@ SolidSidedBorder::SolidSidedBorder(const gfx::Insets& insets, SkColor color)
}
void SolidSidedBorder::Paint(const View& view, gfx::Canvas* canvas) {
- // Top border.
- canvas->FillRect(gfx::Rect(0, 0, view.width(), insets_.top()), color_);
- // Left border.
- canvas->FillRect(gfx::Rect(0, insets_.top(), insets_.left(),
- view.height() - insets_.height()), color_);
- // Bottom border.
- canvas->FillRect(gfx::Rect(0, view.height() - insets_.bottom(), view.width(),
- insets_.bottom()), color_);
- // Right border.
- canvas->FillRect(gfx::Rect(view.width() - insets_.right(), insets_.top(),
- insets_.right(), view.height() - insets_.height()),
- color_);
+ // Undo DSF so that we can be sure to draw an integral number of pixels for
+ // the border. Integral scale factors should be unaffected by this, but for
+ // fractional scale factors this ensures sharp lines.
+ gfx::ScopedCanvas scoped(canvas);
+ float dsf = canvas->UndoDeviceScaleFactor();
+
+ gfx::RectF bounds(view.GetLocalBounds());
Peter Kasting 2017/02/17 02:40:15 Nit: Prefer = to () for this (see https://www.chro
Evan Stade 2017/02/17 06:19:55 For rectf from rect you have to use the constructo
Peter Kasting 2017/02/17 07:13:19 Oh, I didn't even see that you were converting int
+ bounds.Scale(dsf);
+ // This scaling operation floors the inset values.
+ bounds.Inset(insets_.Scale(dsf));
+ canvas->ClipRect(bounds, SkClipOp::kDifference);
+ canvas->DrawColor(color_);
}
gfx::Insets SolidSidedBorder::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