diff options
| author | Romain Guy <romainguy@google.com> | 2013-07-29 19:17:59 -0700 |
|---|---|---|
| committer | Romain Guy <romainguy@google.com> | 2013-07-30 10:51:24 -0700 |
| commit | 8018c8db8221aa604b3c083e09d173cc27e53d83 (patch) | |
| tree | 60cbc26ddde4fa65a476a7e869d88f358b734210 /core/jni/android/graphics/Path.cpp | |
| parent | 93d34a61dbdfd9ece9ac4a53d78e896638172895 (diff) | |
| download | frameworks_base-8018c8db8221aa604b3c083e09d173cc27e53d83.zip frameworks_base-8018c8db8221aa604b3c083e09d173cc27e53d83.tar.gz frameworks_base-8018c8db8221aa604b3c083e09d173cc27e53d83.tar.bz2 | |
Add path ops API
Path ops can be used to combine two paths instances in a single path
object. The following operations can be used:
- Difference
- Reverse difference
- Union
- XOR
- Intersection
To use the API:
Path p1 = createCircle();
Path p2 = createRect();
Path result = new Path();
result.op(p1, p2, Path.Op.DIFFERENCE);
This code will subtract the rectangle from the circle and generate
the resulting path in "result."
Change-Id: Ic25244665b6691a7df0b0002a09da73d937b553b
Diffstat (limited to 'core/jni/android/graphics/Path.cpp')
| -rw-r--r-- | core/jni/android/graphics/Path.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp index eb9e004..ab7f1dc 100644 --- a/core/jni/android/graphics/Path.cpp +++ b/core/jni/android/graphics/Path.cpp @@ -25,6 +25,7 @@ #include <android_runtime/AndroidRuntime.h> #include "SkPath.h" +#include "pathops/SkPathOps.h" #include <Caches.h> @@ -67,8 +68,7 @@ public: return obj->getFillType(); } - static void setFillType(JNIEnv* env, jobject clazz, SkPath* path, - SkPath::FillType ft) { + static void setFillType(JNIEnv* env, jobject clazz, SkPath* path, SkPath::FillType ft) { path->setFillType(ft); } @@ -200,7 +200,7 @@ public: } static void addRoundRectXY(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect, - jfloat rx, jfloat ry, SkPath::Direction dir) { + jfloat rx, jfloat ry, SkPath::Direction dir) { SkRect rect_; GraphicsJNI::jrectf_to_rect(env, rect, &rect_); SkScalar rx_ = SkFloatToScalar(rx); @@ -209,7 +209,7 @@ public: } static void addRoundRect8(JNIEnv* env, jobject, SkPath* obj, jobject rect, - jfloatArray array, SkPath::Direction dir) { + jfloatArray array, SkPath::Direction dir) { SkRect rect_; GraphicsJNI::jrectf_to_rect(env, rect, &rect_); AutoJavaFloatArray afa(env, array, 8); @@ -261,7 +261,10 @@ public: static void transform__Matrix(JNIEnv* env, jobject clazz, SkPath* obj, SkMatrix* matrix) { obj->transform(*matrix); } - + + static jboolean op(JNIEnv* env, jobject clazz, SkPath* p1, SkPath* p2, SkPathOp op, SkPath* r) { + return Op(*p1, *p2, op, r); + } }; static JNINativeMethod methods[] = { @@ -301,7 +304,8 @@ static JNINativeMethod methods[] = { {"native_offset","(IFF)V", (void*) SkPathGlue::offset__FF}, {"native_setLastPoint","(IFF)V", (void*) SkPathGlue::setLastPoint}, {"native_transform","(III)V", (void*) SkPathGlue::transform__MatrixPath}, - {"native_transform","(II)V", (void*) SkPathGlue::transform__Matrix} + {"native_transform","(II)V", (void*) SkPathGlue::transform__Matrix}, + {"native_op","(IIII)Z", (void*) SkPathGlue::op} }; int register_android_graphics_Path(JNIEnv* env) { |
