gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./TODO gzz/client/AbstractUpdateManager.jav...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO gzz/client/AbstractUpdateManager.jav...
Date: Mon, 20 Jan 2003 09:22:57 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        03/01/20 09:22:57

Modified files:
        .              : TODO 
        gzz/client     : AbstractUpdateManager.java 
        gzz/gfx/gl     : GLSpanner.java GLUtil.java MipzipLoader.java 
        gzz/mem        : MemoryPartitioner.java 
        gzz/view       : pagespanview.py xubuoy.py 

Log message:
        mipzip in xupdf

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.527&tr2=1.528&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/client/AbstractUpdateManager.java.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLSpanner.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLUtil.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/MipzipLoader.java.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/mem/MemoryPartitioner.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/pagespanview.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/xubuoy.py.diff?tr1=1.41&tr2=1.42&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.527 gzz/TODO:1.528
--- gzz/TODO:1.527      Mon Jan 20 02:55:15 2003
+++ gzz/TODO    Mon Jan 20 09:22:56 2003
@@ -254,7 +254,8 @@
          color really is right)
     tjl:
        - xupdf: distorted multi-page PDF view with xu links
-           - use mipzips
+           - use proper importances and pixel counts
+           - debug mipzips
            - overall goal: USEFUL when article writing starts
            - multiple instances of same cell visible as a buoy --> keys?
                - special matcher? or pp/VobKeyer?
@@ -263,6 +264,7 @@
            + adjustable zoom / distortion area by mouse
            + joystick?
            - use off-screen buffer for libpaper r2t
+       - implement AbstractUpdateManager.chgAfter
        - create an additional focus object into umltool; "a teared
           round edge around focused object"
        - matrix inv!
Index: gzz/gzz/client/AbstractUpdateManager.java
diff -u gzz/gzz/client/AbstractUpdateManager.java:1.32 
gzz/gzz/client/AbstractUpdateManager.java:1.33
--- gzz/gzz/client/AbstractUpdateManager.java:1.32      Sat Jan 18 10:18:21 2003
+++ gzz/gzz/client/AbstractUpdateManager.java   Mon Jan 20 09:22:57 2003
@@ -41,7 +41,7 @@
  */
 
 public abstract class AbstractUpdateManager implements Runnable {
-public static final String rcsid = "$Id: AbstractUpdateManager.java,v 1.32 
2003/01/18 15:18:21 tjl Exp $";
+public static final String rcsid = "$Id: AbstractUpdateManager.java,v 1.33 
2003/01/20 14:22:57 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -190,8 +190,17 @@
        return animationtime;
     }
 
-    /* Called by a space to inform that some cells have been 
-     * changed 
+    /** We want to update the screen, but not start immediately in order to do
+     * some more background processing.
+     * For example, when MipzipLoader is working, we want to update the screen 
when new information
+     * has been loaded, but not right away.
+     */
+    public static void chgAfter(int millis) {
+       // XXX Implement
+    }
+
+    /** Called by a space to inform that some cells have been 
+     * changed and all windows should be updated.
      */
     public static void chg() { instance.chgImpl(); }
     protected void chgImpl() {
@@ -206,12 +215,10 @@
     }
 
     /** Disable all updating of windows.
-     * This is a potentially time-consuming operation, and can take up to 
-     * several seconds at worst. This is if the thread is in the X event 
-     * waiting.
      */
     public static void freeze() {
        if(dbg) pa("Updatemanager freeze");
+       instance.interruptEventloop();
        synchronized(instance.ordering) { instance.disabled++; }
        if(dbg) pa("Updatemanager frozen "+instance.disabled);
     }
Index: gzz/gzz/gfx/gl/GLSpanner.java
diff -u gzz/gzz/gfx/gl/GLSpanner.java:1.1 gzz/gzz/gfx/gl/GLSpanner.java:1.2
--- gzz/gzz/gfx/gl/GLSpanner.java:1.1   Mon Jan 20 02:58:47 2003
+++ gzz/gzz/gfx/gl/GLSpanner.java       Mon Jan 20 09:22:57 2003
@@ -100,6 +100,7 @@
         */
        public final float x0, y0, x1, y1;
 
+
        private float pixelmult;
 
        /** Cause the texture to be 
@@ -110,7 +111,12 @@
         *              of the drawn area.
         */
        public GL.Texture getTexture(float importance, float pixels) {
-           return page.getTexture(importance, pixelmult * pixels);
+           GL.Texture tex = page.getTexture(importance, pixelmult * pixels);
+           String er = GLUtil.checkMipmap(tex);
+           if(er != null) {
+               pa("MIPMAPS NOT CONSISTENT! "+er+" "+page);
+           }
+           return tex;
        }
 
        private SpanRect(SpanPage page, PageSpan sp) {
@@ -128,9 +134,9 @@
 
     }
 
