make export to applet/application more efficient (issue #747), plus auto-import for P3D

This commit is contained in:
benfry
2011-06-23 19:34:01 +00:00
parent da978de108
commit bd1451d019
6 changed files with 71 additions and 78 deletions
+8 -1
View File
@@ -4,12 +4,19 @@
<property environment="env" />
<!-- oh ant, you're so cute and convoluted -->
<target name="build" depends="sdk_chatter,actual_build" />
<target name="build" depends="sdk_chatter,sdk_whining,actual_build" />
<target name="sdk_chatter" unless="env.ANDROID_SDK">
<echo message="ANDROID_SDK not set, skipping build of android-core.zip" />
</target>
<target name="sdk_whining">
<available file="${env.ANDROID_SDK}/platforms/android-7/android.jar"
property="andoid-jar-present" />
<fail unless="andoid-jar-present"
message="Android SDK 7 could not be found in ${env.ANDROID_SDK}/platforms/android-7/android.jar" />
</target>
<target name="actual_build" if="env.ANDROID_SDK">
<mkdir dir="bin" />
<javac target="1.5"
+2
View File
@@ -11,6 +11,8 @@ X remove A2D and A3D constants
o colorMode() error
o http://code.google.com/p/processing/issues/detail?id=223
_ /opt/android using version #s again? fix build script
_ tries to create and AVD when running on the phone.. why?
_ this is a real problem, causes lots of crashing on startup
_ add INTERNET permissions to the android net examples
+22 -57
View File
@@ -249,6 +249,21 @@ public class JavaBuild {
}
}
// Automatically insert the OpenGL import line if P3D is used. Do this by
// modifying the code here instead of
String scrubbed = scrubComments(sketch.getCode(0).getProgram());
String[] matches = PApplet.match(scrubbed, SIZE_REGEX);
String renderer = "";
if (matches != null) {
// Adding back the trim() for 0136 to handle Bug #769
if (matches.length == 4) renderer = matches[3].trim();
// Actually, matches.length should always be 4...
}
// OpenGL import time! Really, this is for P3D, but may as well do it
// for OpenGL as well.
if (renderer.equals("P3D") || renderer.equals("OPENGL")) {
bigCode.insert(0, "import processing.opengl.*; ");
}
PreprocessorResult result;
try {
@@ -335,7 +350,7 @@ public class JavaBuild {
// TODO not tested since removing ORO matcher.. ^ could be a problem
String mess = "^line (\\d+):(\\d+):\\s";
String[] matches = PApplet.match(tsre.toString(), mess);
matches = PApplet.match(tsre.toString(), mess);
if (matches != null) {
int errorLine = Integer.parseInt(matches[1]) - 1;
int errorColumn = Integer.parseInt(matches[2]);
@@ -876,26 +891,6 @@ public class JavaBuild {
}
}
// if (dataFolder.exists()) {
// String dataFiles[] = Base.listFiles(dataFolder, false);
// int offset = folder.getAbsolutePath().length() + 1;
// for (int i = 0; i < dataFiles.length; i++) {
// if (Base.isWindows()) {
// dataFiles[i] = dataFiles[i].replace('\\', '/');
// }
// File dataFile = new File(dataFiles[i]);
// if (dataFile.isDirectory()) continue;
//
// // don't export hidden files
// // skipping dot prefix removes all: . .. .DS_Store
// if (dataFile.getName().charAt(0) == '.') continue;
//
// entry = new ZipEntry(dataFiles[i].substring(offset));
// zos.putNextEntry(entry);
// zos.write(Base.loadBytesRaw(dataFile));
// zos.closeEntry();
// }
// }
// Add the data folder to the output .jar file
addDataFolder(zos);
@@ -904,41 +899,8 @@ public class JavaBuild {
// since there may be some inner classes
// (add any .class files from the applet dir, then delete them)
// TODO this needs to be recursive (for packages)
// String classfiles[] = appletFolder.list();
// for (int i = 0; i < classfiles.length; i++) {
// if (classfiles[i].endsWith(".class")) {
// entry = new ZipEntry(classfiles[i]);
// zos.putNextEntry(entry);
// zos.write(Base.loadBytesRaw(new File(appletFolder, classfiles[i])));
// zos.closeEntry();
// }
// }
addClasses(zos, binFolder);
// remove the .class files from the applet folder. if they're not
// removed, the msjvm will complain about an illegal access error,
// since the classes are outside the jar file.
// for (int i = 0; i < classfiles.length; i++) {
// if (classfiles[i].endsWith(".class")) {
// File deadguy = new File(appletFolder, classfiles[i]);
// if (!deadguy.delete()) {
// Base.showWarning("Could not delete",
// classfiles[i] + " could not \n" +
// "be deleted from the applet folder. \n" +
// "You'll need to remove it by hand.", null);
// }
// }
// }
// if (false) {
// if (!srcFolder.delete() || !binFolder.delete()) {
// Base.showWarning("Could not delete",
// buildFolder.getName() + " could not \n" +
// "be deleted from the applet folder. \n" +
// "You'll need to remove it by hand.", null);
// }
// }
// close up the jar file
zos.flush();
zos.close();
@@ -1511,7 +1473,8 @@ public class JavaBuild {
// System.out.println(" adding item " + relativePath);
ZipEntry entry = new ZipEntry(relativePath);
zos.putNextEntry(entry);
zos.write(Base.loadBytesRaw(sub));
//zos.write(Base.loadBytesRaw(sub));
PApplet.saveStream(zos, new FileInputStream(sub));
zos.closeEntry();
}
}
@@ -1534,7 +1497,8 @@ public class JavaBuild {
if (dataFile.getName().charAt(0) != '.') {
ZipEntry entry = new ZipEntry(path.substring(offset));
zos.putNextEntry(entry);
zos.write(Base.loadBytesRaw(dataFile));
//zos.write(Base.loadBytesRaw(dataFile));
PApplet.saveStream(zos, new FileInputStream(dataFile));
zos.closeEntry();
}
}
@@ -1640,7 +1604,8 @@ public class JavaBuild {
files[i].charAt(0) != '.') {
ZipEntry entry = new ZipEntry(nowfar);
zos.putNextEntry(entry);
zos.write(Base.loadBytesRaw(sub));
//zos.write(Base.loadBytesRaw(sub));
PApplet.saveStream(zos, new FileInputStream(sub));
zos.closeEntry();
}
}
+19 -13
View File
@@ -5033,20 +5033,11 @@ public class PApplet extends Applet
// make sure that this path actually exists before writing
createPath(targetFile);
tempFile = File.createTempFile(targetFile.getName(), null, parentDir);
FileOutputStream targetStream = new FileOutputStream(tempFile);
BufferedInputStream bis = new BufferedInputStream(sourceStream, 16384);
FileOutputStream fos = new FileOutputStream(tempFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = bis.read(buffer)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.flush();
bos.close();
bos = null;
saveStream(targetStream, sourceStream);
targetStream.close();
targetStream = null;
if (targetFile.exists()) {
if (!targetFile.delete()) {
@@ -5069,6 +5060,21 @@ public class PApplet extends Applet
return false;
}
}
static public void saveStream(OutputStream targetStream,
InputStream sourceStream) throws IOException {
BufferedInputStream bis = new BufferedInputStream(sourceStream, 16384);
BufferedOutputStream bos = new BufferedOutputStream(targetStream);
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = bis.read(buffer)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.flush();
}
/**
+7 -1
View File
@@ -344,8 +344,9 @@ X nobody felt strongly enough about getShape()
X so better to not change (and start breaking things)
xml changes
o see if write() is necessary inside PNodeXML
X see if write() is necessary inside PNodeXML
o it needs a proper header on it, so maybe that's the difference w/ toString()
X verified that toString() also writes a header
o inefficient: the way new nodes are created
o also inefficient: adding/removing kids just nukes the children array
X toString() adds the XML header
@@ -363,6 +364,8 @@ X http://code.google.com/p/processing/issues/detail?id=440
X PNode is final(?) name, get that implemented
andres
_ beginRaw() not working with 3D
_ http://code.google.com/p/processing/issues/detail?id=744
_ OpenGL noSmooth() problems
_ http://code.google.com/p/processing/issues/detail?id=328
_ inconsistent anti-aliasing with OpenGL
@@ -454,6 +457,7 @@ _ add docs for screenWidth and screenHeight
_ remove delay() documentation
2.0
_ enable smooth() by default
_ Abnormal high Java CPU usage at empty sketch with draw()
_ http://code.google.com/p/processing/issues/detail?id=729
_ https://forum.processing.org/topic/absurd-java-cpu-usage-at-empty-sketch-with-draw
@@ -515,6 +519,8 @@ _ -> resize() is fine with PImage and PGraphics...
_ we may be inheriting the resize() from Java -> make it final?
_ if PShape3D, then is it PShape2D? or do you handle both the same?
_ svg fonts
_ would be nifty if we could convert on the fly to ttf for speed...
_ http://code.google.com/p/processing/issues/detail?id=748
_ check on DXFWriter, since it used to subclass P3D
_ at least implement is3D?
_ Potential race condition when resizing sketches
+13 -6
View File
@@ -25,6 +25,11 @@ X make sketch.properties usable elsewhere by loading/reloading
X http://code.google.com/p/processing/issues/detail?id=722
X Export to Application reports "Could not copy source file:"
X http://code.google.com/p/processing/issues/detail?id=638
X automatically insert the 'import processing.opengl' when P3D used
X add support for automatically including OpenGL when asking for P3D
X when using P3D and not realizing that it's really OpenGL...
X Export Application Fails When Large File in Data Folder
X http://code.google.com/p/processing/issues/detail?id=747
cleanup
X how is autoformat doing? good now
@@ -48,6 +53,13 @@ X -> everyone thinks this is funny
_ update the build instructions page
_ http://code.google.com/p/processing/wiki/BuildInstructions
_ switch to a non-modified version of the launcher exe
_ move the launcher to jsmooth or something like that?
_ is there a better way to handle the data folder for apps?
_ rather than adding it to the main zip file?
_ otherwise ppl are copying really large files into a jar...
decisions
_ kill external editor (for all its quirks) in favor of command line?
_ use external editor needs to enable/disable across all windows
@@ -57,10 +69,7 @@ _ does editor.bgcolor live in the theme.txt file for the mode?
_ or should it be a user preference thing
_ for that matter, need to decide on how much modes can customize themselves
required for 0198 release
_ automatically insert the 'import processing.opengl' when P3D used
_ add support for automatically including OpenGL when asking for P3D
_ when using P3D and not realizing that it's really OpenGL...
_ how to catch these?
Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: Could not initialize class javax.media.opengl.GLProfile
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
@@ -72,7 +81,6 @@ _ http://code.google.com/p/processing/issues/detail?id=688
_ write quicktime uncompressed (w/o qtjava)
_ http://www.randelshofer.ch/blog/2010/10/writing-quicktime-movies-in-pure-java/
pnode: look more closely at json and xml compatibility
frequent requests/projects
@@ -149,7 +157,6 @@ gsoc
_ "install library" menu option
_ see how library installation goes, then possibly do same w/ examples
3.0
_ better text editor / live debugging (integrate Eclipse JDT)
_ line numbers