gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz ./TODO doc/gl/Mipzip.rst gfx/util/texpacker...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO doc/gl/Mipzip.rst gfx/util/texpacker...
Date: Fri, 17 Jan 2003 03:06:07 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        03/01/17 03:06:07

Modified files:
        .              : TODO 
        doc/gl         : Mipzip.rst 
        gfx/util       : texpacker.py 
        gzz/gfx/gl     : MipzipLoader.java 

Log message:
        More mipzipping. Adjust TODO

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.518&tr2=1.519&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/gl/Mipzip.rst.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/texpacker.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/MipzipLoader.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.518 gzz/TODO:1.519
--- gzz/TODO:1.518      Thu Jan 16 06:24:36 2003
+++ gzz/TODO    Fri Jan 17 03:06:07 2003
@@ -246,20 +246,10 @@
          colors (not "not" tests but test that the 
          color really is right)
     tjl:
-       - make saving/loading compressed textures in zip files easy.
-       - matrix inv!
-       - faster (asynch) loading of (pagespan) images
-           - move Image class (imageraster &c) out from Os-GLX.
-             Os-GLX should only contain methods to directly
-             load images into given memory buffers in given
-             formats.
-           - load in separate thread
-           - discard high-rez images when not in use
-           - use lower resolution first, lazily load better
-       - create an additional focus object into umltool; "a teared
-          round edge around focused object"
-       - keymapping in both directions
+       - connect mipzip to memoryconsumer
+       - mipzip test program
        - xupdf: distorted multi-page PDF view with xu links
+           - use mipzips
            - overall goal: USEFUL when article writing starts
            - multiple instances of same cell visible as a buoy --> keys?
                - special matcher? or pp/VobKeyer?
@@ -267,6 +257,10 @@
            - structure editing
            + adjustable zoom / distortion area by mouse
            + joystick?
+       - create an additional focus object into umltool; "a teared
+          round edge around focused object"
+       - matrix inv!
+       - vobmatcher keymapping to work in both directions
        - PEG move Obs to gzz.util, freeze some gzz.util classes
        - better graphics for xupdf and pp
            - fillets without the original object
@@ -302,6 +296,10 @@
            - GRABBING BUOYS ?!!!
        + polygon puzzle view
     anybody:
+       + move Image class (imageraster &c) out from Os-GLX.
+         Os-GLX should only contain methods to directly
+         load images into given memory buffers in given
+         formats.
        - first cut at merge [important, non-trivial task]
 
        - irregu:
Index: gzz/doc/gl/Mipzip.rst
diff -u gzz/doc/gl/Mipzip.rst:1.4 gzz/doc/gl/Mipzip.rst:1.5
--- gzz/doc/gl/Mipzip.rst:1.4   Thu Jan 16 11:06:28 2003
+++ gzz/doc/gl/Mipzip.rst       Fri Jan 17 03:06:07 2003
@@ -20,12 +20,12 @@
 
     class FormatData
        fields
-           name: "texformat"
+           name: texformat
            comment: texformatname
 
     class LevelData
        fields
-           name: "i"
+           name: i
            comment: resolution
            content: data
 
Index: gzz/gfx/util/texpacker.py
diff -u gzz/gfx/util/texpacker.py:1.2 gzz/gfx/util/texpacker.py:1.3
--- gzz/gfx/util/texpacker.py:1.2       Thu Jan 16 11:06:28 2003
+++ gzz/gfx/util/texpacker.py   Fri Jan 17 03:06:07 2003
@@ -39,6 +39,7 @@
        System.exit(0)
 
     def handle(self, texfile):
+       GL.freeQueue()
        im = GL.createImage(texfile)
        d = im.getSize();
        print d
@@ -86,5 +87,5 @@
 
 
 gfxapi = GraphicsAPI.getInstance()
-gfxapi.startUpdateManager(Main(["../mstmpimg/014290275B45C8E59A24F635BF615D9DD9B32563F1-170-1"]))
+gfxapi.startUpdateManager(Main(args))
 
Index: gzz/gzz/gfx/gl/MipzipLoader.java
diff -u gzz/gzz/gfx/gl/MipzipLoader.java:1.4 
gzz/gzz/gfx/gl/MipzipLoader.java:1.5
--- gzz/gzz/gfx/gl/MipzipLoader.java:1.4        Thu Jan 16 11:06:28 2003
+++ gzz/gzz/gfx/gl/MipzipLoader.java    Fri Jan 17 03:06:07 2003
@@ -5,13 +5,21 @@
 import java.io.*;
 import java.util.*;
 import java.util.zip.*;
