2003/10/28 10:10:18
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:40:07 +0000 (07:40 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:40:07 +0000 (07:40 +0000)
darcs-hash:20040130074007-2ba56-9c4b76cab09929293690a3393b06eb61b6d1dde0.gz

src/org/xwt/builtin/splash.xwt
src/org/xwt/plat/AWT.java
src/org/xwt/plat/Darwin.java
src/org/xwt/plat/Java2.java
src/org/xwt/plat/OpenGL.cc
src/org/xwt/plat/OpenGL.java
src/org/xwt/plat/Win32.cc
src/org/xwt/plat/Win32.java
src/org/xwt/plat/X11.cc
src/org/xwt/plat/X11.java

index 9d6ef80..2682d44 100644 (file)
@@ -1,18 +1,17 @@
 <xwt>
 
-    <template thisbox="window" orient="vertical" width="394" height="276">
+    <template orient="vertical" width="394" height="276" color="white">
 
         KeyPressed += function(k) { if (k == "escape") thisbox = null; }
 
         var progress = function(n, d) {
-            $innerbar.width = $bar.width * n / d;
+            $innerbar.width = $bar.width * n / d + 1;
+            $text.text = "downloaded " + (xwt.math.ceil(100 * n/d)) + "%";
             xwt.yield();
         }
 
         xwt.thread = function() {
-            var img = xwt.org.xwt.builtin["splash.png"];
-            fill = img;
-            xwt.yield();
+            xwt.window = thisbox;
             x = (xwt.screenWidth - width) / 2;
             y = (xwt.screenHeight - height) / 2;
             var origin = xwt.origin;
             xwt.println("origin is " + origin);
             var new_rr = xwt.unzip(xwt.watchProgress(xwt.load(origin), progress));
             var new_xwt = xwt.clone(new_rr);
+            $text.font = xwt.fonts.vera["Vera.ttf"];
+$text.textcolor = "#f11ff1";
+            $text.fontsize = 80;
+            $text.text = "downloading...";
+Press1 += function() { xwt.thread = function() {
+            var img = xwt.org.xwt.builtin["splash.png"];
+            fill = img;
+            xwt.yield();
             new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
+            thisbox = null;
+} }
         }
 
-        <box packed="false" id="bar" x="20" y="236" width="354" height="18" align="left">
+        <box height="236" align="bottomleft" packed="false" x="20" y="0">
+            <box fontcolor="white" id="text" shrink="true"/>
+        </box>
+        <box packed="false" id="bar" x="20" y="236" width="354" height="20" align="left">
             <box id="innerbar" fill="blue" width="10"/>
         </box>
 
index 771bdbb..fd9703b 100644 (file)
@@ -126,11 +126,11 @@ public class AWT extends JVM {
         
         public AWTPicture(int[] b, int w, int h) {
             data = b;
-            Image img = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, cmodel, b, 0, w));
+            i = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, cmodel, b, 0, w));
             MediaTracker mediatracker = new MediaTracker(new Canvas());
-            mediatracker.addImage(img, 1);
+            mediatracker.addImage(i, 1);
             try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
-            mediatracker.removeImage(img);
+            mediatracker.removeImage(i);
             synchronized(AWTPixelBuffer.class) { 
                 if (AWTPixelBuffer.component == null) {
                     AWTPixelBuffer.component = new Frame();
@@ -138,8 +138,6 @@ public class AWT extends JVM {
                     AWTPixelBuffer.component.addNotify();
                 }
             }
-            this.i = AWTPixelBuffer.component.createImage(w, h);
-            this.i.getGraphics().drawImage(img, 0, 0, null);
         }
     }
     
@@ -166,24 +164,32 @@ public class AWT extends JVM {
         
         public int getHeight() { return i == null ? 0 : i.getHeight(null); }
         public int getWidth() { return i == null ? 0 : i.getWidth(null); }
-        public void setClip(int x, int y, int x2, int y2) { g.setClip(x, y, x2 - x, y2 - y); }
 
-        public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
-            g.drawImage(((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
-        }
-        
-        public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
-                                         int sx1, int sy1, int sx2, int sy2, int rgb) {
-            AWTPicture p = (AWTPicture)source;
-            Graphics g = p.i.getGraphics();
-            g.setXORMode(new Color(rgb));
-            g.fillRect(0, 0, p.i.getWidth(null), p.i.getHeight(null));
-            drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);
-            g.fillRect(0, 0, p.i.getWidth(null), p.i.getHeight(null));
+        public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
+            g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
+            g.drawImage(((AWTPicture)source).i, dx, dy, null);
+            g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
         }
 
-        public void fillRect(int x, int y, int x2, int y2, int argb) {
-            // FEATURE: use an LRU cache for Color objects
+        /** implemented with java.awt 1.1's setXORMode() */
+        public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+
+            // XOR the target region
+            g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+            g.setColor(new Color(0x0, 0x0, 0x0));
+            g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+
+            // blacken the area we want the glyph to cover
+            g.setPaintMode();
+            drawPicture(source, dx, dy, cx1, cy1, cx2, cy2);
+
+            // XOR back, turning black into the chosen rgb color
+            g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+            g.setColor(new Color(0x0, 0x0, 0x0));
+            g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+
+            // restore the graphics context
+            g.setPaintMode();
         }
 
         // FIXME: try to use os acceleration
@@ -235,7 +241,7 @@ public class AWT extends JVM {
         public void setLocation() { window.setLocation(root.x, root.y); }
         public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); }
         public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
