From: xwt Date: Fri, 30 Jan 2004 07:40:35 +0000 (+0000) Subject: 2003/10/29 04:06:21 X-Git-Tag: RC3~396 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=20c80526fbef20ad0b6f1cd67805871c10616bea;p=org.ibex.core.git 2003/10/29 04:06:21 darcs-hash:20040130074035-3ac31-54458830cf157ab77e5a2669d88fbb6b97abd1bf.gz --- diff --git a/src/org/xwt/plat/Win32.cc b/src/org/xwt/plat/Win32.cc index 95fe5f7..9cdb62b 100644 --- a/src/org/xwt/plat/Win32.cc +++ b/src/org/xwt/plat/Win32.cc @@ -354,12 +354,21 @@ static jint* scratch_bits = NULL; 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) { @@ -403,16 +412,16 @@ void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* sour } // 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); } }