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

Side by Side Diff: ui/views/painter.cc

Issue 2322653002: Sharpen MdTextButton border for fractional scale factors. (Closed)
Patch Set: always have an opaque bg Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/painter.h" 5 #include "ui/views/painter.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 SolidRoundRectPainter::~SolidRoundRectPainter() {} 58 SolidRoundRectPainter::~SolidRoundRectPainter() {}
59 59
60 gfx::Size SolidRoundRectPainter::GetMinimumSize() const { 60 gfx::Size SolidRoundRectPainter::GetMinimumSize() const {
61 return gfx::Size(); 61 return gfx::Size();
62 } 62 }
63 63
64 void SolidRoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { 64 void SolidRoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
65 gfx::ScopedCanvas scoped_canvas(canvas); 65 gfx::ScopedCanvas scoped_canvas(canvas);
66 const float scale = canvas->UndoDeviceScaleFactor(); 66 const float scale = canvas->UndoDeviceScaleFactor();
67 67
68 gfx::RectF border_rect_f((gfx::SizeF(size))); 68 gfx::RectF border_rect_f(gfx::ScaleToEnclosingRect(gfx::Rect(size), scale));
69 border_rect_f.Scale(scale);
70 const SkScalar scaled_corner_radius = SkFloatToScalar(radius_ * scale); 69 const SkScalar scaled_corner_radius = SkFloatToScalar(radius_ * scale);
71 70
72 SkPaint paint; 71 SkPaint paint;
73 paint.setAntiAlias(true); 72 paint.setAntiAlias(true);
74 paint.setStyle(SkPaint::kFill_Style); 73 paint.setStyle(SkPaint::kFill_Style);
75 paint.setColor(bg_color_); 74 paint.setColor(bg_color_);
76 canvas->DrawRoundRect(border_rect_f, scaled_corner_radius, paint); 75 canvas->DrawRoundRect(border_rect_f, scaled_corner_radius, paint);
77 76
78 border_rect_f.Inset(gfx::InsetsF(0.5f)); 77 border_rect_f.Inset(gfx::InsetsF(0.5f));
79 paint.setStyle(SkPaint::kStroke_Style); 78 paint.setStyle(SkPaint::kStroke_Style);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 canvas->DrawImageInt(*images_[LEFT], 0, 0); 385 canvas->DrawImageInt(*images_[LEFT], 0, 0);
387 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), 386 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(),
388 0); 387 0);
389 canvas->TileImageInt( 388 canvas->TileImageInt(
390 *images_[CENTER], images_[LEFT]->width(), 0, 389 *images_[CENTER], images_[LEFT]->width(), 0,
391 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), 390 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(),
392 images_[LEFT]->height()); 391 images_[LEFT]->height());
393 } 392 }
394 393
395 } // namespace views 394 } // namespace views
OLDNEW
« ui/views/controls/button/md_text_button.cc ('K') | « ui/views/controls/focusable_border.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698