-    Map span2rect = new WeakHashMap();
+    static Map span2rect = new WeakHashMap();
 
-    Map sb2spansb =  new WeakHashMap();
+    static Map sb2spansb =  new WeakHashMap();
 
     /** Get the texrect for a given pagespan.
      * This method will return immediately, either
@@ -141,7 +147,7 @@
      *                         1 = at focus, 0 = very peripheral
      * @param pixScale The number of pixels per imagespan unit: the resolution 
needed.
      */
-    SpanRect getSpanRect(PageSpan sp, float importance, float pixScale) {
+    public static SpanRect getSpanRect(PageSpan sp) {
        SpanRect r = (SpanRect)span2rect.get(sp);
        if(r == null) {
            PageImageScroll sb = (PageImageScroll)sp.getScrollBlock();
Index: gzz/gzz/gfx/gl/GLUtil.java
diff -u gzz/gzz/gfx/gl/GLUtil.java:1.1 gzz/gzz/gfx/gl/GLUtil.java:1.2
--- gzz/gzz/gfx/gl/GLUtil.java:1.1      Sun Jan 19 05:08:12 2003
+++ gzz/gzz/gfx/gl/GLUtil.java  Mon Jan 20 09:22:57 2003
@@ -54,4 +54,40 @@
        backup = null;
     }
 
+    /** Check mipmap levels of a texture.
+     * @return null, if everything is OK, an error string otherwise.
+     */
+    static public String checkMipmap(GL.Texture tex) {
+       int base = (int)tex.getParameter("TEXTURE_BASE_LEVEL")[0];
+       int max = (int)tex.getParameter("TEXTURE_MAX_LEVEL")[0];
+
+       int w = (int)tex.getLevelParameter(base, "TEXTURE_WIDTH")[0];
+       int h = (int)tex.getLevelParameter(base, "TEXTURE_HEIGHT")[0];
+       int format = (int)tex.getLevelParameter(base, 
"TEXTURE_INTERNAL_FORMAT")[0];
+
+       if(w == 0 || h == 0) {
+           return "Warning: texture base level size zero: "+w+" "+h;
+       }
+
+       for(int i=base+1; i<max; i++) {
+           if(w == 1 && h == 1) break;
+           w /= 2; if(w == 0) w = 1;
+           h /= 2; if(h == 0) h = 1;
+
+           int wc = (int)tex.getLevelParameter(i, "TEXTURE_WIDTH")[0];
+           int hc = (int)tex.getLevelParameter(i, "TEXTURE_HEIGHT")[0];
+           int formatc = (int)tex.getLevelParameter(i, 
"TEXTURE_INTERNAL_FORMAT")[0];
+
+           if(wc != w || hc != h)
+               return "Texture level size wrong: "+base+" "+i+" "+w+" "+h+" 
"+wc+" "+hc;
+
+           if(formatc != format)
+               return "Texture level format wrong: "+base+" "+i+" "+format+" 
"+formatc;
+
+
+           
+       }
+       return null;
+    }
+
 }
Index: gzz/gzz/gfx/gl/MipzipLoader.java
diff -u gzz/gzz/gfx/gl/MipzipLoader.java:1.14 
gzz/gzz/gfx/gl/MipzipLoader.java:1.15
--- gzz/gzz/gfx/gl/MipzipLoader.java:1.14       Sun Jan 19 05:08:12 2003
+++ gzz/gzz/gfx/gl/MipzipLoader.java    Mon Jan 20 09:22:57 2003
@@ -248,7 +248,7 @@
                    levels[i].loadData();
                    AbstractUpdateManager.doWhenIdle( 
                            levels[i], priority - 10 - .1f * i);
-                   AbstractUpdateManager.chg();
+                   // AbstractUpdateManager.chg();
                    priority += .05;
                    bg.addTask(r_runBg, priority);
                } catch(IOException e) {
@@ -302,8 +302,10 @@
 
        if(dbg) pa("MipzipLoader "+this+" firstNotIn!! "+ i);
        if(currentBaseLevel != i+1) {
+           boolean wasGreater = currentBaseLevel > i+1;
            setBaseLevel(i+1);
-           AbstractUpdateManager.chg();
+           if(wasGreater)
+               AbstractUpdateManager.chg();
            return;
        }
     }
