static jint scratch_w = 0;
static jint scratch_h = 0;
+#define max(a,b) ((a)>(b)?(a):(b))
+#define min(a,b) ((a)<(b)?(a):(b))
+
void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* source0,
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;
+ cx1 = max(dx, cx1);
+ cy1 = max(dy, cy1);
+ cx2 = min(dx + source->getWidth(), cx2);
+ cy2 = min(dy + source->getHeight(), cy2);
+ if (cx1 >= cx2 || cy1 >= cy2) return;
+
if (source->hasalpha) {
if (scratch == NULL || scratch_w < cx2 - cx1 || scratch_h < cy2 - cy1) {
}
// copy back from scratch to screen
- BitBlt((HDC)hdc, cx1, cy1, cx2, cy2, (HDC)scratch_dc, 0, 0, SRCCOPY);
+ BitBlt((HDC)hdc, cx1, cy1, cx2 - cx1, cy2 - cy1, (HDC)scratch_dc, 0, 0, SRCCOPY);
} else {
// FIXME: support alphaOnly case here
if (source->hasmask) {
- 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);
+ BitBlt((HDC)hdc, cx1, cy1, cx2 - cx1, cy2 - cy1, (HDC)source->maskdc, cx1 - dx, cy1 - dy, SRCAND);
+ BitBlt((HDC)hdc, cx1, cy1, cx2 - cx1, cy2 - cy1, (HDC)source->hdc, cx1 - dx, cy1 - dy, SRCPAINT);
} else {
- BitBlt((HDC)hdc, cx1, cy1, cx2, cy2, (HDC)source->hdc, cx1 - dx, cy1 - dy, SRCCOPY);
+ BitBlt((HDC)hdc, cx1, cy1, cx2 - cx1, cy2 - cy1, (HDC)source->hdc, cx1 - dx, cy1 - dy, SRCCOPY);
}
}