From 9cc9bed6bfca1693977031301f5405cf05f05698 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:39:42 +0000 Subject: [PATCH] 2003/10/19 02:21:59 darcs-hash:20040130073942-2ba56-520f6b99a3fa2d9178c062abbf701216972cb949.gz --- src/org/xwt/plat/GCJ.cc | 1 + src/org/xwt/plat/Win32.cc | 14 ++++++++++---- src/org/xwt/plat/Win32.java | 13 ++++++++----- src/org/xwt/plat/X11.cc | 5 ++++- src/org/xwt/plat/X11.java | 11 +++++------ 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/org/xwt/plat/GCJ.cc b/src/org/xwt/plat/GCJ.cc index 4fe25f1..474e640 100644 --- a/src/org/xwt/plat/GCJ.cc +++ b/src/org/xwt/plat/GCJ.cc @@ -23,6 +23,7 @@ extern "C" { #include #include +#define TRUE 1 using org::xwt::util::Log; #define TRUE 1 diff --git a/src/org/xwt/plat/Win32.cc b/src/org/xwt/plat/Win32.cc index 7f5799c..37fcb3f 100644 --- a/src/org/xwt/plat/Win32.cc +++ b/src/org/xwt/plat/Win32.cc @@ -5,6 +5,7 @@ #define INT32 WIN32_INT32 // this has to precede the others so we don't get collisions on min/max +#include #include #include @@ -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); diff --git a/src/org/xwt/plat/Win32.java b/src/org/xwt/plat/Win32.java index 218383d..1bb0bdf 100644 --- a/src/org/xwt/plat/Win32.java +++ b/src/org/xwt/plat/Win32.java @@ -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) { diff --git a/src/org/xwt/plat/X11.cc b/src/org/xwt/plat/X11.cc index 3344622..cd5ce11 100644 --- a/src/org/xwt/plat/X11.cc +++ b/src/org/xwt/plat/X11.cc @@ -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); diff --git a/src/org/xwt/plat/X11.java b/src/org/xwt/plat/X11.java index 6d94727..9973742 100644 --- a/src/org/xwt/plat/X11.java +++ b/src/org/xwt/plat/X11.java @@ -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; } -- 1.7.10.4