Feat: Don't do last render image request, use local image
This commit is contained in:
BIN
resources/frame_compute_method.jpg
Normal file
BIN
resources/frame_compute_method.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
BIN
resources/frame_power_detection.jpg
Normal file
BIN
resources/frame_power_detection.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
@@ -329,9 +329,6 @@ public class Client {
|
||||
gui.error("Client::run problem with confirmJob (returned " + ret + ")");
|
||||
sendError(step);
|
||||
}
|
||||
else {
|
||||
gui.AddFrameRendered();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.jobsToValidate.add(this.renderingJob);
|
||||
@@ -446,9 +443,6 @@ public class Client {
|
||||
this.log.debug("Client::senderLoop confirm failed, ret: " + ret);
|
||||
sendError(step);
|
||||
}
|
||||
else {
|
||||
gui.AddFrameRendered();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
}
|
||||
@@ -795,15 +789,17 @@ public class Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.isValidatingJob = false;
|
||||
this.previousJob = ajob;
|
||||
|
||||
gui.AddFrameRendered();
|
||||
|
||||
// we can remove the frame file
|
||||
File frame = new File(ajob.getOutputImagePath());
|
||||
frame.delete();
|
||||
ajob.setOutputImagePath(null);
|
||||
|
||||
this.isValidatingJob = false;
|
||||
this.previousJob = ajob;
|
||||
return Error.Type.OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -686,42 +686,6 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
||||
return ServerCode.UNKNOWN;
|
||||
}
|
||||
|
||||
public byte[] getLastRender() {
|
||||
try {
|
||||
HttpURLConnection httpCon = this.HTTPRequest(this.getPage("last-render-frame"));
|
||||
|
||||
InputStream inStrm = httpCon.getInputStream();
|
||||
if (httpCon.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
this.log.debug("Server::getLastRender code not ok " + httpCon.getResponseCode());
|
||||
return null;
|
||||
}
|
||||
int size = httpCon.getContentLength();
|
||||
|
||||
if (size <= 0) {
|
||||
this.log.debug("Server::getLastRender size is negative (size: " + size + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] ret = new byte[size];
|
||||
byte[] ch = new byte[512 * 1024];
|
||||
int n = 0;
|
||||
int i = 0;
|
||||
while ((n = inStrm.read(ch)) != -1) {
|
||||
System.arraycopy(ch, 0, ret, i, n);
|
||||
i += n;
|
||||
}
|
||||
inStrm.close();
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
this.log.debug("Server::getLastRender Exception " + e + " stacktrace: " + sw.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String generateXMLForMD5cache() {
|
||||
List<FileMD5> md5s = new ArrayList<>();
|
||||
for (File local_file : this.user_config.getLocalCacheFiles()) {
|
||||
|
||||
@@ -27,9 +27,9 @@ import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -46,11 +46,8 @@ import javax.swing.SpringLayout;
|
||||
|
||||
import com.sheepit.client.Client;
|
||||
import com.sheepit.client.Job;
|
||||
import com.sheepit.client.RenderProcess;
|
||||
import com.sheepit.client.Server;
|
||||
import com.sheepit.client.Stats;
|
||||
import com.sheepit.client.Utils;
|
||||
import com.sheepit.client.os.OS;
|
||||
import com.sheepit.client.standalone.GuiSwing;
|
||||
import com.sheepit.client.standalone.GuiSwing.ActivityType;
|
||||
|
||||
@@ -307,28 +304,44 @@ public class Working implements Activity {
|
||||
Client client = parent.getClient();
|
||||
if (client != null) {
|
||||
Job lastJob = client.getPreviousJob();
|
||||
Server server = client.getServer();
|
||||
if (server != null) {
|
||||
byte[] data = server.getLastRender();
|
||||
if (data != null) {
|
||||
InputStream is = new ByteArrayInputStream(data);
|
||||
try {
|
||||
BufferedImage image = ImageIO.read(is);
|
||||
if (image != null) {
|
||||
lastRender.setIcon(new ImageIcon(image));
|
||||
if (lastJob != null) {
|
||||
// don't use lastJob.getProcessRender().getDuration() due to timezone
|
||||
if (lastJob.getProcessRender().getDuration() > 1) {
|
||||
lastRenderTime.setText("Render time : " + Utils.humanDuration(new Date(lastJob.getProcessRender().getEndTime() - lastJob.getProcessRender().getStartTime())));
|
||||
ImageIcon icon = null;
|
||||
int idInt = Integer.parseInt(lastJob.getId());
|
||||
if (idInt == 1) {
|
||||
icon = new ImageIcon(getClass().getResource("/frame_compute_method.jpg"));
|
||||
}
|
||||
else if (idInt < 20) {
|
||||
icon = new ImageIcon(getClass().getResource("/frame_power_detection.jpg"));
|
||||
}
|
||||
else {
|
||||
try {
|
||||
String path = lastJob.getOutputImagePath();
|
||||
|
||||
BufferedImage img = ImageIO.read(new File(path));
|
||||
float width = img.getWidth();
|
||||
float height = img.getHeight();
|
||||
float factor = 1.0f;
|
||||
if (height > 200) {
|
||||
factor = 200f / height;
|
||||
}
|
||||
if (width * factor > 200) {
|
||||
factor = Math.min(factor, 200f / width);
|
||||
}
|
||||
icon = new ImageIcon(img.getScaledInstance((int)(width * factor), (int)(height * factor), Image.SCALE_FAST));
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.println("Working::showLastRender() exception " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (icon != null) {
|
||||
lastRender.setIcon(icon);
|
||||
// don't use lastJob.getProcessRender().getDuration() due to timezone
|
||||
if (lastJob.getProcessRender().getDuration() > 1) {
|
||||
lastRenderTime.setText("Render time : " + Utils.humanDuration(new Date(lastJob.getProcessRender().getEndTime() - lastJob.getProcessRender().getStartTime())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user