提交 dc071052 编写于 作者: S skovatch

7187834: [macosx] Usage of private API in macosx 2D implementation causes Apple Store rejection

Reviewed-by: prr, igor
上级 fba2d1c2
...@@ -41,7 +41,7 @@ void UnlockImagePixels(JNIEnv* env, ImageSDOps* isdo); ...@@ -41,7 +41,7 @@ void UnlockImagePixels(JNIEnv* env, ImageSDOps* isdo);
// If there is an image present, this is a no-op // If there is an image present, this is a no-op
void makeSureImageIsCreated(ImageSDOps* isdo); void makeSureImageIsCreated(ImageSDOps* isdo);
struct _ContextInfo typedef struct _ContextInfo
{ {
BOOL useWindowContextReference; BOOL useWindowContextReference;
BOOL canUseJavaPixelsAsContext; BOOL canUseJavaPixelsAsContext;
...@@ -50,10 +50,9 @@ struct _ContextInfo ...@@ -50,10 +50,9 @@ struct _ContextInfo
size_t bytesPerRow; size_t bytesPerRow;
CGImageAlphaInfo alphaInfo; CGImageAlphaInfo alphaInfo;
CGColorSpaceRef colorSpace; CGColorSpaceRef colorSpace;
} } ContextInfo;
typedef ContextInfo;
struct _ImageInfo typedef struct _ImageInfo
{ {
size_t bitsPerComponent; size_t bitsPerComponent;
size_t bitsPerPixel; size_t bitsPerPixel;
...@@ -61,8 +60,7 @@ struct _ImageInfo ...@@ -61,8 +60,7 @@ struct _ImageInfo
size_t bytesPerRow; size_t bytesPerRow;
CGImageAlphaInfo alphaInfo; CGImageAlphaInfo alphaInfo;
CGColorSpaceRef colorSpace; CGColorSpaceRef colorSpace;
} } ImageInfo;
typedef ImageInfo;
struct _ImageSDOps struct _ImageSDOps
{ {
......
...@@ -53,10 +53,6 @@ ...@@ -53,10 +53,6 @@
// for vImage framework headers // for vImage framework headers
#include <Accelerate/Accelerate.h> #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] = static ContextInfo sDefaultContextInfo[sun_java2d_OSXOffScreenSurfaceData_TYPE_3BYTE_RGB+1] =
{ {
{YES, YES, 8, 4, 0, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, NULL}, // TYPE_CUSTOM // special case {YES, YES, 8, 4, 0, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, NULL}, // TYPE_CUSTOM // special case
...@@ -942,7 +938,6 @@ PRINT("createContext") ...@@ -942,7 +938,6 @@ PRINT("createContext")
// intitalize the context to match the Java coordinate system // intitalize the context to match the Java coordinate system
// BG, since the context is created above, we can just concat // 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)); 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 CGContextSaveGState(qsdo->cgRef); // this will make sure we don't go pass device context settings
...@@ -1114,7 +1109,10 @@ PRINT("syncFromJavaPixels") ...@@ -1114,7 +1109,10 @@ PRINT("syncFromJavaPixels")
if (qsdo->cgRef != NULL) if (qsdo->cgRef != NULL)
{ {
CGContextSaveGState(qsdo->cgRef); 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); CGContextSetBlendMode(qsdo->cgRef, kCGBlendModeCopy);
CGContextSetAlpha(qsdo->cgRef, 1.0f); CGContextSetAlpha(qsdo->cgRef, 1.0f);
CGContextDrawImage(qsdo->cgRef, CGRectMake(0, 0, width, height), javaImg); CGContextDrawImage(qsdo->cgRef, CGRectMake(0, 0, width, height), javaImg);
......
...@@ -50,9 +50,6 @@ ...@@ -50,9 +50,6 @@
// same value as defined in Sun's own code // same value as defined in Sun's own code
#define XOR_ALPHA_CUTOFF 128 #define XOR_ALPHA_CUTOFF 128
// private Quartz routines needed here
CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
static CGFloat gRoundRectCtrlpts[10][12] = static CGFloat gRoundRectCtrlpts[10][12] =
{ {
...@@ -536,7 +533,7 @@ QUARTZ_RENDERER_INLINE void doImageCG(JNIEnv *env, CGContextRef cgRef, jobject i ...@@ -536,7 +533,7 @@ QUARTZ_RENDERER_INLINE void doImageCG(JNIEnv *env, CGContextRef cgRef, jobject i
makeSureImageIsCreated(isdo); makeSureImageIsCreated(isdo);
CGAffineTransform ctm = CGContextGetCTM(cgRef); CGContextSaveGState(cgRef);
CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty)); CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty));
jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask; jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask;
...@@ -551,7 +548,7 @@ QUARTZ_RENDERER_INLINE void doImageCG(JNIEnv *env, CGContextRef cgRef, jobject i ...@@ -551,7 +548,7 @@ QUARTZ_RENDERER_INLINE void doImageCG(JNIEnv *env, CGContextRef cgRef, jobject i
CGImageRelease(subImg); CGImageRelease(subImg);
} }
CGContextSetCTM(cgRef, ctm); CGContextRestoreGState(cgRef);
UnlockImage(env, isdo); UnlockImage(env, isdo);
} }
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import "ThreadUtilities.h" #import "ThreadUtilities.h"
// private Quartz routines needed here
CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
//#define DEBUG //#define DEBUG
#if defined DEBUG #if defined DEBUG
#define PRINT(msg) {fprintf(stderr, "%s\n", msg);} #define PRINT(msg) {fprintf(stderr, "%s\n", msg);}
...@@ -50,9 +47,6 @@ CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx); ...@@ -50,9 +47,6 @@ CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
#define PRINT(msg) {} #define PRINT(msg) {}
#endif #endif
// from CGAffineTransformPrivate.h
extern CGPoint CGPointApplyInverseAffineTransform(CGPoint point, CGAffineTransform t);
#define kOffset (0.5f) #define kOffset (0.5f)
BOOL gAdjustForJavaDrawing; BOOL gAdjustForJavaDrawing;
...@@ -608,7 +602,8 @@ PRINT(" SetUpCGContext") ...@@ -608,7 +602,8 @@ PRINT(" SetUpCGContext")
// We need to flip both y coefficeints to flip the offset point into the java coordinate system. // 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; ctm.b = -ctm.b; ctm.d = -ctm.d; ctm.tx = 0.0f; ctm.ty = 0.0f;
CGPoint offsets = {kOffset, kOffset}; CGPoint offsets = {kOffset, kOffset};
offsets = CGPointApplyInverseAffineTransform(offsets, ctm); CGAffineTransform inverse = CGAffineTransformInvert(ctm);
offsets = CGPointApplyAffineTransform(offsets, inverse);
qsdo->graphicsStateInfo.offsetX = offsets.x; qsdo->graphicsStateInfo.offsetX = offsets.x;
qsdo->graphicsStateInfo.offsetY = offsets.y; qsdo->graphicsStateInfo.offsetY = offsets.y;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册