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