The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* libs/android_runtime/android/graphics/Path.cpp |
| 2 | ** |
| 3 | ** Copyright 2006, The Android Open Source Project |
| 4 | ** |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 8 | ** |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 10 | ** |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | // This file was generated from the C++ include file: SkPath.h |
| 19 | // Any changes made to this file will be discarded by the build. |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 20 | // To change this file, either edit the include, or device/tools/gluemaker/main.cpp, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | // or one of the auxilary file specifications in device/tools/gluemaker. |
| 22 | |
| 23 | #include "jni.h" |
| 24 | #include "GraphicsJNI.h" |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 25 | #include "core_jni_helpers.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
| 27 | #include "SkPath.h" |
Derek Sollenberger | eece0dd | 2014-02-27 14:31:29 -0500 | [diff] [blame] | 28 | #include "SkPathOps.h" |
Chris Craik | 96202d5 | 2017-04-27 15:26:17 -0700 | [diff] [blame] | 29 | #include "SkGeometry.h" // WARNING: Internal Skia Header |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 31 | #include <vector> |
| 32 | #include <map> |
Romain Guy | a2341a9 | 2010-09-08 18:04:33 -0700 | [diff] [blame] | 33 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | namespace android { |
| 35 | |
| 36 | class SkPathGlue { |
| 37 | public: |
| 38 | |
John Reck | 205d83e | 2018-03-28 14:36:58 -0700 | [diff] [blame] | 39 | static void finalizer(SkPath* obj) { |
John Reck | 205d83e | 2018-03-28 14:36:58 -0700 | [diff] [blame] | 40 | delete obj; |
| 41 | } |
| 42 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 43 | // ---------------- Regular JNI ----------------------------- |
| 44 | |
| 45 | static jlong init(JNIEnv* env, jclass clazz) { |
| 46 | return reinterpret_cast<jlong>(new SkPath()); |
| 47 | } |
| 48 | |
| 49 | static jlong init_Path(JNIEnv* env, jclass clazz, jlong valHandle) { |
| 50 | SkPath* val = reinterpret_cast<SkPath*>(valHandle); |
| 51 | return reinterpret_cast<jlong>(new SkPath(*val)); |
| 52 | } |
| 53 | |
John Reck | 205d83e | 2018-03-28 14:36:58 -0700 | [diff] [blame] | 54 | static jlong getFinalizer(JNIEnv* env, jclass clazz) { |
| 55 | return static_cast<jlong>(reinterpret_cast<uintptr_t>(&finalizer)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | } |
| 57 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 58 | static void set(JNIEnv* env, jclass clazz, jlong dstHandle, jlong srcHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 59 | SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); |
| 60 | const SkPath* src = reinterpret_cast<SkPath*>(srcHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | *dst = *src; |
| 62 | } |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 63 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 64 | static void computeBounds(JNIEnv* env, jclass clazz, jlong objHandle, jobject jbounds) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 65 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 66 | const SkRect& bounds = obj->getBounds(); |
| 67 | GraphicsJNI::rect_to_jrectf(bounds, env, jbounds); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 69 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 70 | static void incReserve(JNIEnv* env, jclass clazz, jlong objHandle, jint extraPtCount) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 71 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | obj->incReserve(extraPtCount); |
| 73 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 74 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 75 | static void moveTo__FF(JNIEnv* env, jclass clazz, jlong objHandle, jfloat x, jfloat y) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 76 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 77 | obj->moveTo(x, y); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 79 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 80 | static void rMoveTo(JNIEnv* env, jclass clazz, jlong objHandle, jfloat dx, jfloat dy) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 81 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 82 | obj->rMoveTo(dx, dy); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 84 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 85 | static void lineTo__FF(JNIEnv* env, jclass clazz, jlong objHandle, jfloat x, jfloat y) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 86 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 87 | obj->lineTo(x, y); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 89 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 90 | static void rLineTo(JNIEnv* env, jclass clazz, jlong objHandle, jfloat dx, jfloat dy) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 91 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 92 | obj->rLineTo(dx, dy); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 94 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 95 | static void quadTo__FFFF(JNIEnv* env, jclass clazz, jlong objHandle, jfloat x1, jfloat y1, |
| 96 | jfloat x2, jfloat y2) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 97 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 98 | obj->quadTo(x1, y1, x2, y2); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 100 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 101 | static void rQuadTo(JNIEnv* env, jclass clazz, jlong objHandle, jfloat dx1, jfloat dy1, |
| 102 | jfloat dx2, jfloat dy2) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 103 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 104 | obj->rQuadTo(dx1, dy1, dx2, dy2); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 106 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 107 | static void cubicTo__FFFFFF(JNIEnv* env, jclass clazz, jlong objHandle, jfloat x1, jfloat y1, |
| 108 | jfloat x2, jfloat y2, jfloat x3, jfloat y3) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 109 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 110 | obj->cubicTo(x1, y1, x2, y2, x3, y3); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 112 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 113 | static void rCubicTo(JNIEnv* env, jclass clazz, jlong objHandle, jfloat x1, jfloat y1, |
| 114 | jfloat x2, jfloat y2, jfloat x3, jfloat y3) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 115 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 116 | obj->rCubicTo(x1, y1, x2, y2, x3, y3); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 118 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 119 | static void arcTo(JNIEnv* env, jclass clazz, jlong objHandle, jfloat left, jfloat top, |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 120 | jfloat right, jfloat bottom, jfloat startAngle, jfloat sweepAngle, |
| 121 | jboolean forceMoveTo) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 122 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 123 | SkRect oval = SkRect::MakeLTRB(left, top, right, bottom); |
| 124 | obj->arcTo(oval, startAngle, sweepAngle, forceMoveTo); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 126 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 127 | static void close(JNIEnv* env, jclass clazz, jlong objHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 128 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | obj->close(); |
| 130 | } |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 131 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 132 | static void addRect(JNIEnv* env, jclass clazz, jlong objHandle, |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 133 | jfloat left, jfloat top, jfloat right, jfloat bottom, jint dirHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 134 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Mike Reed | 15760c9 | 2019-11-25 11:43:48 -0500 | [diff] [blame] | 135 | SkPathDirection dir = static_cast<SkPathDirection>(dirHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 136 | obj->addRect(left, top, right, bottom, dir); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | } |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 138 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 139 | static void addOval(JNIEnv* env, jclass clazz, jlong objHandle, |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 140 | jfloat left, jfloat top, jfloat right, jfloat bottom, jint dirHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 141 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Mike Reed | 15760c9 | 2019-11-25 11:43:48 -0500 | [diff] [blame] | 142 | SkPathDirection dir = static_cast<SkPathDirection>(dirHandle); |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 143 | SkRect oval = SkRect::MakeLTRB(left, top, right, bottom); |
| 144 | obj->addOval(oval, dir); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | } |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 146 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 147 | static void addCircle(JNIEnv* env, jclass clazz, jlong objHandle, jfloat x, jfloat y, |
| 148 | jfloat radius, jint dirHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 149 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Mike Reed | 15760c9 | 2019-11-25 11:43:48 -0500 | [diff] [blame] | 150 | SkPathDirection dir = static_cast<SkPathDirection>(dirHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 151 | obj->addCircle(x, y, radius, dir); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 152 | } |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 153 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 154 | static void addArc(JNIEnv* env, jclass clazz, jlong objHandle, jfloat left, jfloat top, |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 155 | jfloat right, jfloat bottom, jfloat startAngle, jfloat sweepAngle) { |
| 156 | SkRect oval = SkRect::MakeLTRB(left, top, right, bottom); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 157 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 158 | obj->addArc(oval, startAngle, sweepAngle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 159 | } |
Chris Craik | 7979388 | 2014-04-25 13:08:25 -0700 | [diff] [blame] | 160 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 161 | static void addRoundRectXY(JNIEnv* env, jclass clazz, jlong objHandle, jfloat left, jfloat top, |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 162 | jfloat right, jfloat bottom, jfloat rx, jfloat ry, jint dirHandle) { |
| 163 | SkRect rect = SkRect::MakeLTRB(left, top, right, bottom); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 164 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Mike Reed | 15760c9 | 2019-11-25 11:43:48 -0500 | [diff] [blame] | 165 | SkPathDirection dir = static_cast<SkPathDirection>(dirHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 166 | obj->addRoundRect(rect, rx, ry, dir); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 168 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 169 | static void addRoundRect8(JNIEnv* env, jclass clazz, jlong objHandle, jfloat left, jfloat top, |
| 170 | jfloat right, jfloat bottom, jfloatArray array, jint dirHandle) { |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 171 | SkRect rect = SkRect::MakeLTRB(left, top, right, bottom); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 172 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Mike Reed | 15760c9 | 2019-11-25 11:43:48 -0500 | [diff] [blame] | 173 | SkPathDirection dir = static_cast<SkPathDirection>(dirHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | AutoJavaFloatArray afa(env, array, 8); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 175 | #ifdef SK_SCALAR_IS_FLOAT |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | const float* src = afa.ptr(); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 177 | #else |
| 178 | #error Need to convert float array to SkScalar array before calling the following function. |
| 179 | #endif |
| 180 | obj->addRoundRect(rect, src, dir); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 182 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 183 | static void addPath__PathFF(JNIEnv* env, jclass clazz, jlong objHandle, jlong srcHandle, |
| 184 | jfloat dx, jfloat dy) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 185 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 186 | SkPath* src = reinterpret_cast<SkPath*>(srcHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 187 | obj->addPath(*src, dx, dy); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 189 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 190 | static void addPath__Path(JNIEnv* env, jclass clazz, jlong objHandle, jlong srcHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 191 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 192 | SkPath* src = reinterpret_cast<SkPath*>(srcHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | obj->addPath(*src); |
| 194 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 195 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 196 | static void addPath__PathMatrix(JNIEnv* env, jclass clazz, jlong objHandle, jlong srcHandle, |
| 197 | jlong matrixHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 198 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 199 | SkPath* src = reinterpret_cast<SkPath*>(srcHandle); |
| 200 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | obj->addPath(*src, *matrix); |
| 202 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 203 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 204 | static void offset__FF(JNIEnv* env, jclass clazz, jlong objHandle, jfloat dx, jfloat dy) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 205 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 206 | obj->offset(dx, dy); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | } |
| 208 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 209 | static void setLastPoint(JNIEnv* env, jclass clazz, jlong objHandle, jfloat dx, jfloat dy) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 210 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Leon Scroggins III | 2e0103e | 2014-04-04 17:05:24 -0400 | [diff] [blame] | 211 | obj->setLastPt(dx, dy); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 213 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 214 | static void transform__MatrixPath(JNIEnv* env, jclass clazz, jlong objHandle, jlong matrixHandle, |
| 215 | jlong dstHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 216 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 217 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); |
| 218 | SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 219 | obj->transform(*matrix, dst); |
| 220 | } |
Antonio Calabrese | 2460958 | 2014-06-12 16:32:03 -0700 | [diff] [blame] | 221 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 222 | static void transform__Matrix(JNIEnv* env, jclass clazz, jlong objHandle, jlong matrixHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 223 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 224 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | obj->transform(*matrix); |
| 226 | } |
Romain Guy | 8018c8d | 2013-07-29 19:17:59 -0700 | [diff] [blame] | 227 | |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 228 | static jboolean op(JNIEnv* env, jclass clazz, jlong p1Handle, jlong p2Handle, jint opHandle, |
| 229 | jlong rHandle) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 230 | SkPath* p1 = reinterpret_cast<SkPath*>(p1Handle); |
| 231 | SkPath* p2 = reinterpret_cast<SkPath*>(p2Handle); |
| 232 | SkPathOp op = static_cast<SkPathOp>(opHandle); |
| 233 | SkPath* r = reinterpret_cast<SkPath*>(rHandle); |
| 234 | return Op(*p1, *p2, op, r); |
Romain Guy | 8018c8d | 2013-07-29 19:17:59 -0700 | [diff] [blame] | 235 | } |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 236 | |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 237 | typedef SkPoint (*bezierCalculation)(float t, const SkPoint* points); |
| 238 | |
| 239 | static void addMove(std::vector<SkPoint>& segmentPoints, std::vector<float>& lengths, |
| 240 | const SkPoint& point) { |
| 241 | float length = 0; |
| 242 | if (!lengths.empty()) { |
| 243 | length = lengths.back(); |
| 244 | } |
| 245 | segmentPoints.push_back(point); |
| 246 | lengths.push_back(length); |
| 247 | } |
| 248 | |
| 249 | static void addLine(std::vector<SkPoint>& segmentPoints, std::vector<float>& lengths, |
| 250 | const SkPoint& toPoint) { |
| 251 | if (segmentPoints.empty()) { |
| 252 | segmentPoints.push_back(SkPoint::Make(0, 0)); |
| 253 | lengths.push_back(0); |
| 254 | } else if (segmentPoints.back() == toPoint) { |
| 255 | return; // Empty line |
| 256 | } |
| 257 | float length = lengths.back() + SkPoint::Distance(segmentPoints.back(), toPoint); |
| 258 | segmentPoints.push_back(toPoint); |
| 259 | lengths.push_back(length); |
| 260 | } |
| 261 | |
| 262 | static float cubicCoordinateCalculation(float t, float p0, float p1, float p2, float p3) { |
| 263 | float oneMinusT = 1 - t; |
| 264 | float oneMinusTSquared = oneMinusT * oneMinusT; |
| 265 | float oneMinusTCubed = oneMinusTSquared * oneMinusT; |
| 266 | float tSquared = t * t; |
| 267 | float tCubed = tSquared * t; |
| 268 | return (oneMinusTCubed * p0) + (3 * oneMinusTSquared * t * p1) |
| 269 | + (3 * oneMinusT * tSquared * p2) + (tCubed * p3); |
| 270 | } |
| 271 | |
| 272 | static SkPoint cubicBezierCalculation(float t, const SkPoint* points) { |
| 273 | float x = cubicCoordinateCalculation(t, points[0].x(), points[1].x(), |
| 274 | points[2].x(), points[3].x()); |
| 275 | float y = cubicCoordinateCalculation(t, points[0].y(), points[1].y(), |
| 276 | points[2].y(), points[3].y()); |
| 277 | return SkPoint::Make(x, y); |
| 278 | } |
| 279 | |
| 280 | static float quadraticCoordinateCalculation(float t, float p0, float p1, float p2) { |
| 281 | float oneMinusT = 1 - t; |
| 282 | return oneMinusT * ((oneMinusT * p0) + (t * p1)) + t * ((oneMinusT * p1) + (t * p2)); |
| 283 | } |
| 284 | |
| 285 | static SkPoint quadraticBezierCalculation(float t, const SkPoint* points) { |
| 286 | float x = quadraticCoordinateCalculation(t, points[0].x(), points[1].x(), points[2].x()); |
| 287 | float y = quadraticCoordinateCalculation(t, points[0].y(), points[1].y(), points[2].y()); |
| 288 | return SkPoint::Make(x, y); |
| 289 | } |
| 290 | |
| 291 | // Subdivide a section of the Bezier curve, set the mid-point and the mid-t value. |
| 292 | // Returns true if further subdivision is necessary as defined by errorSquared. |
| 293 | static bool subdividePoints(const SkPoint* points, bezierCalculation bezierFunction, |
| 294 | float t0, const SkPoint &p0, float t1, const SkPoint &p1, |
| 295 | float& midT, SkPoint &midPoint, float errorSquared) { |
| 296 | midT = (t1 + t0) / 2; |
| 297 | float midX = (p1.x() + p0.x()) / 2; |
| 298 | float midY = (p1.y() + p0.y()) / 2; |
| 299 | |
| 300 | midPoint = (*bezierFunction)(midT, points); |
| 301 | float xError = midPoint.x() - midX; |
| 302 | float yError = midPoint.y() - midY; |
| 303 | float midErrorSquared = (xError * xError) + (yError * yError); |
| 304 | return midErrorSquared > errorSquared; |
| 305 | } |
| 306 | |
| 307 | // Divides Bezier curves until linear interpolation is very close to accurate, using |
| 308 | // errorSquared as a metric. Cubic Bezier curves can have an inflection point that improperly |
| 309 | // short-circuit subdivision. If you imagine an S shape, the top and bottom points being the |
| 310 | // starting and end points, linear interpolation would mark the center where the curve places |
| 311 | // the point. It is clearly not the case that we can linearly interpolate at that point. |
| 312 | // doubleCheckDivision forces a second examination between subdivisions to ensure that linear |
| 313 | // interpolation works. |
| 314 | static void addBezier(const SkPoint* points, |
| 315 | bezierCalculation bezierFunction, std::vector<SkPoint>& segmentPoints, |
| 316 | std::vector<float>& lengths, float errorSquared, bool doubleCheckDivision) { |
| 317 | typedef std::map<float, SkPoint> PointMap; |
| 318 | PointMap tToPoint; |
| 319 | |
| 320 | tToPoint[0] = (*bezierFunction)(0, points); |
| 321 | tToPoint[1] = (*bezierFunction)(1, points); |
| 322 | |
| 323 | PointMap::iterator iter = tToPoint.begin(); |
| 324 | PointMap::iterator next = iter; |
| 325 | ++next; |
| 326 | while (next != tToPoint.end()) { |
| 327 | bool needsSubdivision = true; |
| 328 | SkPoint midPoint; |
| 329 | do { |
| 330 | float midT; |
| 331 | needsSubdivision = subdividePoints(points, bezierFunction, iter->first, |
| 332 | iter->second, next->first, next->second, midT, midPoint, errorSquared); |
| 333 | if (!needsSubdivision && doubleCheckDivision) { |
| 334 | SkPoint quarterPoint; |
| 335 | float quarterT; |
| 336 | needsSubdivision = subdividePoints(points, bezierFunction, iter->first, |
| 337 | iter->second, midT, midPoint, quarterT, quarterPoint, errorSquared); |
| 338 | if (needsSubdivision) { |
| 339 | // Found an inflection point. No need to double-check. |
| 340 | doubleCheckDivision = false; |
| 341 | } |
| 342 | } |
| 343 | if (needsSubdivision) { |
| 344 | next = tToPoint.insert(iter, PointMap::value_type(midT, midPoint)); |
| 345 | } |
| 346 | } while (needsSubdivision); |
| 347 | iter = next; |
| 348 | next++; |
| 349 | } |
| 350 | |
| 351 | // Now that each division can use linear interpolation with less than the allowed error |
| 352 | for (iter = tToPoint.begin(); iter != tToPoint.end(); ++iter) { |
| 353 | addLine(segmentPoints, lengths, iter->second); |
| 354 | } |
| 355 | } |
| 356 | |
Chris Craik | 96202d5 | 2017-04-27 15:26:17 -0700 | [diff] [blame] | 357 | static void createVerbSegments(const SkPath::Iter& pathIter, SkPath::Verb verb, |
| 358 | const SkPoint* points, std::vector<SkPoint>& segmentPoints, |
| 359 | std::vector<float>& lengths, float errorSquared, float errorConic) { |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 360 | switch (verb) { |
| 361 | case SkPath::kMove_Verb: |
| 362 | addMove(segmentPoints, lengths, points[0]); |
| 363 | break; |
| 364 | case SkPath::kClose_Verb: |
George Mount | 7fe03a2 | 2013-11-22 17:08:28 -0800 | [diff] [blame] | 365 | addLine(segmentPoints, lengths, points[0]); |
| 366 | break; |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 367 | case SkPath::kLine_Verb: |
| 368 | addLine(segmentPoints, lengths, points[1]); |
| 369 | break; |
| 370 | case SkPath::kQuad_Verb: |
| 371 | addBezier(points, quadraticBezierCalculation, segmentPoints, lengths, |
| 372 | errorSquared, false); |
| 373 | break; |
| 374 | case SkPath::kCubic_Verb: |
| 375 | addBezier(points, cubicBezierCalculation, segmentPoints, lengths, |
| 376 | errorSquared, true); |
| 377 | break; |
Chris Craik | 96202d5 | 2017-04-27 15:26:17 -0700 | [diff] [blame] | 378 | case SkPath::kConic_Verb: { |
| 379 | SkAutoConicToQuads converter; |
| 380 | const SkPoint* quads = converter.computeQuads( |
| 381 | points, pathIter.conicWeight(), errorConic); |
| 382 | for (int i = 0; i < converter.countQuads(); i++) { |
| 383 | // Note: offset each subsequent quad by 2, since end points are shared |
| 384 | const SkPoint* quad = quads + i * 2; |
| 385 | addBezier(quad, quadraticBezierCalculation, segmentPoints, lengths, |
| 386 | errorConic, false); |
| 387 | } |
| 388 | break; |
| 389 | } |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 390 | default: |
Chris Craik | 96202d5 | 2017-04-27 15:26:17 -0700 | [diff] [blame] | 391 | static_assert(SkPath::kMove_Verb == 0 |
| 392 | && SkPath::kLine_Verb == 1 |
| 393 | && SkPath::kQuad_Verb == 2 |
| 394 | && SkPath::kConic_Verb == 3 |
| 395 | && SkPath::kCubic_Verb == 4 |
| 396 | && SkPath::kClose_Verb == 5 |
| 397 | && SkPath::kDone_Verb == 6, |
| 398 | "Path enum changed, new types may have been added."); |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 399 | break; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | // Returns a float[] with each point along the path represented by 3 floats |
| 404 | // * fractional length along the path that the point resides |
| 405 | // * x coordinate |
| 406 | // * y coordinate |
| 407 | // Note that more than one point may have the same length along the path in |
| 408 | // the case of a move. |
| 409 | // NULL can be returned if the Path is empty. |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 410 | static jfloatArray approximate(JNIEnv* env, jclass clazz, jlong pathHandle, |
| 411 | float acceptableError) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 412 | SkPath* path = reinterpret_cast<SkPath*>(pathHandle); |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 413 | SkASSERT(path); |
| 414 | SkPath::Iter pathIter(*path, false); |
| 415 | SkPath::Verb verb; |
| 416 | SkPoint points[4]; |
| 417 | std::vector<SkPoint> segmentPoints; |
| 418 | std::vector<float> lengths; |
| 419 | float errorSquared = acceptableError * acceptableError; |
Chris Craik | 96202d5 | 2017-04-27 15:26:17 -0700 | [diff] [blame] | 420 | float errorConic = acceptableError / 2; // somewhat arbitrary |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 421 | |
Mike Reed | 7d48969 | 2019-11-27 11:15:43 -0500 | [diff] [blame] | 422 | while ((verb = pathIter.next(points)) != SkPath::kDone_Verb) { |
Chris Craik | 96202d5 | 2017-04-27 15:26:17 -0700 | [diff] [blame] | 423 | createVerbSegments(pathIter, verb, points, segmentPoints, lengths, |
| 424 | errorSquared, errorConic); |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | if (segmentPoints.empty()) { |
George Mount | 68cfdad | 2014-09-11 10:25:31 -0700 | [diff] [blame] | 428 | int numVerbs = path->countVerbs(); |
| 429 | if (numVerbs == 1) { |
| 430 | addMove(segmentPoints, lengths, path->getPoint(0)); |
| 431 | } else { |
| 432 | // Invalid or empty path. Fall back to point(0,0) |
| 433 | addMove(segmentPoints, lengths, SkPoint()); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | float totalLength = lengths.back(); |
| 438 | if (totalLength == 0) { |
| 439 | // Lone Move instructions should still be able to animate at the same value. |
| 440 | segmentPoints.push_back(segmentPoints.back()); |
| 441 | lengths.push_back(1); |
| 442 | totalLength = 1; |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | size_t numPoints = segmentPoints.size(); |
| 446 | size_t approximationArraySize = numPoints * 3; |
| 447 | |
| 448 | float* approximation = new float[approximationArraySize]; |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 449 | |
| 450 | int approximationIndex = 0; |
George Mount | 7fe03a2 | 2013-11-22 17:08:28 -0800 | [diff] [blame] | 451 | for (size_t i = 0; i < numPoints; i++) { |
George Mount | c96c7b2 | 2013-08-23 13:31:31 -0700 | [diff] [blame] | 452 | const SkPoint& point = segmentPoints[i]; |
| 453 | approximation[approximationIndex++] = lengths[i] / totalLength; |
| 454 | approximation[approximationIndex++] = point.x(); |
| 455 | approximation[approximationIndex++] = point.y(); |
| 456 | } |
| 457 | |
| 458 | jfloatArray result = env->NewFloatArray(approximationArraySize); |
| 459 | env->SetFloatArrayRegion(result, 0, approximationArraySize, approximation); |
| 460 | delete[] approximation; |
| 461 | return result; |
| 462 | } |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 463 | |
| 464 | // ---------------- @FastNative ----------------------------- |
| 465 | |
| 466 | static jboolean isRect(JNIEnv* env, jclass clazz, jlong objHandle, jobject jrect) { |
| 467 | SkRect rect; |
| 468 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 469 | jboolean result = obj->isRect(&rect); |
John Reck | 205d83e | 2018-03-28 14:36:58 -0700 | [diff] [blame] | 470 | if (jrect) { |
| 471 | GraphicsJNI::rect_to_jrectf(rect, env, jrect); |
| 472 | } |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 473 | return result; |
| 474 | } |
| 475 | |
| 476 | // ---------------- @CriticalNative ------------------------- |
| 477 | |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 478 | static void reset(CRITICAL_JNI_PARAMS_COMMA jlong objHandle) { |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 479 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 480 | obj->reset(); |
| 481 | } |
| 482 | |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 483 | static void rewind(CRITICAL_JNI_PARAMS_COMMA jlong objHandle) { |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 484 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 485 | obj->rewind(); |
| 486 | } |
| 487 | |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 488 | static jboolean isEmpty(CRITICAL_JNI_PARAMS_COMMA jlong objHandle) { |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 489 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 490 | return obj->isEmpty(); |
| 491 | } |
| 492 | |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 493 | static jboolean isConvex(CRITICAL_JNI_PARAMS_COMMA jlong objHandle) { |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 494 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
| 495 | return obj->isConvex(); |
| 496 | } |
| 497 | |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 498 | static jint getFillType(CRITICAL_JNI_PARAMS_COMMA jlong objHandle) { |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 499 | SkPath* obj = reinterpret_cast<SkPath*>(objHandle); |
Mike Reed | 6a8bf8e | 2019-12-03 13:01:07 -0500 | [diff] [blame] | 500 | return static_cast<int>(obj->getFillType()); |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 501 | } |
| 502 | |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 503 | static void setFillType(CRITICAL_JNI_PARAMS_COMMA jlong pathHandle, jint ftHandle) {; |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 504 | SkPath* path = reinterpret_cast<SkPath*>(pathHandle); |
Mike Reed | 6a8bf8e | 2019-12-03 13:01:07 -0500 | [diff] [blame] | 505 | SkPathFillType ft = static_cast<SkPathFillType>(ftHandle); |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 506 | path->setFillType(ft); |
| 507 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 508 | }; |
| 509 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 510 | static const JNINativeMethod methods[] = { |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 511 | {"nInit","()J", (void*) SkPathGlue::init}, |
| 512 | {"nInit","(J)J", (void*) SkPathGlue::init_Path}, |
John Reck | 205d83e | 2018-03-28 14:36:58 -0700 | [diff] [blame] | 513 | {"nGetFinalizer", "()J", (void*) SkPathGlue::getFinalizer}, |
Chris Craik | 2414e1b | 2016-12-12 13:56:15 -0800 | [diff] [blame] | 514 | {"nSet","(JJ)V", (void*) SkPathGlue::set}, |
| 515 | {"nComputeBounds","(JLandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds}, |
| 516 | {"nIncReserve","(JI)V", (void*) SkPathGlue::incReserve}, |
| 517 | {"nMoveTo","(JFF)V", (void*) SkPathGlue::moveTo__FF}, |
| 518 | {"nRMoveTo","(JFF)V", (void*) SkPathGlue::rMoveTo}, |
| 519 | {"nLineTo","(JFF)V", (void*) SkPathGlue::lineTo__FF}, |
| 520 | {"nRLineTo","(JFF)V", (void*) SkPathGlue::rLineTo}, |
| 521 | {"nQuadTo","(JFFFF)V", (void*) SkPathGlue::quadTo__FFFF}, |
| 522 | {"nRQuadTo","(JFFFF)V", (void*) SkPathGlue::rQuadTo}, |
| 523 | {"nCubicTo","(JFFFFFF)V", (void*) SkPathGlue::cubicTo__FFFFFF}, |
| 524 | {"nRCubicTo","(JFFFFFF)V", (void*) SkPathGlue::rCubicTo}, |
| 525 | {"nArcTo","(JFFFFFFZ)V", (void*) SkPathGlue::arcTo}, |
| 526 | {"nClose","(J)V", (void*) SkPathGlue::close}, |
| 527 | {"nAddRect","(JFFFFI)V", (void*) SkPathGlue::addRect}, |
| 528 | {"nAddOval","(JFFFFI)V", (void*) SkPathGlue::addOval}, |
| 529 | {"nAddCircle","(JFFFI)V", (void*) SkPathGlue::addCircle}, |
| 530 | {"nAddArc","(JFFFFFF)V", (void*) SkPathGlue::addArc}, |
| 531 | {"nAddRoundRect","(JFFFFFFI)V", (void*) SkPathGlue::addRoundRectXY}, |
| 532 | {"nAddRoundRect","(JFFFF[FI)V", (void*) SkPathGlue::addRoundRect8}, |
| 533 | {"nAddPath","(JJFF)V", (void*) SkPathGlue::addPath__PathFF}, |
| 534 | {"nAddPath","(JJ)V", (void*) SkPathGlue::addPath__Path}, |
| 535 | {"nAddPath","(JJJ)V", (void*) SkPathGlue::addPath__PathMatrix}, |
| 536 | {"nOffset","(JFF)V", (void*) SkPathGlue::offset__FF}, |
| 537 | {"nSetLastPoint","(JFF)V", (void*) SkPathGlue::setLastPoint}, |
| 538 | {"nTransform","(JJJ)V", (void*) SkPathGlue::transform__MatrixPath}, |
| 539 | {"nTransform","(JJ)V", (void*) SkPathGlue::transform__Matrix}, |
| 540 | {"nOp","(JJIJ)Z", (void*) SkPathGlue::op}, |
| 541 | {"nApproximate", "(JF)[F", (void*) SkPathGlue::approximate}, |
| 542 | |
| 543 | // ------- @FastNative below here ---------------------- |
| 544 | {"nIsRect","(JLandroid/graphics/RectF;)Z", (void*) SkPathGlue::isRect}, |
| 545 | |
| 546 | // ------- @CriticalNative below here ------------------ |
| 547 | {"nReset","(J)V", (void*) SkPathGlue::reset}, |
| 548 | {"nRewind","(J)V", (void*) SkPathGlue::rewind}, |
| 549 | {"nIsEmpty","(J)Z", (void*) SkPathGlue::isEmpty}, |
| 550 | {"nIsConvex","(J)Z", (void*) SkPathGlue::isConvex}, |
| 551 | {"nGetFillType","(J)I", (void*) SkPathGlue::getFillType}, |
| 552 | {"nSetFillType","(JI)V", (void*) SkPathGlue::setFillType}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 553 | }; |
| 554 | |
| 555 | int register_android_graphics_Path(JNIEnv* env) { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 556 | return RegisterMethodsOrDie(env, "android/graphics/Path", methods, NELEM(methods)); |
Derek Sollenberger | 1ad545d | 2015-08-20 14:23:14 -0400 | [diff] [blame] | 557 | |
Mike Reed | 15760c9 | 2019-11-25 11:43:48 -0500 | [diff] [blame] | 558 | static_assert(0 == (int)SkPathDirection::kCW, "direction_mismatch"); |
| 559 | static_assert(1 == (int)SkPathDirection::kCCW, "direction_mismatch"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | } |