| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |