[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] libvob ./Makefile org/nongnu/libvob/gl/GL.java ...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] libvob ./Makefile org/nongnu/libvob/gl/GL.java ... |
Date: |
Wed, 22 Oct 2003 04:57:50 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/10/22 04:57:50
Modified files:
. : Makefile
org/nongnu/libvob/gl: GL.java SimpleAlphaFont.java
org/nongnu/libvob/gl/virtualtexture:
NonDeletingIndirectMipzipManager.java
src/jni : FTFont.cxx Main.cxx QuadFont.cxx Texture.cxx
Added files:
. : runsnaps.py
vob/demo/aniso : fontscene.py
vob/lava/snaps : __init__.py aniso_fontscene.py aniso_gf4go.py
vob/putil : snapshots.py snapshotutil.py
Log message:
Arch sync
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/runsnaps.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/Makefile.diff?tr1=1.47&tr2=1.48&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/FTFont.cxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Main.cxx.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/QuadFont.cxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Texture.cxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/aniso/fontscene.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/lava/snaps/__init__.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/lava/snaps/aniso_fontscene.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/lava/snaps/aniso_gf4go.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/snapshots.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/snapshotutil.py?rev=1.1
Patches:
Index: libvob/Makefile
diff -u libvob/Makefile:1.47 libvob/Makefile:1.48
--- libvob/Makefile:1.47 Sun Sep 28 09:02:16 2003
+++ libvob/Makefile Wed Oct 22 04:57:48 2003
@@ -110,6 +110,9 @@
runusertest::
$(GLLIB) $(JYTHON) runusertest.py $(DBG) $(TEST)
+runsnaps::
+ $(GLLIB) $(JYTHON) runsnaps.py $(DBG) $(SNAPS)
+
copyrighted::
python ../fenfire/metacode/copyrighter.py Libvob
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.27
libvob/org/nongnu/libvob/gl/GL.java:1.28
--- libvob/org/nongnu/libvob/gl/GL.java:1.27 Sat Oct 18 02:11:15 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Wed Oct 22 04:57:48 2003
@@ -537,19 +537,6 @@
}
- /** Copy this texture into the given texture.
- * This function can be used for downsampling by copying from a
non-zero level
- * @param into The texture to copy into
- * @param levelFrom The mipmap level from which to copy. Note that the
texture
- * is always copied TO level 0.
- * @param internalFormat The internalFormat to use in the texture into.
- * @param transferformat The format to use for the transfer.
- */
- public void downsampleInto(Texture into, String target, int levelFrom,
String internalFormat, String transferformat) {
- impl_Texture_downsampleInto(getId(), into.getId(), target,
levelFrom,
- internalFormat, transferformat);
- }
-
/** Load an image into a part of this texture.
*/
public void loadSubImage(int level, Image img, int x, int y, int xoffs,
int yoffs, int w, int h) {
@@ -600,8 +587,6 @@
int border, String format, String type, byte[] data) ;
static private native void impl_Texture_loadSubImage(int id,
int level, int imgid, int x, int y, int xoffs, int yoffs, int w, int h)
;
- static private native void impl_Texture_downsampleInto(int id, int intoid,
String target,
- int level, String internalFormat, String transferformat);
static private native void impl_Texture_copyTexImage2D(
int id, int wid, String buffer,
String target, int level,
@@ -716,17 +701,23 @@
}
+ public static FTFont createFTFont(String filename, int pixelSize_X,
+ int pixelSize_Y) {
+ return createFTFont(filename, pixelSize_X, pixelSize_Y, 1 << 16, 0, 0,
1 << 16);
+ }
/** Create a freetype font, with the given
* pixel sizes.
*/
public static FTFont createFTFont(String filename, int pixelSize_X,
- int pixelSize_Y) {
- int id = impl_FTFont_create(filename, pixelSize_X, pixelSize_Y);
+ int pixelSize_Y,
+ int xx, int xy, int yx, int
yy) {
+ int id = impl_FTFont_create(filename, pixelSize_X, pixelSize_Y, xx, xy,
yx, yy);
if(id < 0)
throw new Error("Couldn't create font '"+filename+"'");
return new FTFont(id);
}
- private static native int impl_FTFont_create(String filename, int psx, int
psy);
+ private static native int impl_FTFont_create(String filename, int psx, int
psy,
+ int xx, int xy, int yx, int
yy);
private static native void impl_FTFont_delete(int id);
private static native int[] impl_FTFont_getMeasurements(int id, int[]
characters) ;
private static native byte[][] impl_FTFont_getBitmaps(int id, int[]
characters) ;
@@ -808,6 +799,15 @@
xadvance, yadvance);
}
+ /** Get the measurements for a single glyph.
+ * @param glyph The index of the glyph
+ * @return A float array of 11 elements, in order of parameters
+ * of setMeasurements
+ */
+ public float[] getMeasurements(int glyph) {
+ return impl_QuadFont_getMeasurements(getId(),
+ glyph);
+ }
}
public static QuadFont createQuadFont() {
@@ -826,6 +826,7 @@
float x0, float y0, float x1, float y1,
float tx0, float ty0, float tx1, float ty1,
float xadvance, float yadvance) ;
+ private static native float[] impl_QuadFont_getMeasurements(int id, int
glyph);
private static native String[] impl_QuadFont_getTexUnits(int id);
private static native String[] impl_QuadFont_getTexTargets(int id);
@@ -989,6 +990,13 @@
public byte[] get() {
return impl_ByteVector_get(getId());
}
+
+ /** Set the values from a byte array.
+ */
+ public void set(byte[] bytes) {
+ impl_ByteVector_set(getId(), bytes);
+ }
+
/** Get the values from the vector as an array of ints.
* Each integer is formed by packing 4 bytes.
*/
@@ -1028,6 +1036,7 @@
int x, int y, float z, int width, int height,
String format, String type) ;
static private native int impl_ByteVector_get(int id, int ind);
+ static private native int impl_ByteVector_set(int id, byte[] bytes);
static private native byte[] impl_ByteVector_get(int id);
static private native int[] impl_ByteVector_getInts(int id);
Index: libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java
diff -u libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.3
libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.4
--- libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.3 Sat Oct 18
02:12:06 2003
+++ libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java Wed Oct 22 04:57:48 2003
@@ -34,6 +34,8 @@
* of an example - other implementations should work on sharing code.
*/
public class SimpleAlphaFont {
+ public static boolean dbg = false;
+ private static void pa(String s) { System.out.println(s); }
// Even though it's wasteful, allocates all tiles.
static public Mosaic2D.Tile[] generateTiles(int[] chars, int[] meas, int
border) {
@@ -156,4 +158,115 @@
return new GLFont(height, yoffs, widths, quadFont);
}
+
+ static private int toint(byte a) {
+ if(a < 0) return a + 256;
+ return a;
+ }
+ static private byte tobyte(int a) {
+ if(a > 127) return (byte)(a - 256);
+ return (byte)a;
+ }
+ static private byte avg(byte a, byte b) {
+ return tobyte((toint(a) + toint(b))/2);
+ }
+
+ static private void shrinkX(byte[] data, int width, int height, int fac) {
+ if(fac != 2) throw new Error("!!!");
+ for(int i=0; i<data.length / 2; i++)
+ data[i] = avg(data[2*i], data[2*i+1]);
+ }
+
+ static private void shrinkY(byte[] data, int width, int height, int fac) {
+ if(fac != 2) throw new Error("!!!");
+ for(int y=0; y<height/2; y++) {
+ for(int x=0; x<width; x++) {
+ data[x+width*y] = avg(data[x+width*(2*y)],
data[x+width*(2*y+1)]);
+ }
+ }
+ }
+
+ /** Post-process a quadfont by reducing resolution by n in the given
direction.
+ * Useful for aniso font experiments, where we want to
+ * retain the exact same layout in the mipmaps, not much else.
+ */
+ static public void postprocessGLFont_reduceReso(GL.QuadFont f, int xfac,
int yfac) {
+ if(xfac <= 0 || yfac <= 0) throw new Error("Not allowed: "+xfac+"
"+yfac);
+ if(xfac > 1 && yfac > 1) {
+ postprocessGLFont_reduceReso(f, xfac, 1);
+ postprocessGLFont_reduceReso(f, 1, yfac);
+ }
+ GL.Texture[] textures = f.getTextures();
+ for(int i=0; i<textures.length; i++) {
+ int width = (int)(textures[i].getLevelParameter(0,
"TEXTURE_WIDTH")[0]);
+ int height = (int)(textures[i].getLevelParameter(0,
"TEXTURE_HEIGHT")[0]);
+ byte[] tex = new byte[width * height];
+ textures[i].getTexImage(0, "ALPHA", "UNSIGNED_BYTE", tex);
+
+ if(xfac > 1)
+ shrinkX(tex, width, height, xfac);
+ if(yfac > 1)
+ shrinkY(tex, width, height, yfac);
+
+ textures[i].texImage2D(0, "ALPHA", width / xfac, height / yfac, 0,
+ "ALPHA", "UNSIGNED_BYTE", tex);
+
+ }
+ }
+
+ /** Get a DrawPixels gl renderable for drawing the actual texels
+ * of a given level for a given character using a GL_LUMINANCE mapping.
+ */
+ static public org.nongnu.libvob.Vob getLevelDrawPixels(GL.QuadFont f, int
glyph, int lod) {
+ GL.Texture[] textures = f.getTextures();
+ float[] meas = f.getMeasurements(glyph);
+ GL.Texture tex = textures[(int)meas[0]];
+
+ float tx0 = meas[5];
+ float ty0 = meas[6];
+ float tx1 = meas[7];
+ float ty1 = meas[8];
+
+ int width = (int)(tex.getLevelParameter(lod, "TEXTURE_WIDTH")[0]);
+ int height = (int)(tex.getLevelParameter(lod, "TEXTURE_HEIGHT")[0]);
+ byte[] data = new byte[width * height];
+ tex.getTexImage(lod, "ALPHA", "UNSIGNED_BYTE", data);
+
+ int x = (int)(tx0 * width);
+ int w = (int)Math.ceil(tx1 * width) - x;
+
+ int y = (int)(ty0 * height);
+ int h = (int)Math.ceil(ty1 * height) - y;
+
+ byte[] ndata = new byte[w*h];
+ for(int xi = 0; xi < w; xi ++) {
+ for(int yi = 0; yi < h; yi ++) {
+ ndata[xi + w*yi] = data[x + xi + width * (y + yi)];
+ }
+ }
+ GL.ByteVector v = GL.createByteVector(w*h);
+ v.set(ndata);
+
+ pa("getleveldp: "+glyph+" "+lod+" "+x+" "+y+" "+w+" "+h);
+ if(dbg) if(w < 20 && h < 20) {
+ StringBuffer s = new StringBuffer();
+ StringBuffer s0 = new StringBuffer();
+ StringBuffer s1 = new StringBuffer();
+ for(int i=0; i<w*h; i++){
+ s.append(" ");
+ s.append(v.get(i));
+ s0.append(" ");
+ s0.append(ndata[i]);
+ }
+ pa(""+s);
+ pa(""+s0);
+ }
+
+ return GLRen.createDrawPixels(w, h, "LUMINANCE", "UNSIGNED_BYTE", v);
+
+ }
+
}
+
+
+
Index:
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java
diff -u
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java:1.3
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java:1.4
---
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java:1.3
Sat Oct 18 02:12:06 2003
+++
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java
Wed Oct 22 04:57:48 2003
@@ -80,6 +80,11 @@
*/
private MipmapArray loadTmp;
+ /** The lod (importance level) of loadTmp currently.
+ * Used to set the priority of the next GL task.
+ */
+ int loadTmpLevel;
+
// ---- The loaded state
/** The state of a single texture slot.
@@ -365,6 +370,10 @@
}
}
+ private float getGLPriority(int level) {
+ return glPriority + 2 * level;
+ }
+
private Runnable r_runBg = new Runnable() {
public void run() {
synchronized(NonDeletingIndirectMipzipManager.this) {
@@ -378,7 +387,7 @@
}
if(res) {
background.addTask(r_runBg, bgPriority);
- glBackground.addTask(r_runGL, glPriority);
+ glBackground.addTask(r_runGL, getGLPriority(loadTmpLevel));
}
}
}
@@ -456,6 +465,7 @@
Slot unfinished = null;
boolean loadScheduled = false;
boolean demoted = false;
+ int highestLevel = 100;
for(int i=0; i<nlevels; i++) {
for(int j=0; j<slots[i].length; j++) {
if(!demoted &&
@@ -467,6 +477,7 @@
// demoting before the new images come
// out from the disk is not good...?
glDemote(i, j);
+ if(i < highestLevel) highestLevel = i;
demoted = true;
} else if(!loadScheduled &&
!slots[i][j].allLoaded()) {
@@ -477,16 +488,17 @@
// Start loading the first incomplete
// in-place slot we have
slots[i][j].requestLoad(loadTmp);
+ loadTmpLevel = i;
loadScheduled = true;
background.addTask(r_runBg, bgPriority);
}
}
if(loadScheduled && demoted)
- glBackground.addTask(r_runGL, glPriority);
+ glBackground.addTask(r_runGL,
getGLPriority(highestLevel));
}
}
if(loadScheduled || demoted)
- glBackground.addTask(r_runGL, glPriority);
+ glBackground.addTask(r_runGL, getGLPriority(highestLevel));
}
}
}
Index: libvob/src/jni/FTFont.cxx
diff -u libvob/src/jni/FTFont.cxx:1.2 libvob/src/jni/FTFont.cxx:1.3
--- libvob/src/jni/FTFont.cxx:1.2 Fri Oct 10 09:52:25 2003
+++ libvob/src/jni/FTFont.cxx Wed Oct 22 04:57:48 2003
@@ -58,7 +58,8 @@
extern "C" {
jf( jint, impl_1FTFont_1create )
- (JNIEnv *env, jclass, jstring filename, jint pixsize_x, jint pixsize_y)
+ (JNIEnv *env, jclass, jstring filename, jint pixsize_x, jint pixsize_y,
+ jint xx, jint xy, jint yx, jint yy)
{
std::string filename_str = jstr2stdstr(env, filename);
if(!inited) {
@@ -82,7 +83,14 @@
return -1;
}
+
+ FT_Matrix transform;
+ transform.xx = xx;
+ transform.xy = xy;
+ transform.yx = yx;
+ transform.yy = yy;
+ FT_Set_Transform(*face, &transform, 0);
return ftfonts.add(face);
}
Index: libvob/src/jni/Main.cxx
diff -u libvob/src/jni/Main.cxx:1.28 libvob/src/jni/Main.cxx:1.29
--- libvob/src/jni/Main.cxx:1.28 Sat Oct 18 02:11:15 2003
+++ libvob/src/jni/Main.cxx Wed Oct 22 04:57:48 2003
@@ -548,6 +548,20 @@
return arr;
}
+jf(void, impl_1ByteVector_1set)
+ (JNIEnv *env, jclass, jint id, jbyteArray array) {
+ jbyte *bytes = env->GetByteArrayElements(array, 0);
+ ByteVector *v = bytevectors[id];
+
+ unsigned len = env->GetArrayLength(array);
+ if(len > v->size()) len = v->size();
+
+ for(int i=0; i<len; i++)
+ (*v)[i] = bytes[i];
+
+ env->ReleaseByteArrayElements(array, bytes, 0);
+}
+
jf(jintArray, impl_1ByteVector_1getInts)
(JNIEnv *env, jclass, jint id) {
int len = bytevectors[id]->size() / 4;
Index: libvob/src/jni/QuadFont.cxx
diff -u libvob/src/jni/QuadFont.cxx:1.2 libvob/src/jni/QuadFont.cxx:1.3
--- libvob/src/jni/QuadFont.cxx:1.2 Fri Oct 10 09:52:25 2003
+++ libvob/src/jni/QuadFont.cxx Wed Oct 22 04:57:48 2003
@@ -154,6 +154,32 @@
}
+jf(jfloatArray, impl_1QuadFont_1getMeasurements)
+ (JNIEnv *env, jclass, jint id, jint glyph)
+{
+ Text::QuadFont *quadFont = quadFonts.get(id);
+
+ jfloatArray ret = env->NewFloatArray(11);
+ jfloat *p = env->GetFloatArrayElements(ret, 0);
+
+ p[0] = quadFont->textureIndex[glyph];
+
+ p[1] = quadFont->coordinates[8*glyph + 0];
+ p[2] = quadFont->coordinates[8*glyph + 1];
+ p[3] = quadFont->coordinates[8*glyph + 2];
+ p[4] = quadFont->coordinates[8*glyph + 3];
+ p[5] = quadFont->coordinates[8*glyph + 4];
+ p[6] = quadFont->coordinates[8*glyph + 5];
+ p[7] = quadFont->coordinates[8*glyph + 6];
+ p[8] = quadFont->coordinates[8*glyph + 7];
+
+ p[9] = quadFont->advances[glyph];
+ p[10] = 0;
+
+ env->ReleaseFloatArrayElements(ret, p, 0);
+ return ret;
+}
+
jobjectArray enumVector2tokenStringArray(JNIEnv *env, vector<GLenum> &vec) {
jobjectArray ret = env->NewObjectArray(
vec.size(),
Index: libvob/src/jni/Texture.cxx
diff -u libvob/src/jni/Texture.cxx:1.2 libvob/src/jni/Texture.cxx:1.3
--- libvob/src/jni/Texture.cxx:1.2 Sat Oct 18 02:11:15 2003
+++ libvob/src/jni/Texture.cxx Wed Oct 22 04:57:48 2003
@@ -186,7 +186,7 @@
glPopClientAttrib();
env->ReleaseByteArrayElements(jdata, b, 0);
- GLERR;
+ if(GLERR_JNI(env)) return;
}
@@ -220,39 +220,6 @@
// glFinish(); // Appears that NV 4191 drivers need this.
env->ReleaseByteArrayElements(jdata, data, 0);
GLERR;
-
-}
-
-
-jf(void, impl_1Texture_1downsampleInto)
- (JNIEnv *env, jclass, jint id, jint intoid, jstring targetstr, jint level,
jstring internalFormat, jstring transferType)
-{
- GLenum target = tokenFromJstring(env, targetstr);
- GLenum intern = tokenFromJstring(env, internalFormat);
- GLenum trans = tokenFromJstring(env, transferType);
- glBindTexture(target, id);
- GLint w=0,h=0;
- // XXX Only does 2D
- glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &w);
- glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &h);
-
- GLubyte *data = new GLubyte[w*h*4]; // assuming 4 components
-
- glPixelStorei(GL_PACK_ROW_LENGTH, 0);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glGetTexImage(target, level, trans, GL_UNSIGNED_BYTE, data);
-
-
- glBindTexture(target, intoid);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
- glTexImage2D(target, 0, intern, w, h, 0, trans, GL_UNSIGNED_BYTE,
- data);
-
- delete[] data;
- glBindTexture(target, 0);
-
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] libvob ./Makefile org/nongnu/libvob/gl/GL.java ...,
Tuomas J. Lukka <=