gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gzz/client/Gra...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gzz/client/Gra...
Date: Mon, 14 Oct 2002 14:15:20 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/10/14 14:15:19

Modified files:
        .              : TODO 
        gfx/jni        : GzzGL-jni.cxx 
        gzz/client     : GraphicsAPI.java 
        gzz/client/awt : AWTScreen.java 
        gzz/client/gl  : GLScreen.java 
        gzz/gfx/gl     : GL.java 
        gzz/util       : ColorUtil.java 
        gzz/vob        : RectBgVob.java 
        test/gzz/gfx/gl: checkColor.py 

Log message:
        A more portable scheme to get pixels, for use in awt-gl tests

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.290&tr2=1.291&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/client/GraphicsAPI.java.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/client/awt/AWTScreen.java.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/client/gl/GLScreen.java.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/util/ColorUtil.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/RectBgVob.java.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/gfx/gl/checkColor.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -c gzz/TODO:1.290 gzz/TODO:1.291
*** gzz/TODO:1.290      Mon Oct 14 13:49:29 2002
--- gzz/TODO    Mon Oct 14 14:15:19 2002
***************
*** 63,68 ****
--- 63,70 ----
        - fix Mirror-test bug
        - porting: make sure all demos etc. work with plain mesa
      humppake:
+       - get rid of JniStrConv - isn't that taken care of by
+         GL_Testing?
        - culling of coordsys: coordsys may, at setparams time,
          decide not to be shown.
            - generalizes culledpaperquad
***************
*** 85,95 ****
        + [GI03] libpaper NV2x paletted texture
        + [GI03] irregu animations
        + [GI03] paper animations?
        - Main zz view:
              - Clipping in awt
            - cell size in OpenGL
!               - make graphics tests that work for both OpenGL and AWT!
!           - ZZ vanishingview cell size for pagespans and linebroken
              paragraphs, as well as libpaper backgrounds
        - PP [deadline 5.11]
            - make it work again
--- 87,97 ----
        + [GI03] libpaper NV2x paletted texture
        + [GI03] irregu animations
        + [GI03] paper animations?
+       - graphics tests that work for both OpenGL and AWT
        - Main zz view:
              - Clipping in awt
            - cell size in OpenGL
!           + ZZ vanishingview cell size for pagespans and linebroken
              paragraphs, as well as libpaper backgrounds
        - PP [deadline 5.11]
            - make it work again
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -c gzz/gfx/jni/GzzGL-jni.cxx:1.50 gzz/gfx/jni/GzzGL-jni.cxx:1.51
*** gzz/gfx/jni/GzzGL-jni.cxx:1.50      Thu Oct 10 01:10:21 2002
--- gzz/gfx/jni/GzzGL-jni.cxx   Mon Oct 14 14:15:19 2002
***************
*** 804,809 ****
--- 804,817 ----
      return arr;
  }
  
+ JNIEXPORT jintArray JNICALL Java_gzz_gfx_gl_GL_impl_1ByteVector_1getInts
+   (JNIEnv *env, jclass, jint id) {
+     int len = bytevectors[id]->size() / 4;
+     jintArray arr = env->NewIntArray(len);
+     env->SetIntArrayRegion(arr, 0, len, (jint*) (&(*(bytevectors[id]))[0]));
+     return arr;
+ }
+ 
  
  // Renderable
  
Index: gzz/gzz/client/GraphicsAPI.java
diff -c gzz/gzz/client/GraphicsAPI.java:1.23 
gzz/gzz/client/GraphicsAPI.java:1.24
*** gzz/gzz/client/GraphicsAPI.java:1.23        Thu Oct 10 10:11:02 2002
--- gzz/gzz/client/GraphicsAPI.java     Mon Oct 14 14:15:19 2002
***************
*** 139,144 ****
--- 139,150 ----
        }
        private final GraphicsAPI gfxapi;
  
+       /** Read pixels from the screen.
+        * @return An array of size w*h, of A, R, G, B from 
+        * highest to lowest bit. (BGRA)
+        */
+       public abstract int[] readPixels(int x, int y, int w, int h) ;
+ 
        /** Get the GraphicsAPI this window is associated with.
         */
        public GraphicsAPI getGraphicsAPI() { return gfxapi; }