-        public void setSize(int width, int height) { window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
+        public void _setSize(int width, int height) { window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
         public void setInvisible(boolean b) { window.setVisible(!b); }
         protected void _setMinimized(boolean b) { if (Log.on) Log.log(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
         protected void _setMaximized(boolean b) {
index a3e4141..44d0ec2 100644 (file)
@@ -145,7 +145,7 @@ public class Darwin extends POSIX {
         private native void natSetTitleBarText(String s);
         public void setTitleBarText(final String s) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetTitleBarText(s); } }); }
         private native void natSetSize(int w, int h);
-        public void setSize(final int w, final int h) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetSize(w,h); } }); }
+        public void _setSize(final int w, final int h) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetSize(w,h); } }); }
         private native void natSetLocation();
         public void setLocation() { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetLocation(); } }); }
         private native void natToFront();
@@ -244,10 +244,10 @@ public class Darwin extends POSIX {
             super.setLimits(mnw,mnh,mxw,mxh);
         }
         
-        public void setSize(int w, int h) {
+        public void _setSize(int w, int h) {
             w = Math.min(w,gl.maxSurfaceWidth);
             h = Math.min(h,gl.maxSurfaceWidth);
-            super.setSize(w,h);
+            super._setSize(w,h);
         }
         
         private native void natBlit(GLCarbonPixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2);
index 28522d1..e596c62 100644 (file)
@@ -89,23 +89,6 @@ public class Java2 extends AWT {
                 }});
     }
 
-    protected Socket __getSocket(String host, int port, boolean ssl, boolean negotiate) throws IOException {
-        return super._getSocket(host, port, ssl, negotiate);
-    }
-    protected Socket _getSocket(final String host, final int port, final boolean ssl, final boolean negotiate) throws IOException {
-        return (Socket)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
-                public Object run() {
-                    try {
-                        return __getSocket(host, port, ssl, negotiate);
-                    } catch (Exception e) {
-                        if (Log.on) Log.log(Java2.class, "Error attempting to create socket");
-                        if (Log.on) Log.log(Java2.class, e);
-                        return null;
-                    }
-                }
-            });
-    }
-    
     protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return new Java2PixelBuffer(w, h); }
     protected Surface _createSurface(final Box root, final boolean framed) {
         return (Surface)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
@@ -190,11 +173,7 @@ public class Java2 extends AWT {
         private static int[] ibank = null;
         private static byte[] bbank = null;
         private static int bank_start = 0;
-        
-        public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
-            _doDrawImage(g, ((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
-        }
-        
+
         public Java2PixelBuffer(int w, int h) {
             SampleModel sm = cm.createCompatibleSampleModel(w, h);
             int numSamples = w * h * sm.getNumDataElements();
@@ -238,31 +217,6 @@ public class Java2 extends AWT {
         }
     }
 
-    /** used to avoid garbage creation with getClipBounds() */
-    private static Rectangle clipBounds = new Rectangle();
-    
-    protected static void _doDrawImage(Graphics g, Image i, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver o) {
-        if (dx1 == dx2 || dy1 == dy2) return;
-        g.drawImage(i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, o);
-    }
-
-    private String __getClipBoard() { return super._getClipBoard(); }
-    protected String _getClipBoard() {
-        return (String)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
-                public Object run() { return __getClipBoard();  }
-            });
-    }
-
-    private void __setClipBoard(String s) { super._setClipBoard(s); }
-    protected void _setClipBoard(final String s) {
-        java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
-                public Object run() {
-                    __setClipBoard(s);
-                    return null;
-                }
-            });
-    }
-
     protected String getDescriptiveName() { return isJava14 ? "Java 1.4+ JVM" : "Java 1.2+ JVM"; }
 
 }
