[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob ./Makefile include/vob/jni/Types.hxx inc...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob ./Makefile include/vob/jni/Types.hxx inc... |
Date: |
Mon, 16 Jun 2003 12:16:30 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/06/16 12:16:30
Modified files:
. : Makefile
include/vob/jni: Types.hxx
include/vob/vobs: Paper.hxx
org/nongnu/libvob/gl: GL.java MipzipLoader.java
MipzipMemoryConsumer.java
org/nongnu/libvob/memory: MemoryConsumer.java
src/jni : Main.cxx Makefile TexAccum.cxx vobjnidef.hxx
test/vob/gl : texaccum.test
Added files:
include/vob/stats: TexAccum.hxx
src/stats : Makefile Stats.cxx TexAccum.cxx
Removed files:
include/vob/lod: TexPoly.hxx
src/lod : Makefile TexPoly.cxx
Log message:
Pushing statistics to Java side via weakref callbacks
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/Makefile.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Types.hxx.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/stats/TexAccum.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Paper.hxx.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/MipzipLoader.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/MipzipMemoryConsumer.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/memory/MemoryConsumer.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Main.cxx.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Makefile.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/TexAccum.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/vobjnidef.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/stats/Makefile?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/stats/Stats.cxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/stats/TexAccum.cxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/vob/gl/texaccum.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: libvob/Makefile
diff -u libvob/Makefile:1.41 libvob/Makefile:1.42
--- libvob/Makefile:1.41 Fri Jun 13 08:01:01 2003
+++ libvob/Makefile Mon Jun 16 12:16:29 2003
@@ -1,6 +1,6 @@
include rules.mk
-SUBDIRS = src/trans src/util src/texture src/paper src/lines src/os src/main
src/geom src/lod
+SUBDIRS = src/trans src/util src/texture src/paper src/lines src/os src/main
src/geom src/stats
# ctest off for now
RAWSRC = `find org/ -name "*.java"`
Index: libvob/include/vob/jni/Types.hxx
diff -u libvob/include/vob/jni/Types.hxx:1.24
libvob/include/vob/jni/Types.hxx:1.25
--- libvob/include/vob/jni/Types.hxx:1.24 Mon Jun 9 11:04:36 2003
+++ libvob/include/vob/jni/Types.hxx Mon Jun 16 12:16:29 2003
@@ -39,7 +39,7 @@
#include <vob/jni/Strings.hxx>
#include <vob/paper/Paper.hxx>
#include <vob/util/ImageLoader.hxx>
-#include <vob/lod/TexPoly.hxx>
+#include <vob/jni/Stats.hxx>
@@ -74,7 +74,7 @@
extern ObjectStorer<ImageLoader::RGBARaster> images;
- extern ObjectStorer<LOD::TexAccum> texaccums;
+ extern ObjectStorer<TexAccum_JNI> texaccums;
typedef ::Vob::Paper::Paper P; // g++3.2 doesn't like ::... inside
@@ -236,7 +236,7 @@
out = vobNs[in];
END_VOB_JNI_CONVERSION
- START_VOB_JNI_CONVERSION_IDDED(LOD::TexAccum *,
+ START_VOB_JNI_CONVERSION_IDDED(Stats::TexAccum *,
"GL.TexAccum")
out = texaccums.get_allowNull(in);
END_VOB_JNI_CONVERSION
Index: libvob/include/vob/vobs/Paper.hxx
diff -u libvob/include/vob/vobs/Paper.hxx:1.12
libvob/include/vob/vobs/Paper.hxx:1.13
--- libvob/include/vob/vobs/Paper.hxx:1.12 Wed Jun 11 13:41:56 2003
+++ libvob/include/vob/vobs/Paper.hxx Mon Jun 16 12:16:30 2003
@@ -124,7 +124,7 @@
return ret;
}
-inline void addToAccum(LOD::TexAccum *acc, Verts &v,
+inline void addToAccum(Stats::TexAccum *acc, Verts &v,
int v0, int v1, int v2) {
acc->add(
v.points[v0].final,
@@ -222,7 +222,7 @@
float diceLength, diceLength2;
int diceDepth;
- LOD::TexAccum *texAccum;
+ Stats::TexAccum *texAccum;
template<class F> void params(F &f) {
f(paper, x0, y0, x1, y1, flags, diceLength, diceLength2, diceDepth,
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.16
libvob/org/nongnu/libvob/gl/GL.java:1.17
--- libvob/org/nongnu/libvob/gl/GL.java:1.16 Mon Jun 9 11:04:36 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Mon Jun 16 12:16:30 2003
@@ -824,12 +824,44 @@
static public TexAccum createTexAccum() {
return new TexAccum(impl_TexAccum_create());
}
+ static public TexAccum createTexAccum(StatsCallback cb, Object clos) {
+ return new TexAccum(impl_TexAccum_create_cb(
+ new WeakStatsCaller(cb, clos)
+ ));
+ }
static private native int impl_TexAccum_create();
+ static private native int impl_TexAccum_create_cb(Object obj);
static private native void impl_TexAccum_delete(int id);
static private native double impl_TexAccum_get(int id, int mip);
static private native void impl_TexAccum_clear(int id);
+ static public native void callQueuedStatistics();
+ static public native void clearQueuedStatistics();
+// --------------------- WeakStatsCaller
+ /** The class that handles StatsCallbacks using weak references.
+ */
+ static protected class WeakStatsCaller {
+ java.lang.ref.WeakReference obj;
+ java.lang.ref.WeakReference clos;
+ public WeakStatsCaller(StatsCallback obj, Object clos) {
+ this.obj = new java.lang.ref.WeakReference(obj);
+ this.clos = new java.lang.ref.WeakReference(clos);
+ }
+ public void call() {
+ StatsCallback cb = (StatsCallback) obj.get();
+ if(cb == null) return;
+ cb.call(clos.get());
+ }
+ }
+
+// ---------------------- StatsCallback
+ /** An object to be called when statistics have been
+ * added to a statistics-collecting class, e.g.TexAccum.
+ */
+ public interface StatsCallback {
+ void call(Object clos);
+ }
//----------Misc
Index: libvob/org/nongnu/libvob/gl/MipzipLoader.java
diff -u libvob/org/nongnu/libvob/gl/MipzipLoader.java:1.2
libvob/org/nongnu/libvob/gl/MipzipLoader.java:1.3
--- libvob/org/nongnu/libvob/gl/MipzipLoader.java:1.2 Tue Apr 22 21:27:48 2003
+++ libvob/org/nongnu/libvob/gl/MipzipLoader.java Mon Jun 16 12:16:30 2003
@@ -88,6 +88,8 @@
private final Level[] levels;
+ /** The size of the original image embedded in the mipzip file, in texture
coordinates.
+ */
public final float origWidth, origHeight;
/** Open (if not already open) and return the ZipFile.
Index: libvob/org/nongnu/libvob/gl/MipzipMemoryConsumer.java
diff -u libvob/org/nongnu/libvob/gl/MipzipMemoryConsumer.java:1.1
libvob/org/nongnu/libvob/gl/MipzipMemoryConsumer.java:1.2
--- libvob/org/nongnu/libvob/gl/MipzipMemoryConsumer.java:1.1 Wed Mar 26
13:13:25 2003
+++ libvob/org/nongnu/libvob/gl/MipzipMemoryConsumer.java Mon Jun 16
12:16:30 2003
@@ -40,8 +40,6 @@
MemoryPartitioner pool;
MipzipLoader mipzip;
- public boolean getScalable() { return true; }
-
public int getMaxBytes(float quality) {
int mb = mipzip.getMemory(
mipzip.getLevelForQuality(quality));
Index: libvob/org/nongnu/libvob/memory/MemoryConsumer.java
diff -u libvob/org/nongnu/libvob/memory/MemoryConsumer.java:1.1
libvob/org/nongnu/libvob/memory/MemoryConsumer.java:1.2
--- libvob/org/nongnu/libvob/memory/MemoryConsumer.java:1.1 Wed Mar 26
13:13:25 2003
+++ libvob/org/nongnu/libvob/memory/MemoryConsumer.java Mon Jun 16 12:16:30 2003
@@ -41,14 +41,11 @@
* <li> May be interpolated: a quality between any two qualities that have been
* given to the MemoryPartitioner API may be given.
* </ul>
- * an example of quality would be DPI (dots per inch) for images.
+ * an example of quality would be DPI (dots per inch) for images, or a mipmap
level index
+ * starting from 0 = (1x1).
+ * (i.e. log(DPI)) .
*/
public interface MemoryConsumer {
- /** Whether this object can make use of byte amounts less
- * than getMaxBytes() returns.
- * For example, images can be scaled down but text cannot.
- */
- boolean getScalable();
/** The maximum number of bytes this object would like to consume.
* @param quality The quality at which the maximum bytes are requested.
*/
Index: libvob/src/jni/Main.cxx
diff -u libvob/src/jni/Main.cxx:1.16 libvob/src/jni/Main.cxx:1.17
--- libvob/src/jni/Main.cxx:1.16 Wed Jun 4 01:00:14 2003
+++ libvob/src/jni/Main.cxx Mon Jun 16 12:16:30 2003
@@ -96,8 +96,6 @@
}
-/** If an exception occurred, print a debug message for it and clear it.
-*/
void javaExc(JNIEnv *env, const char *where) {
if(env->ExceptionOccurred()) {
cerr << "Exception in "<<where<<"\n";
Index: libvob/src/jni/Makefile
diff -u libvob/src/jni/Makefile:1.31 libvob/src/jni/Makefile:1.32
--- libvob/src/jni/Makefile:1.31 Mon Jun 9 11:04:36 2003
+++ libvob/src/jni/Makefile Mon Jun 16 12:16:30 2003
@@ -20,7 +20,7 @@
TEXTUREOBJS=../texture/Texture.o ../texture/Texture_pipetexture.o
UTILOBJS=../util/Perlin.o ../util/buildmipmaps.o ../util/Debug.o
../util/ImageLoader.o ../util/intersect.o
GEOMOBJS=../geom/Quadrics.o
-LODOBJS=../lod/TexPoly.o
+STATSOBJS=../stats/TexAccum.o ../stats/Stats.o
TRANSOBJS=../trans/Transform.o ../trans/Coorder.o
@@ -28,7 +28,7 @@
OBJS= $(sources:%.cxx=%.o)
-JNIOBJS=$(OBJS) $(VOB_OBJS) $(TRANS_OBJS) $(OSOBJS) $(TEXTUREOBJS) $(UTILOBJS)
$(CALLGLOBJS) $(TRANSOBJS) $(MAINOBJS) $(GLMOSAICTEXTOBJS) $(PAPEROBJS)
$(LINESOBJ) $(GEOMOBJS) $(LODOBJS)
+JNIOBJS=$(OBJS) $(VOB_OBJS) $(TRANS_OBJS) $(OSOBJS) $(TEXTUREOBJS) $(UTILOBJS)
$(CALLGLOBJS) $(TRANSOBJS) $(MAINOBJS) $(GLMOSAICTEXTOBJS) $(PAPEROBJS)
$(LINESOBJ) $(GEOMOBJS) $(STATSOBJS)
EXTRAINCLUDE=-I${JAVAHOME}/include -I${JAVAHOME}/include/linux
-I${JAVAHOME}/include/kaffe
Index: libvob/src/jni/TexAccum.cxx
diff -u libvob/src/jni/TexAccum.cxx:1.1 libvob/src/jni/TexAccum.cxx:1.2
--- libvob/src/jni/TexAccum.cxx:1.1 Mon Jun 9 11:04:36 2003
+++ libvob/src/jni/TexAccum.cxx Mon Jun 16 12:16:30 2003
@@ -38,7 +38,9 @@
#include <vob/util/ObjectStorer.hxx>
#include <vob/paper/Paper.hxx>
-#include <vob/lod/TexPoly.hxx>
+#include <vob/stats/TexAccum.hxx>
+
+#include <vob/jni/Types.hxx>
#include "org_nongnu_libvob_gl_GL.h"
#include "vobjnidef.hxx"
@@ -47,33 +49,84 @@
namespace Vob {
namespace JNI {
-ObjectStorer<LOD::TexAccum> texaccums("texaccums");
+Stats::Statistics statistics;
+
+ObjectStorer<TexAccum_JNI> texaccums("texaccums");
+
+jclass globalclass_WeakStatsCaller = 0;
+jmethodID WSC_call = 0;
+
+TexAccum_JNI::TexAccum_JNI(JNIEnv *env,
+ Stats::Statistics *stats, jobject cb) :
+ Stats::TexAccum(stats) {
+ if(cb)
+ cb = env->NewGlobalRef(cb);
+ this->callback = cb;
+}
+TexAccum_JNI::~TexAccum_JNI() {
+}
+void TexAccum_JNI::prepareToDelete(JNIEnv *env) {
+ if(callback) {
+ env->DeleteGlobalRef(callback);
+ callback = 0;
+ }
+}
+void TexAccum_JNI::call(void *u) {
+ if(callback) {
+ JNIEnv *env = (JNIEnv *)u;
+ env->CallVoidMethod(callback, WSC_call);
+ javaExc(env, "StatsCallback");
+ }
+}
extern "C" {
jf( jint, impl_1TexAccum_1create )
(JNIEnv *env, jclass) {
- LOD::TexAccum *accum = new LOD::TexAccum();
+ TexAccum_JNI *accum = new TexAccum_JNI(env, &statistics, 0);
+ return texaccums.add(accum);
+}
+
+jf( jint, impl_1TexAccum_1create_1cb )
+ (JNIEnv *env, jclass, jobject cb) {
+ TexAccum_JNI *accum = new TexAccum_JNI(env, &statistics, cb);
+ if(!globalclass_WeakStatsCaller) {
+ globalclass_WeakStatsCaller =
+ (jclass)(env->NewGlobalRef(env->GetObjectClass(cb)));
+ WSC_call = env->GetMethodID(globalclass_WeakStatsCaller,
+ "call", "()V");
+ }
return texaccums.add(accum);
}
jf( void, impl_1TexAccum_1delete )
(JNIEnv *env, jclass, jint id) {
+ TexAccum_JNI *accum = texaccums.get(id);
+ accum->prepareToDelete(env);
texaccums.remove(id);
}
jf( void, impl_1TexAccum_1clear )
(JNIEnv *env, jclass, jint id) {
- LOD::TexAccum *accum = texaccums.get(id);
+ Stats::TexAccum *accum = texaccums.get(id);
accum->clear();
}
jf( jdouble, impl_1TexAccum_1get )
(JNIEnv *env, jclass, jint id, jint mip) {
- LOD::TexAccum *accum = texaccums.get(id);
- if(mip < 0 || mip >= LOD::TexAccum::NLEVELS)
+ Stats::TexAccum *accum = texaccums.get(id);
+ if(mip < 0 || mip >= Stats::TexAccum::NLEVELS)
return -1;
return accum->pixels[mip];
+}
+
+jf( void, callQueuedStatistics )
+ (JNIEnv *env, jclass) {
+ statistics.call(env);
+}
+jf( void, clearQueuedStatistics )
+ (JNIEnv *env, jclass) {
+ statistics.clear();
}
}
Index: libvob/src/jni/vobjnidef.hxx
diff -u libvob/src/jni/vobjnidef.hxx:1.3 libvob/src/jni/vobjnidef.hxx:1.4
--- libvob/src/jni/vobjnidef.hxx:1.3 Wed Jun 11 13:41:56 2003
+++ libvob/src/jni/vobjnidef.hxx Mon Jun 16 12:16:30 2003
@@ -38,5 +38,9 @@
extern void releaseWindow() ;
extern ObjectStorer<Os::RenderingSurface> windows;
+/** If an exception occurred, print a debug message for it and clear it.
+*/
+void javaExc(JNIEnv *env, const char *where) ;
+
}
}
Index: libvob/test/vob/gl/texaccum.test
diff -u libvob/test/vob/gl/texaccum.test:1.2
libvob/test/vob/gl/texaccum.test:1.3
--- libvob/test/vob/gl/texaccum.test:1.2 Wed Jun 11 13:41:56 2003
+++ libvob/test/vob/gl/texaccum.test Mon Jun 16 12:16:30 2003
@@ -86,3 +86,45 @@
assert l[8] != 0
assert l[7] == 0
assert l[11] == 0
+
+class CB(vob.gl.GL.StatsCallback):
+ def __init__(self):
+ self.list = []
+ def call(self, o):
+ self.list.append(o)
+
+def testCallback():
+ vs = getvs()
+ vs.map.put(vob.vobs.SolidBackdropVob(Color.black))
+
+ paper = vob.gl.SpecialPapers.cgraphPaper(1)
+
+ cb = CB()
+ accum = vob.gl.GL.createTexAccum(cb, "1")
+ assert len(cb.list) == 0
+
+ quad = vob.gl.GLRen.createFixedPaperQuad(paper,
+ 0, 0, 1, 1, 0, 1, 1, 10, accum)
+ cs = vs.orthoCS(0, "A", 0, 10, 10, 100, 100)
+ vs.put(quad, cs)
+
+ render(vs)
+ assert len(cb.list) == 0
+ vob.gl.GL.clearQueuedStatistics()
+ assert len(cb.list) == 0
+ vob.gl.GL.callQueuedStatistics()
+ assert len(cb.list) == 0
+
+ render(vs)
+ assert len(cb.list) == 0
+ vob.gl.GL.callQueuedStatistics()
+ assert len(cb.list) == 1
+ vob.gl.GL.clearQueuedStatistics()
+ assert len(cb.list) == 1
+
+ assert cb.list[0] == "1"
+
+
+
+
+