421 break; 422 } 423 424 return renderType; 425 } 426 QUARTZ_RENDERER_INLINE SDRenderType doArc(QuartzSDOps *qsdo, CGFloat x, CGFloat y, CGFloat w, CGFloat h, CGFloat angleStart, CGFloat angleExtent, jint arcType, BOOL fill) 427 { 428 PRINT(" doArc") 429 if (YES) 430 { 431 return doArcUsingCG(qsdo->cgRef, x, y, w, h, angleStart, angleExtent, arcType, fill, 432 qsdo->graphicsStateInfo.offsetX, qsdo->graphicsStateInfo.offsetY); 433 } 434 // here we can add other implementations (ex. using QuickDraw, OpenGL, etc.) 435 } 436 437 QUARTZ_RENDERER_INLINE SDRenderType doPolyUsingCG(JNIEnv *env, CGContextRef cgRef, jintArray xpointsarray, jintArray ypointsarray, jint npoints, BOOL polygon, BOOL fill, CGFloat offsetX, CGFloat offsetY) 438 { 439 SDRenderType renderType = SD_Nothing; 440 441 if (npoints > 1) 442 { 443 if (fill == YES) 444 { 445 renderType = SD_Fill; 446 } 447 else 448 { 449 renderType = SD_Stroke; 450 } 451 452 jint i; 453 454 jint* xpoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, xpointsarray, NULL); 455 jint* ypoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, ypointsarray, NULL); 456 457 CGContextMoveToPoint(cgRef, xpoints[0]+offsetX, ypoints[0]+offsetY); 458 459 for (i=1; i<npoints; i++) 460 { 461 CGContextAddLineToPoint(cgRef, xpoints[i]+offsetX, ypoints[i]+offsetY); 462 } 463 464 if (polygon == YES) 465 { 466 if ((xpoints[0] != xpoints[npoints-1]) || (ypoints[0] != ypoints[npoints-1])) // according to the specs (only applies to polygons, not polylines) 467 { 468 CGContextAddLineToPoint(cgRef, xpoints[0]+offsetX, ypoints[0]+offsetY); 469 } 470 } 471 472 (*env)->ReleasePrimitiveArrayCritical(env, ypointsarray, ypoints, 0); 473 (*env)->ReleasePrimitiveArrayCritical(env, xpointsarray, xpoints, 0); 474 } 475 | 421 break; 422 } 423 424 return renderType; 425 } 426 QUARTZ_RENDERER_INLINE SDRenderType doArc(QuartzSDOps *qsdo, CGFloat x, CGFloat y, CGFloat w, CGFloat h, CGFloat angleStart, CGFloat angleExtent, jint arcType, BOOL fill) 427 { 428 PRINT(" doArc") 429 if (YES) 430 { 431 return doArcUsingCG(qsdo->cgRef, x, y, w, h, angleStart, angleExtent, arcType, fill, 432 qsdo->graphicsStateInfo.offsetX, qsdo->graphicsStateInfo.offsetY); 433 } 434 // here we can add other implementations (ex. using QuickDraw, OpenGL, etc.) 435 } 436 437 QUARTZ_RENDERER_INLINE SDRenderType doPolyUsingCG(JNIEnv *env, CGContextRef cgRef, jintArray xpointsarray, jintArray ypointsarray, jint npoints, BOOL polygon, BOOL fill, CGFloat offsetX, CGFloat offsetY) 438 { 439 SDRenderType renderType = SD_Nothing; 440 441 if (xpointsarray == NULL || ypointsarray == NULL) { 442 return SD_Nothing; 443 } 444 if (npoints > 1) 445 { 446 if (fill == YES) 447 { 448 renderType = SD_Fill; 449 } 450 else 451 { 452 renderType = SD_Stroke; 453 } 454 455 jint i; 456 457 jint* xpoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, xpointsarray, NULL); 458 if (xpoints == NULL) { 459 return SD_Nothing; 460 } 461 jint* ypoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, ypointsarray, NULL); 462 if (ypoints == NULL) { 463 (*env)->ReleasePrimitiveArrayCritical(env, xpointsarray, xpoints, 0); 464 return SD_Nothing; 465 } 466 467 CGContextMoveToPoint(cgRef, xpoints[0]+offsetX, ypoints[0]+offsetY); 468 469 for (i=1; i<npoints; i++) 470 { 471 CGContextAddLineToPoint(cgRef, xpoints[i]+offsetX, ypoints[i]+offsetY); 472 } 473 474 if (polygon == YES) 475 { 476 if ((xpoints[0] != xpoints[npoints-1]) || (ypoints[0] != ypoints[npoints-1])) // according to the specs (only applies to polygons, not polylines) 477 { 478 CGContextAddLineToPoint(cgRef, xpoints[0]+offsetX, ypoints[0]+offsetY); 479 } 480 } 481 482 (*env)->ReleasePrimitiveArrayCritical(env, ypointsarray, ypoints, 0); 483 (*env)->ReleasePrimitiveArrayCritical(env, xpointsarray, xpoints, 0); 484 } 485 |