fenfire-commits
[Top][All Lists]
Advanced

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

[ff-cvs] libvob include/vob/vobs/Text.hxx src/main/Rende...


From: Tuomas J. Lukka
Subject: [ff-cvs] libvob include/vob/vobs/Text.hxx src/main/Rende...
Date: Sat, 16 Aug 2003 08:20:15 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Tuomas J. Lukka <address@hidden>        03/08/16 08:20:14

Modified files:
        include/vob/vobs: Text.hxx 
        src/main       : Renderer.cxx 
        src/texture    : Makefile irregu.texture 
        vob/putil      : effects.py 

Log message:
        Speed up fenpdf startup by rearranging loop in irregu texture. We 
really should cache it. I hope this didn't break anything.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Text.hxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/main/Renderer.cxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/texture/Makefile.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/texture/irregu.texture.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/effects.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: libvob/include/vob/vobs/Text.hxx
diff -u libvob/include/vob/vobs/Text.hxx:1.6 
libvob/include/vob/vobs/Text.hxx:1.7
--- libvob/include/vob/vobs/Text.hxx:1.6        Fri Aug 15 14:53:38 2003
+++ libvob/include/vob/vobs/Text.hxx    Sat Aug 16 08:20:14 2003
@@ -38,6 +38,8 @@
 namespace Vob {
 namespace Vobs {
 
+    PREDBGVAR(dbg_text);
+
 typedef GLMosaicText::Renderer<
            GLMosaicText::DenseGlyphs<unsigned short>, 
            unsigned short> 
@@ -61,25 +63,28 @@
        Vertexer(const Coords &c) : c(c) { }
        template<class T> void operator()(const T &x, const T &y) {
            ZVec tmp(x, y, 0);
+           DBG(dbg_text) << "Vertex "<<tmp<<"\n";
            c.vertex(tmp);
        }
     };
 
     template<class T> void render(const T &t) const {
-       if (0) {
-           std::cout << "HorizText:\\n";
+       if (dbg_text) {
+           DBG(dbg_text) << "HorizText:\\n";
            for (typename str::const_iterator it = text.begin(); 
                    it != text.end(); ++it)
-               cout << "'" << (char)*it << "' (" << 
+               DBG(dbg_text) << "'" << (char)*it << "' (" << 
                        (int)*it << ")\\n";
        }
        Vertexer<T> vertexer(t);
+       DBG(dbg_text) << "Start text render "<<rend<<" "<<rend->rend<<"\n";
        GLMosaicText::renderIter(*(rend->rend), text.begin(), text.end(), 
                0,yoffs,
                vertexer, (flags & 1 ? 
                        GLMosaicText::normalBindTexture_01 :
                        GLMosaicText::normalBindTexture)
                );
+       DBG(dbg_text) << "End text render\n";
 
     }
 
Index: libvob/src/main/Renderer.cxx
diff -u libvob/src/main/Renderer.cxx:1.11 libvob/src/main/Renderer.cxx:1.12
--- libvob/src/main/Renderer.cxx:1.11   Sat Aug  9 09:28:35 2003
+++ libvob/src/main/Renderer.cxx        Sat Aug 16 08:20:14 2003
@@ -43,6 +43,7 @@
        DBGVAR(dbg_irregularquad, "IrregularQuad");
        DBGVAR(dbg_vfillets, "VFillets");
        DBGVAR(dbg_calllist, "Calllist");
+       DBGVAR(dbg_text, "Text");
 
        std::string testStateRetainCorrect;
     }
Index: libvob/src/texture/Makefile
diff -u libvob/src/texture/Makefile:1.4 libvob/src/texture/Makefile:1.5
--- libvob/src/texture/Makefile:1.4     Fri Jun  6 16:04:20 2003
+++ libvob/src/texture/Makefile Sat Aug 16 08:20:14 2003
@@ -10,6 +10,9 @@
 
 all: Texture_decl.generated.hxx Texture_const.generated.cxx Texture.o 
$(TEXTURE_OBJS) $(TEXTURE_EXES) Texture_gettexture.o Texture_pipetexture.o
 
+# We have some extra here, since these need to be really fast
+OPTFLAGS=-O3 -ffast-math
+
 %.o : %.texture ../../include/vob/Texture.hxx Makefile
        file=$<; \
        name=$${file%.texture}; \
@@ -19,7 +22,7 @@
          echo "virtual void render(TextureParam *, int, int, int, int, float 
*);"; \
          echo "};"; echo "#line 1 \"$<\""; \
          cat $<; echo "}}"; } > $${name}_tmp.generated.cxx; \
-       $(CXX) $(CXXFLAGS) -x c++ -c $${name}_tmp.generated.cxx -o $@        
+       $(CXX) $(CXXFLAGS) $(OPTFLAGS) -x c++ -c $${name}_tmp.generated.cxx -o 
$@        
 
 %.bin : %.texture binmain.o Texture.o $(EXTRAOBJS) Makefile
        file=$<; \
@@ -31,7 +34,7 @@
          echo "};"; echo ""; \
          echo "Texture *bin_texture = new $$name();"; echo "#line 1 \"$<\""; \
          cat $<; echo "}}"; } > $${name}_tmp2.generated.cxx; \
-       $(CXX) $(CXXFLAGS) $${name}_tmp2.generated.cxx Texture.o binmain.o 
$(EXTRAOBJS) -o $@ ../util/Perlin.o 
+       $(CXX) $(CXXFLAGS) $(OPTFLAGS) $${name}_tmp2.generated.cxx Texture.o 
binmain.o $(EXTRAOBJS) -o $@ ../util/Perlin.o 
 
 Texture_decl.generated.hxx: *.texture
        for file in *.texture; do \
