7187834: [macosx] Usage of private API in macosx 2D implementation causes Apple Store rejection
Reviewed-by: prr, igor
--- a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.h Mon Aug 27 11:28:08 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.h Wed Sep 05 09:34:19 2012 -0700
@@ -41,7 +41,7 @@
// If there is an image present, this is a no-op
void makeSureImageIsCreated(ImageSDOps* isdo);
-struct _ContextInfo
+typedef struct _ContextInfo
{
BOOL useWindowContextReference;
BOOL canUseJavaPixelsAsContext;
@@ -50,10 +50,9 @@
size_t bytesPerRow;
CGImageAlphaInfo alphaInfo;
CGColorSpaceRef colorSpace;
-}
-typedef ContextInfo;
+} ContextInfo;
-struct _ImageInfo
+typedef struct _ImageInfo
{
size_t bitsPerComponent;
size_t bitsPerPixel;
@@ -61,8 +60,7 @@
size_t bytesPerRow;
CGImageAlphaInfo alphaInfo;
CGColorSpaceRef colorSpace;
-}
-typedef ImageInfo;
+} ImageInfo;
struct _ImageSDOps
{
--- a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m Mon Aug 27 11:28:08 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m Wed Sep 05 09:34:19 2012 -0700
@@ -53,10 +53,6 @@
// for vImage framework headers
#include <Accelerate/Accelerate.h>
-
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
static ContextInfo sDefaultContextInfo[sun_java2d_OSXOffScreenSurfaceData_TYPE_3BYTE_RGB+1] =
{
{YES, YES, 8, 4, 0, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, NULL}, // TYPE_CUSTOM // special case
@@ -942,7 +938,6 @@
// intitalize the context to match the Java coordinate system
// BG, since the context is created above, we can just concat
- //CGContextSetCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, -1, 0, isdo->height));
CGContextConcatCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, -1, 0, isdo->height));
CGContextSaveGState(qsdo->cgRef); // this will make sure we don't go pass device context settings
@@ -1114,7 +1109,10 @@
if (qsdo->cgRef != NULL)
{
CGContextSaveGState(qsdo->cgRef);
- CGContextSetCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, 1, 0, 0));
+ CGAffineTransform currCTM = CGContextGetCTM(qsdo->cgRef);
+ CGAffineTransform inverse = CGAffineTransformInvert(currCTM);
+ CGContextConcatCTM(qsdo->cgRef, inverse);
+ CGContextConcatCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, 1, 0, 0));
CGContextSetBlendMode(qsdo->cgRef, kCGBlendModeCopy);
CGContextSetAlpha(qsdo->cgRef, 1.0f);
CGContextDrawImage(qsdo->cgRef, CGRectMake(0, 0, width, height), javaImg);
--- a/jdk/src/macosx/native/sun/awt/QuartzRenderer.m Mon Aug 27 11:28:08 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/QuartzRenderer.m Wed Sep 05 09:34:19 2012 -0700
@@ -50,9 +50,6 @@
// same value as defined in Sun's own code
#define XOR_ALPHA_CUTOFF 128
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
static CGFloat gRoundRectCtrlpts[10][12] =
{
@@ -536,7 +533,7 @@
makeSureImageIsCreated(isdo);
- CGAffineTransform ctm = CGContextGetCTM(cgRef);
+ CGContextSaveGState(cgRef);
CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty));
jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask;
@@ -551,7 +548,7 @@
CGImageRelease(subImg);
}
- CGContextSetCTM(cgRef, ctm);
+ CGContextRestoreGState(cgRef);
UnlockImage(env, isdo);
}
--- a/jdk/src/macosx/native/sun/awt/QuartzSurfaceData.m Mon Aug 27 11:28:08 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/QuartzSurfaceData.m Wed Sep 05 09:34:19 2012 -0700
@@ -40,9 +40,6 @@
#import <AppKit/AppKit.h>
#import "ThreadUtilities.h"
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
//#define DEBUG
#if defined DEBUG
#define PRINT(msg) {fprintf(stderr, "%s\n", msg);}
@@ -50,9 +47,6 @@
#define PRINT(msg) {}
#endif
-// from CGAffineTransformPrivate.h
-extern CGPoint CGPointApplyInverseAffineTransform(CGPoint point, CGAffineTransform t);
-
#define kOffset (0.5f)
BOOL gAdjustForJavaDrawing;
@@ -608,7 +602,8 @@
// We need to flip both y coefficeints to flip the offset point into the java coordinate system.
ctm.b = -ctm.b; ctm.d = -ctm.d; ctm.tx = 0.0f; ctm.ty = 0.0f;
CGPoint offsets = {kOffset, kOffset};
- offsets = CGPointApplyInverseAffineTransform(offsets, ctm);
+ CGAffineTransform inverse = CGAffineTransformInvert(ctm);
+ offsets = CGPointApplyAffineTransform(offsets, inverse);
qsdo->graphicsStateInfo.offsetX = offsets.x;
qsdo->graphicsStateInfo.offsetY = offsets.y;
}