Index: gzz/gzz/mem/MemoryPartitioner.java
diff -u gzz/gzz/mem/MemoryPartitioner.java:1.11 
gzz/gzz/mem/MemoryPartitioner.java:1.12
--- gzz/gzz/mem/MemoryPartitioner.java:1.11     Sat Jan 18 15:24:26 2003
+++ gzz/gzz/mem/MemoryPartitioner.java  Mon Jan 20 09:22:57 2003
@@ -212,6 +212,7 @@
        if(maximportance <= 0) return;
        // Else, find a good exponent
        for(int round = 0; ; round++) {
+           float mulf = (round > 5 ? .999f : 1);
            // Sum of maxbytes multiplied with priority^round
            int sumReduced = 0;
            if(dbg) pa("Rerate round "+round);
@@ -220,7 +221,7 @@
                ConsumerRecord rec = (ConsumerRecord)consumer2record.get(cons);
                float imp = 0;
                if(rec.curImportance > 0)
-                   imp = (float)Math.pow(.99 * 
rec.curImportance/maximportance, round);
+                   imp = (float)Math.pow(mulf * 
rec.curImportance/maximportance, round);
                else if(round == 0)
                    imp = 1;
                int byt = cons.getMaxBytes(rec.curQuality);
@@ -235,7 +236,7 @@
                    ConsumerRecord rec = 
(ConsumerRecord)consumer2record.get(cons);
                    float imp = 0;
                    if(rec.curImportance > 0)
-                       imp = (float)Math.pow(.99 * 
rec.curImportance/maximportance, round);
+                       imp = (float)Math.pow(mulf * 
rec.curImportance/maximportance, round);
                    else if(round == 0)
                        imp = 1;
                    int byt = cons.getMaxBytes(rec.curQuality);
Index: gzz/gzz/view/pagespanview.py
diff -u gzz/gzz/view/pagespanview.py:1.23 gzz/gzz/view/pagespanview.py:1.24
--- gzz/gzz/view/pagespanview.py:1.23   Thu Dec 12 13:41:48 2002
+++ gzz/gzz/view/pagespanview.py        Mon Jan 20 09:22:57 2003
@@ -1,5 +1,6 @@
 from __future__ import nested_scopes
-from gzz.gfx.gl import GL, GLRen, GLSpans, Paper, GLCache, Stencil
+import math
+from gzz.gfx.gl import GL, GLRen, GLSpanner, Paper, GLCache, Stencil
 import gfx.libpaper.papermill
 from gfx.libutil import nvcode, effects
 import gzz
@@ -13,7 +14,6 @@
 # Module pagespanview
 
 globalseedoffs = -7
-globalLOD = 0
 
 
 def enf2span(enf):
@@ -39,15 +39,19 @@
        globalscrollblockPapers[hashkey] = ret
     return ret
 
+class PDFPage:
+    def __init__(self, span, scrollblockPaper):
+       self.rect = GLSpanner.getSpanRect(span)
+       print "Rect: ",self.rect
+       (self.paperwhite, self.w, self.h, self.paperwithbg) = pdfpaper(span, 
self.rect, scrollblockPaper) 
 
 def getPDFPapers(content):
     contentspan = enf2span(content)
     scrollblockPaper = getScrollblockPaper(contentspan.getScrollBlock())
     ret = []
     for i in range(0, content.length()):
-       rect = GLSpans.getRect(contentspan.subSpan(i,i+1), globalLOD)
-       print "Rect: ",globalLOD, rect
-       ret.append( pdfpaper(rect, scrollblockPaper) )
+       rect = PDFPage(contentspan.subSpan(i,i+1), scrollblockPaper)
+       ret.append( rect )
     return ret
 
 filters = """
@@ -60,7 +64,7 @@
     global filters
     filters = filt
 
-def pdfpaper(pdfrect, background): 
+def pdfpaper(span, pdfrect, background): 
     """Get the papers for the pages.
 
     Returns: (pdf on white background, width, height, 
@@ -69,11 +73,12 @@
     # Papercoords: (0,0) .. (w,h) where
     # w = pdfrect.w / 72 / 6, same for h
     # ret: (paper, w, h)
-    pw = pdfrect.w / 72.0 / 6
-    ph = pdfrect.h / 72.0 / 6
+    dim = span.getSize()
+    pw = dim.width / 72.0 / 6
+    ph = dim.height / 72.0 / 6
     wm = (pdfrect.x1-pdfrect.x0) / pw
     hm = (pdfrect.y1-pdfrect.y0) / ph
-    texid = pdfrect.texId
+    texid = pdfrect.getTexture(0.1, 500).getTexId()
 
     filt = filters
 
@@ -134,7 +139,6 @@
            assert p == 1
            ppass = pap.getPass(0)
 
-           texid = pdfrect.texId
 
            tc = texcode
            ppass.setSetupcode(ppass.getSetupcode() +  nvcode.combinercode("""
@@ -218,15 +222,15 @@
        print "Cell content: ",self.content.toString()
        self.pap = getPDFPapers(self.content)
        self.irregu = effects.IrreguFrame(
-          0, 0, self.pap[0][1] / self.pap[0][2] * len(self.pap), 1,
+          0, 0, self.pap[0].w / self.pap[0].h * len(self.pap), 1,
                        0.06, 0.25)
-       self.papersize = (self.pap[0][1] * len(self.pap), self.pap[0][2])
+       self.papersize = (self.pap[0].w * len(self.pap), self.pap[0].h)
 
        h = 1
        ph = self.papersize[1]
        self.scale = h/ph
 
-       self.scaledsheetsize = (self.pap[0][1] * self.scale, self.pap[0][2] * 
self.scale)
+       self.scaledsheetsize = (self.pap[0].w * self.scale, self.pap[0].h * 
self.scale)
        self.scaledsize = (len(self.pap) * self.scaledsheetsize[0], 
self.scaledsheetsize[1])
        print "Scaledsize: ",self.scaledsheetsize
     # Height = always 1.
@@ -247,7 +251,7 @@
        # print "x,y for place: ",curx, ycoord
        # print papers
        grid = 13
-       corners = (0, 0, papers[0][1], papers[0][2], self.dicefactor)
+       corners = (0, 0, papers[0].w, papers[0].h, self.dicefactor)
        cs2 = vs.coords.affineCoordsys(0, 0, 0, 0, 1, 0, 0, 1)
        vs.matcher.add(cs2, key+"_p2_") 
 
@@ -286,11 +290,11 @@
                    if onlypages == None or i in onlypages:
                        if fancy:
                                pq = GLRen.createPaperQuad(
-                                   papers[i][3], *corners)
+                                   papers[i].paperwithbg, *corners)
                                 vs.map.put(pq, cs_cull, cs2)
                        else:
                                pq = GLRen.createPaperQuad(
-                                   papers[i][0], *corners)
+                                   papers[i].paperwhite, *corners)
                                vs.map.put(pq, cs_cull, cs2)
 
                    self.curx += self.scaledsheetsize[0]
@@ -352,6 +356,16 @@
         assert -2 < (my[0]-inv[0]) < 2  and  -2 < (my[1]-inv[1]) < 2
                                
         return (page, pointx, pointy)
+
+    def reqTextures(self, x, y, all=0, importance = 1):
+       (page, px, py) = self.paperpoint_inv(x, y)
+       print "Request page ",page
+       self.pap[page].rect.getTexture(importance, 4000)
+       if all:
+           for i in range(0, len(self.pap)):
+               if i == page: continue
+               imp = importance * 1.0 / (1 + abs(i - page))
+               self.pap[i].rect.getTexture(imp, 4000)
         
     def hitClip(self, coords, point3, cliprect):
        src = zeros(3, 'f') # assume only one point
Index: gzz/gzz/view/xubuoy.py
diff -u gzz/gzz/view/xubuoy.py:1.41 gzz/gzz/view/xubuoy.py:1.42
--- gzz/gzz/view/xubuoy.py:1.41 Thu Dec 19 04:12:39 2002
+++ gzz/gzz/view/xubuoy.py      Mon Jan 20 09:22:57 2003
@@ -445,12 +445,6 @@
        elif key == 'c':
            self.clip = not self.clip
            AbstractUpdateManager.chg()
-       elif key == 'l':
-           pagespanview.globalLOD = 1 - pagespanview.globalLOD
-           print "Lod: ",pagespanview.globalLOD
-           AbstractUpdateManager.setNoAnimation()
-           AbstractUpdateManager.chg()
-           self.moveToCell(self.cursor)
        elif key == 'p':
            self.usefancypaper = not self.usefancypaper
            AbstractUpdateManager.setNoAnimation()
@@ -691,6 +685,7 @@
            self.cliprect = None
 
         if ispdf(self.cursor):
+           self.view.reqTextures(globalx, globaly, all=1)
            self.view.placepapers(vs, cs1_trans, cliprect = clip,
                fancy = self.usefancypaper, showTessel = self.showtessel)
             maincs = cs1_trans




reply via email to

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