#include <org/xwt/plat/GCJ.h>
#include <org/xwt/util/Log.h>
+#define TRUE 1
using org::xwt::util::Log;
#define TRUE 1
#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>
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) {
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;
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);
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) {
}
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;
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);
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; }