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

Side by Side Diff: ui/gfx/canvas.cc

Issue 2714753002: Improve appearance of focus rings at fractional scales. (Closed)
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « ui/gfx/canvas.h ('k') | ui/views/controls/slider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gfx/canvas.h" 5 #include "ui/gfx/canvas.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 366 }
367 367
368 void Canvas::DrawFocusRect(const Rect& rect) { 368 void Canvas::DrawFocusRect(const Rect& rect) {
369 DrawFocusRect(RectF(rect)); 369 DrawFocusRect(RectF(rect));
370 } 370 }
371 371
372 void Canvas::DrawFocusRect(const RectF& rect) { 372 void Canvas::DrawFocusRect(const RectF& rect) {
373 DrawDashedRect(rect, SK_ColorGRAY); 373 DrawDashedRect(rect, SK_ColorGRAY);
374 } 374 }
375 375
376 void Canvas::DrawSolidFocusRect(RectF rect, SkColor color, float thickness) { 376 void Canvas::DrawSolidFocusRect(RectF rect, SkColor color, int thickness) {
377 cc::PaintFlags flags; 377 cc::PaintFlags flags;
378 flags.setColor(color); 378 flags.setColor(color);
379 flags.setStrokeWidth(SkFloatToScalar(thickness)); 379 const float adjusted_thickness =
380 std::floor(thickness * image_scale_) / image_scale_;
381 flags.setStrokeWidth(SkFloatToScalar(adjusted_thickness));
380 flags.setStyle(cc::PaintFlags::kStroke_Style); 382 flags.setStyle(cc::PaintFlags::kStroke_Style);
381 rect.Inset(gfx::InsetsF(thickness / 2)); 383 rect.Inset(gfx::InsetsF(adjusted_thickness / 2));
382 DrawRect(rect, flags); 384 DrawRect(rect, flags);
383 } 385 }
384 386
385 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { 387 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) {
386 cc::PaintFlags flags; 388 cc::PaintFlags flags;
387 DrawImageInt(image, x, y, flags); 389 DrawImageInt(image, x, y, flags);
388 } 390 }
389 391
390 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8_t a) { 392 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8_t a) {
391 cc::PaintFlags flags; 393 cc::PaintFlags flags;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 flags.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); 612 flags.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
611 flags.setShader(CreateImageRepShaderForScale( 613 flags.setShader(CreateImageRepShaderForScale(
612 image_rep, SkShader::kRepeat_TileMode, shader_scale, 614 image_rep, SkShader::kRepeat_TileMode, shader_scale,
613 remove_image_scale ? image_rep.scale() : 1.f)); 615 remove_image_scale ? image_rep.scale() : 1.f));
614 616
615 // The rect will be filled by the bitmap. 617 // The rect will be filled by the bitmap.
616 canvas_->drawRect(dest_rect, flags); 618 canvas_->drawRect(dest_rect, flags);
617 } 619 }
618 620
619 } // namespace gfx 621 } // namespace gfx
OLDNEW
« 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