Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
强制终止/SuperSpine
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloento committed Mar 25, 2021
1 parent 7ee668b commit f8a3e68
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.QYun.SuperSpineViewer.Controller;

import com.QYun.Spine.SuperSpine;
import com.QYun.SuperSpineViewer.Loader;
import com.QYun.SuperSpineViewer.Main;
import com.QYun.SuperSpineViewer.RecordFX;
Expand All @@ -19,9 +18,6 @@
import java.util.ResourceBundle;

public class Exporter extends Main implements Initializable {
private final SuperSpine spine = new SuperSpine();
private final RecordFX record = new RecordFX();

@FXML
private Label L_Version;
@FXML
Expand All @@ -44,7 +40,7 @@ void B_Export() {
spine.setSpeed(quality);
spine.setIsPlay(true);
System.out.println("请求:开始录制");
record.startRecording(spine.getProjectName() + "_" + spine.getAnimate());
recordFX.Start(spine.getProjectName() + "_" + spine.getAnimate());
}
}

Expand Down Expand Up @@ -141,9 +137,9 @@ public void initialize(URL location, ResourceBundle resources) {
FPS = L_FPS;
Skel = L_Skel;
Atlas = L_Atlas;
recordFX = record;
progressBar = P_Export;
T_Path.setText(outPath);
recordFX = new RecordFX();
spine.spineVersionProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> L_Version.setText("Version : " + newValue)));

System.out.println("SuperSpineViewer已启动");
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/QYun/SuperSpineViewer/Controller/Spine.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.QYun.SuperSpineViewer.Controller;

import com.QYun.Spine.SuperSpine;
import com.QYun.Spine.Universal;
import com.QYun.SuperSpineViewer.Loader;
import com.QYun.SuperSpineViewer.Main;
Expand Down Expand Up @@ -67,7 +66,6 @@ public class Spine extends Main implements Initializable {

@Override
public void initialize(URL location, ResourceBundle resources) {
SuperSpine spine = new SuperSpine();
ImageView spineLogo = new ImageView();
spineLogo.setImage(new Image("/UI/SpineLogo.png", 138, 0, true, true, false));

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/QYun/SuperSpineViewer/Loader.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.QYun.SuperSpineViewer;

import com.QYun.Spine.SuperSpine;
import com.QYun.Spine.Universal;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl.LwjglFXApplication;
Expand All @@ -19,7 +18,6 @@ public class Loader extends Main {
private final String[] dataSuffixes = {".json", ".skel"};
private final String[] endSuffixes = {"", ".txt", ".bytes"};
private final String[] atlasSuffixes = {".atlas", "-pma.atlas"};
private final SuperSpine spine = new SuperSpine();
private final Universal universal = new Universal();

private void whichVersion(String skel) {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/QYun/SuperSpineViewer/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.QYun.SuperSpineViewer;

import com.QYun.Spine.SuperSpine;
import com.QYun.SuperSpineViewer.Controller.Launcher;
import com.QYun.SuperSpineViewer.Controller.Spine;
import com.jfoenix.controls.JFXProgressBar;
Expand All @@ -11,6 +12,8 @@
import java.util.prefs.Preferences;

public class Main {
public static final SuperSpine spine = new SuperSpine();
public static final Preferences Pref = Preferences.userRoot().node("/com/QYun/SuperSpineViewer");
public static RecordFX recordFX;
public static Spine spineController;
public static JFXProgressBar progressBar;
Expand All @@ -21,13 +24,12 @@ public class Main {
public static int width;
public static int height;
public static byte perform = 6;
public static byte sequence = 0;
public static byte sequence;
public static float quality = 0.5f;
public static boolean isLoad = false;
public static boolean preA = true;
public static boolean recording = false;
public static String openPath = null;
public static Preferences Pref = Preferences.userRoot().node("/com/QYun/SuperSpineViewer");
public static String openPath;
public static String outPath = Pref.get("lastSave", System.getProperty("user.home"));

public static void main(String[] args) {
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/com/QYun/SuperSpineViewer/RecordFX.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.QYun.SuperSpineViewer;

import com.QYun.Spine.SuperSpine;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.PixmapIO;
Expand All @@ -26,7 +25,6 @@ public class RecordFX extends Main {
})) {{
allowCoreThreadTimeOut(true);
}};
private final SuperSpine spine = new SuperSpine();
private String fileName = null;
private short counter;
private short items;
Expand All @@ -43,7 +41,7 @@ public void recorderFX(WritableImage image) {
}
}

public void startRecording(String fileName) {
public void Start(String fileName) {
if (!recording) {
while (spine.getPercent() == 2)
Thread.onSpinWait();
Expand All @@ -54,6 +52,19 @@ public void startRecording(String fileName) {
}
}

public void Exit() {
recording = false;
savePool.shutdownNow();
savePool.setCorePoolSize(0);
savePool.setMaximumPoolSize(1);
spine.setSpeed(1);
spine.setIsPlay(false);
counter = 0;
items = 0;
System.out.println("强制停止");
System.gc();
}

private void ffmpegFX() {
try {
System.out.println("FFmpeg处理开始");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public void process(final int width, final int height, final ByteBuffer data, fi
recordFX.recorderFX(new WritableImage(width, height) {{
getPixelWriter().setPixels(0, 0, width, height, javafx.scene.image.PixelFormat.getByteBgraPreInstance(), data, stride);
}});
} catch (OutOfMemoryError ignored) {
recordFX.Exit();
System.out.println("内存不足,导出终止");
} finally {
// Notify the render thread that we're done processing
signal.release();
Expand Down

0 comments on commit f8a3e68

Please sign in to comment.