提交 8ae43a41 编写于 作者: M Mathieu Bastian

Update JOGL, clean-up NB modes and dispose of GL resources on TopComponent close to address #2546

上级 4457c42b
<?xml version="1.0" encoding="UTF-8"?>
<mode version="2.4">
<name unique="contextmode"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="60" weight="0.7"/>
<path orientation="vertical" number="40" weight="0.7"/>
<path orientation="horizontal" number="80" weight="0.252324037184595"/>
<path orientation="vertical" number="81" weight="0.10926694329183956"/>
</constraints>
<bounds x="0" y="0" width="0" height="0"/>
<frame state="0"/>
<empty-behavior permanent="false"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="90" weight="0.17"/>
<path orientation="vertical" number="5" weight="0.13"/>
</constraints>
<frame state="0"/>
<empty-behavior permanent="true"/>
</mode>
<?xml version="1.0" encoding="UTF-8"?>
<mode version="2.4">
<name unique="editor"/>
<kind type="editor"/>
<state type="joined"/>
<!--<bounds x="0" y="0" width="0" height="0"/>-->
<frame state="0"/>
<kind type="editor"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="20" weight="0.66"/>
<path orientation="vertical" number="60" weight="1.0"/>
</constraints>
<frame state="0"/>
<empty-behavior permanent="true"/>
</mode>
<?xml version="1.0" encoding="UTF-8"?>
<mode version="2.4">
<name unique="filtersmode"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="60" weight="0.7"/>
<path orientation="vertical" number="40" weight="0.7"/>
<path orientation="horizontal" number="80" weight="0.252324037184595"/>
<path orientation="vertical" number="82" weight="0.8865836791147994"/>
</constraints>
<bounds x="1260" y="536" width="252" height="306"/>
<frame state="0"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="90" weight="0.17"/>
<path orientation="vertical" number="7" weight="0.87"/>
</constraints>
<bounds x="1260" y="536" width="252" height="306"/>
<frame state="0"/>
<empty-behavior permanent="true"/>
</mode>
<?xml version="1.0" encoding="UTF-8"?>
<mode version="2.4">
<name unique="layoutmode"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="20" weight="0.2"/>
<path orientation="vertical" number="60" weight="0.6"/>
</constraints>
<bounds x="168" y="210" width="537" height="479"/>
<frame state="0"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="10" weight="0.17"/>
<path orientation="vertical" number="50" weight="0.6"/>
</constraints>
<bounds x="168" y="210" width="537" height="479"/>
<frame state="0"/>
<empty-behavior permanent="true"/>
</mode>
<?xml version="1.0" encoding="UTF-8"?>
<mode version="2.4">
<name unique="rankingmode"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="20" weight="0.2"/>
<path orientation="vertical" number="20" weight="0.4"/>
</constraints>
<bounds x="0" y="0" width="0" height="0"/>
<frame state="0"/>
<active-tc id="RankingTopComponent" />
<empty-behavior permanent="false"/>
<kind type="view"/>
<state type="joined"/>
<constraints>
<path orientation="horizontal" number="10" weight="0.17"/>
<path orientation="vertical" number="40" weight="0.4"/>
</constraints>
<frame state="0"/>
<empty-behavior permanent="true"/>
</mode>
......@@ -16,9 +16,8 @@
<name>VisualizationImpl</name>
<properties>
<jogl.version>2.4.0-rc-20210111</jogl.version>
<jogl.version>v2.4.0-rc4</jogl.version>
<jogl.version.jogl.all>2.4.0-rc-20221118</jogl.version.jogl.all>
<jogl.version.natives.macos>2.4.0-rc4</jogl.version.natives.macos>
</properties>
<dependencies>
......@@ -86,6 +85,26 @@
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-ui</artifactId>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-dialogs</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>project-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>desktop-project</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>utils-longtask</artifactId>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-modules</artifactId>
</dependency>
<!-- Gluegen -->
<dependency>
<groupId>org.jogamp.gluegen</groupId>
......@@ -94,33 +113,28 @@
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<artifactId>gluegen-rt-natives-linux-amd64</artifactId>
<version>${jogl.version}</version>
<classifier>natives-linux-amd64</classifier>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<artifactId>gluegen-rt-natives-linux-i586</artifactId>
<version>${jogl.version}</version>
<classifier>natives-linux-i586</classifier>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<version>${jogl.version.natives.macos}</version>
<classifier>natives-macosx-universal</classifier>
<artifactId>gluegen-rt-natives-macosx-universal</artifactId>
<version>${jogl.version}</version>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<artifactId>gluegen-rt-natives-windows-amd64</artifactId>
<version>${jogl.version}</version>
<classifier>natives-windows-amd64</classifier>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<artifactId>gluegen-rt-natives-windows-i586</artifactId>
<version>${jogl.version}</version>
<classifier>natives-windows-i586</classifier>
</dependency>
<!-- JOGL -->
<dependency>
......@@ -130,53 +144,28 @@
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<artifactId>jogl-all-natives-linux-amd64</artifactId>
<version>${jogl.version}</version>
<classifier>natives-linux-amd64</classifier>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<artifactId>jogl-all-natives-linux-i586</artifactId>
<version>${jogl.version}</version>
<classifier>natives-linux-i586</classifier>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<version>${jogl.version.natives.macos}</version>
<classifier>natives-macosx-universal</classifier>
<artifactId>jogl-all-natives-macosx-universal</artifactId>
<version>${jogl.version}</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<artifactId>jogl-all-natives-windows-amd64</artifactId>
<version>${jogl.version}</version>
<classifier>natives-windows-amd64</classifier>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<artifactId>jogl-all-natives-windows-i586</artifactId>
<version>${jogl.version}</version>
<classifier>natives-windows-i586</classifier>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-dialogs</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>project-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>desktop-project</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>utils-longtask</artifactId>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-modules</artifactId>
</dependency>
</dependencies>
......@@ -215,4 +204,14 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jogl-jzy3d</id>
<name>JOGL Jzy3d</name>
<url>https://maven.jzy3d.org/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
......@@ -92,10 +92,14 @@ public interface GraphDrawable {
public void initConfig(GL2 gl);
public void initMouseEvents();
public GraphicalConfiguration getGraphicalConfiguration();
public void destroy();
public boolean isDestroyed();
public Point getLocationOnScreen();
public void reinitWindow();
......
......@@ -49,12 +49,10 @@ import java.awt.event.KeyEvent;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.gephi.project.api.ProjectController;
import org.gephi.project.api.Workspace;
import org.gephi.project.api.WorkspaceListener;
import org.gephi.tools.api.ToolController;
import org.gephi.ui.utils.UIUtils;
import org.gephi.visualization.VizController;
import org.gephi.visualization.apiimpl.GraphDrawable;
import org.gephi.visualization.opengl.AbstractEngine;
......@@ -63,6 +61,7 @@ import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
......@@ -94,36 +93,36 @@ public class GraphTopComponent extends TopComponent implements AWTEventListener
initComponents();
setName(NbBundle.getMessage(GraphTopComponent.class, "CTL_GraphTopComponent"));
// setToolTipText(NbBundle.getMessage(GraphTopComponent.class, "HINT_GraphTopComponent"));
//Request component activation and therefore initialize JOGL2 component
WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
if (!Utilities.isMac()) {
WindowManager.getDefault().invokeWhenUIReady(this::initDrawable);
}
initKeyEventContextMenuActionMappings();
}
private void initDrawable() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
open();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
//Init
initCollapsePanel();
initToolPanels();
drawable = VizController.getInstance().getDrawable();
engine = VizController.getInstance().getEngine();
requestActive();
add(drawable.getGraphComponent(), BorderLayout.CENTER);
remove(waitingLabel);
}
});
//Init
initCollapsePanel();
initToolPanels();
drawable = VizController.getInstance().getDrawable();
engine = VizController.getInstance().getEngine();
requestActive();
add(drawable.getGraphComponent(), BorderLayout.CENTER);
remove(waitingLabel);
drawable.initMouseEvents();
}
});
initKeyEventContextMenuActionMappings();
// add(drawable.getGraphComponent(), BorderLayout.CENTER);
// remove(waitingLabel);
}
private void initCollapsePanel() {
if (vizBarController != null) {
return;
}
vizBarController = new VizBarController();
if (VizController.getInstance().getVizConfig().isShowVizVar()) {
collapsePanel.init(vizBarController.getToolbar(), vizBarController.getExtendedBar(), false);
......@@ -150,6 +149,9 @@ public class GraphTopComponent extends TopComponent implements AWTEventListener
// }
private void initToolPanels() {
if (toolbar != null) {
return;
}
final ToolController tc = Lookup.getDefault().lookup(ToolController.class);
if (tc != null) {
if (VizController.getInstance().getVizConfig().isToolbar()) {
......@@ -308,4 +310,28 @@ public class GraphTopComponent extends TopComponent implements AWTEventListener
String version = p.getProperty("version");
// TODO read your settings according to their version
}
@Override
protected void componentClosed() {
super.componentClosed();
// On Mac we dispose the canvas to avoid haning issues
if (Utilities.isMac()) {
engine.stopDisplay();
drawable.destroy();
remove(drawable.getGraphComponent());
add(waitingLabel, BorderLayout.CENTER);
}
}
@Override
protected void componentOpened() {
super.componentOpened();
// On Mac we destroy and reinit the drawable here instead than once
// to address freeze issues within JOGL
if (Utilities.isMac()) {
initDrawable();
}
}
}
......@@ -110,6 +110,7 @@ public abstract class GLAbstractListener implements GLEventListener, VizArchitec
private boolean showGLLog = true;
private volatile boolean resizing = false;
private double aspectRatio = 0;
private boolean destroyed = false;
public GLAbstractListener() {
this.vizController = VizController.getInstance();
......@@ -129,9 +130,14 @@ public abstract class GLAbstractListener implements GLEventListener, VizArchitec
cameraLocation = vizController.getVizConfig().getDefaultCameraPosition();
cameraTarget = vizController.getVizConfig().getDefaultCameraTarget();
initMouseEvents();
}
@Override
public void initMouseEvents() {
//Mouse events
if (vizController.getVizConfig().isReduceFpsWhenMouseOut() ||
vizController.getVizConfig().isPauseLoopWhenMouseOut()) {
if (graphMouseAdapter == null && (vizController.getVizConfig().isReduceFpsWhenMouseOut() ||
vizController.getVizConfig().isPauseLoopWhenMouseOut())) {
graphMouseAdapter = new GraphMouseAdapter();
if (window != null) {
graphMouseAdapterNewt = new MouseAdapter() {
......@@ -179,6 +185,7 @@ public abstract class GLAbstractListener implements GLEventListener, VizArchitec
caps.setAlphaBits(8); //if NOT opaque
caps.setDoubleBuffered(true);
caps.setHardwareAccelerated(true);
caps.setOnscreen(true);
//FSAA
int antialisaing = vizController.getVizConfig().getAntialiasing();
......@@ -386,6 +393,7 @@ public abstract class GLAbstractListener implements GLEventListener, VizArchitec
@Override
public void destroy() {
destroyed = true;
if (graphMouseAdapterNewt != null) {
window.removeMouseListener(graphMouseAdapterNewt);
} else if (graphMouseAdapterCanvas != null) {
......@@ -395,6 +403,11 @@ public abstract class GLAbstractListener implements GLEventListener, VizArchitec
drawable.destroy();
}
@Override
public boolean isDestroyed() {
return destroyed;
}
public void renderTestCube(GL2 gl) {
float cubeSize = 1f;
......
......@@ -124,10 +124,4 @@ public class GraphCanvas extends GLAbstractListener {
}
}
}
@Override
public void destroy() {
super.destroy();
glCanvas.destroy();
}
}
......@@ -8,7 +8,7 @@ default_cachedir="${DEFAULT_CACHEDIR_ROOT}/${gephi.minor.version}"
# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="--branding ${branding.token} -J-Dsun.java2d.metal=true -J-Dsun.java2d.noddraw=true -J-Dsun.awt.noerasebackground=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dnetbeans.indexing.noFileRefresh=true -J-Dplugin.manager.check.interval=EVERY_DAY -J-Dapple.awt.application.appearance=system -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.base/java.nio=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED"
default_options="--branding ${branding.token} -J-Dsun.java2d.metal=true -J-Dsun.java2d.noddraw=true -J-Dsun.awt.noerasebackground=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dnetbeans.indexing.noFileRefresh=true -J-Dnetbeans.winsys.hideEmptyDocArea=true -J-Dplugin.manager.check.interval=EVERY_DAY -J-Dapple.awt.application.appearance=system -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.base/java.nio=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED"
# for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea
# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册