Index: libvob/src/texture/irregu.texture
diff -u libvob/src/texture/irregu.texture:1.4 
libvob/src/texture/irregu.texture:1.5
--- libvob/src/texture/irregu.texture:1.4       Fri Jun  6 16:04:20 2003
+++ libvob/src/texture/irregu.texture   Sat Aug 16 08:20:14 2003
@@ -32,7 +32,7 @@
 
 #define FPARAM(name, default) float name = params->getFloat(#name, default);
 
-#define INVERT(i, x) ((i) + 2 * (0.5 - (i)) * (x))
+#define INVERT(i, x) ((i) + 2 * (0.5f - (i)) * (x))
 
 float filter(float *data, int w, int h, int c, float x, float y) {
     
@@ -96,6 +96,7 @@
     tr(texparams, ',', ' ');
 
     {
+       fprintf(stderr, "reading\n");
        char s[1000];
        sprintf(s, "../libvob/src/texture/%s.bin %d %d %d %d %s", 
                texture,
@@ -113,7 +114,7 @@
 
        fread(data, sizeof(float), width * height * depth * 4, f);
        pclose(f);
-       fprintf(stderr, "\n");
+       fprintf(stderr, "read\n");
     }
 
     for (i = 0; i < width * height * depth * 4; i++) {
@@ -138,6 +139,7 @@
        if (angles)
            data[i] = floor(data[i] * quantize + 0.5) / quantize;
     }
+    fprintf(stderr, "l1\n");
     
     for (int comp = 0; comp < angles && comp < components; comp++) {
 
@@ -152,12 +154,48 @@
                
                float maxh = -1E+10;
                for (float r = -radius; r <= radius; r += eps) {
+
+                   float startx = i + dx * r;
+                   float starty = j + dy * r;
+
+                   int ix0 = (int)floor(startx);
+                   int iy0 = (int)floor(starty);
+                   float fx = startx - ix0;
+                   float fy = starty - iy0;
+
+
+                   int ix1 = ix0 + 1;
+                   int iy1 = iy0 + 1;
+                   ix0 &= width - 1; ix1 &= width - 1;
+                   iy0 &= height - 1; iy1 &= height - 1;
+
+                   float d00 = data[3 + (ix0 + width * iy0) * 4] ;
+                   float d01 = data[3 + (ix0 + width * iy1) * 4] ;
+                   float d10 = data[3 + (ix1 + width * iy0) * 4] ;
+                   float d11 = data[3 + (ix1 + width * iy1) * 4] ;
+
+                   while(r <= radius && fx >= 0 && fx <= 1 &&
+                           fy >= 0 && fy <= 1) {
+                       float val = 
+                           d00 * (1 - fx) * (1 - fy) +
+                           d01 * (1 - fx) * fy +
+                           d10 * fx * (1 - fy) + 
+                           d11 * fx * fy;
+                       val += sqrt(radius * radius - r * r) * m;
+                       if(val > maxh) maxh = val;
+
+                       r += eps;
+                       fx += eps * dx;
+                       fy += eps * dy;
+                   }
+               /*
                    float h = filter(data + 3, width, height, 4, 
                                     i + dx * r, j + dy * r);
 
                    h += sqrt(radius * radius - r * r) * m;
                    //h += radius * scale;
                    if (h > maxh) maxh = h;
+                   */
                }
 
                origdata[ind + comp] = maxh;
@@ -177,13 +215,15 @@
                data[i+3]);
     }
 #endif
+    fprintf(stderr, "l2\n");
 
     for (int i = 0; i < width * height * depth; i++)
        for (int c = angles; c < components; c++) 
            origdata[i * components + c] = data[4 * i + 3 - (c - angles)];
 
     delete[] data;
+    fprintf(stderr, "done\n");
 }
 
 
-
+// vim: syntax=c :
Index: libvob/vob/putil/effects.py
diff -u libvob/vob/putil/effects.py:1.2 libvob/vob/putil/effects.py:1.3
--- libvob/vob/putil/effects.py:1.2     Mon Apr 14 09:44:02 2003
+++ libvob/vob/putil/effects.py Sat Aug 16 08:20:14 2003
@@ -32,14 +32,17 @@
     dicefactor = .4
     # dicefactor = 0.03
 
+    print "Start Irregu shading..."
+
     tex = GL.createTexture()
-    tex.shade(128, 128, 0, 1, "INTENSITY", "LUMINANCE",
+    tex = getCachedTexture([128, 128, 0, 1, "INTENSITY", "LUMINANCE",
              "sawnoise", ["bias", "0.5",
                           "scale", "0.15", "freq", "1", "df", "2", 
-                          "scale2", "0.25", "freq2", "10", "df2", ".5"])
+                          "scale2", "0.25", "freq2", "10", "df2", ".5"]])
     #                       "scale", "0.2", "freq", "1", "df", "2", 
     #                       "scale2", "0.05", "freq2", "12", "df2", "1.5"])
 
+    print "part 1 done"
     ripple_scale = 0.25
     tex2 = getCachedTexture([256, 256, 0, 4, "RGBA", "RGBA",
                              "irregu", ["radius", "2",
@@ -49,6 +52,8 @@
                                         "eps", ".125",
                                         "scaling", "const"]],
                             shade_all_levels = 1)
+
+    print "done"
 
     boxtex = GL.createTexture()
 




reply via email to

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