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
27 #import "PrinterSurfaceData.h"
28 #import "jni_util.h"
29 #import <JavaNativeFoundation/JavaNativeFoundation.h>
30
31
32 //#define DEBUG 1
33 #if defined DEBUG
34 #define PRINT(msg) {fprintf(stderr, "%s\n", msg);}
35 #else
36 #define PRINT(msg) {}
37 #endif
38
39 static LockFunc PrintSD_Lock;
40 static UnlockFunc PrintSD_Unlock;
41 static GetRasInfoFunc PrintSD_GetRasInfo;
42 static ReleaseFunc PrintSD_ReleaseRasInfo;
43 static void flush(JNIEnv *env, QuartzSDOps *qsdo);
44
45 static void PrintSD_startCGContext(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType)
46 {
47 PRINT(" PrintSD_startCGContext")
48
49 if (qsdo->cgRef != NULL)
50 {
66
67 static void PrintSD_dispose(JNIEnv *env, SurfaceDataOps *sdo)
68 {
69 PRINT(" PrintSD_dispose")
70 QuartzSDOps *qsdo = (QuartzSDOps *)sdo;
71
72 (*env)->DeleteGlobalRef(env, qsdo->javaGraphicsStatesObjects);
73
74 if (qsdo->graphicsStateInfo.batchedLines != NULL)
75 {
76 free(qsdo->graphicsStateInfo.batchedLines);
77 qsdo->graphicsStateInfo.batchedLines = NULL;
78 }
79
80 qsdo->BeginSurface = NULL;
81 qsdo->FinishSurface = NULL;
82 }
83
84 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps(JNIEnv *env, jobject jthis, jlong nsRef, jobject jGraphicsState, jobjectArray jGraphicsStateObject, jint width, jint height)
85 {
86 JNF_COCOA_ENTER(env);
87
88 PRINT("Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps")
89
90 PrintSDOps *psdo = (PrintSDOps*)SurfaceData_InitOps(env, jthis, sizeof(PrintSDOps));
91 if (psdo == NULL) {
92 JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
93 return;
94 }
95
96 psdo->nsRef = (NSGraphicsContext*)jlong_to_ptr(nsRef);
97 psdo->width = width;
98 psdo->height = height;
99
100 QuartzSDOps *qsdo = (QuartzSDOps*)psdo;
101 qsdo->BeginSurface = PrintSD_startCGContext;
102 qsdo->FinishSurface = PrintSD_finishCGContext;
103 qsdo->cgRef = [psdo->nsRef graphicsPort];
104
105 qsdo->javaGraphicsStates = (jint*)((*env)->GetDirectBufferAddress(env, jGraphicsState));
106 qsdo->javaGraphicsStatesObjects = (*env)->NewGlobalRef(env, jGraphicsStateObject);
107
108 qsdo->graphicsStateInfo.batchedLines = NULL;
109 qsdo->graphicsStateInfo.batchedLinesCount = 0;
110
111 SurfaceDataOps *sdo = (SurfaceDataOps*)qsdo;
112 sdo->Lock = PrintSD_Lock;
113 sdo->Unlock = PrintSD_Unlock;
114 sdo->GetRasInfo = PrintSD_GetRasInfo;
115 sdo->Release = PrintSD_ReleaseRasInfo;
116 sdo->Setup = NULL;
117 sdo->Dispose = PrintSD_dispose;
118
119 JNF_COCOA_EXIT(env);
120 }
121
122 static jint PrintSD_Lock(JNIEnv *env, SurfaceDataOps *sdo, SurfaceDataRasInfo *pRasInfo, jint lockflags)
123 {
124 PRINT(" PrintSD_Lock")
125 jint status = SD_FAILURE;
126
127 //QuartzSDOps *qsdo = (QuartzSDOps*)sdo;
128 //PrintSD_startCGContext(env, qsdo, SD_Image);
129
130 status = SD_SUCCESS;
131
132 return status;
133 }
134 static void PrintSD_Unlock(JNIEnv *env, SurfaceDataOps *sdo, SurfaceDataRasInfo *pRasInfo)
135 {
136 PRINT(" PrintSD_Unlock")
137
138 //QuartzSDOps *qsdo = (QuartzSDOps*)sdo;
139 //PrintSD_finishCGContext(env, qsdo);
|
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
27 #import "PrinterSurfaceData.h"
28 #import "jni_util.h"
29
30 //#define DEBUG 1
31 #if defined DEBUG
32 #define PRINT(msg) {fprintf(stderr, "%s\n", msg);}
33 #else
34 #define PRINT(msg) {}
35 #endif
36
37 static LockFunc PrintSD_Lock;
38 static UnlockFunc PrintSD_Unlock;
39 static GetRasInfoFunc PrintSD_GetRasInfo;
40 static ReleaseFunc PrintSD_ReleaseRasInfo;
41 static void flush(JNIEnv *env, QuartzSDOps *qsdo);
42
43 static void PrintSD_startCGContext(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType)
44 {
45 PRINT(" PrintSD_startCGContext")
46
47 if (qsdo->cgRef != NULL)
48 {
64
65 static void PrintSD_dispose(JNIEnv *env, SurfaceDataOps *sdo)
66 {
67 PRINT(" PrintSD_dispose")
68 QuartzSDOps *qsdo = (QuartzSDOps *)sdo;
69
70 (*env)->DeleteGlobalRef(env, qsdo->javaGraphicsStatesObjects);
71
72 if (qsdo->graphicsStateInfo.batchedLines != NULL)
73 {
74 free(qsdo->graphicsStateInfo.batchedLines);
75 qsdo->graphicsStateInfo.batchedLines = NULL;
76 }
77
78 qsdo->BeginSurface = NULL;
79 qsdo->FinishSurface = NULL;
80 }
81
82 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps(JNIEnv *env, jobject jthis, jlong nsRef, jobject jGraphicsState, jobjectArray jGraphicsStateObject, jint width, jint height)
83 {
84 JNI_COCOA_ENTER(env);
85
86 PRINT("Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps")
87
88 PrintSDOps *psdo = (PrintSDOps*)SurfaceData_InitOps(env, jthis, sizeof(PrintSDOps));
89 if (psdo == NULL) {
90 JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
91 return;
92 }
93
94 psdo->nsRef = (NSGraphicsContext*)jlong_to_ptr(nsRef);
95 psdo->width = width;
96 psdo->height = height;
97
98 QuartzSDOps *qsdo = (QuartzSDOps*)psdo;
99 qsdo->BeginSurface = PrintSD_startCGContext;
100 qsdo->FinishSurface = PrintSD_finishCGContext;
101 qsdo->cgRef = [psdo->nsRef graphicsPort];
102
103 qsdo->javaGraphicsStates = (jint*)((*env)->GetDirectBufferAddress(env, jGraphicsState));
104 qsdo->javaGraphicsStatesObjects = (*env)->NewGlobalRef(env, jGraphicsStateObject);
105
106 qsdo->graphicsStateInfo.batchedLines = NULL;
107 qsdo->graphicsStateInfo.batchedLinesCount = 0;
108
109 SurfaceDataOps *sdo = (SurfaceDataOps*)qsdo;
110 sdo->Lock = PrintSD_Lock;
111 sdo->Unlock = PrintSD_Unlock;
112 sdo->GetRasInfo = PrintSD_GetRasInfo;
113 sdo->Release = PrintSD_ReleaseRasInfo;
114 sdo->Setup = NULL;
115 sdo->Dispose = PrintSD_dispose;
116
117 JNI_COCOA_EXIT(env);
118 }
119
120 static jint PrintSD_Lock(JNIEnv *env, SurfaceDataOps *sdo, SurfaceDataRasInfo *pRasInfo, jint lockflags)
121 {
122 PRINT(" PrintSD_Lock")
123 jint status = SD_FAILURE;
124
125 //QuartzSDOps *qsdo = (QuartzSDOps*)sdo;
126 //PrintSD_startCGContext(env, qsdo, SD_Image);
127
128 status = SD_SUCCESS;
129
130 return status;
131 }
132 static void PrintSD_Unlock(JNIEnv *env, SurfaceDataOps *sdo, SurfaceDataRasInfo *pRasInfo)
133 {
134 PRINT(" PrintSD_Unlock")
135
136 //QuartzSDOps *qsdo = (QuartzSDOps*)sdo;
137 //PrintSD_finishCGContext(env, qsdo);
|