From 19f6331a6fffac34723de2b2767d1197de44e1d6 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Sat, 5 Dec 2015 01:11:07 -0800 Subject: [PATCH] Add a bunch of missing Path functions Part of #252 --- sky/engine/core/painting/CanvasPath.h | 33 ++++++++++++++------------- sky/engine/core/painting/Path.idl | 16 +++++++++++-- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/sky/engine/core/painting/CanvasPath.h b/sky/engine/core/painting/CanvasPath.h index af19bb98ecd..31bd816e1f2 100644 --- a/sky/engine/core/painting/CanvasPath.h +++ b/sky/engine/core/painting/CanvasPath.h @@ -9,6 +9,7 @@ #include "sky/engine/core/painting/Offset.h" #include "sky/engine/core/painting/Rect.h" +#include "sky/engine/core/painting/RRect.h" #include "sky/engine/tonic/dart_wrappable.h" #include "sky/engine/wtf/PassRefPtr.h" #include "sky/engine/wtf/RefCounted.h" @@ -29,25 +30,25 @@ public: return adoptRef(new CanvasPath); } - void moveTo(float x, float y) - { - m_path.moveTo(x, y); - } - - void lineTo(float x, float y) - { - m_path.lineTo(x, y); - } - - void arcTo(const Rect& rect, float startAngle, float sweepAngle, bool forceMoveTo) - { + void moveTo(float x, float y) { m_path.moveTo(x, y); } + void relativeMoveTo(float x, float y) { m_path.rMoveTo(x, y); } + void lineTo(float x, float y) { m_path.lineTo(x, y); } + void relativeLineTo(float x, float y) { m_path.rLineTo(x, y); } + void quadraticBezierTo(float x1, float y1, float x2, float y2) { m_path.quadTo(x1, y1, x2, y2); } + void relativeQuadraticBezierTo(float x1, float y1, float x2, float y2) { m_path.rQuadTo(x1, y1, x2, y2); } + void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) { m_path.cubicTo(x1, y1, x2, y2, x3, y3); } + void relativeCubicTo(float x1, float y1, float x2, float y2, float x3, float y3) { m_path.rCubicTo(x1, y1, x2, y2, x3, y3); } + void conicTo(float x1, float y1, float x2, float y2, float w) { m_path.conicTo(x1, y1, x2, y2, w); } + void relativeConicTo(float x1, float y1, float x2, float y2, float w) { m_path.rConicTo(x1, y1, x2, y2, w); } + void arcTo(const Rect& rect, float startAngle, float sweepAngle, bool forceMoveTo) { m_path.arcTo(rect.sk_rect, startAngle*180.0/M_PI, sweepAngle*180.0/M_PI, forceMoveTo); } - - void addOval(const Rect& oval) - { - m_path.addOval(oval.sk_rect); + void addRect(const Rect& rect) { m_path.addRect(rect.sk_rect); } + void addOval(const Rect& oval) { m_path.addOval(oval.sk_rect); } + void addArc(const Rect& rect, float startAngle, float sweepAngle) { + m_path.addArc(rect.sk_rect, startAngle*180.0/M_PI, sweepAngle*180.0/M_PI); } + void addRRect(const RRect& rrect) { m_path.addRRect(rrect.sk_rrect); } void close() { diff --git a/sky/engine/core/painting/Path.idl b/sky/engine/core/painting/Path.idl index 2b8d639c0f7..dcc4d23db3a 100644 --- a/sky/engine/core/painting/Path.idl +++ b/sky/engine/core/painting/Path.idl @@ -7,11 +7,23 @@ ImplementedAs=CanvasPath, ] interface Path { void moveTo(float x, float y); + void relativeMoveTo(float dx, float dy); void lineTo(float x, float y); + void relativeLineTo(float dx, float dy); + void quadraticBezierTo(float x1, float y1, float x2, float y2); + void relativeQuadraticBezierTo(float x1, float y1, float x2, float y2); + void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3); + void relativeCubicTo(float x1, float y1, float x2, float y2, float x3, float y3); + void conicTo(float x1, float y1, float x2, float y2, float w); + void relativeConicTo(float x1, float y1, float x2, float y2, float w); void arcTo(Rect rect, float startAngle, float sweepAngle, boolean forceMoveTo); // angles in radians - void addOval(Rect oval); - void close(); + void addRect(Rect rect); + void addOval(Rect oval); + void addArc(Rect oval, float startAngle, float sweepAngle); // angles in radians + void addRRect(RRect rrect); + + void close(); void reset(); Path shift(Offset offset);