summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-04 19:57:39 +0100
committerSven Gothel <[email protected]>2023-03-04 19:57:39 +0100
commitead8651394c792950025114cfcb6476e8b82bf50 (patch)
tree28d3ff3c78d95c8c6d85512335a1f8c613cde10b /src
parent0b796fe6963705a231bc1f24a5b4e6651b7e928f (diff)
GLDrawableFactoryImpl:createDummyDrawable(): Similar to createOffscreenDrawable() prefer createSurfacelessImpl() over createDummySurfaceImpl() to reduce resources (no actual window)
This enhances the 'dummy drawable' use-case implementation, i.e. for shared context.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java20
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java9
2 files changed, 16 insertions, 13 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 28ecd1029..b165f3b77 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -537,8 +537,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
* @param height
*/
protected final GLDrawableImpl createSurfacelessDrawable(final AbstractGraphicsDevice device2Use,
- final GLCapabilitiesImmutable capsRequested,
- final int width, final int height) {
+ final GLCapabilitiesImmutable capsRequested,
+ final int width, final int height) {
if(width<=0 || height<=0) {
throw new GLException("initial size must be positive (were (" + width + " x " + height + "))");
}
@@ -551,8 +551,12 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
@Override
public final GLDrawable createDummyDrawable(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser) {
final AbstractGraphicsDevice device;
+ final SharedResourceRunner.Resource sr = getOrCreateSharedResource( deviceReq );
+ if( null == sr ) {
+ throw new GLException("No shared resource for requested: "+deviceReq);
+ }
if( createNewDevice ) {
- device = getOrCreateSharedDevice(deviceReq);
+ device = sr.getDevice();
if(null == device) {
throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice);
}
@@ -561,8 +565,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
deviceReq.lock();
}
try {
- final ProxySurface dummySurface = createDummySurfaceImpl(deviceReq, device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64);
- return createOnscreenDrawableImpl(dummySurface);
+ final GLRendererQuirks glrq = sr.getRendererQuirks(capsRequested.getGLProfile());
+ final ProxySurface surface;
+ if( null != glrq && !glrq.exist(GLRendererQuirks.NoSurfacelessCtx) ) {
+ surface = createSurfacelessImpl(deviceReq, device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64);
+ } else {
+ surface = createDummySurfaceImpl(deviceReq, device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64);
+ }
+ return createOnscreenDrawableImpl(surface);
} finally {
if( !createNewDevice ) {
deviceReq.unlock();
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java b/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java
index 044aebc21..9a8afc937 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2014 JogAmp Community. All rights reserved.
+ * Copyright 2014-2023 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -27,13 +27,6 @@
*/
package com.jogamp.nativewindow;
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.NativeSurface;
-import com.jogamp.nativewindow.ProxySurface;
-import com.jogamp.nativewindow.UpstreamSurfaceHook;
-
-import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize;
-
public class GenericUpstreamSurfacelessHook extends UpstreamSurfaceHookMutableSize {
/**
* @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getSurfaceWidth(ProxySurface)},