+import gzz.client.*;
+import gzz.util.*;
 import gzz.*;
 
 /** A loader for Mipzip files: files of zipped, 
  * compressed mipmap levels.
  */
 public class MipzipLoader {
+    public static boolean dbg = false;
+    final static void pa(String s) { System.out.println(s); }
 
+    private int goalBaseLevel = 0;
+
+    private Background bg = null;
+    private float priority = 0;
 
     /** The file in which the mipmaps are stored.
      */
@@ -53,14 +61,18 @@
        }
     }
 
+    private static final int STATE_NONE = 1,
+                            STATE_DATALOADED = 2,
+                            STATE_INTEXTURE = 3;
+
     /** A single mipmap level.
      */
-    private class Level {
+    private class Level implements Runnable {
 
        /** Whether this level is loaded into
         * the texture.
         */
-       boolean loaded = false;
+       int state = STATE_NONE;
 
        /** The index of this level.
         */
@@ -81,22 +93,25 @@
         * thread.
         */
        synchronized void loadData() throws IOException {
-           if(loaded || loadedData != null) return;
+           if(state != STATE_NONE) return;
            // Not sure if required, but safer
            loadedData = readEntry(""+level);
+           state = STATE_DATALOADED;
        }
 
+       synchronized public void run() { texImage(); }
+
        /** Call TexImage and afterwards discard the loaded data.
         * Must be called in GL thread.
         */
        synchronized void texImage() {
-           if(loadedData == null)
-               return;
+           if(state != STATE_DATALOADED) return;
            tex.compressedTexImage(level, texFormat,
                        size.width, size.height, 0,
                        loadedData);
-           loaded = true;
+           state = STATE_INTEXTURE;
            loadedData = null;
+           AbstractUpdateManager.doWhenIdle( r_runGL, priority);
        }
 
        /** Discard the texture level from the GL side.
@@ -104,9 +119,14 @@
         * Hope this really works.
         */
        synchronized void discard() {
-           if(!loaded) return;
-           tex.loadNull2D(level, texFormat, 1, 1, 0, "RGB", "FLOAT");
-           loaded = false;
+           switch(state) {
+           case STATE_INTEXTURE:
+               tex.loadNull2D(level, texFormat, 
+                       1, 1, 0, "RGB", "FLOAT");
+           case STATE_DATALOADED:
+               loadedData = null;
+           }
+           state = STATE_NONE;
        }
 
        /** Create a level.
@@ -141,6 +161,76 @@
        setBaseLevel(level);
     }
 
+    /** Set the base level goal for
+     * asynchronous loading.
+     */
+    synchronized public void setGoalBaseLevel(int level,
+                               Background bg, float priority) {
+       this.goalBaseLevel = level;
+       this.bg = bg;
+       this.priority = priority;
+       bg.addTask(r_runBg, priority);
+    }
+
+    private Runnable r_runBg = new Runnable() {
+       public void run() {
+           runBg();
+       }
+    };
+    private Runnable r_runGL = new Runnable() {
+       public void run() {
+           runGL();
+       }
+    };
+
+    synchronized private void runBg() {
+       // See what data is missing and load it
+       for(int i=levels.length-1; i >= goalBaseLevel && i >= 0;
+                   i--) {
+           if(levels[i].state == STATE_NONE) {
+               // Ah, data missing -> load now
+               // and reschedule
+               try {
+                   levels[i].loadData();
+                   AbstractUpdateManager.doWhenIdle( 
+                           levels[i], priority);
+                   bg.addTask(r_runBg, priority);
+               } catch(IOException e) {
+                   pa("Exception while loading mipzip data "+e);
+                   e.printStackTrace();
+               }
+               break;
+           }
+       }
+       // Schedule runGL always
+       AbstractUpdateManager.doWhenIdle( r_runGL, priority);
+    }
+
+    // See if any too large mipmaps still here
+    // If yes, discard and reschedule.
+    // Then, set base level and return.
+    synchronized private void runGL() {
+       for(int i=0; i<goalBaseLevel && i < levels.length-1; 
+                                               i++) {
+           if(levels[i].state != STATE_NONE) {
+               levels[i].discard();
+               AbstractUpdateManager.doWhenIdle(r_runGL, 
+                           priority);
+               return;
+           }
+       }
+
+       // Find first texture that has not been teximaged.
+       for(int i=levels.length-1; i >= goalBaseLevel && i >= 0;
+                   i--) {
+           if(levels[i].state != STATE_INTEXTURE) {
+               setBaseLevel(i+1);
+           }
+       }
+    }
+
+    /** Create a new MipzipLoader for the given mipzip file.
+     */
     public MipzipLoader(File mipzipFile) throws IOException {
        this.mipzipFile = mipzipFile;
        this.tex = GL.createTexture();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]