Chromium Code Reviews| 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 { |