2003/10/19 02:21:59
[org.ibex.core.git] / src / org / xwt / plat / Win32.cc
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);