index 5540c2d..b7b0eeb 100644 (file)
@@ -88,12 +88,12 @@ void OpenGL$GLPixelBuffer::setColor(jint argb) {
 void OpenGL$GLPixelBuffer::fillTrapezoid(jint x1, jint x2, jint y1, jint x3, jint x4, jint y2, jint color) {
     activateContext();
     setColor(color);
-    glBegin(GL_QUADS); 
+    glBegin(GL_QUADS); {
         glVertex3f(x1,y1,0.0f );   
         glVertex3f(x3,y2,0.0f );  
         glVertex3f(x4,y2,0.0f ); 
         glVertex3f(x2,y1,0.0f ); 
-    glEnd();
+    } glEnd();
 }
 
 void OpenGL$GLPixelBuffer::setClip(jint x1, jint y1, jint x2, jint y2) {
@@ -176,21 +176,21 @@ void OpenGL$RectGLPicture::natInit(Object *data_, jboolean alphaOnly) {
     textureName = (jint)tex;
 }
 
-void OpenGL$RectGLPicture::draw(jint dx1, jint dy1, jint dx2, jint dy2,jint sx1, jint sy1, jint sx2, jint sy2) { 
-       glEnable(GL_TEXTURE_RECTANGLE_EXT);
-       glBindTexture(GL_TEXTURE_RECTANGLE_EXT, textureName);    
-       glBegin(GL_QUADS); 
-       glTexCoord2i (sx1, sy1   );
-        glVertex3i   (dx1, dy1, 0);   
-        glTexCoord2i (sx2, sy1   ); 
-        glVertex3i   (dx2, dy1, 0);
-        glTexCoord2i (sx2, sy2   ); 
-        glVertex3i   (dx2, dy2, 0);
-        glTexCoord2i (sx1, sy2   );
-        glVertex3i   (dx1, dy2, 0);
-       glEnd();
-       glDisable(GL_TEXTURE_RECTANGLE_EXT);
-       checkGLError();
+void OpenGL$RectGLPicture::draw(jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) { 
+    glEnable(GL_TEXTURE_RECTANGLE_EXT);
+    glBindTexture(GL_TEXTURE_RECTANGLE_EXT, textureName);    
+    glBegin(GL_QUADS); {
+      glTexCoord2i (cx1 - dx, cy1 - dy   );
+      glVertex3i   (dx1,      dy1,      0);
+      glTexCoord2i (cx2 - dx, cy1 - dy   );
+      glVertex3i   (dx2,      dy1,      0);
+      glTexCoord2i (cx2 - dx, cy2 - dy   );
+      glVertex3i   (dx2,      dy2,      0);
+      glTexCoord2i (cx1 - dx, cy2 - dy   );
+      glVertex3i   (dx1,      dy2,      0);
+    } glEnd();
+    glDisable(GL_TEXTURE_RECTANGLE_EXT);
+    checkGLError();
 }
 
 void OpenGL::natDeleteTexture(jint tex_) {
@@ -267,26 +267,20 @@ void OpenGL$SquareGLPicture::natInit(Object *data_, jboolean alphaOnly) {
     textureName = (jint)tex;
 }
 
-void OpenGL$SquareGLPicture::draw(jint dx1, jint dy1, jint dx2, jint dy2,jint sx1, jint sy1, jint sx2, jint sy2) {
-    float tx1,ty1,tx2,ty2; // normalized texture coords
-    tx1 = (float) sx1 / (float) texWidth;
-    ty1 = (float) sy1 / (float) texHeight;
-    tx2 = (float) sx2 / (float) texWidth;
-    ty2 = (float) sy2 / (float) texHeight;
-
+void OpenGL$SquareGLPicture::draw(jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) {
     glEnable(GL_TEXTURE_2D);
     glBindTexture(GL_TEXTURE_2D, textureName);    
     checkGLError();
-    glBegin(GL_QUADS); 
-        glTexCoord2f (tx1, ty1   );
-        glVertex3i   (dx1, dy1, 0);
-        glTexCoord2f (tx2, ty1   ); 
-        glVertex3i   (dx2, dy1, 0);
-        glTexCoord2f (tx2, ty2   ); 
-        glVertex3i   (dx2, dy2, 0);
-        glTexCoord2f (tx1, ty2   );
-        glVertex3i   (dx1, dy2, 0);
-    glEnd();
+    glBegin(GL_QUADS); {
+        glTexCoord2f (cx1 - dx, cy1 - dy   );
+        glVertex3i   (dx1,      dy1,      0);
+        glTexCoord2f (cx2 - dx, cy1 - dy   );
+        glVertex3i   (dx2,      dy1,      0);
+        glTexCoord2f (cx2 - dx, cy2 - dy   );
+        glVertex3i   (dx2,      dy2,      0);
+        glTexCoord2f (cx1 - dx, cy2 - dy   );
+        glVertex3i   (dx1,      dy2,      0);
+    } glEnd();
     glDisable(GL_TEXTURE_2D);
     checkGLError();
 }
index 284fb62..68ed8c1 100644 (file)
@@ -79,21 +79,19 @@ abstract class OpenGL {
         public void drawString(String font, String text, int x, int y, int color) {
             //System.out.println("drawString(): " + text);
         }
-        
-        //public native void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
-        //int sx1, int sy1, int sx2, int sy2, int rgb);
-        public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, int rgb) {
-            drawPicture_(source,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,rgb);
+
+        public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+            drawPicture_(source, dx, dy, cx1, cy1, cx2, cy2, rgb);
         }
-        public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2) {
-            drawPicture_(source,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,0xffffffff);
+        public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
+            drawPicture_(source, dx, dy, cx1, cy1, cx2, cy2, 0xffffffff);
         }
 
-        private void drawPicture_(Picture source, int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2, int color) {
+        private void drawPicture_(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int color) {
             activateContext();
             setColor(color);
             GLPicture p = (GLPicture) source;
-            p.draw(dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2);
+            p.draw(dx,dy,cx1,cy1,cx2,cy2);
         }
     }
     
@@ -139,7 +137,7 @@ abstract class OpenGL {
             this.height = h;
         }
         
-        public abstract void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2);
+        public abstract void draw(int dx, int dy, int cx1, int cy1, int cx2, int cy2);
         protected abstract void finalize();
     }
     
@@ -155,7 +153,7 @@ abstract class OpenGL {
             natInit(data,alphaOnly);
         }
     
-        public native void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2);  
+        public native void draw(int dx, int dy, int cx1, int cy1, int cx2, int cy2);  
         protected void finalize() { gl.deleteTexture(textureName); }
     }
     
