8238075: [OGL] Delete unused properties

Reviewed-by: kizune
This commit is contained in:
Sergey Bylokhov 2020-03-11 21:58:16 -07:00
parent afe70e6985
commit 4f1fabd8d0
4 changed files with 163 additions and 233 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -63,7 +63,7 @@ public final class CGraphicsDevice extends GraphicsDevice
public CGraphicsDevice(final int displayID) { public CGraphicsDevice(final int displayID) {
this.displayID = displayID; this.displayID = displayID;
config = CGLGraphicsConfig.getConfig(this, displayID, 0); config = CGLGraphicsConfig.getConfig(this);
// initializes default device state, might be redundant step since we // initializes default device state, might be redundant step since we
// call "displayChanged()" later anyway, but we do not want to leave the // call "displayChanged()" later anyway, but we do not want to leave the
// device in an inconsistent state after construction // device in an inconsistent state after construction

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -64,13 +64,9 @@ import static sun.java2d.opengl.OGLSurfaceData.TEXTURE;
public final class CGLGraphicsConfig extends CGraphicsConfig public final class CGLGraphicsConfig extends CGraphicsConfig
implements OGLGraphicsConfig implements OGLGraphicsConfig
{ {
//private static final int kOpenGLSwapInterval =
// RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
private static final int kOpenGLSwapInterval = 0; // TODO
private static boolean cglAvailable; private static boolean cglAvailable;
private static ImageCapabilities imageCaps = new CGLImageCaps(); private static ImageCapabilities imageCaps = new CGLImageCaps();
private int pixfmt;
private BufferCapabilities bufferCaps; private BufferCapabilities bufferCaps;
private long pConfigInfo; private long pConfigInfo;
private ContextCapabilities oglCaps; private ContextCapabilities oglCaps;
@ -79,8 +75,7 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
private final int maxTextureSize; private final int maxTextureSize;
private static native boolean initCGL(); private static native boolean initCGL();
private static native long getCGLConfigInfo(int displayID, int visualnum, private static native long getCGLConfigInfo();
int swapInterval);
private static native int getOGLCapabilities(long configInfo); private static native int getOGLCapabilities(long configInfo);
/** /**
@ -95,12 +90,9 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
cglAvailable = initCGL(); cglAvailable = initCGL();
} }
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt, private CGLGraphicsConfig(CGraphicsDevice device, long configInfo,
long configInfo, int maxTextureSize, int maxTextureSize, ContextCapabilities oglCaps) {
ContextCapabilities oglCaps) {
super(device); super(device);
this.pixfmt = pixfmt;
this.pConfigInfo = configInfo; this.pConfigInfo = configInfo;
this.oglCaps = oglCaps; this.oglCaps = oglCaps;
this.maxTextureSize = maxTextureSize; this.maxTextureSize = maxTextureSize;
@ -125,8 +117,7 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
OGLSurfaceData.TEXTURE); OGLSurfaceData.TEXTURE);
} }
public static CGLGraphicsConfig getConfig(CGraphicsDevice device, public static CGLGraphicsConfig getConfig(CGraphicsDevice device)
int displayID, int pixfmt)
{ {
if (!cglAvailable) { if (!cglAvailable) {
return null; return null;
@ -142,7 +133,7 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
// surfaces/contexts, so we should first invalidate the current // surfaces/contexts, so we should first invalidate the current
// Java-level context and flush the queue... // Java-level context and flush the queue...
OGLContext.invalidateCurrentContext(); OGLContext.invalidateCurrentContext();
cfginfo = getCGLConfigInfo(displayID, pixfmt, kOpenGLSwapInterval); cfginfo = getCGLConfigInfo();
if (cfginfo != 0L) { if (cfginfo != 0L) {
textureSize = nativeGetMaxTextureSize(); textureSize = nativeGetMaxTextureSize();
// 7160609: GL still fails to create a square texture of this // 7160609: GL still fails to create a square texture of this
@ -163,7 +154,7 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
int oglCaps = getOGLCapabilities(cfginfo); int oglCaps = getOGLCapabilities(cfginfo);
ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]); ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);
return new CGLGraphicsConfig(device, pixfmt, cfginfo, textureSize, caps); return new CGLGraphicsConfig(device, cfginfo, textureSize, caps);
} }
public static boolean isCGLAvailable() { public static boolean isCGLAvailable() {
@ -253,8 +244,7 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
@Override @Override
public String toString() { public String toString() {
String display = getDevice().getIDstring(); return ("CGLGraphicsConfig[" + getDevice().getIDstring() + "]");
return ("CGLGraphicsConfig[" + display + ", pixfmt=" + pixfmt + "]");
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,10 +32,6 @@
#import "OGLContext.h" #import "OGLContext.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface GraphicsConfigUtil : NSObject {}
+ (void) _getCGLConfigInfo: (NSMutableArray *)argValue;
@end
// REMIND: Using an NSOpenGLPixelBuffer as the scratch surface has been // REMIND: Using an NSOpenGLPixelBuffer as the scratch surface has been
// problematic thus far (seeing garbage and flickering when switching // problematic thus far (seeing garbage and flickering when switching
// between an NSView and the scratch surface), so the following enables // between an NSView and the scratch surface), so the following enables
@ -50,20 +46,12 @@
/** /**
* The CGLGraphicsConfigInfo structure contains information specific to a * The CGLGraphicsConfigInfo structure contains information specific to a
* given CGLGraphicsConfig (pixel format). * given CGLGraphicsConfig.
*
* jint screen;
* The screen and PixelFormat for the associated CGLGraphicsConfig.
*
* NSOpenGLPixelFormat *pixfmt;
* The pixel format of the native NSOpenGL context.
* *
* OGLContext *context; * OGLContext *context;
* The context associated with this CGLGraphicsConfig. * The context associated with this CGLGraphicsConfig.
*/ */
typedef struct _CGLGraphicsConfigInfo { typedef struct _CGLGraphicsConfigInfo {
jint screen;
NSOpenGLPixelFormat *pixfmt;
OGLContext *context; OGLContext *context;
} CGLGraphicsConfigInfo; } CGLGraphicsConfigInfo;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,9 +34,6 @@
#import <ApplicationServices/ApplicationServices.h> #import <ApplicationServices/ApplicationServices.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h> #import <JavaNativeFoundation/JavaNativeFoundation.h>
#pragma mark -
#pragma mark "--- Mac OS X specific methods for GL pipeline ---"
/** /**
* Disposes all memory and resources associated with the given * Disposes all memory and resources associated with the given
* CGLGraphicsConfigInfo (including its native OGLContext data). * CGLGraphicsConfigInfo (including its native OGLContext data).
@ -77,9 +74,6 @@ OGLGC_DestroyOGLGraphicsConfig(jlong pConfigInfo)
free(cglinfo); free(cglinfo);
} }
#pragma mark -
#pragma mark "--- CGLGraphicsConfig methods ---"
/** /**
* This is a globally shared context used when creating textures. When any * This is a globally shared context used when creating textures. When any
* new contexts are created, they specify this context as the "share list" * new contexts are created, they specify this context as the "share list"
@ -112,49 +106,23 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_initCGL
return JNI_TRUE; return JNI_TRUE;
} }
/** /**
* Determines whether the CGL pipeline can be used for a given GraphicsConfig * Determines whether the CGL pipeline can be used for a given GraphicsConfig.
* provided its screen number and visual ID. If the minimum requirements are * If the minimum requirements are met, the native CGLGraphicsConfigInfo
* met, the native CGLGraphicsConfigInfo structure is initialized for this * structure is initialized for this GraphicsConfig with the necessary
* GraphicsConfig with the necessary information (pixel format, etc.) * information and a pointer to this structure is returned as a jlong. If
* and a pointer to this structure is returned as a jlong. If
* initialization fails at any point, zero is returned, indicating that CGL * initialization fails at any point, zero is returned, indicating that CGL
* cannot be used for this GraphicsConfig (we should fallback on an existing * cannot be used for this GraphicsConfig (we should fallback on an existing 2D
* 2D pipeline). * pipeline).
*/ */
JNIEXPORT jlong JNICALL JNIEXPORT jlong JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
(JNIEnv *env, jclass cglgc, (JNIEnv *env, jclass cglgc)
jint displayID, jint pixfmt, jint swapInterval)
{ {
jlong ret = 0L; __block jlong ret = 0L;
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
NSMutableArray * retArray = [NSMutableArray arrayWithCapacity:3]; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
[retArray addObject: [NSNumber numberWithInt: (int)displayID]];
[retArray addObject: [NSNumber numberWithInt: (int)pixfmt]];
[retArray addObject: [NSNumber numberWithInt: (int)swapInterval]];
if ([NSThread isMainThread]) {
[GraphicsConfigUtil _getCGLConfigInfo: retArray];
} else {
[GraphicsConfigUtil performSelectorOnMainThread: @selector(_getCGLConfigInfo:) withObject: retArray waitUntilDone: YES];
}
NSNumber * num = (NSNumber *)[retArray objectAtIndex: 0];
ret = (jlong)[num longValue];
JNF_COCOA_EXIT(env);
return ret;
}
@implementation GraphicsConfigUtil
+ (void) _getCGLConfigInfo: (NSMutableArray *)argValue {
AWT_ASSERT_APPKIT_THREAD;
jint displayID = (jint)[(NSNumber *)[argValue objectAtIndex: 0] intValue];
jint swapInterval = (jint)[(NSNumber *)[argValue objectAtIndex: 2] intValue];
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
[argValue removeAllObjects];
J2dRlsTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo"); J2dRlsTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo");
@ -179,8 +147,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
if (sharedPixelFormat == nil) { if (sharedPixelFormat == nil) {
J2dRlsTraceLn(J2D_TRACE_ERROR, J2dRlsTraceLn(J2D_TRACE_ERROR,
"CGLGraphicsConfig_getCGLConfigInfo: shared NSOpenGLPixelFormat is NULL"); "CGLGraphicsConfig_getCGLConfigInfo: shared NSOpenGLPixelFormat is NULL");
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
@ -190,7 +156,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
shareContext: NULL]; shareContext: NULL];
if (sharedContext == nil) { if (sharedContext == nil) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: shared NSOpenGLContext is NULL"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: shared NSOpenGLContext is NULL");
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
} }
@ -205,7 +170,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
defer: false]; defer: false];
if (window == nil) { if (window == nil) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: NSWindow is NULL"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: NSWindow is NULL");
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
@ -214,7 +178,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
initWithFrame: contentRect]; initWithFrame: contentRect];
if (scratchSurface == nil) { if (scratchSurface == nil) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: NSView is NULL"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: NSView is NULL");
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
[window setContentView: scratchSurface]; [window setContentView: scratchSurface];
@ -234,7 +197,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
shareContext: sharedContext]; shareContext: sharedContext];
if (context == nil) { if (context == nil) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: NSOpenGLContext is NULL"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: NSOpenGLContext is NULL");
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
@ -255,7 +217,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
if (!OGLContext_IsVersionSupported(versionstr)) { if (!OGLContext_IsVersionSupported(versionstr)) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: OpenGL 1.2 is required"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: OpenGL 1.2 is required");
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
J2dRlsTraceLn1(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo: OpenGL version=%s", versionstr); J2dRlsTraceLn1(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo: OpenGL version=%s", versionstr);
@ -290,17 +251,10 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
fprintf(stderr, "WARNING: GL pipe is running in software mode (Renderer ID=0x%x)\n", (int)value); fprintf(stderr, "WARNING: GL pipe is running in software mode (Renderer ID=0x%x)\n", (int)value);
} }
#endif #endif
// 0: the buffers are swapped with no regard to the vertical refresh rate
// 1: the buffers are swapped only during the vertical retrace
GLint params = swapInterval;
[context setValues: &params forParameter: NSOpenGLCPSwapInterval];
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)malloc(sizeof(CGLCtxInfo)); CGLCtxInfo *ctxinfo = (CGLCtxInfo *)malloc(sizeof(CGLCtxInfo));
if (ctxinfo == NULL) { if (ctxinfo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGC_InitOGLContext: could not allocate memory for ctxinfo"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGC_InitOGLContext: could not allocate memory for ctxinfo");
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
memset(ctxinfo, 0, sizeof(CGLCtxInfo)); memset(ctxinfo, 0, sizeof(CGLCtxInfo));
@ -312,7 +266,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGC_InitOGLContext: could not allocate memory for oglc"); J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGC_InitOGLContext: could not allocate memory for oglc");
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
free(ctxinfo); free(ctxinfo);
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
memset(oglc, 0, sizeof(OGLContext)); memset(oglc, 0, sizeof(OGLContext));
@ -326,19 +279,18 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
free(oglc); free(oglc);
free(ctxinfo); free(ctxinfo);
[argValue addObject: [NSNumber numberWithLong: 0L]];
return; return;
} }
memset(cglinfo, 0, sizeof(CGLGraphicsConfigInfo)); memset(cglinfo, 0, sizeof(CGLGraphicsConfigInfo));
cglinfo->screen = displayID;
cglinfo->pixfmt = sharedPixelFormat;
cglinfo->context = oglc; cglinfo->context = oglc;
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
[argValue addObject: [NSNumber numberWithLong:ptr_to_jlong(cglinfo)]]; ret = ptr_to_jlong(cglinfo);
[pool drain]; [pool drain];
}];
JNF_COCOA_EXIT(env);
return ret;
} }
@end //GraphicsConfigUtil
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getOGLCapabilities Java_sun_java2d_opengl_CGLGraphicsConfig_getOGLCapabilities