aboutsummaryrefslogtreecommitdiff
path: root/src/macosx/native
diff options
context:
space:
mode:
Diffstat (limited to 'src/macosx/native')
-rw-r--r--src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser4
-rw-r--r--src/macosx/native/sun/awt/CGraphicsDevice.m15
-rw-r--r--src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m55
3 files changed, 28 insertions, 46 deletions
diff --git a/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser b/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser
index cda3de5e2f..dd674ec558 100644
--- a/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser
+++ b/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser
@@ -5,7 +5,9 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
diff --git a/src/macosx/native/sun/awt/CGraphicsDevice.m b/src/macosx/native/sun/awt/CGraphicsDevice.m
index 6a22c65451..570c4d663b 100644
--- a/src/macosx/native/sun/awt/CGraphicsDevice.m
+++ b/src/macosx/native/sun/awt/CGraphicsDevice.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -94,16 +94,18 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
static CGDisplayModeRef getBestModeForParameters(CFArrayRef allModes, int w, int h, int bpp, int refrate) {
CGDisplayModeRef bestGuess = NULL;
CFIndex numModes = CFArrayGetCount(allModes), n;
- int thisBpp = 0;
+
for(n = 0; n < numModes; n++ ) {
CGDisplayModeRef cRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(allModes, n);
if(cRef == NULL) {
continue;
}
CFStringRef modeString = CGDisplayModeCopyPixelEncoding(cRef);
- thisBpp = getBPPFromModeString(modeString);
+ int thisBpp = getBPPFromModeString(modeString);
CFRelease(modeString);
- if (thisBpp != bpp || (int)CGDisplayModeGetHeight(cRef) != h || (int)CGDisplayModeGetWidth(cRef) != w) {
+ int thisH = (int)CGDisplayModeGetHeight(cRef);
+ int thisW = (int)CGDisplayModeGetWidth(cRef);
+ if (thisBpp != bpp || thisH != h || thisW != w) {
// One of the key parameters does not match
continue;
}
@@ -114,11 +116,12 @@ static CGDisplayModeRef getBestModeForParameters(CFArrayRef allModes, int w, int
// Refresh rate might be 0 in display mode and we ask for specific display rate
// but if we do not find exact match then 0 refresh rate might be just Ok
- if (CGDisplayModeGetRefreshRate(cRef) == refrate) {
+ int thisRefrate = (int)CGDisplayModeGetRefreshRate(cRef);
+ if (thisRefrate == refrate) {
// Exact match
return cRef;
}
- if (CGDisplayModeGetRefreshRate(cRef) == 0) {
+ if (thisRefrate == 0) {
// Not exactly what was asked for, but may fit our needs if we don't find an exact match
bestGuess = cRef;
}
diff --git a/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m b/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m
index d4c1d71eb8..0c32ac3849 100644
--- a/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m
+++ b/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m
@@ -145,31 +145,6 @@ JNF_COCOA_EXIT(env);
}
/**
- * Returns a pointer (as a jlong) to the native CGLGraphicsConfigInfo
- * associated with the given OGLSDOps. This method can be called from
- * shared code to retrieve the native GraphicsConfig data in a platform-
- * independent manner.
- */
-jlong
-OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
-{
- J2dTraceLn(J2D_TRACE_INFO, "OGLSD_GetNativeConfigInfo");
-
- if (oglsdo == NULL) {
- J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: ops are null");
- return 0L;
- }
-
- CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
- if (cglsdo == NULL) {
- J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: cgl ops are null");
- return 0L;
- }
-
- return ptr_to_jlong(cglsdo->configInfo);
-}
-
-/**
* Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current,
* this method will return NULL; otherwise, returns a pointer to the
@@ -409,21 +384,9 @@ extern GetRasInfoFunc OGLSD_GetRasInfo;
extern UnlockFunc OGLSD_Unlock;
extern DisposeFunc OGLSD_Dispose;
-
-void
-CGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
-{
- OGLSDOps *oglsdo = (OGLSDOps *)ops;
- jlong pConfigInfo = OGLSD_GetNativeConfigInfo(oglsdo);
- JNU_CallStaticMethodByName(env, NULL, "sun/java2d/opengl/CGLSurfaceData",
- "dispose", "(JJ)V",
- ptr_to_jlong(ops), pConfigInfo);
-}
-
-
JNIEXPORT void JNICALL
Java_sun_java2d_opengl_CGLSurfaceData_initOps
- (JNIEnv *env, jobject cglsd,
+ (JNIEnv *env, jobject cglsd, jobject gc,
jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
jint xoff, jint yoff, jboolean isOpaque)
{
@@ -431,8 +394,22 @@ Java_sun_java2d_opengl_CGLSurfaceData_initOps
J2dTraceLn1(J2D_TRACE_INFO, " pPeerData=%p", jlong_to_ptr(pPeerData));
J2dTraceLn2(J2D_TRACE_INFO, " xoff=%d, yoff=%d", (int)xoff, (int)yoff);
+ gc = (*env)->NewGlobalRef(env, gc);
+ if (gc == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+ return;
+ }
+
OGLSDOps *oglsdo = (OGLSDOps *)
SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
+ if (oglsdo == NULL) {
+ (*env)->DeleteGlobalRef(env, gc);
+ JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+ return;
+ }
+ // later the graphicsConfig will be used for deallocation of oglsdo
+ oglsdo->graphicsConfig = gc;
+
CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
if (cglsdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
@@ -444,7 +421,7 @@ Java_sun_java2d_opengl_CGLSurfaceData_initOps
oglsdo->sdOps.Lock = OGLSD_Lock;
oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
oglsdo->sdOps.Unlock = OGLSD_Unlock;
- oglsdo->sdOps.Dispose = CGLSD_Dispose;
+ oglsdo->sdOps.Dispose = OGLSD_Dispose;
oglsdo->drawableType = OGLSD_UNDEFINED;
oglsdo->activeBuffer = GL_FRONT;