Chromium Code Reviews| 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 DrawLine(PointF(p1), PointF(p2), flags); | 314 DrawLine(PointF(p1), PointF(p2), flags); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void Canvas::DrawLine(const PointF& p1, | 317 void Canvas::DrawLine(const PointF& p1, |
| 318 const PointF& p2, | 318 const PointF& p2, |
| 319 const cc::PaintFlags& flags) { | 319 const cc::PaintFlags& flags) { |
| 320 canvas_->drawLine(SkFloatToScalar(p1.x()), SkFloatToScalar(p1.y()), | 320 canvas_->drawLine(SkFloatToScalar(p1.x()), SkFloatToScalar(p1.y()), |
| 321 SkFloatToScalar(p2.x()), SkFloatToScalar(p2.y()), flags); | 321 SkFloatToScalar(p2.x()), SkFloatToScalar(p2.y()), flags); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void Canvas::DrawSharpLine(const PointF& p1, const PointF& p2, SkColor color) { | |
| 325 ScopedCanvas scoped(this); | |
| 326 float dsf = UndoDeviceScaleFactor(); | |
| 327 | |
| 328 PointF start = p1; | |
|
Peter Kasting
2017/02/15 00:43:59
Nit: If you're just going to copy these anyway, I
Evan Stade
2017/02/15 16:54:46
I thought we never passed non-PODs by value and co
| |
| 329 start.Scale(dsf); | |
| 330 PointF end = p2; | |
| 331 end.Scale(dsf); | |
| 332 | |
| 333 cc::PaintFlags flags; | |
| 334 flags.setColor(color); | |
| 335 flags.setStrokeWidth(std::floor(dsf)); | |
|
Evan Stade
2017/02/14 23:06:03
I guess I could use gfx::ToFlooredInt for this, bu
Peter Kasting
2017/02/15 00:43:59
floor() returns a float, which is potentially outs
Evan Stade
2017/02/15 16:54:46
Done.
| |
| 336 | |
| 337 DrawLine(start, end, flags); | |
| 338 } | |
| 339 | |
| 324 void Canvas::DrawCircle(const Point& center_point, | 340 void Canvas::DrawCircle(const Point& center_point, |
| 325 int radius, | 341 int radius, |
| 326 const cc::PaintFlags& flags) { | 342 const cc::PaintFlags& flags) { |
| 327 DrawCircle(PointF(center_point), radius, flags); | 343 DrawCircle(PointF(center_point), radius, flags); |
| 328 } | 344 } |
| 329 | 345 |
| 330 void Canvas::DrawCircle(const PointF& center_point, | 346 void Canvas::DrawCircle(const PointF& center_point, |
| 331 float radius, | 347 float radius, |
| 332 const cc::PaintFlags& flags) { | 348 const cc::PaintFlags& flags) { |
| 333 canvas_->drawCircle(SkFloatToScalar(center_point.x()), | 349 canvas_->drawCircle(SkFloatToScalar(center_point.x()), |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 flags.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); | 616 flags.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); |
| 601 flags.setShader(CreateImageRepShaderForScale( | 617 flags.setShader(CreateImageRepShaderForScale( |
| 602 image_rep, SkShader::kRepeat_TileMode, shader_scale, | 618 image_rep, SkShader::kRepeat_TileMode, shader_scale, |
| 603 remove_image_scale ? image_rep.scale() : 1.f)); | 619 remove_image_scale ? image_rep.scale() : 1.f)); |
| 604 | 620 |
| 605 // The rect will be filled by the bitmap. | 621 // The rect will be filled by the bitmap. |
| 606 canvas_->drawRect(dest_rect, flags); | 622 canvas_->drawRect(dest_rect, flags); |
| 607 } | 623 } |
| 608 | 624 |
| 609 } // namespace gfx | 625 } // namespace gfx |
| OLD | NEW |