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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "third_party/skia/include/effects/SkGradientShader.h" | 13 #include "third_party/skia/include/effects/SkGradientShader.h" |
14 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/geometry/rect_conversions.h" | 16 #include "ui/gfx/geometry/rect_conversions.h" |
| 17 #include "ui/gfx/geometry/rect_f.h" |
17 #include "ui/gfx/geometry/safe_integer_conversions.h" | 18 #include "ui/gfx/geometry/safe_integer_conversions.h" |
18 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
19 #include "ui/gfx/scoped_canvas.h" | 20 #include "ui/gfx/scoped_canvas.h" |
20 #include "ui/gfx/skia_util.h" | 21 #include "ui/gfx/skia_util.h" |
21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
22 | 23 |
23 namespace gfx { | 24 namespace gfx { |
24 | 25 |
25 Canvas::Canvas(const Size& size, float image_scale, bool is_opaque) | 26 Canvas::Canvas(const Size& size, float image_scale, bool is_opaque) |
26 : image_scale_(image_scale), | 27 : image_scale_(image_scale), |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 SkIntToScalar(center_point.y()), SkIntToScalar(radius), paint); | 299 SkIntToScalar(center_point.y()), SkIntToScalar(radius), paint); |
299 } | 300 } |
300 | 301 |
301 void Canvas::DrawRoundRect(const Rect& rect, | 302 void Canvas::DrawRoundRect(const Rect& rect, |
302 int radius, | 303 int radius, |
303 const SkPaint& paint) { | 304 const SkPaint& paint) { |
304 canvas_->drawRoundRect(RectToSkRect(rect), SkIntToScalar(radius), | 305 canvas_->drawRoundRect(RectToSkRect(rect), SkIntToScalar(radius), |
305 SkIntToScalar(radius), paint); | 306 SkIntToScalar(radius), paint); |
306 } | 307 } |
307 | 308 |
| 309 void Canvas::DrawRoundRect(const RectF& rect, |
| 310 float radius, |
| 311 const SkPaint& paint) { |
| 312 canvas_->drawRoundRect(RectFToSkRect(rect), SkFloatToScalar(radius), |
| 313 SkFloatToScalar(radius), paint); |
| 314 } |
| 315 |
308 void Canvas::DrawPath(const SkPath& path, const SkPaint& paint) { | 316 void Canvas::DrawPath(const SkPath& path, const SkPaint& paint) { |
309 canvas_->drawPath(path, paint); | 317 canvas_->drawPath(path, paint); |
310 } | 318 } |
311 | 319 |
312 void Canvas::DrawFocusRect(const Rect& rect) { | 320 void Canvas::DrawFocusRect(const Rect& rect) { |
313 DrawDashedRect(rect, SK_ColorGRAY); | 321 DrawDashedRect(rect, SK_ColorGRAY); |
314 } | 322 } |
315 | 323 |
316 void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) { | 324 void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) { |
317 SkPaint paint; | 325 SkPaint paint; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 // by the paint). | 628 // by the paint). |
621 SkPaint p(paint); | 629 SkPaint p(paint); |
622 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); | 630 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); |
623 p.setShader(shader.get()); | 631 p.setShader(shader.get()); |
624 | 632 |
625 // The rect will be filled by the bitmap. | 633 // The rect will be filled by the bitmap. |
626 canvas_->drawRect(dest_rect, p); | 634 canvas_->drawRect(dest_rect, p); |
627 } | 635 } |
628 | 636 |
629 } // namespace gfx | 637 } // namespace gfx |
OLD | NEW |