< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m
Print this page
rev 54096 : 8259651: [macOS] Replace JNF_COCOA_ENTER/EXIT macros
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion
*** 25,35 ****
#import <stdlib.h>
#import "sun_java2d_opengl_CGLSurfaceData.h"
! #import "jni_util.h"
#import "OGLRenderQueue.h"
#import "CGLGraphicsConfig.h"
#import "CGLSurfaceData.h"
#import "ThreadUtilities.h"
--- 25,35 ----
#import <stdlib.h>
#import "sun_java2d_opengl_CGLSurfaceData.h"
! #import "JNIUtilities.h"
#import "OGLRenderQueue.h"
#import "CGLGraphicsConfig.h"
#import "CGLSurfaceData.h"
#import "ThreadUtilities.h"
*** 60,72 ****
fprintf(stderr, "about to unlock focus: %p %p\n",
cglsdo->peerData, ctxinfo->context);
NSOpenGLView *nsView = cglsdo->peerData;
if (nsView != NULL) {
! JNF_COCOA_ENTER(env);
[nsView unlockFocus];
! JNF_COCOA_EXIT(env);
}
}
#endif
/**
--- 60,72 ----
fprintf(stderr, "about to unlock focus: %p %p\n",
cglsdo->peerData, ctxinfo->context);
NSOpenGLView *nsView = cglsdo->peerData;
if (nsView != NULL) {
! JNI_COCOA_ENTER(env);
[nsView unlockFocus];
! JNI_COCOA_EXIT(env);
}
}
#endif
/**
*** 83,93 ****
J2dRlsTraceLn(J2D_TRACE_ERROR,
"CGLSD_MakeCurrentToScratch: context is null");
return JNI_FALSE;
}
! JNF_COCOA_ENTER(env);
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
#if USE_NSVIEW_FOR_SCRATCH
[ctxinfo->context makeCurrentContext];
#else
--- 83,93 ----
J2dRlsTraceLn(J2D_TRACE_ERROR,
"CGLSD_MakeCurrentToScratch: context is null");
return JNI_FALSE;
}
! JNI_COCOA_ENTER(env);
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
#if USE_NSVIEW_FOR_SCRATCH
[ctxinfo->context makeCurrentContext];
#else
*** 97,107 ****
cubeMapFace: 0
mipMapLevel: 0
currentVirtualScreen: [ctxinfo->context currentVirtualScreen]];
#endif
! JNF_COCOA_EXIT(env);
return JNI_TRUE;
}
/**
--- 97,107 ----
cubeMapFace: 0
mipMapLevel: 0
currentVirtualScreen: [ctxinfo->context currentVirtualScreen]];
#endif
! JNI_COCOA_EXIT(env);
return JNI_TRUE;
}
/**
*** 111,121 ****
void
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
{
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
! JNF_COCOA_ENTER(env);
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
if (oglsdo->drawableType == OGLSD_WINDOW) {
// detach the NSView from the NSOpenGLContext
CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
--- 111,121 ----
void
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
{
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
! JNI_COCOA_ENTER(env);
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
if (oglsdo->drawableType == OGLSD_WINDOW) {
// detach the NSView from the NSOpenGLContext
CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
*** 124,134 ****
[ctxinfo->context clearDrawable];
}
oglsdo->drawableType = OGLSD_UNDEFINED;
! JNF_COCOA_EXIT(env);
}
/**
* Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current,
--- 124,134 ----
[ctxinfo->context clearDrawable];
}
oglsdo->drawableType = OGLSD_UNDEFINED;
! JNI_COCOA_EXIT(env);
}
/**
* Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current,
*** 152,162 ****
return NULL;
}
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
! JNF_COCOA_ENTER(env);
// avoid changing the context's target view whenever possible, since
// calling setView causes flickering; as long as our context is current
// to some view, it's not necessary to switch to the scratch surface
if ([ctxinfo->context view] == nil) {
--- 152,162 ----
return NULL;
}
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
! JNI_COCOA_ENTER(env);
// avoid changing the context's target view whenever possible, since
// calling setView causes flickering; as long as our context is current
// to some view, it's not necessary to switch to the scratch surface
if ([ctxinfo->context view] == nil) {
*** 179,189 ****
// will ensure that we are bound to the scratch surface (and not
// some other framebuffer object)
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
! JNF_COCOA_EXIT(env);
return oglc;
}
/**
--- 179,189 ----
// will ensure that we are bound to the scratch surface (and not
// some other framebuffer object)
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
! JNI_COCOA_EXIT(env);
return oglc;
}
/**
*** 233,243 ****
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
return oglc;
}
! JNF_COCOA_ENTER(env);
CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
NSView *nsView = (NSView *)cglsdo->peerData;
if ([ctxinfo->context view] != nsView) {
--- 233,243 ----
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
return oglc;
}
! JNI_COCOA_ENTER(env);
CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
NSView *nsView = (NSView *)cglsdo->peerData;
if ([ctxinfo->context view] != nsView) {
*** 250,260 ****
// must bind to the default (windowing system provided)
// framebuffer
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
! JNF_COCOA_EXIT(env);
return oglc;
}
/**
--- 250,260 ----
// must bind to the default (windowing system provided)
// framebuffer
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
! JNI_COCOA_EXIT(env);
return oglc;
}
/**
*** 282,298 ****
if (v == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_InitOGLWindow: view is invalid");
return JNI_FALSE;
}
! JNF_COCOA_ENTER(env);
NSRect surfaceBounds = [v bounds];
oglsdo->drawableType = OGLSD_WINDOW;
oglsdo->isOpaque = JNI_TRUE;
oglsdo->width = surfaceBounds.size.width;
oglsdo->height = surfaceBounds.size.height;
! JNF_COCOA_EXIT(env);
J2dTraceLn2(J2D_TRACE_VERBOSE, " created window: w=%d h=%d", oglsdo->width, oglsdo->height);
return JNI_TRUE;
}
--- 282,298 ----
if (v == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_InitOGLWindow: view is invalid");
return JNI_FALSE;
}
! JNI_COCOA_ENTER(env);
NSRect surfaceBounds = [v bounds];
oglsdo->drawableType = OGLSD_WINDOW;
oglsdo->isOpaque = JNI_TRUE;
oglsdo->width = surfaceBounds.size.width;
oglsdo->height = surfaceBounds.size.height;
! JNI_COCOA_EXIT(env);
J2dTraceLn2(J2D_TRACE_VERBOSE, " created window: w=%d h=%d", oglsdo->width, oglsdo->height);
return JNI_TRUE;
}
*** 300,323 ****
void
OGLSD_SwapBuffers(JNIEnv *env, jlong pPeerData)
{
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SwapBuffers");
! JNF_COCOA_ENTER(env);
[[NSOpenGLContext currentContext] flushBuffer];
! JNF_COCOA_EXIT(env);
}
void
OGLSD_Flush(JNIEnv *env)
{
OGLSDOps *dstOps = OGLRenderQueue_GetCurrentDestination();
if (dstOps != NULL) {
CGLSDOps *dstCGLOps = (CGLSDOps *)dstOps->privOps;
CGLLayer *layer = (CGLLayer*)dstCGLOps->layer;
if (layer != NULL) {
! [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
AWT_ASSERT_APPKIT_THREAD;
[layer setNeedsDisplay];
#ifdef REMOTELAYER
/* If there's a remote layer (being used for testing)
--- 300,323 ----
void
OGLSD_SwapBuffers(JNIEnv *env, jlong pPeerData)
{
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SwapBuffers");
! JNI_COCOA_ENTER(env);
[[NSOpenGLContext currentContext] flushBuffer];
! JNI_COCOA_EXIT(env);
}
void
OGLSD_Flush(JNIEnv *env)
{
OGLSDOps *dstOps = OGLRenderQueue_GetCurrentDestination();
if (dstOps != NULL) {
CGLSDOps *dstCGLOps = (CGLSDOps *)dstOps->privOps;
CGLLayer *layer = (CGLLayer*)dstCGLOps->layer;
if (layer != NULL) {
! [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
AWT_ASSERT_APPKIT_THREAD;
[layer setNeedsDisplay];
#ifdef REMOTELAYER
/* If there's a remote layer (being used for testing)
*** 444,453 ****
// drawable has changed size
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
OGLContext *oglc = cglsdo->configInfo->context;
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
! JNF_COCOA_ENTER(env);
[ctxinfo->context update];
! JNF_COCOA_EXIT(env);
}
}
--- 444,453 ----
// drawable has changed size
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
OGLContext *oglc = cglsdo->configInfo->context;
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
! JNI_COCOA_ENTER(env);
[ctxinfo->context update];
! JNI_COCOA_EXIT(env);
}
}
< prev index next >