src/macosx/native/sun/awt/QuartzRenderer.m

Print this page




  33 #import "ImageSurfaceData.h"
  34 
  35 
  36 //#define DEBUG 1
  37 #if defined DEBUG
  38     #define QUARTZ_RENDERER_INLINE
  39     #define PRINT(msg) {fprintf(stderr, "%s\n", msg);fflush(stderr);}
  40 #else
  41     #define QUARTZ_RENDERER_INLINE static inline
  42     #define PRINT(msg) {}
  43 #endif
  44 
  45 // Copied the following from Math.java
  46 #define PI 3.14159265358979323846f
  47 
  48 #define BATCHED_POINTS_SIZE 1024
  49 
  50 // same value as defined in Sun's own code
  51 #define XOR_ALPHA_CUTOFF 128
  52 
  53 // private Quartz routines needed here
  54 CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
  55 
  56 
  57 static CGFloat gRoundRectCtrlpts[10][12] =
  58 {
  59     {0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  60     {0.0f, 0.0f, 1.0f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  61     {0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f, 1.0f, 0.0f},
  62     {1.0f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  63     {1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, -0.5f},
  64     {1.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  65     {1.0f, 0.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -0.5f, 0.0f, 0.0f},
  66     {0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  67     {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f},
  68     {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  69 };
  70 
  71 CG_EXTERN CGRect CGRectApplyAffineTransform(CGRect rect, CGAffineTransform t);
  72 
  73 
  74 CGRect sanitizedRect(CGFloat x1, CGFloat y1, CGFloat x2, CGFloat y2) {
  75     CGFloat temp;


 519     CGFloat a = 1.0f;
 520     CGFloat b = 0.0f;
 521     CGFloat c = 0.0f;
 522     CGFloat d = -1.0f;
 523     CGFloat tx = dx;
 524     CGFloat ty = dy+dh;
 525 
 526     if (flipv == YES)
 527     {
 528         d = 1.0f;
 529         ty -= dh;
 530     }
 531     if (fliph == YES)
 532     {
 533         a = -1.0f;
 534         tx += dw;
 535     }
 536 
 537     makeSureImageIsCreated(isdo);
 538 
 539     CGAffineTransform ctm = CGContextGetCTM(cgRef);
 540     CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty));
 541     jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask;
 542 
 543     if ((sx == 0) && (sy == 0) && (sw == w) && (sh == h)) // no subimages allowed here
 544     {
 545         CGContextDrawImage(cgRef, CGRectMake(0, 0, dw, dh), isdo->imgRef);
 546     }
 547     else // handle subimages
 548     {
 549         CGImageRef subImg = CGImageCreateWithImageInRect(isdo->imgRef, CGRectMake(sx, sy, sw, sh));
 550         CGContextDrawImage(cgRef, CGRectMake(0.0f, 0.0f, dw, dh), subImg);
 551         CGImageRelease(subImg);
 552     }
 553 
 554     CGContextSetCTM(cgRef, ctm);
 555     UnlockImage(env, isdo);
 556 }
 557 
 558 QUARTZ_RENDERER_INLINE void doImage(JNIEnv *env, QuartzSDOps *qsdo, jobject imageSurfaceData,
 559                                 jboolean fliph, jboolean flipv, jint w, jint h, jint sx, jint sy, jint sw, jint sh, jint dx, jint dy, jint dw, jint dh)
 560 {
 561     if ((w > 0) && (h > 0) && (sw > 0) && (sh > 0) && (dw > 0) && (dh > 0))
 562     {
 563        doImageCG(env, qsdo->cgRef, imageSurfaceData,
 564                             qsdo->graphicsStateInfo.interpolation, (BOOL)fliph, (BOOL)flipv, (jint)w, (jint)h, (jint)sx, (jint)sy, (jint)sw, (jint)sh, (jint)dx, (jint)dy, (jint)dw, (jint)dh);
 565     }
 566 }
 567 
 568 
 569 
 570 QUARTZ_RENDERER_INLINE void completePath(JNIEnv *env, QuartzSDOps *qsdo, CGContextRef cgRef, jint renderType)
 571 {
 572     switch (renderType)
 573     {
 574         case SD_Stroke:




  33 #import "ImageSurfaceData.h"
  34 
  35 
  36 //#define DEBUG 1
  37 #if defined DEBUG
  38     #define QUARTZ_RENDERER_INLINE
  39     #define PRINT(msg) {fprintf(stderr, "%s\n", msg);fflush(stderr);}
  40 #else
  41     #define QUARTZ_RENDERER_INLINE static inline
  42     #define PRINT(msg) {}
  43 #endif
  44 
  45 // Copied the following from Math.java
  46 #define PI 3.14159265358979323846f
  47 
  48 #define BATCHED_POINTS_SIZE 1024
  49 
  50 // same value as defined in Sun's own code
  51 #define XOR_ALPHA_CUTOFF 128
  52 



  53 
  54 static CGFloat gRoundRectCtrlpts[10][12] =
  55 {
  56     {0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  57     {0.0f, 0.0f, 1.0f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  58     {0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f, 1.0f, 0.0f},
  59     {1.0f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  60     {1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, -0.5f},
  61     {1.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  62     {1.0f, 0.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -0.5f, 0.0f, 0.0f},
  63     {0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  64     {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f},
  65     {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  66 };
  67 
  68 CG_EXTERN CGRect CGRectApplyAffineTransform(CGRect rect, CGAffineTransform t);
  69 
  70 
  71 CGRect sanitizedRect(CGFloat x1, CGFloat y1, CGFloat x2, CGFloat y2) {
  72     CGFloat temp;


 516     CGFloat a = 1.0f;
 517     CGFloat b = 0.0f;
 518     CGFloat c = 0.0f;
 519     CGFloat d = -1.0f;
 520     CGFloat tx = dx;
 521     CGFloat ty = dy+dh;
 522 
 523     if (flipv == YES)
 524     {
 525         d = 1.0f;
 526         ty -= dh;
 527     }
 528     if (fliph == YES)
 529     {
 530         a = -1.0f;
 531         tx += dw;
 532     }
 533 
 534     makeSureImageIsCreated(isdo);
 535 
 536     CGContextSaveGState(cgRef);
 537     CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty));
 538     jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask;
 539 
 540     if ((sx == 0) && (sy == 0) && (sw == w) && (sh == h)) // no subimages allowed here
 541     {
 542         CGContextDrawImage(cgRef, CGRectMake(0, 0, dw, dh), isdo->imgRef);
 543     }
 544     else // handle subimages
 545     {
 546         CGImageRef subImg = CGImageCreateWithImageInRect(isdo->imgRef, CGRectMake(sx, sy, sw, sh));
 547         CGContextDrawImage(cgRef, CGRectMake(0.0f, 0.0f, dw, dh), subImg);
 548         CGImageRelease(subImg);
 549     }
 550 
 551     CGContextRestoreGState(cgRef);
 552     UnlockImage(env, isdo);
 553 }
 554 
 555 QUARTZ_RENDERER_INLINE void doImage(JNIEnv *env, QuartzSDOps *qsdo, jobject imageSurfaceData,
 556                                 jboolean fliph, jboolean flipv, jint w, jint h, jint sx, jint sy, jint sw, jint sh, jint dx, jint dy, jint dw, jint dh)
 557 {
 558     if ((w > 0) && (h > 0) && (sw > 0) && (sh > 0) && (dw > 0) && (dh > 0))
 559     {
 560        doImageCG(env, qsdo->cgRef, imageSurfaceData,
 561                             qsdo->graphicsStateInfo.interpolation, (BOOL)fliph, (BOOL)flipv, (jint)w, (jint)h, (jint)sx, (jint)sy, (jint)sw, (jint)sh, (jint)dx, (jint)dy, (jint)dw, (jint)dh);
 562     }
 563 }
 564 
 565 
 566 
 567 QUARTZ_RENDERER_INLINE void completePath(JNIEnv *env, QuartzSDOps *qsdo, CGContextRef cgRef, jint renderType)
 568 {
 569     switch (renderType)
 570     {
 571         case SD_Stroke: