spa%hara.fctunl.rccn.pt@MITVMA.MIT.EDU (Salvador Pinto Abreu) (01/03/89)
While we're at it, I have another patch to speedup handling of exposure events in the ImageEdit widget as distributed in X.V11R3. For large images this is really necessary. By the way, I have done some work in porting the HP Xw widgets to the R3 intrinsics. It is not finished (I still have problems with Popups and a few layout widgets) but most of the stuff is working now. If there is interest I may post the diffs to xpert. *** Note: This patch must be applied with 'patch -l' because most BITNET mailers trucidate tabs. *** ImageEdit.c.old Tue Jan 3 13:38:10 1989 --- ImageEdit.c Tue Jan 3 13:37:50 1989 *************** *** 368,374 static void Redisplay (iw, event, region) XwImageEditWidget iw; ! XEvent * event; Region region; { --- 368,374 ----- static void Redisplay (iw, event, region) XwImageEditWidget iw; ! XExposeEvent * event; Region region; { *************** *** 421,426 iw -> primitive.highlight_thickness, rect, 1, Unsorted); yPos = gridThickness + iw -> primitive.highlight_thickness; --- 421,427 ----- iw -> primitive.highlight_thickness, rect, 1, Unsorted); + XClipBox (region, rect); #define SCALE_WI(v) \ (((v) - gridThickness - iw->primitive.highlight_thickness) / \ *************** *** 422,427 rect, 1, Unsorted); yPos = gridThickness + iw -> primitive.highlight_thickness; --- 423,431 ----- XClipBox (region, rect); + #define SCALE_WI(v) \ + (((v) - gridThickness - iw->primitive.highlight_thickness) / \ + (gridThickness + pixelScale)) #define SCALE_IW(v) \ ((v) * (gridThickness + pixelScale) + \ *************** *** 423,429 ! yPos = gridThickness + iw -> primitive.highlight_thickness; for (y = 0; y < image -> height; y++) { --- 427,435 ----- (((v) - gridThickness - iw->primitive.highlight_thickness) / \ (gridThickness + pixelScale)) ! #define SCALE_IW(v) \ ! ((v) * (gridThickness + pixelScale) + \ ! (gridThickness + iw->primitive.highlight_thickness)) { int xwMin = rect[0].x - 1; *************** *** 425,433 yPos = gridThickness + iw -> primitive.highlight_thickness; ! for (y = 0; y < image -> height; y++) ! { ! xPos = gridThickness + iw -> primitive.highlight_thickness; for (x = 0; x < image -> width; x++) { --- 431,441 ----- ((v) * (gridThickness + pixelScale) + \ (gridThickness + iw->primitive.highlight_thickness)) ! { ! int xwMin = rect[0].x - 1; ! int xwMax = rect[0].x + rect[0].width + 1; ! int ywMin = rect[0].y - 1; ! int ywMax = rect[0].y + rect[0].height + 1; int xiMin = SCALE_WI(xwMin) - 1; int xiMax = SCALE_WI(xwMax) + 1; *************** *** 429,437 { xPos = gridThickness + iw -> primitive.highlight_thickness; ! for (x = 0; x < image -> width; x++) ! { ! pixel = XGetPixel (image, x, y); if (pixel != background) { --- 437,446 ----- int ywMin = rect[0].y - 1; int ywMax = rect[0].y + rect[0].height + 1; ! int xiMin = SCALE_WI(xwMin) - 1; ! int xiMax = SCALE_WI(xwMax) + 1; ! int yiMin = SCALE_WI(ywMin) - 1; ! int yiMax = SCALE_WI(ywMax) + 1; if (xiMin < 0) xiMin = 0; if (yiMin < 0) yiMin = 0; *************** *** 433,446 { pixel = XGetPixel (image, x, y); ! if (pixel != background) ! { ! if (pixel != foreground) ! { ! foreground = pixel; ! values.foreground = foreground; ! XChangeGC (display, drawGC, valueMask, &values); ! } if (XRectInRegion (region, xPos, yPos, pixelScale, pixelScale) != RectangleOut) --- 442,451 ----- int yiMin = SCALE_WI(ywMin) - 1; int yiMax = SCALE_WI(ywMax) + 1; ! if (xiMin < 0) xiMin = 0; ! if (yiMin < 0) yiMin = 0; ! if (xiMax > image->width) xiMax = image->width; ! if (yiMax > image->height) yiMax = image->height; yPos = SCALE_IW(yiMin); *************** *** 442,451 XChangeGC (display, drawGC, valueMask, &values); } ! if (XRectInRegion (region, xPos, yPos, ! pixelScale, pixelScale) != RectangleOut) ! XFillRectangle (display, window, drawGC, ! xPos, yPos, pixelScale, pixelScale); } --- 447,453 ----- if (xiMax > image->width) xiMax = image->width; if (yiMax > image->height) yiMax = image->height; ! yPos = SCALE_IW(yiMin); for (y = yiMin; y < yiMax; y++) { xPos = SCALE_IW(xiMin); *************** *** 447,453 XFillRectangle (display, window, drawGC, xPos, yPos, pixelScale, pixelScale); ! } xPos += gridThickness + pixelScale; } --- 449,456 ----- yPos = SCALE_IW(yiMin); ! for (y = yiMin; y < yiMax; y++) { ! xPos = SCALE_IW(xiMin); for (x = xiMin; x < xiMax; x++) { pixel = XGetPixel (image, x, y); *************** *** 449,456 } ! xPos += gridThickness + pixelScale; ! } yPos += gridThickness + pixelScale; } --- 452,459 ----- for (y = yiMin; y < yiMax; y++) { xPos = SCALE_IW(xiMin); ! for (x = xiMin; x < xiMax; x++) { ! pixel = XGetPixel (image, x, y); if (pixel != background) { if (pixel != foreground) { *************** *** 452,458 xPos += gridThickness + pixelScale; } ! yPos += gridThickness + pixelScale; } XFreeGC (display, drawGC); --- 455,479 ----- for (x = xiMin; x < xiMax; x++) { pixel = XGetPixel (image, x, y); ! if (pixel != background) { ! if (pixel != foreground) { ! foreground = pixel; ! values.foreground = foreground; ! XChangeGC (display, drawGC, valueMask, &values); ! } ! ! if (XRectInRegion (region, xPos, yPos, ! pixelScale, pixelScale) != RectangleOut) ! XFillRectangle (display, window, drawGC, ! xPos, yPos, pixelScale, pixelScale); ! ! } ! ! xPos += gridThickness + pixelScale; ! } ! ! yPos += gridThickness + pixelScale; ! } } XFreeGC (display, drawGC); --- Salvador Pinto Abreu BITNET/Internet: spa@hara.fctunl.rccn.pt or: FCT_SPA@PTIFM.BITNET UUCP: ...{mcvax,inria}!inesc!unl!spa PSI/VMS: PSI%(+2680)05010310::SPA ARPA: spa%hara.fctunl.rccn.pt@mitvma.mit.edu Phone: (+351) (1) 295-4464 x.0560 Fax: (+351) (1) 295-4461 Snail: Dept. de Informatica, Universidade Nova de Lisboa 2825 Monte Caparica, PORTUGAL