Path.cpp revision 2e0103eb340822f9d580c1aa8492bae8394b8243
1/* libs/android_runtime/android/graphics/Path.cpp 2** 3** Copyright 2006, The Android Open Source Project 4** 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 8** 9** http://www.apache.org/licenses/LICENSE-2.0 10** 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 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. 20// To change this file, either edit the include, or device/tools/gluemaker/main.cpp, 21// or one of the auxilary file specifications in device/tools/gluemaker. 22 23#include "jni.h" 24#include "GraphicsJNI.h" 25#include <android_runtime/AndroidRuntime.h> 26 27#include "SkPath.h" 28#include "SkPathOps.h" 29 30#include <Caches.h> 31#include <vector> 32#include <map> 33 34namespace android { 35 36class SkPathGlue { 37public: 38 39 static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { 40 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 41#ifdef USE_OPENGL_RENDERER 42 if (android::uirenderer::Caches::hasInstance()) { 43 android::uirenderer::Caches::getInstance().resourceCache.destructor(obj); 44 return; 45 } 46#endif 47 delete obj; 48 } 49 50 static jlong init1(JNIEnv* env, jobject clazz) { 51 return reinterpret_cast<jlong>(new SkPath()); 52 } 53 54 static jlong init2(JNIEnv* env, jobject clazz, jlong valHandle) { 55 SkPath* val = reinterpret_cast<SkPath*>(valHandle); 56 return reinterpret_cast<jlong>(new SkPath(*val)); 57 } 58 59 static void reset(JNIEnv* env, jobject clazz, jlong objHandle) { 60 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 61 obj->reset(); 62 } 63 64 static void rewind(JNIEnv* env, jobject clazz, jlong objHandle) { 65 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 66 obj->rewind(); 67 } 68 69 static void assign(JNIEnv* env, jobject clazz, jlong dstHandle, jlong srcHandle) { 70 SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); 71 const SkPath* src = reinterpret_cast<SkPath*>(srcHandle); 72 *dst = *src; 73 } 74 75 static jboolean isConvex(JNIEnv* env, jobject clazz, jlong objHandle) { 76 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 77 return obj->isConvex(); 78 } 79 80 static jint getFillType(JNIEnv* env, jobject clazz, jlong objHandle) { 81 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 82 return obj->getFillType(); 83 } 84 85 static void setFillType(JNIEnv* env, jobject clazz, jlong pathHandle, jint ftHandle) { 86 SkPath* path = reinterpret_cast<SkPath*>(pathHandle); 87 SkPath::FillType ft = static_cast<SkPath::FillType>(ftHandle); 88 path->setFillType(ft); 89 } 90 91 static jboolean isEmpty(JNIEnv* env, jobject clazz, jlong objHandle) { 92 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 93 return obj->isEmpty(); 94 } 95 96 static jboolean isRect(JNIEnv* env, jobject clazz, jlong objHandle, jobject jrect) { 97 SkRect rect; 98 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 99 jboolean result = obj->isRect(&rect); 100 GraphicsJNI::rect_to_jrectf(rect, env, jrect); 101 return result; 102 } 103 104 static void computeBounds(JNIEnv* env, jobject clazz, jlong objHandle, jobject jbounds) { 105 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 106 const SkRect& bounds = obj->getBounds(); 107 GraphicsJNI::rect_to_jrectf(bounds, env, jbounds); 108 } 109 110 static void incReserve(JNIEnv* env, jobject clazz, jlong objHandle, jint extraPtCount) { 111 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 112 obj->incReserve(extraPtCount); 113 } 114 115 static void moveTo__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y) { 116 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 117 obj->moveTo(x, y); 118 } 119 120 static void rMoveTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { 121 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 122 obj->rMoveTo(dx, dy); 123 } 124 125 static void lineTo__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y) { 126 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 127 obj->lineTo(x, y); 128 } 129 130 static void rLineTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { 131 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 132 obj->rLineTo(dx, dy); 133 } 134 135 static void quadTo__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2) { 136 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 137 obj->quadTo(x1, y1, x2, y2); 138 } 139 140 static void rQuadTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx1, jfloat dy1, jfloat dx2, jfloat dy2) { 141 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 142 obj->rQuadTo(dx1, dy1, dx2, dy2); 143 } 144 145 static void cubicTo__FFFFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) { 146 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 147 obj->cubicTo(x1, y1, x2, y2, x3, y3); 148 } 149 150 static void rCubicTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) { 151 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 152 obj->rCubicTo(x1, y1, x2, y2, x3, y3); 153 } 154 155 static void arcTo(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jfloat startAngle, jfloat sweepAngle, jboolean forceMoveTo) { 156 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 157 SkRect oval_; 158 GraphicsJNI::jrectf_to_rect(env, oval, &oval_); 159 obj->arcTo(oval_, startAngle, sweepAngle, forceMoveTo); 160 } 161 162 static void close(JNIEnv* env, jobject clazz, jlong objHandle) { 163 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 164 obj->close(); 165 } 166 167 static void addRect__RectFI(JNIEnv* env, jobject clazz, jlong objHandle, jobject jrect, jint dirHandle) { 168 SkRect rect; 169 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 170 SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); 171 GraphicsJNI::jrectf_to_rect(env, jrect, &rect); 172 obj->addRect(rect, dir); 173 } 174 175 static void addRect__FFFFI(JNIEnv* env, jobject clazz, jlong objHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, jint dirHandle) { 176 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 177 SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); 178 obj->addRect(left, top, right, bottom, dir); 179 } 180 181 static void addOval(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jint dirHandle) { 182 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 183 SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); 184 SkRect oval_; 185 GraphicsJNI::jrectf_to_rect(env, oval, &oval_); 186 obj->addOval(oval_, dir); 187 } 188 189 static void addCircle(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y, jfloat radius, jint dirHandle) { 190 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 191 SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); 192 obj->addCircle(x, y, radius, dir); 193 } 194 195 static void addArc(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jfloat startAngle, jfloat sweepAngle) { 196 SkRect oval_; 197 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 198 GraphicsJNI::jrectf_to_rect(env, oval, &oval_); 199 obj->addArc(oval_, startAngle, sweepAngle); 200 } 201 202 static void addRoundRectXY(JNIEnv* env, jobject clazz, jlong objHandle, jobject jrect, 203 jfloat rx, jfloat ry, jint dirHandle) { 204 SkRect rect; 205 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 206 SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); 207 GraphicsJNI::jrectf_to_rect(env, jrect, &rect); 208 obj->addRoundRect(rect, rx, ry, dir); 209 } 210 211 static void addRoundRect8(JNIEnv* env, jobject, jlong objHandle, jobject jrect, 212 jfloatArray array, jint dirHandle) { 213 SkRect rect; 214 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 215 SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); 216 GraphicsJNI::jrectf_to_rect(env, jrect, &rect); 217 AutoJavaFloatArray afa(env, array, 8); 218#ifdef SK_SCALAR_IS_FLOAT 219 const float* src = afa.ptr(); 220#else 221 #error Need to convert float array to SkScalar array before calling the following function. 222#endif 223 obj->addRoundRect(rect, src, dir); 224 } 225 226 static void addPath__PathFF(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jfloat dx, jfloat dy) { 227 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 228 SkPath* src = reinterpret_cast<SkPath*>(srcHandle); 229 obj->addPath(*src, dx, dy); 230 } 231 232 static void addPath__Path(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle) { 233 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 234 SkPath* src = reinterpret_cast<SkPath*>(srcHandle); 235 obj->addPath(*src); 236 } 237 238 static void addPath__PathMatrix(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jlong matrixHandle) { 239 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 240 SkPath* src = reinterpret_cast<SkPath*>(srcHandle); 241 SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); 242 obj->addPath(*src, *matrix); 243 } 244 245 static void offset__FFPath(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy, jlong dstHandle) { 246 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 247 SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); 248 obj->offset(dx, dy, dst); 249 } 250 251 static void offset__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { 252 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 253 obj->offset(dx, dy); 254 } 255 256 static void setLastPoint(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { 257 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 258 obj->setLastPt(dx, dy); 259 } 260 261 static void transform__MatrixPath(JNIEnv* env, jobject clazz, jlong objHandle, jlong matrixHandle, jlong dstHandle) { 262 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 263 SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); 264 SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); 265 obj->transform(*matrix, dst); 266 } 267 268 static void transform__Matrix(JNIEnv* env, jobject clazz, jlong objHandle, jlong matrixHandle) { 269 SkPath* obj = reinterpret_cast<SkPath*>(objHandle); 270 SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); 271 obj->transform(*matrix); 272 } 273 274 static jboolean op(JNIEnv* env, jobject clazz, jlong p1Handle, jlong p2Handle, jint opHandle, jlong rHandle) { 275 SkPath* p1 = reinterpret_cast<SkPath*>(p1Handle); 276 SkPath* p2 = reinterpret_cast<SkPath*>(p2Handle); 277 SkPathOp op = static_cast<SkPathOp>(opHandle); 278 SkPath* r = reinterpret_cast<SkPath*>(rHandle); 279 return Op(*p1, *p2, op, r); 280 } 281 282 typedef SkPoint (*bezierCalculation)(float t, const SkPoint* points); 283 284 static void addMove(std::vector<SkPoint>& segmentPoints, std::vector<float>& lengths, 285 const SkPoint& point) { 286 float length = 0; 287 if (!lengths.empty()) { 288 length = lengths.back(); 289 } 290 segmentPoints.push_back(point); 291 lengths.push_back(length); 292 } 293 294 static void addLine(std::vector<SkPoint>& segmentPoints, std::vector<float>& lengths, 295 const SkPoint& toPoint) { 296 if (segmentPoints.empty()) { 297 segmentPoints.push_back(SkPoint::Make(0, 0)); 298 lengths.push_back(0); 299 } else if (segmentPoints.back() == toPoint) { 300 return; // Empty line 301 } 302 float length = lengths.back() + SkPoint::Distance(segmentPoints.back(), toPoint); 303 segmentPoints.push_back(toPoint); 304 lengths.push_back(length); 305 } 306 307 static float cubicCoordinateCalculation(float t, float p0, float p1, float p2, float p3) { 308 float oneMinusT = 1 - t; 309 float oneMinusTSquared = oneMinusT * oneMinusT; 310 float oneMinusTCubed = oneMinusTSquared * oneMinusT; 311 float tSquared = t * t; 312 float tCubed = tSquared * t; 313 return (oneMinusTCubed * p0) + (3 * oneMinusTSquared * t * p1) 314 + (3 * oneMinusT * tSquared * p2) + (tCubed * p3); 315 } 316 317 static SkPoint cubicBezierCalculation(float t, const SkPoint* points) { 318 float x = cubicCoordinateCalculation(t, points[0].x(), points[1].x(), 319 points[2].x(), points[3].x()); 320 float y = cubicCoordinateCalculation(t, points[0].y(), points[1].y(), 321 points[2].y(), points[3].y()); 322 return SkPoint::Make(x, y); 323 } 324 325 static float quadraticCoordinateCalculation(float t, float p0, float p1, float p2) { 326 float oneMinusT = 1 - t; 327 return oneMinusT * ((oneMinusT * p0) + (t * p1)) + t * ((oneMinusT * p1) + (t * p2)); 328 } 329 330 static SkPoint quadraticBezierCalculation(float t, const SkPoint* points) { 331 float x = quadraticCoordinateCalculation(t, points[0].x(), points[1].x(), points[2].x()); 332 float y = quadraticCoordinateCalculation(t, points[0].y(), points[1].y(), points[2].y()); 333 return SkPoint::Make(x, y); 334 } 335 336 // Subdivide a section of the Bezier curve, set the mid-point and the mid-t value. 337 // Returns true if further subdivision is necessary as defined by errorSquared. 338 static bool subdividePoints(const SkPoint* points, bezierCalculation bezierFunction, 339 float t0, const SkPoint &p0, float t1, const SkPoint &p1, 340 float& midT, SkPoint &midPoint, float errorSquared) { 341 midT = (t1 + t0) / 2; 342 float midX = (p1.x() + p0.x()) / 2; 343 float midY = (p1.y() + p0.y()) / 2; 344 345 midPoint = (*bezierFunction)(midT, points); 346 float xError = midPoint.x() - midX; 347 float yError = midPoint.y() - midY; 348 float midErrorSquared = (xError * xError) + (yError * yError); 349 return midErrorSquared > errorSquared; 350 } 351 352 // Divides Bezier curves until linear interpolation is very close to accurate, using 353 // errorSquared as a metric. Cubic Bezier curves can have an inflection point that improperly 354 // short-circuit subdivision. If you imagine an S shape, the top and bottom points being the 355 // starting and end points, linear interpolation would mark the center where the curve places 356 // the point. It is clearly not the case that we can linearly interpolate at that point. 357 // doubleCheckDivision forces a second examination between subdivisions to ensure that linear 358 // interpolation works. 359 static void addBezier(const SkPoint* points, 360 bezierCalculation bezierFunction, std::vector<SkPoint>& segmentPoints, 361 std::vector<float>& lengths, float errorSquared, bool doubleCheckDivision) { 362 typedef std::map<float, SkPoint> PointMap; 363 PointMap tToPoint; 364 365 tToPoint[0] = (*bezierFunction)(0, points); 366 tToPoint[1] = (*bezierFunction)(1, points); 367 368 PointMap::iterator iter = tToPoint.begin(); 369 PointMap::iterator next = iter; 370 ++next; 371 while (next != tToPoint.end()) { 372 bool needsSubdivision = true; 373 SkPoint midPoint; 374 do { 375 float midT; 376 needsSubdivision = subdividePoints(points, bezierFunction, iter->first, 377 iter->second, next->first, next->second, midT, midPoint, errorSquared); 378 if (!needsSubdivision && doubleCheckDivision) { 379 SkPoint quarterPoint; 380 float quarterT; 381 needsSubdivision = subdividePoints(points, bezierFunction, iter->first, 382 iter->second, midT, midPoint, quarterT, quarterPoint, errorSquared); 383 if (needsSubdivision) { 384 // Found an inflection point. No need to double-check. 385 doubleCheckDivision = false; 386 } 387 } 388 if (needsSubdivision) { 389 next = tToPoint.insert(iter, PointMap::value_type(midT, midPoint)); 390 } 391 } while (needsSubdivision); 392 iter = next; 393 next++; 394 } 395 396 // Now that each division can use linear interpolation with less than the allowed error 397 for (iter = tToPoint.begin(); iter != tToPoint.end(); ++iter) { 398 addLine(segmentPoints, lengths, iter->second); 399 } 400 } 401 402 static void createVerbSegments(SkPath::Verb verb, const SkPoint* points, 403 std::vector<SkPoint>& segmentPoints, std::vector<float>& lengths, float errorSquared) { 404 switch (verb) { 405 case SkPath::kMove_Verb: 406 addMove(segmentPoints, lengths, points[0]); 407 break; 408 case SkPath::kClose_Verb: 409 addLine(segmentPoints, lengths, points[0]); 410 break; 411 case SkPath::kLine_Verb: 412 addLine(segmentPoints, lengths, points[1]); 413 break; 414 case SkPath::kQuad_Verb: 415 addBezier(points, quadraticBezierCalculation, segmentPoints, lengths, 416 errorSquared, false); 417 break; 418 case SkPath::kCubic_Verb: 419 addBezier(points, cubicBezierCalculation, segmentPoints, lengths, 420 errorSquared, true); 421 break; 422 default: 423 // Leave element as NULL, Conic sections are not supported. 424 break; 425 } 426 } 427 428 // Returns a float[] with each point along the path represented by 3 floats 429 // * fractional length along the path that the point resides 430 // * x coordinate 431 // * y coordinate 432 // Note that more than one point may have the same length along the path in 433 // the case of a move. 434 // NULL can be returned if the Path is empty. 435 static jfloatArray approximate(JNIEnv* env, jclass, jlong pathHandle, float acceptableError) 436 { 437 SkPath* path = reinterpret_cast<SkPath*>(pathHandle); 438 SkASSERT(path); 439 SkPath::Iter pathIter(*path, false); 440 SkPath::Verb verb; 441 SkPoint points[4]; 442 std::vector<SkPoint> segmentPoints; 443 std::vector<float> lengths; 444 float errorSquared = acceptableError * acceptableError; 445 446 while ((verb = pathIter.next(points)) != SkPath::kDone_Verb) { 447 createVerbSegments(verb, points, segmentPoints, lengths, errorSquared); 448 } 449 450 if (segmentPoints.empty()) { 451 return NULL; 452 } 453 454 size_t numPoints = segmentPoints.size(); 455 size_t approximationArraySize = numPoints * 3; 456 457 float* approximation = new float[approximationArraySize]; 458 float totalLength = lengths.back(); 459 460 int approximationIndex = 0; 461 for (size_t i = 0; i < numPoints; i++) { 462 const SkPoint& point = segmentPoints[i]; 463 approximation[approximationIndex++] = lengths[i] / totalLength; 464 approximation[approximationIndex++] = point.x(); 465 approximation[approximationIndex++] = point.y(); 466 } 467 468 jfloatArray result = env->NewFloatArray(approximationArraySize); 469 env->SetFloatArrayRegion(result, 0, approximationArraySize, approximation); 470 delete[] approximation; 471 return result; 472 } 473}; 474 475static JNINativeMethod methods[] = { 476 {"finalizer", "(J)V", (void*) SkPathGlue::finalizer}, 477 {"init1","()J", (void*) SkPathGlue::init1}, 478 {"init2","(J)J", (void*) SkPathGlue::init2}, 479 {"native_reset","(J)V", (void*) SkPathGlue::reset}, 480 {"native_rewind","(J)V", (void*) SkPathGlue::rewind}, 481 {"native_set","(JJ)V", (void*) SkPathGlue::assign}, 482 {"native_isConvex","(J)Z", (void*) SkPathGlue::isConvex}, 483 {"native_getFillType","(J)I", (void*) SkPathGlue::getFillType}, 484 {"native_setFillType","(JI)V", (void*) SkPathGlue::setFillType}, 485 {"native_isEmpty","(J)Z", (void*) SkPathGlue::isEmpty}, 486 {"native_isRect","(JLandroid/graphics/RectF;)Z", (void*) SkPathGlue::isRect}, 487 {"native_computeBounds","(JLandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds}, 488 {"native_incReserve","(JI)V", (void*) SkPathGlue::incReserve}, 489 {"native_moveTo","(JFF)V", (void*) SkPathGlue::moveTo__FF}, 490 {"native_rMoveTo","(JFF)V", (void*) SkPathGlue::rMoveTo}, 491 {"native_lineTo","(JFF)V", (void*) SkPathGlue::lineTo__FF}, 492 {"native_rLineTo","(JFF)V", (void*) SkPathGlue::rLineTo}, 493 {"native_quadTo","(JFFFF)V", (void*) SkPathGlue::quadTo__FFFF}, 494 {"native_rQuadTo","(JFFFF)V", (void*) SkPathGlue::rQuadTo}, 495 {"native_cubicTo","(JFFFFFF)V", (void*) SkPathGlue::cubicTo__FFFFFF}, 496 {"native_rCubicTo","(JFFFFFF)V", (void*) SkPathGlue::rCubicTo}, 497 {"native_arcTo","(JLandroid/graphics/RectF;FFZ)V", (void*) SkPathGlue::arcTo}, 498 {"native_close","(J)V", (void*) SkPathGlue::close}, 499 {"native_addRect","(JLandroid/graphics/RectF;I)V", (void*) SkPathGlue::addRect__RectFI}, 500 {"native_addRect","(JFFFFI)V", (void*) SkPathGlue::addRect__FFFFI}, 501 {"native_addOval","(JLandroid/graphics/RectF;I)V", (void*) SkPathGlue::addOval}, 502 {"native_addCircle","(JFFFI)V", (void*) SkPathGlue::addCircle}, 503 {"native_addArc","(JLandroid/graphics/RectF;FF)V", (void*) SkPathGlue::addArc}, 504 {"native_addRoundRect","(JLandroid/graphics/RectF;FFI)V", (void*) SkPathGlue::addRoundRectXY}, 505 {"native_addRoundRect","(JLandroid/graphics/RectF;[FI)V", (void*) SkPathGlue::addRoundRect8}, 506 {"native_addPath","(JJFF)V", (void*) SkPathGlue::addPath__PathFF}, 507 {"native_addPath","(JJ)V", (void*) SkPathGlue::addPath__Path}, 508 {"native_addPath","(JJJ)V", (void*) SkPathGlue::addPath__PathMatrix}, 509 {"native_offset","(JFFJ)V", (void*) SkPathGlue::offset__FFPath}, 510 {"native_offset","(JFF)V", (void*) SkPathGlue::offset__FF}, 511 {"native_setLastPoint","(JFF)V", (void*) SkPathGlue::setLastPoint}, 512 {"native_transform","(JJJ)V", (void*) SkPathGlue::transform__MatrixPath}, 513 {"native_transform","(JJ)V", (void*) SkPathGlue::transform__Matrix}, 514 {"native_op","(JJIJ)Z", (void*) SkPathGlue::op}, 515 {"native_approximate", "(JF)[F", (void*) SkPathGlue::approximate}, 516}; 517 518int register_android_graphics_Path(JNIEnv* env) { 519 int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Path", methods, 520 sizeof(methods) / sizeof(methods[0])); 521 return result; 522} 523 524} 525