< prev index next >

src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m

Print this page
rev 13714 : 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
Reviewed-by: prr, avu


 128             oglsdo->textureID = 0;
 129         }
 130         if (cglsdo->pbuffer != NULL) {
 131             [cglsdo->pbuffer release];
 132             cglsdo->pbuffer = NULL;
 133         }
 134     } else if (oglsdo->drawableType == OGLSD_WINDOW) {
 135         // detach the NSView from the NSOpenGLContext
 136         CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
 137         OGLContext *oglc = cglInfo->context;
 138         CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
 139         [ctxinfo->context clearDrawable];
 140     }
 141 
 142     oglsdo->drawableType = OGLSD_UNDEFINED;
 143 
 144 JNF_COCOA_EXIT(env);
 145 }
 146 
 147 /**
 148  * Returns a pointer (as a jlong) to the native CGLGraphicsConfigInfo
 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     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_GetNativeConfigInfo");
 157 
 158     if (oglsdo == NULL) {
 159         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: ops are null");
 160         return 0L;
 161     }
 162 
 163     CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
 164     if (cglsdo == NULL) {
 165         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: cgl ops are null");
 166         return 0L;
 167     }
 168 
 169     return ptr_to_jlong(cglsdo->configInfo);
 170 }
 171 
 172 /**
 173  * Makes the given GraphicsConfig's context current to its associated
 174  * "scratch" surface.  If there is a problem making the context current,
 175  * this method will return NULL; otherwise, returns a pointer to the
 176  * OGLContext that is associated with the given GraphicsConfig.
 177  */
 178 OGLContext *
 179 OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
 180 {
 181     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
 182 
 183     CGLGraphicsConfigInfo *cglInfo = (CGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
 184     if (cglInfo == NULL) {
 185         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_SetScratchContext: cgl config info is null");
 186         return NULL;
 187     }
 188 
 189     OGLContext *oglc = cglInfo->context;
 190     if (oglc == NULL) {
 191         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_SetScratchContext: ogl context is null");
 192         return NULL;


 394                     remoteLayer.textureWidth = layer.textureWidth;
 395                     remoteLayer.textureHeight = layer.textureHeight;
 396                     [remoteLayer setNeedsDisplay];
 397                 }
 398 #endif /* REMOTELAYER */
 399             }];
 400         }
 401     }
 402 }
 403 
 404 #pragma mark -
 405 #pragma mark "--- CGLSurfaceData methods ---"
 406 
 407 extern LockFunc        OGLSD_Lock;
 408 extern GetRasInfoFunc  OGLSD_GetRasInfo;
 409 extern UnlockFunc      OGLSD_Unlock;
 410 extern DisposeFunc     OGLSD_Dispose;
 411 
 412 JNIEXPORT void JNICALL
 413 Java_sun_java2d_opengl_CGLSurfaceData_initOps
 414     (JNIEnv *env, jobject cglsd,
 415      jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
 416      jint xoff, jint yoff, jboolean isOpaque)
 417 {
 418     J2dTraceLn(J2D_TRACE_INFO, "CGLSurfaceData_initOps");
 419     J2dTraceLn1(J2D_TRACE_INFO, "  pPeerData=%p", jlong_to_ptr(pPeerData));
 420     J2dTraceLn2(J2D_TRACE_INFO, "  xoff=%d, yoff=%d", (int)xoff, (int)yoff);
 421 






 422     OGLSDOps *oglsdo = (OGLSDOps *)
 423         SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));








 424     CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
 425     if (cglsdo == NULL) {
 426         JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
 427         return;
 428     }
 429 
 430     oglsdo->privOps = cglsdo;
 431 
 432     oglsdo->sdOps.Lock               = OGLSD_Lock;
 433     oglsdo->sdOps.GetRasInfo         = OGLSD_GetRasInfo;
 434     oglsdo->sdOps.Unlock             = OGLSD_Unlock;
 435     oglsdo->sdOps.Dispose            = OGLSD_Dispose;
 436 
 437     oglsdo->drawableType = OGLSD_UNDEFINED;
 438     oglsdo->activeBuffer = GL_FRONT;
 439     oglsdo->needsInit = JNI_TRUE;
 440     oglsdo->xOffset = xoff;
 441     oglsdo->yOffset = yoff;
 442     oglsdo->isOpaque = isOpaque;
 443 




 128             oglsdo->textureID = 0;
 129         }
 130         if (cglsdo->pbuffer != NULL) {
 131             [cglsdo->pbuffer release];
 132             cglsdo->pbuffer = NULL;
 133         }
 134     } else if (oglsdo->drawableType == OGLSD_WINDOW) {
 135         // detach the NSView from the NSOpenGLContext
 136         CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
 137         OGLContext *oglc = cglInfo->context;
 138         CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
 139         [ctxinfo->context clearDrawable];
 140     }
 141 
 142     oglsdo->drawableType = OGLSD_UNDEFINED;
 143 
 144 JNF_COCOA_EXIT(env);
 145 }
 146 
 147 /**

























 148  * Makes the given GraphicsConfig's context current to its associated
 149  * "scratch" surface.  If there is a problem making the context current,
 150  * this method will return NULL; otherwise, returns a pointer to the
 151  * OGLContext that is associated with the given GraphicsConfig.
 152  */
 153 OGLContext *
 154 OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
 155 {
 156     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
 157 
 158     CGLGraphicsConfigInfo *cglInfo = (CGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
 159     if (cglInfo == NULL) {
 160         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_SetScratchContext: cgl config info is null");
 161         return NULL;
 162     }
 163 
 164     OGLContext *oglc = cglInfo->context;
 165     if (oglc == NULL) {
 166         J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_SetScratchContext: ogl context is null");
 167         return NULL;


 369                     remoteLayer.textureWidth = layer.textureWidth;
 370                     remoteLayer.textureHeight = layer.textureHeight;
 371                     [remoteLayer setNeedsDisplay];
 372                 }
 373 #endif /* REMOTELAYER */
 374             }];
 375         }
 376     }
 377 }
 378 
 379 #pragma mark -
 380 #pragma mark "--- CGLSurfaceData methods ---"
 381 
 382 extern LockFunc        OGLSD_Lock;
 383 extern GetRasInfoFunc  OGLSD_GetRasInfo;
 384 extern UnlockFunc      OGLSD_Unlock;
 385 extern DisposeFunc     OGLSD_Dispose;
 386 
 387 JNIEXPORT void JNICALL
 388 Java_sun_java2d_opengl_CGLSurfaceData_initOps
 389     (JNIEnv *env, jobject cglsd, jobject gc,
 390      jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
 391      jint xoff, jint yoff, jboolean isOpaque)
 392 {
 393     J2dTraceLn(J2D_TRACE_INFO, "CGLSurfaceData_initOps");
 394     J2dTraceLn1(J2D_TRACE_INFO, "  pPeerData=%p", jlong_to_ptr(pPeerData));
 395     J2dTraceLn2(J2D_TRACE_INFO, "  xoff=%d, yoff=%d", (int)xoff, (int)yoff);
 396 
 397     gc = (*env)->NewGlobalRef(env, gc);
 398     if (gc == NULL) {
 399         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
 400         return;
 401     }
 402 
 403     OGLSDOps *oglsdo = (OGLSDOps *)
 404         SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
 405     if (oglsdo == NULL) {
 406         (*env)->DeleteGlobalRef(env, gc);
 407         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
 408         return;
 409     }
 410     // later the graphicsConfig will be used for deallocation of oglsdo
 411     oglsdo->graphicsConfig = gc;
 412 
 413     CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
 414     if (cglsdo == NULL) {
 415         JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
 416         return;
 417     }
 418 
 419     oglsdo->privOps = cglsdo;
 420 
 421     oglsdo->sdOps.Lock               = OGLSD_Lock;
 422     oglsdo->sdOps.GetRasInfo         = OGLSD_GetRasInfo;
 423     oglsdo->sdOps.Unlock             = OGLSD_Unlock;
 424     oglsdo->sdOps.Dispose            = OGLSD_Dispose;
 425 
 426     oglsdo->drawableType = OGLSD_UNDEFINED;
 427     oglsdo->activeBuffer = GL_FRONT;
 428     oglsdo->needsInit = JNI_TRUE;
 429     oglsdo->xOffset = xoff;
 430     oglsdo->yOffset = yoff;
 431     oglsdo->isOpaque = isOpaque;
 432 


< prev index next >