Index: gzz/gzz/client/awt/AWTScreen.java
diff -c gzz/gzz/client/awt/AWTScreen.java:1.22 
gzz/gzz/client/awt/AWTScreen.java:1.23
*** gzz/gzz/client/awt/AWTScreen.java:1.22      Thu Sep 26 07:54:07 2002
--- gzz/gzz/client/awt/AWTScreen.java   Mon Oct 14 14:15:19 2002
***************
*** 28,40 ****
  
  import gzz.util.InputEventUtil;
  import gzz.util.JavaIncompat;
  
  /** A single output window.
   */
  public abstract class AWTScreen
        extends GraphicsAPI.Window
        implements MouseListener, MouseMotionListener, Obs, 
JUpdateManager.EventProcessor {
!     public static final String rcsid = "$Id: AWTScreen.java,v 1.22 2002/09/26 
11:54:07 benja Exp $";
  
      public static boolean dbg = false;
      private static void p(String s) { if(dbg) pa(s); }
--- 28,41 ----
  
  import gzz.util.InputEventUtil;
  import gzz.util.JavaIncompat;
+ import java.awt.image.PixelGrabber;
  
  /** A single output window.
   */
  public abstract class AWTScreen
        extends GraphicsAPI.Window
        implements MouseListener, MouseMotionListener, Obs, 
JUpdateManager.EventProcessor {
!     public static final String rcsid = "$Id: AWTScreen.java,v 1.23 2002/10/14 
18:15:19 tjl Exp $";
  
      public static boolean dbg = false;
      private static void p(String s) { if(dbg) pa(s); }
***************
*** 111,116 ****
--- 112,129 ----
      VobScene listprev, listnext;
      int[] interplist;
  
+     public int[] readPixels(int x, int y, int w, int h) {
+       int[] pix = new int[w*h];
+       PixelGrabber pg = new PixelGrabber(cache.getSource(),
+                       x, y, w, h, pix, 0, w);
+       try {
+           pg.grabPixels();
+       } catch(InterruptedException e) {
+           throw new Error("Interrupted readpixels");
+       }
+       return pix;
+     }
+ 
      /** Renders a frame of the view animation onto Graphics buffer
       */
      void renderAnimImage(VobScene prev, VobScene next, float fract, float 
lod) {
***************
*** 243,250 ****
              if(useGlobalCache)
                  gr.drawImage(cache, 0, 0, d.width-1, d.height-1,
                                      0, 0, d.width-1, d.height-1, null);
!                 else
!                     gr.drawImage(cache, 0, 0, null);
          }
          public void update(Graphics gr) {
              // Default behaviour overridden because we clear the canvas 
ourselves
--- 256,263 ----
              if(useGlobalCache)
                  gr.drawImage(cache, 0, 0, d.width-1, d.height-1,
                                      0, 0, d.width-1, d.height-1, null);
!           else
!               gr.drawImage(cache, 0, 0, null);
          }
          public void update(Graphics gr) {
              // Default behaviour overridden because we clear the canvas 
ourselves
Index: gzz/gzz/client/gl/GLScreen.java
diff -c gzz/gzz/client/gl/GLScreen.java:1.35 
gzz/gzz/client/gl/GLScreen.java:1.36
*** gzz/gzz/client/gl/GLScreen.java:1.35        Sun Oct  6 09:44:57 2002
--- gzz/gzz/client/gl/GLScreen.java     Mon Oct 14 14:15:19 2002
***************
*** 33,39 ****
  import java.util.HashMap;
  
  public class GLScreen extends GraphicsAPI.Window {
! public static final String rcsid = "$Id: GLScreen.java,v 1.35 2002/10/06 
13:44:57 tjl Exp $";
      public static boolean dbg = false;
      private static void pa(String s) { System.err.println(s); }
  
--- 33,39 ----
  import java.util.HashMap;
  
  public class GLScreen extends GraphicsAPI.Window {
! public static final String rcsid = "$Id: GLScreen.java,v 1.36 2002/10/14 
18:15:19 tjl Exp $";
      public static boolean dbg = false;
      private static void pa(String s) { System.err.println(s); }
  
***************
*** 258,263 ****
--- 258,272 ----
                                               (GLVobCoorder)osc.coords, fract,
                                               true, showFinal);
  
+     }
+ 
+     public int[] readPixels(int x, int y, int w, int h) {
+       GL.ByteVector v = GL.createByteVector(w*h*4);
+       Dimension d = getSize();
+       v.readFromBuffer_ubytes(window, "FRONT",
+                   x, d.height-1-y, w, h,
+                   "BGRA");
+       return v.getInts();
      }
      public float timeRender(VobScene vs, int iters) {
        return ((GLVobCoorder)vs.coords).timeRender(window, (GLVobMap)vs.map,
Index: gzz/gzz/gfx/gl/GL.java
diff -c gzz/gzz/gfx/gl/GL.java:1.12 gzz/gzz/gfx/gl/GL.java:1.13
*** gzz/gzz/gfx/gl/GL.java:1.12 Thu Oct 10 01:10:21 2002
--- gzz/gzz/gfx/gl/GL.java      Mon Oct 14 14:15:19 2002
***************
*** 646,651 ****
--- 646,657 ----
        public byte[] get() {
            return impl_ByteVector_get(getId());
        }
+       /** Get the values from the vector as an array of ints.
+        * Each integer is formed by packing 4 bytes.
+        */
+       public int[] getInts() {
+           return impl_ByteVector_getInts(getId());
+       }
  
      }
      /** Create a new bytevector of size 0.
***************
*** 667,672 ****
--- 673,679 ----
            String format) ;
      static private native int impl_ByteVector_get(int id, int ind);
      static private native byte[] impl_ByteVector_get(int id);
+     static private native int[] impl_ByteVector_getInts(int id);
  
  //----------Misc
  
Index: gzz/gzz/util/ColorUtil.java
diff -c gzz/gzz/util/ColorUtil.java:1.5 gzz/gzz/util/ColorUtil.java:1.6
*** gzz/gzz/util/ColorUtil.java:1.5     Mon Aug 19 16:54:52 2002
--- gzz/gzz/util/ColorUtil.java Mon Oct 14 14:15:19 2002
***************
*** 1,7 ****
  /*   
  ColorUtil.java
   *    
!  *    Copyright (c) 2001, Ted Nelson and Tuomas Lukka
   *
   *    You may use and distribute under the terms of either the GNU Lesser
   *    General Public License, either version 2 of the license or,
--- 1,7 ----
  /*   
  ColorUtil.java
   *    
!  *    Copyright (c) 2001-2002, Ted Nelson and Tuomas Lukka
   *
   *    You may use and distribute under the terms of either the GNU Lesser
   *    General Public License, either version 2 of the license or,
***************
*** 30,36 ****
   */
  
  public final class ColorUtil {
! public static final String rcsid = "$Id: ColorUtil.java,v 1.5 2002/08/19 
20:54:52 benja Exp $";
  
      public static Color[] fadingColors_line(int n) {
        Color[] res = new Color[n];
--- 30,36 ----
   */
  
  public final class ColorUtil {
! public static final String rcsid = "$Id: ColorUtil.java,v 1.6 2002/10/14 
18:15:19 tjl Exp $";
  
      public static Color[] fadingColors_line(int n) {
        Color[] res = new Color[n];
***************
*** 59,64 ****
--- 59,65 ----
        return res;
      }
  
+ 
      public static String colorGLString(Color c) {
        //float[] f = c.getRGBColorComponents(null);
        //return ""+f[0]+" "+f[1]+" "+f[2];
***************
*** 76,79 ****
--- 77,99 ----
                        ((value & GREEN_MASK) >> 8) / 255f + " " +
                        (value & BLUE_MASK) / 255f;
        }
+ 
+     /** Get the average color of an array of colors.
+      */
+     public static Color avgColor(int[] colors) {
+       float r = 0, g = 0, b = 0;
+       for(int i=0; i<colors.length; i++) {
+           int c = colors[i];
+           r += (c >> 16) & 0xff;
+           g += (c >> 8) & 0xff;
+           b += (c >> 0) & 0xff;
+       }
+       r /= colors.length;
+       g /= colors.length;
+       b /= colors.length;
+       r /= 255;
+       g /= 255;
+       b /= 255;
+       return new Color(r, g, b);
+     }
  }
Index: gzz/gzz/vob/RectBgVob.java
diff -c gzz/gzz/vob/RectBgVob.java:1.14 gzz/gzz/vob/RectBgVob.java:1.15
*** gzz/gzz/vob/RectBgVob.java:1.14     Mon Sep 23 04:24:26 2002
--- gzz/gzz/vob/RectBgVob.java  Mon Oct 14 14:15:19 2002
***************
*** 39,45 ****
   */
  
  public class RectBgVob extends Vob {
! public static final String rcsid = "$Id: RectBgVob.java,v 1.14 2002/09/23 
08:24:26 tjl Exp $";
      public static boolean dbg = false;
      static final void p(String s) { if(dbg) System.out.println(s); }
      static final void pa(String s) { System.out.println(s); }
--- 39,45 ----
   */
  
  public class RectBgVob extends Vob {
! public static final String rcsid = "$Id: RectBgVob.java,v 1.15 2002/10/14 
18:15:19 tjl Exp $";
      public static boolean dbg = false;
      static final void p(String s) { if(dbg) System.out.println(s); }
      static final void pa(String s) { System.out.println(s); }
***************
*** 101,127 ****
        if(glList == null) {
            String bgcall = "";
            if(nsolids > 0) {
!               double w = 2.0 / nsolids;
  
                for(int i=0; i<nsolids; i++) {
!                   double x1 = i*w - 1;
                    double x2 = x1 + w;
                    Color c = solids[i];
                      bgcall += (
                        "Color "+ColorUtil.colorGLString(solids[i])+" 1\n"+
                        "Begin QUAD_STRIP\n"+
                        "Vertex "+x1+" 1\n" +
!                       "Vertex "+x1+" -1\n"+
                        "Vertex "+x2+" 1\n"+
!                       "Vertex "+x2+" -1\n"+
                        "End\n");
                }
            } else {
                bgcall = (
                    "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
                    "Begin QUAD_STRIP\n"+
!                   "Vertex 1 1\nVertex 1 -1\n"+
!                   "Vertex -1 1\nVertex -1 -1\n"+
                    "End\n");
            }
  
--- 101,127 ----
        if(glList == null) {
            String bgcall = "";
            if(nsolids > 0) {
!               double w = 1.0 / nsolids;
  
                for(int i=0; i<nsolids; i++) {
!                   double x1 = i*w;
                    double x2 = x1 + w;
                    Color c = solids[i];
                      bgcall += (
                        "Color "+ColorUtil.colorGLString(solids[i])+" 1\n"+
                        "Begin QUAD_STRIP\n"+
                        "Vertex "+x1+" 1\n" +
!                       "Vertex "+x1+" 0\n"+
                        "Vertex "+x2+" 1\n"+
!                       "Vertex "+x2+" 0\n"+
                        "End\n");
                }
            } else {
                bgcall = (
                    "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
                    "Begin QUAD_STRIP\n"+
!                   "Vertex 1 1\nVertex 1 0\n"+
!                   "Vertex 0 1\nVertex 0 0\n"+
                    "End\n");
            }
  
***************
*** 134,142 ****
                "Color 0 0 0 1\n"+
                "Begin LINE_STRIP\n"+
                "Vertex 1 1\n"+
!               "Vertex 1 -1\n"+
!               "Vertex -1 -1\n"+
!               "Vertex -1 1\n"+
                "Vertex 1 1\n"+
                "End\n"+
  
--- 134,142 ----
                "Color 0 0 0 1\n"+
                "Begin LINE_STRIP\n"+
                "Vertex 1 1\n"+
!               "Vertex 1 0\n"+
!               "Vertex 0 0\n"+
!               "Vertex 0 1\n"+
                "Vertex 1 1\n"+
                "End\n"+
  
Index: gzz/test/gzz/gfx/gl/checkColor.py
diff -c gzz/test/gzz/gfx/gl/checkColor.py:1.3 
gzz/test/gzz/gfx/gl/checkColor.py:1.4
*** gzz/test/gzz/gfx/gl/checkColor.py:1.3       Sat Oct 12 06:18:09 2002
--- gzz/test/gzz/gfx/gl/checkColor.py   Mon Oct 14 14:15:19 2002
***************
*** 1,3 ****
--- 1,5 ----
+ import gzz
+ 
  needGL()
  
  win = getGraphicsWindow()
***************
*** 11,33 ****
      vs.coords.renderInterp(win, vs.map, None, None, 0, 1, 1)
  
  def getAvgColor(x, y, w, h):
!     bv = GL.createByteVector(10000)
!     # We want to give the window coords differently, y = 0 is up.
!     bounds = win.window.getBounds()
!     y = bounds.height - 1 - y
!     bv.readFromBuffer_ubytes(win.window, "FRONT", x, y, w, h, "RGB")
!     r = 0.0
!     g = 0.0
!     b = 0.0
!     for i in range(0,w*h):
!       r += bv.get(3*i)
!       g += bv.get(3*i+1)
!       b += bv.get(3*i+2)
!     r /= w*h
!     g /= w*h
!     b /= w*h
! 
!     return (r, g, b)
  
  def checkAvgColor(x, y, w, h, color, delta=10):
      real = getAvgColor(x, y, w, h)
--- 13,22 ----
      vs.coords.renderInterp(win, vs.map, None, None, 0, 1, 1)
  
  def getAvgColor(x, y, w, h):
!     
!     colors = win.readPixels(x, y, w, h)
!     color = gzz.util.ColorUtil.avgColor(colors)
!     return [c*255 for c in color.getComponents(None)]
  
  def checkAvgColor(x, y, w, h, color, delta=10):
      real = getAvgColor(x, y, w, h)




reply via email to

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