author | pchelko |
Fri, 14 Mar 2014 17:48:28 +0400 | |
changeset 23652 | 11515e3c3f85 |
parent 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
12047
diff
changeset
|
2 |
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
12047 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
#import "SurfaceData.h" |
|
27 |
#import "BufImgSurfaceData.h" |
|
28 |
#import "AWTFont.h" |
|
29 |
#import <Cocoa/Cocoa.h> |
|
30 |
||
31 |
// these flags are not defined on Tiger on PPC, so we need to make them a no-op |
|
32 |
#if !defined(kCGBitmapByteOrder32Host) |
|
33 |
#define kCGBitmapByteOrder32Host 0 |
|
34 |
#endif |
|
35 |
#if !defined(kCGBitmapByteOrder16Host) |
|
36 |
#define kCGBitmapByteOrder16Host 0 |
|
37 |
#endif |
|
38 |
||
39 |
// NOTE : Modify the printSurfaceDataDiagnostics API if you change this enum |
|
40 |
enum SDRenderType |
|
41 |
{ |
|
42 |
SD_Nothing, |
|
43 |
SD_Stroke, |
|
44 |
SD_Fill, |
|
45 |
SD_EOFill, |
|
46 |
SD_Shade, |
|
47 |
SD_Pattern, |
|
48 |
SD_Image, |
|
49 |
SD_Text, |
|
50 |
SD_CopyArea, |
|
51 |
SD_Queue, |
|
52 |
SD_External |
|
53 |
}; |
|
54 |
typedef enum SDRenderType SDRenderType; |
|
55 |
||
56 |
struct _stateShadingInfo |
|
57 |
{ |
|
58 |
CGPoint start; |
|
59 |
CGPoint end; |
|
60 |
CGFloat colors[8]; |
|
61 |
BOOL cyclic; |
|
62 |
CGFloat length; // of the total segment (used by the cyclic gradient) |
|
63 |
CGFloat period; // of the cycle (used by the cyclic gradient) |
|
64 |
CGFloat offset; // of the cycle from the start (used by the cyclic gradient) |
|
65 |
}; |
|
66 |
typedef struct _stateShadingInfo StateShadingInfo; |
|
67 |
||
68 |
struct _statePatternInfo |
|
69 |
{ |
|
70 |
CGFloat tx; |
|
71 |
CGFloat ty; |
|
72 |
CGFloat sx; |
|
73 |
CGFloat sy; |
|
74 |
jint width; |
|
75 |
jint height; |
|
76 |
jobject sdata; |
|
77 |
}; |
|
78 |
typedef struct _statePatternInfo StatePatternInfo; |
|
79 |
||
80 |
struct _stateGraphicsInfo |
|
81 |
{ |
|
82 |
BOOL adjustedLineWidth; |
|
83 |
BOOL adjustedAntialias; |
|
84 |
BOOL antialiased; |
|
85 |
jint interpolation; |
|
86 |
BOOL simpleColor; |
|
87 |
BOOL simpleStroke; |
|
88 |
CGAffineTransform ctm; |
|
89 |
CGFloat offsetX; |
|
90 |
CGFloat offsetY; |
|
91 |
struct CGPoint* batchedLines; |
|
92 |
UInt32 batchedLinesCount; |
|
93 |
}; |
|
94 |
typedef struct _stateGraphicsInfo StateGraphicsInfo; |
|
95 |
||
96 |
typedef struct _QuartzSDOps QuartzSDOps; |
|
97 |
typedef void BeginContextFunc(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType); |
|
98 |
typedef void FinishContextFunc(JNIEnv *env, QuartzSDOps *qsdo); |
|
99 |
struct _QuartzSDOps |
|
100 |
{ |
|
101 |
BufImgSDOps sdo; // must be the first entry! |
|
102 |
||
103 |
BeginContextFunc* BeginSurface; // used to set graphics states (clip, color, stroke, etc...) |
|
104 |
FinishContextFunc* FinishSurface; // used to finish drawing primitives |
|
105 |
BOOL newContext; |
|
106 |
CGContextRef cgRef; |
|
107 |
||
108 |
jint* javaGraphicsStates; |
|
109 |
jobject javaGraphicsStatesObjects; |
|
110 |
||
111 |
SDRenderType renderType; |
|
112 |
||
113 |
// rdar://problem/5214320 |
|
114 |
// Gradient/Texture fills of Java GeneralPath don't respect the even odd winding rule (quartz pipeline). |
|
115 |
BOOL isEvenOddFill; // Tracks whether the original render type passed into |
|
116 |
// SetUpCGContext(...) is SD_EOFILL. |
|
117 |
// The reason for this field is because SetUpCGContext(...) can |
|
118 |
// change the render type after calling SetUpPaint(...), and right |
|
119 |
// after that, the possibly new render type is then assigned into |
|
120 |
// qsdo->renderType. Sigh!!! |
|
121 |
// This field is potentially used within CompleteCGContext(...) or |
|
122 |
// its callees. |
|
123 |
||
124 |
StateShadingInfo* shadingInfo; // tracks shading and its parameters |
|
125 |
StatePatternInfo* patternInfo; // tracks pattern and its parameters |
|
126 |
StateGraphicsInfo graphicsStateInfo; // tracks other graphics state |
|
127 |
||
128 |
BOOL syncContentsToLayer; // should changed pixels be synced to a CALayer |
|
129 |
CGRect updateRect; // used by the layer synchronization code to track update rects. |
|
130 |
}; |
|
131 |
||
132 |
void SetUpCGContext(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType); |
|
133 |
SDRenderType DoShapeUsingCG(CGContextRef cgRef, jint *types, jfloat *coords, jint numtypes, BOOL fill, CGFloat offsetX, CGFloat offsetY); |
|
134 |
SDRenderType SetUpPaint(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType); |
|
135 |
void CompleteCGContext(JNIEnv *env, QuartzSDOps *qsdo); |
|
136 |
||
137 |
NSColor* ByteParametersToNSColor(JNIEnv* env, jint *javaGraphicsStates, NSColor* defColor); |
|
138 |
||
139 |
#define JNF_COCOA_RENDERER_EXIT(env) \ |
|
140 |
} @catch(NSException *localException) { \ |
|
141 |
qsdo->FinishSurface(env, qsdo); \ |
|
142 |
[JNFException throwToJava:env exception:localException]; \ |
|
143 |
} \ |
|
144 |
if (_token) JNFNativeMethodExit(_token); \ |
|
145 |
} |