diff --git a/sky/engine/core/dart/painting.dart b/sky/engine/core/dart/painting.dart index d4ec7623d02..c7f421f4565 100644 --- a/sky/engine/core/dart/painting.dart +++ b/sky/engine/core/dart/painting.dart @@ -162,6 +162,13 @@ class Path extends NativeFieldWrapperClass2 { /// reset to the origin. void reset() native "Path_reset"; + /// Tests to see if the point is within the path. (That is, whether + /// the point would be in the visible portion of the path if the + /// path was used with [Canvas.clipPath].) + /// + /// Returns true if the point is in the path, and false otherwise. + bool contains(Point position) native "Path_contains"; + /// Returns a copy of the path with all the segments of every /// subpath translated by the given offset. Path shift(Offset offset) native "Path_shift"; @@ -357,7 +364,7 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// Call [restore] to pop the save stack. void save() native "Canvas_save"; - + /// Saves a copy of the current transform and clip on the save /// stack, and then creates a new group which subsequent calls will /// become a part of. When the save stack is later popped, the group @@ -380,7 +387,7 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// Use [save] and [saveLayer] to push state onto the stack. void restore() native "Canvas_restore"; - + /// Returns the number of items on the save stack, including the /// initial state. This means it returns 1 for a clean canvas, and /// that each call to [save] and [saveLayer] increments it, and that @@ -388,7 +395,7 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// This number cannot go below 1. int getSaveCount() native "Canvas_getSaveCount"; - + void translate(double dx, double dy) native "Canvas_translate"; void scale(double sx, double sy) native "Canvas_scale"; void rotate(double radians) native "Canvas_rotate"; diff --git a/sky/engine/core/painting/CanvasPath.cpp b/sky/engine/core/painting/CanvasPath.cpp index 9f041c2be24..991e3941a26 100644 --- a/sky/engine/core/painting/CanvasPath.cpp +++ b/sky/engine/core/painting/CanvasPath.cpp @@ -37,6 +37,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Path); V(Path, addRRect) \ V(Path, close) \ V(Path, reset) \ + V(Path, contains) \ V(Path, shift) FOR_EACH_BINDING(DART_NATIVE_CALLBACK) diff --git a/sky/engine/core/painting/CanvasPath.h b/sky/engine/core/painting/CanvasPath.h index 8f8f57dda1e..510d3c6a665 100644 --- a/sky/engine/core/painting/CanvasPath.h +++ b/sky/engine/core/painting/CanvasPath.h @@ -8,8 +8,9 @@ #include "math.h" #include "sky/engine/core/painting/Offset.h" -#include "sky/engine/core/painting/Rect.h" +#include "sky/engine/core/painting/Point.h" #include "sky/engine/core/painting/RRect.h" +#include "sky/engine/core/painting/Rect.h" #include "sky/engine/tonic/dart_wrappable.h" #include "sky/engine/wtf/PassRefPtr.h" #include "sky/engine/wtf/ThreadSafeRefCounted.h" @@ -19,6 +20,8 @@ // We should probably rationalise these two. // (The existence of that class is why this is CanvasPath and not just Path.) +// The Dart side of this is in ../dart/painting.dart + namespace blink { class DartLibraryNatives; @@ -61,6 +64,8 @@ public: m_path.reset(); } + bool contains(const Point& point) { return m_path.contains(point.sk_point.x(), point.sk_point.y()); } + const SkPath& path() const { return m_path; } PassRefPtr shift(const Offset& offset);