src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m
changeset 58315 07556f8cd819
parent 54873 442e683e65fa
equal deleted inserted replaced
58314:170b727a240a 58315:07556f8cd819
   129 
   129 
   130 JNF_COCOA_EXIT(env);
   130 JNF_COCOA_EXIT(env);
   131 }
   131 }
   132 
   132 
   133 /**
   133 /**
   134  * Returns a pointer (as a jlong) to the native CGLGraphicsConfigInfo
       
   135  * associated with the given OGLSDOps.  This method can be called from
       
   136  * shared code to retrieve the native GraphicsConfig data in a platform-
       
   137  * independent manner.
       
   138  */
       
   139 jlong
       
   140 OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
       
   141 {
       
   142     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_GetNativeConfigInfo");
       
   143 
       
   144     if (oglsdo == NULL) {
       
   145         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: ops are null");
       
   146         return 0L;
       
   147     }
       
   148 
       
   149     CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
       
   150     if (cglsdo == NULL) {
       
   151         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: cgl ops are null");
       
   152         return 0L;
       
   153     }
       
   154 
       
   155     return ptr_to_jlong(cglsdo->configInfo);
       
   156 }
       
   157 
       
   158 /**
       
   159  * Makes the given GraphicsConfig's context current to its associated
   134  * Makes the given GraphicsConfig's context current to its associated
   160  * "scratch" surface.  If there is a problem making the context current,
   135  * "scratch" surface.  If there is a problem making the context current,
   161  * this method will return NULL; otherwise, returns a pointer to the
   136  * this method will return NULL; otherwise, returns a pointer to the
   162  * OGLContext that is associated with the given GraphicsConfig.
   137  * OGLContext that is associated with the given GraphicsConfig.
   163  */
   138  */
   357 extern UnlockFunc      OGLSD_Unlock;
   332 extern UnlockFunc      OGLSD_Unlock;
   358 extern DisposeFunc     OGLSD_Dispose;
   333 extern DisposeFunc     OGLSD_Dispose;
   359 
   334 
   360 JNIEXPORT void JNICALL
   335 JNIEXPORT void JNICALL
   361 Java_sun_java2d_opengl_CGLSurfaceData_initOps
   336 Java_sun_java2d_opengl_CGLSurfaceData_initOps
   362     (JNIEnv *env, jobject cglsd,
   337     (JNIEnv *env, jobject cglsd, jobject gc,
   363      jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
   338      jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
   364      jint xoff, jint yoff, jboolean isOpaque)
   339      jint xoff, jint yoff, jboolean isOpaque)
   365 {
   340 {
   366     J2dTraceLn(J2D_TRACE_INFO, "CGLSurfaceData_initOps");
   341     J2dTraceLn(J2D_TRACE_INFO, "CGLSurfaceData_initOps");
   367     J2dTraceLn1(J2D_TRACE_INFO, "  pPeerData=%p", jlong_to_ptr(pPeerData));
   342     J2dTraceLn1(J2D_TRACE_INFO, "  pPeerData=%p", jlong_to_ptr(pPeerData));
   368     J2dTraceLn2(J2D_TRACE_INFO, "  xoff=%d, yoff=%d", (int)xoff, (int)yoff);
   343     J2dTraceLn2(J2D_TRACE_INFO, "  xoff=%d, yoff=%d", (int)xoff, (int)yoff);
   369 
   344 
       
   345     gc = (*env)->NewGlobalRef(env, gc);
       
   346     if (gc == NULL) {
       
   347         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
       
   348         return;
       
   349     }
       
   350 
   370     OGLSDOps *oglsdo = (OGLSDOps *)
   351     OGLSDOps *oglsdo = (OGLSDOps *)
   371         SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
   352         SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
       
   353     if (oglsdo == NULL) {
       
   354         (*env)->DeleteGlobalRef(env, gc);
       
   355         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
       
   356         return;
       
   357     }
       
   358     // later the graphicsConfig will be used for deallocation of oglsdo
       
   359     oglsdo->graphicsConfig = gc;
       
   360 
   372     CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
   361     CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
   373     if (cglsdo == NULL) {
   362     if (cglsdo == NULL) {
   374         JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
   363         JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
   375         return;
   364         return;
   376     }
   365     }