2003/10/19 02:21:59
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:42 +0000 (07:39 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:42 +0000 (07:39 +0000)
darcs-hash:20040130073942-2ba56-520f6b99a3fa2d9178c062abbf701216972cb949.gz

src/org/xwt/plat/GCJ.cc
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 4fe25f1..474e640 100644 (file)
@@ -23,6 +23,7 @@ extern "C" {
 #include <org/xwt/plat/GCJ.h>
 #include <org/xwt/util/Log.h>
 
+#define TRUE 1
 using org::xwt::util::Log;
 
 #define TRUE 1
index 7f5799c..37fcb3f 100644 (file)
@@ -5,6 +5,7 @@
 #define INT32 WIN32_INT32
 
 // this has to precede the others so we don't get collisions on min/max
+#include <org/xwt/js/JS.h>
 #include <org/xwt/Box.h>
 
 #include <stdint.h>
@@ -360,8 +361,9 @@ static jint scratch_h = 0;
         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 dx1, jint dy1, jint dx2, jint dy2,
+                                                         jint sx1, jint sy1, jint sx2, jint sy2,
+                                                         jint rgb, jboolean alphaOnly) {
     org::xwt::plat::Win32$Win32Picture* source = (org::xwt::plat::Win32$Win32Picture*)source0;
 
     if (source->hasalpha) {
@@ -398,8 +400,10 @@ void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* sour
                 int sx = (x * (sx2 - sx1)) / (dx2 - dx1) + sx1;
                 int sy = (y * (sy2 - sy1)) / (dy2 - dy1) + sy1;
                 jint dst = scratch_bits[y * scratch_w + x];
-                jint src = dat[sy * source->getWidth() + sx];
-                jint alpha = (src & 0xFF000000) >> 24;
+
+                // 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 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;
@@ -410,6 +414,8 @@ void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* sour
         BitBlt((HDC)hdc, dx1, dy1, dx2 - dx1, dy2 - dy1, (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);
index 218383d..1bb0bdf 100644 (file)
@@ -263,12 +263,15 @@ 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 native void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2);
-
-        //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 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 drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
-            int sx1, int sy1, int sx2, int sy2, int rgb) { }
+                                         int sx1, int sy1, int sx2, int sy2, int rgb) {
+            drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, rgb, true);
+        }
+        public native void drawPicture(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 finalize();
         public void drawPicture(Picture source, int x, int y) {
index 3344622..cd5ce11 100644 (file)
@@ -89,7 +89,7 @@ void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s,
 }
 
 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 dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2, int rgb, int alphaOnly) {
 
     org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
     XImage* xi; 
@@ -123,6 +123,9 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
             
             int sourcepixel = sourcedata[source_x + source_y * source->getWidth()];
             int alpha = (sourcepixel & 0xFF000000) >> 24;
+
+            // FEATURE: be smarter here; can we do something better for the alphaonly case?
+            if (alphaOnly) sourcepixel = rgb;
             int source_red = (sourcepixel & 0x00FF0000) >> 16;
             int source_green = (sourcepixel & 0x0000FF00) >> 8;
             int source_blue = (sourcepixel & 0x000000FF);
index 6d94727..9973742 100644 (file)
@@ -175,23 +175,22 @@ public class X11 extends POSIX {
             cliph = y2 - y; if (cliph < 0) cliph = 0;
         }
         
-        //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) { }
-
+                                         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);
             else 
-                slowDrawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);
+                slowDrawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, 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);
 
         /** 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);
+        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 int getWidth() { return width; }
         public int getHeight() { return height; }