@@ -176,7 +174,7 @@ abstract class OpenGL {
             natInit(data,alphaOnly);
         }
         
-        public native void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2); 
+        public native void draw(int dx, int dy, int cx1, int cy1, int cx2, int cy2);  
         protected void finalize() { gl.deleteTexture(textureName); }
     }
     
@@ -243,33 +241,22 @@ abstract class OpenGL {
         private static final int max(int a, int b) { return a > b ? a : b; }
         private static final int min(int a, int b) { return a < b ? a : b; }
         
-        public void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2) {
-            double xscale = (double)(dx2-dx1)/(double)(sx2-sx1);
-            double yscale = (double)(dy2-dy1)/(double)(sy2-sy1);
+        public void draw(int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
             int totalWidth = width;
             int totalHeight = height;
             // *{x,y}{1,2} key: d=dest s=src, p=bounds of this picture, i=intersection of s and p, pd = dest of this pic
-            //System.out.println("Starting draw..." + sx1 + "," + sy1 + " " + sx2 + "," + sy2 + " to " + dx1 +"," + dy1 + " " + dx2 + "," + dy2);
             for(int i=0;i<pics.length;i++) {
                 for(int j=0;j<pics[i].length;j++) {
                     int px1 = j*psize;
                     int py1 = i*psize;
                     int px2 = min(px1+psize,totalWidth);
                     int py2 = min(py1+psize,totalHeight);
-                    int ix1 = max(px1,sx1);
-                    int iy1 = max(py1,sy1);
-                    int ix2 = min(px2,sx2);
-                    int iy2 = min(py2,sy2);
-                    if(ix1 >= ix2 || iy1 >= iy2) continue; // no intersection
-                    
-                    int pdx1 = dx1 + (int) (xscale*(ix1-sx1));
-                    int pdy1 = dy1 + (int) (yscale*(iy1-sy1));
-                    int pdx2 = dx2 - (int) (xscale*(sx2-ix2));
-                    int pdy2 = dy2 - (int) (yscale*(sy2-iy2));
-                    
-                    //System.out.println("" + i + "," + j + " is good... drawing from " + (ix1-px1) + "," + (iy1-py1) + " " + (ix2-px1) + "," + (iy2-py1) + " to " + pdx1 + "," + pdy1 + " to " + pdx2 + "," + pdy2);
-                    
-                    pics[i][j].draw(pdx1,pdy1,pdx2,pdy2,ix1-px1,iy1-py1,ix2-px1,iy2-py1);
+                    int ix1 = max(px1,cx1);
+                    int iy1 = max(py1,cy1);
+                    int ix2 = min(px2,cx2);
+                    int iy2 = min(py2,cy2);
+                    if (ix1 >= ix2 || iy1 >= iy2) continue; // no intersection
+                    pics[i][j].draw(px1, py1, ix1, iy1, ix2, iy2);
                 }
             }
         }
index 37fcb3f..95fe5f7 100644 (file)
@@ -354,25 +354,19 @@ static jint* scratch_bits = NULL;
 static jint scratch_w = 0;
 static jint scratch_h = 0;
 
-#define BLT(dest, dx1, dy1, dx2, dy2, src, sx1, sy1, sx2, sy2, op)                                   \
-    if ((dx2 - dx1 == sx2 - sx1) && (dy2 - dy1 == sy2 - sy1))                                        \
-        BitBlt(dest, dx1, dy1, dx2 - dx1, dy2 - dy1, src, sx1, sy1, op);                             \
-    else                                                                                             \
-        StretchBlt(dest, dx1, dy1, dx2 - dx1, dy2 - dy1, src, sx1, sy1, sx2 - sx1, sy2 - sy1, op);
-        
 void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* source0,
-                                                         jint dx1, jint dy1, jint dx2, jint dy2,
-                                                         jint sx1, jint sy1, jint sx2, jint sy2,
+                                                         jint dx, jint dy,
+                                                         jint cx1, jint cy1, jint cx2, jint cy2,
                                                          jint rgb, jboolean alphaOnly) {
     org::xwt::plat::Win32$Win32Picture* source = (org::xwt::plat::Win32$Win32Picture*)source0;
 
     if (source->hasalpha) {
 
-        if (scratch == NULL || scratch_w < dx2 - dx1 || scratch_h < dy2 - dy1) {
+        if (scratch == NULL || scratch_w < cx2 - cx1 || scratch_h < cy2 - cy1) {
             if (scratch_dc != NULL) DeleteDC(scratch_dc);
             if (scratch != NULL) DeleteObject(scratch);
-            scratch_w = max(dx2 - dx1, scratch_w);
-            scratch_h = max(dy2 - dy1, scratch_h);
+            scratch_w = max(cx2 - cx1, scratch_w);
+            scratch_h = max(cy2 - cy1, scratch_h);
 
             BITMAPINFO bitmapinfo;
             memset(&bitmapinfo, 0, sizeof(BITMAPINFO));
@@ -390,37 +384,35 @@ void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* sour
         }
 
         // copy from screen to scratch
-        BitBlt((HDC)scratch_dc, 0, 0, dx2 - dx1, dy2 - dy1, (HDC)hdc, dx1, dy1, SRCCOPY);
+        BitBlt((HDC)scratch_dc, 0, 0, cx2 - cx1, cy2 - cy1, (HDC)hdc, cx1, cy1, SRCCOPY);
 
         // apply alpha-blending to scratch
         jint* dat = elements(source->data);
 
-        for(int x = max(clipx1, dx1) - dx1; x < min(clipx2, dx2) - dx1; x++)
-            for(int y = max(clipy1, dy1) - dy1; y < min(clipy2, dy2) - dy1; y++) {
-                int sx = (x * (sx2 - sx1)) / (dx2 - dx1) + sx1;
-                int sy = (y * (sy2 - sy1)) / (dy2 - dy1) + sy1;
-                jint dst = scratch_bits[y * scratch_w + x];
+        for(int x = cx1; x < cx2; x++)
+            for(int y = cy1; y < cy2; y++) {
+                jint dst = scratch_bits[(y - dy) * scratch_w + (x - dx)];
 
                 // FEATURE: see if we can leverage GDI to do something more clever here with alphaOnly
-                jint src = alphaOnly ? rgb : dat[sy * source->getWidth() + sx];
-                jint alpha = (dat[sy * source->getWidth() + sx] & 0xFF000000) >> 24;
+                jint src = alphaOnly ? rgb : dat[(y - dy) * source->getWidth() + x - dx];
+                jint alpha = (dat[(y - dy) * source->getWidth() + x - dx] & 0xFF000000) >> 24;
                 jint r = (((src & 0x00FF0000) >> 16) * alpha + ((dst & 0x00FF0000) >> 16) * (0xFF - alpha)) / 0xFF;
                 jint g = (((src & 0x0000FF00) >> 8)  * alpha + ((dst & 0x0000FF00) >> 8)  * (0xFF - alpha)) / 0xFF;
                 jint b = (((src & 0x000000FF))       * alpha + ((dst & 0x000000FF))       * (0xFF - alpha)) / 0xFF;
-                scratch_bits[y * scratch_w + x] = (r << 16) | (g << 8) | b;
+                scratch_bits[(y - dy) * scratch_w + (x - dx)] = (r << 16) | (g << 8) | b;
             }
 
         // copy back from scratch to screen
-        BitBlt((HDC)hdc, dx1, dy1, dx2 - dx1, dy2 - dy1, (HDC)scratch_dc, 0, 0, SRCCOPY);
+        BitBlt((HDC)hdc, cx1, cy1, cx2, cy2, (HDC)scratch_dc, 0, 0, SRCCOPY);
 
     } else {
 
         // FIXME: support alphaOnly case here
         if (source->hasmask) {
-            BLT((HDC)hdc, dx1, dy1, dx2, dy2, (HDC)source->maskdc, sx1, sy1, sx2, sy2, SRCAND);
-            BLT((HDC)hdc, dx1, dy1, dx2, dy2, (HDC)source->hdc, sx1, sy1, sx2, sy2, SRCPAINT);
+            BitBlt((HDC)hdc, cx1, cy1, cx2, cy2, (HDC)source->maskdc, cx1 - dx, cy1 - dy, SRCAND);
+            BitBlt((HDC)hdc, cx1, cy1, cx2, cy2, (HDC)source->hdc, cx1 - dx, cy1 - dy, SRCPAINT);
         } else {
-            BLT((HDC)hdc, dx1, dy1, dx2, dy2, (HDC)source->hdc, sx1, sy1, sx2, sy2, SRCCOPY);
+            BitBlt((HDC)hdc, cx1, cy1, cx2, cy2, (HDC)source->hdc, cx1 - dx, cy1 - dy, SRCCOPY);
         }
 
     }
@@ -452,13 +444,6 @@ void org::xwt::plat::Win32$Win32PixelBuffer::natInit() {
     SelectObject((HDC)hdc, (HBITMAP)hbitmap);
 }
 
-void org::xwt::plat::Win32$Win32PixelBuffer::setClip(jint x, jint y, jint x2, jint y2) {
-    clipx1 = x; clipx2 = x2; clipy1 = y; clipy2 = y2;
-    HRGN hrgn = CreateRectRgn(x, y, x2, y2);
-    SelectClipRgn((HDC)hdc, hrgn);
-    DeleteObject(hrgn);
-}
-
 void org::xwt::plat::Win32$Win32PixelBuffer::finalize() {
     DeleteObject((void*)hdc);
     DeleteObject((void*)hbitmap);
@@ -552,7 +537,7 @@ void org::xwt::plat::Win32$Win32Surface::setLocation() {
     SetWindowPos((HWND)hwnd, NULL, root->x - (point.x - rect.left), root->y - (point.y - rect.top), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
 }
 
-void org::xwt::plat::Win32$Win32Surface::setSize(jint w, jint h) {
+void org::xwt::plat::Win32$Win32Surface::_setSize(jint w, jint h) {
     RECT client_rect, window_rect;
     GetClientRect((HWND)hwnd, &client_rect);
     GetWindowRect((HWND)hwnd, &window_rect);
@@ -582,7 +567,7 @@ void org::xwt::plat::Win32$Win32Surface::setIcon(org::xwt::Picture* p0) {
     HBITMAP bit = CreateCompatibleBitmap((HDC)hdc, icon_width, icon_height);
     HDC memdc = CreateCompatibleDC((HDC)hdc);
     SelectObject(memdc, bit);
-    BLT((HDC)memdc, 0, 0, icon_width, icon_height, (HDC)(p->hdc), 0, 0, p->getWidth(), p->getHeight(), SRCCOPY);
+    BitBlt((HDC)memdc, 0, 0, icon_width, icon_height, (HDC)(p->hdc), 0, 0, SRCCOPY);
 
     // create the mask
     jint* dat = elements(p->data);
index 1bb0bdf..a1891dc 100644 (file)
@@ -193,7 +193,7 @@ public class Win32 extends GCJ {
         public native void _setMinimized(boolean m);
         public native void setInvisible(boolean i);
         public native void _setMaximized(boolean m);
-        public native void setSize(int w, int h);
+        public native void _setSize(int w, int h);
         public native void setLocation();
         public native void setTitleBarText(String s);
         public native void setIcon(Picture p);
@@ -263,20 +263,16 @@ public class Win32 extends GCJ {
 
         public native void setClip(int x, int y, int x2, int y2);
         public native void fillRect(int x, int y, int x2, int y2, int color);
-        public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
-            drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, 0, false);
+        public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
+            drawPicture(source, dx, dy, cx1, cy1, cx2, cy2, 0, false);
         }
-        public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
-                                         int sx1, int sy1, int sx2, int sy2, int rgb) {
-            drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, rgb, true);
+        public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+            drawPicture(source, dx, dy, cx1, cy1, cx2, cy2, rgb, true);
         }
-        public native void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
+        public native void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2,
                                        int rgb, boolean alphaOnly);
 
         public native void finalize();
-        public void drawPicture(Picture source, int x, int y) {
-            drawPicture(source, x, y, x + source.getWidth(), y + source.getHeight(), 0, 0, source.getWidth(), source.getHeight());
-        }
 
         // FIXME: try to use os acceleration
         public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) {
index 629b2e7..c825f25 100644 (file)
@@ -67,29 +67,23 @@ static void ensureShmSize(int size) {
 }
 
 void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s,
-                                                            jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2) {
+                                                         jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) {
     org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
-
-    // it's safe to clip manually since we no that no scaling will be done
-    if (dx1 < clipx) { sx1 += ((clipx - dx1) * (sx2 - sx1)) / (dx2 - dx1); dx1 = clipx; }
-    if (dy1 < clipy) { sy1 += ((clipy - dy1) * (sy2 - sy1)) / (dy2 - dy1); dy1 = clipy; }
-    if (dx2 > clipx + clipw) { sx2 -= ((dx2 - clipx - clipw) * (sx2 - sx1)) / (dx2 - dx1); dx2 = clipx + clipw; }
-    if (dy2 > clipy + cliph) { sy2 -= ((dy2 - clipy - cliph) * (sy2 - sy1)) / (dy2 - dy1); dy2 = clipy + cliph; }
-    if (dx1 > clipx + clipw) return;
-    if (dy1 > clipy + cliph) return;
-    if (dx2 - dx1 <= 0 || dy2 - dy1 <= 0) return;
     
     if (source->doublebuf->stipple != NULL) {
         XSetClipMask(display, (*((GC*)clipped_gc)), *((Pixmap*)source->doublebuf->stipple));
-        XSetClipOrigin(display, (*((GC*)clipped_gc)), dx1 - sx1, dy1 - sy1);
+        XSetClipOrigin(display, (*((GC*)clipped_gc)), cx1 - dx, cy1 - dy);
     } else {
         XSetClipMask(display, (*((GC*)clipped_gc)), None);
     }
-    XCopyArea(display, *((Pixmap*)source->doublebuf->pm), (*((Pixmap*)pm)), (*((GC*)clipped_gc)), sx1, sy1, sx2 - sx1, sy2 - sy1, dx1, dy1);
+    XCopyArea(display,
+              *((Pixmap*)source->doublebuf->pm), (*((Pixmap*)pm)), (*((GC*)clipped_gc)),
+              cx1 - dx, cy1 - cy, cx2 - cx1, cy2 - cy1, dx, dy);
 }
 
 void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
-                                                            jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2, jint rgb, jboolean alphaOnly) {
+                                                         jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2,
+                                                         jint rgb, jboolean alphaOnly) {
 
     org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
     XImage* xi; 
@@ -101,26 +95,26 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
 
     // MEDIUM: write to a shared ximage, then ask the server to do the blit
     } else if (shm_supported) {
-        xi = XShmCreateImage(display, visual, colorDepth, ZPixmap, NULL, &shm_info, dx2 - dx1, dy2 - dy1);
+        xi = XShmCreateImage(display, visual, colorDepth, ZPixmap, NULL, &shm_info, cx2 - cx1, cy2 - cy1);
         ensureShmSize(xi->bytes_per_line * xi->height);
         xi->data = shm_info.shmaddr;
-        XShmGetImage(display, (*((Pixmap*)pm)), xi, dx1, dy1, AllPlanes);
+        XShmGetImage(display, (*((Pixmap*)pm)), xi, cx1, cy1, AllPlanes);
         
     // SLOWEST: write to an ximage, copy it through the TCP connection, ask the server to do the blit
     } else {
-        xi = XGetImage(display, (*((Pixmap*)pm)), dx1, dy1, dx2 - dx1, dy2 - dy1, AllPlanes, ZPixmap);
+        xi = XGetImage(display, (*((Pixmap*)pm)), cx1, cy1, cx2 - cx1, cy2 - cy1, AllPlanes, ZPixmap);
     }
     
     int* sourcedata = (int*)elements(source->data);
-    for(int y=max(dy1, clipy); y<min(dy2, clipy + cliph); y++) {
-        
+    for(int y=cy1; y < cy2; y++) {
+
         char* current_pixel = (xi->data + y * xi->bytes_per_line) +
-            (shared_pixmap ? max(dx1, clipx) * (xi->bits_per_pixel / 8) : - 1 * dy1 * xi->bytes_per_line);
+            (shared_pixmap ? cx1 * (xi->bits_per_pixel / 8) : - 1 * cy1 * xi->bytes_per_line);
         
-        for(int x=max(dx1, clipx); x<min(dx2, clipx + clipw); x++, current_pixel += xi->bits_per_pixel / 8) {
-            int source_x = ((x - dx1) * (sx2 - sx1)) / (dx2 - dx1) + sx1;
-            int source_y = ((y - dy1) * (sy2 - sy1)) / (dy2 - dy1) + sy1;
-            
+        for(int x=cx1; x < cx1; x++, current_pixel += xi->bits_per_pixel / 8) {
+            int source_x = x - dx;
+            int source_y = y - dy;
+
             int sourcepixel = sourcedata[source_x + source_y * source->getWidth()];
             int alpha = (sourcepixel & 0xFF000000) >> 24;
 
@@ -183,11 +177,11 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
         // do nothing, we wrote directly to video memory
         
     } else if (shm_supported) {
-        XShmPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, dx1, dy1, dx2 - dx1, dy2 - dy1, False);
+        XShmPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, cx1, cy1, cx2 - cx1, cy2 - cy1, False);
         XDestroyImage(xi);
         
     } else {
-        XPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, dx1, dy1, dx2 - dx1, dy2 - dy1);
+        XPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, cx1, cy1, cx2 - cx1, cy2 - cy1);
         
     }
 }
@@ -343,7 +337,7 @@ void org::xwt::plat::X11$X11Surface::setLimits(jint minw, jint minh, jint maxw,
     XSetWMNormalHints(display, (*((Window*)window)), &hints);
 }
 
-void org::xwt::plat::X11$X11Surface::setSize (jint width, jint height) {
+void org::xwt::plat::X11$X11Surface::_setSize (jint width, jint height) {
     if (width <= 0 || height <= 0) return;
     XResizeWindow(display, (*((Window*)window)), width, height);
     XFlush(display);
index 9973742..ba739ec 100644 (file)
@@ -66,7 +66,7 @@ public class X11 extends POSIX {
         public native void setIcon(Picture p);
         public native void _setMinimized(boolean b);
         public native void setTitleBarText(String s);
-        public native void setSize(int w, int h);
+        public native void _setSize(int w, int h);
         public native void setLocation();
         public native void natInit();
         public native void toFront();
@@ -125,7 +125,7 @@ public class X11 extends POSIX {
             if (doublebuf != null) return;
             // no point in using a shared pixmap since we'll only write to this image once
             X11PixelBuffer b = new X11PixelBuffer(width, height, false);
-            b.drawPicture(this, 0, 0, width, height, 0, 0, width, height);
+            b.drawPicture(this, 0, 0, 0, 0, width, height);
             if (needsStipple) b.createStipple(this);
             doublebuf = b;
         }
@@ -168,29 +168,21 @@ public class X11 extends POSIX {
             natInit();
         }
 
-        public void setClip(int x, int y, int x2, int y2) {
-            clipx = x; if (clipx < 0) clipx = 0;
-            clipy = y; if (clipy < 0) clipy = 0;
-            clipw = x2 - x; if (clipw < 0) clipw = 0;
-            cliph = y2 - y; if (cliph < 0) cliph = 0;
+        public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {        
+            slowDrawPicture(source, dx, dy, cx1, cy1, cx2, cy2, rgb, true);
         }
-        
-        public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
-                                         int sx1, int sy1, int sx2, int sy2, int rgb) {
-            slowDrawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, rgb, true);
-        }
-        public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
-            if (!(dx2 - dx1 != sx2 - sx1 || dy2 - dy1 != sy2 - sy1) && ((X11Picture)source).doublebuf != null)
-                fastDrawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);
+        public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
+            if (((X11Picture)source).doublebuf != null)
+                fastDrawPicture(source, dx, dy, cx1, cy1, cx2, cy2);
             else 
-                slowDrawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, 0, false);
+                slowDrawPicture(source, dx, dy, cx1, cy1, cx2, cy2, 0, false);
         }
 
         /** fast path for image drawing (no scaling, all-or-nothing alpha) */
-        public native void fastDrawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2);
+        public native void fastDrawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2);
 
         /** slow path for image drawing */
-        public native void slowDrawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, int rgb, boolean alphaOnly);
+        public native void slowDrawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb, boolean alphaOnly);
 
         public int getWidth() { return width; }
         public int getHeight() { return height; }