1 /* |
1 /* |
2 * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
56 extern void |
56 extern void |
57 OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h); |
57 OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h); |
58 |
58 |
59 JNIEXPORT void JNICALL |
59 JNIEXPORT void JNICALL |
60 Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd, |
60 Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd, |
61 jlong pConfigInfo, |
61 jobject gc, jlong pConfigInfo, |
62 jobject peer, jlong hwnd) |
62 jobject peer, jlong hwnd) |
63 { |
63 { |
|
64 gc = (*env)->NewGlobalRef(env, gc); |
|
65 if (gc == NULL) { |
|
66 JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); |
|
67 return; |
|
68 } |
|
69 |
64 OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, wglsd, |
70 OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, wglsd, |
65 sizeof(OGLSDOps)); |
71 sizeof(OGLSDOps)); |
|
72 if (oglsdo == NULL) { |
|
73 (*env)->DeleteGlobalRef(env, gc); |
|
74 JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); |
|
75 return; |
|
76 } |
|
77 // later the graphicsConfig will be used for deallocation of oglsdo |
|
78 oglsdo->graphicsConfig = gc; |
|
79 |
66 WGLSDOps *wglsdo = (WGLSDOps *)malloc(sizeof(WGLSDOps)); |
80 WGLSDOps *wglsdo = (WGLSDOps *)malloc(sizeof(WGLSDOps)); |
67 |
81 |
68 J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps"); |
82 J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps"); |
69 |
83 |
70 if (wglsdo == NULL) { |
84 if (wglsdo == NULL) { |
140 "WGLSD_MakeCurrentToScratch: could not make current"); |
154 "WGLSD_MakeCurrentToScratch: could not make current"); |
141 return JNI_FALSE; |
155 return JNI_FALSE; |
142 } |
156 } |
143 |
157 |
144 return JNI_TRUE; |
158 return JNI_TRUE; |
145 } |
|
146 |
|
147 /** |
|
148 * Returns a pointer (as a jlong) to the native WGLGraphicsConfigInfo |
|
149 * associated with the given OGLSDOps. This method can be called from |
|
150 * shared code to retrieve the native GraphicsConfig data in a platform- |
|
151 * independent manner. |
|
152 */ |
|
153 jlong |
|
154 OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo) |
|
155 { |
|
156 WGLSDOps *wglsdo; |
|
157 |
|
158 if (oglsdo == NULL) { |
|
159 J2dRlsTraceLn(J2D_TRACE_ERROR, |
|
160 "OGLSD_GetNativeConfigInfo: ops are null"); |
|
161 return 0L; |
|
162 } |
|
163 |
|
164 wglsdo = (WGLSDOps *)oglsdo->privOps; |
|
165 if (wglsdo == NULL) { |
|
166 J2dRlsTraceLn(J2D_TRACE_ERROR, |
|
167 "OGLSD_GetNativeConfigInfo: wgl ops are null"); |
|
168 return 0L; |
|
169 } |
|
170 |
|
171 return ptr_to_jlong(wglsdo->configInfo); |
|
172 } |
159 } |
173 |
160 |
174 /** |
161 /** |
175 * Makes the given GraphicsConfig's context current to its associated |
162 * Makes the given GraphicsConfig's context current to its associated |
176 * "scratch" surface. If there is a problem making the context current, |
163 * "scratch" surface. If there is a problem making the context current, |