summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <jan.nijtmans@noemail.net>2016-11-08 12:27:25 (GMT)
committerjan.nijtmans <jan.nijtmans@noemail.net>2016-11-08 12:27:25 (GMT)
commit88e413ba86eb25275fcd47b1886022b2d74b5e37 (patch)
tree88b5af1ccad5aec8962026c04d8f2301de3a3411
parentf3976ba0f67cd4320e02039b9bc3fcdab0bbcc83 (diff)
parentb686d946455e3f361706231cf443cef13572eef1 (diff)
downloadtk-88e413ba86eb25275fcd47b1886022b2d74b5e37.zip
tk-88e413ba86eb25275fcd47b1886022b2d74b5e37.tar.gz
tk-88e413ba86eb25275fcd47b1886022b2d74b5e37.tar.bz2
(micro-) optimize a few Win32 drawing functions, and make them work when npoints=0
FossilOrigin-Name: 159164e2086ea908dd91bb86cbf81f1bd9dc0902
-rw-r--r--macosx/tkMacOSXDraw.c4
-rw-r--r--macosx/tkMacOSXWindowEvent.c4
-rw-r--r--macosx/tkMacOSXXStubs.c4
-rw-r--r--win/tkWinDraw.c71
-rw-r--r--xlib/xgc.c13
5 files changed, 51 insertions, 45 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index f85d6ac..474ed41 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -1695,13 +1695,13 @@ TkMacOSXSetupDrawingContext(
CGContextSetTextDrawingMode(dc.context, kCGTextFill);
CGContextConcatCTM(dc.context, t);
if (dc.clipRgn) {
- #ifdef TK_MAC_DEBUG_DRAWING
+#ifdef TK_MAC_DEBUG_DRAWING
CGContextSaveGState(dc.context);
ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1);
CGContextEOFillPath(dc.context);
CGContextRestoreGState(dc.context);
- #endif /* TK_MAC_DEBUG_DRAWING */
+#endif /* TK_MAC_DEBUG_DRAWING */
CGRect r;
if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect(
*HIShapeGetBounds(dc.clipRgn, &r),
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 461a94c..a669a8a 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -364,10 +364,10 @@ GenerateUpdates(
event.xexpose.count = 0;
Tk_HandleEvent(&event);
- #ifdef TK_MAC_DEBUG_DRAWING
+#ifdef TK_MAC_DEBUG_DRAWING
NSLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x,
event.xexpose.y, event.xexpose.width, event.xexpose.height);
- #endif
+#endif
/*
* Generate updates for the children of this window
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index 1ed526d..8d9820b 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -528,7 +528,7 @@ XClearWindow(
}
/*
-void
+int
XDrawPoint(
Display* display,
Drawable d,
@@ -538,7 +538,7 @@ XDrawPoint(
{
}
-void
+int
XDrawPoints(
Display* display,
Drawable d,
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index bb903db..1d17cc6 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -640,7 +640,6 @@ XFillRectangles(
int nrectangles)
{
HDC dc;
- int i;
RECT rect;
TkWinDCState state;
HBRUSH brush, oldBrush;
@@ -681,25 +680,26 @@ XFillRectangles(
* result with the stipple pattern.
*/
- for (i = 0; i < nrectangles; i++) {
- bitmap = CreateCompatibleBitmap(dc, rectangles[i].width,
- rectangles[i].height);
+ while (nrectangles-- > 0) {
+ bitmap = CreateCompatibleBitmap(dc, rectangles[0].width,
+ rectangles[0].height);
oldBitmap = SelectObject(dcMem, bitmap);
rect.left = 0;
rect.top = 0;
- rect.right = rectangles[i].width;
- rect.bottom = rectangles[i].height;
+ rect.right = rectangles[0].width;
+ rect.bottom = rectangles[0].height;
FillRect(dcMem, &rect, brush);
- BitBlt(dc, rectangles[i].x, rectangles[i].y, rectangles[i].width,
- rectangles[i].height, dcMem, 0, 0, COPYFG);
+ BitBlt(dc, rectangles[0].x, rectangles[0].y, rectangles[0].width,
+ rectangles[0].height, dcMem, 0, 0, COPYFG);
if (gc->fill_style == FillOpaqueStippled) {
FillRect(dcMem, &rect, bgBrush);
- BitBlt(dc, rectangles[i].x, rectangles[i].y,
- rectangles[i].width, rectangles[i].height, dcMem,
+ BitBlt(dc, rectangles[0].x, rectangles[0].y,
+ rectangles[0].width, rectangles[0].height, dcMem,
0, 0, COPYBG);
}
SelectObject(dcMem, oldBitmap);
DeleteObject(bitmap);
+ ++rectangles;
}
DeleteDC(dcMem);
@@ -708,22 +708,24 @@ XFillRectangles(
DeleteObject(bgBrush);
} else {
if (gc->function == GXcopy) {
- for (i = 0; i < nrectangles; i++) {
- rect.left = rectangles[i].x;
- rect.right = rect.left + rectangles[i].width;
- rect.top = rectangles[i].y;
- rect.bottom = rect.top + rectangles[i].height;
+ while (nrectangles-- > 0) {
+ rect.left = rectangles[0].x;
+ rect.right = rect.left + rectangles[0].width;
+ rect.top = rectangles[0].y;
+ rect.bottom = rect.top + rectangles[0].height;
FillRect(dc, &rect, brush);
+ ++rectangles;
}
} else {
HPEN newPen = CreatePen(PS_NULL, 0, gc->foreground);
HPEN oldPen = SelectObject(dc, newPen);
oldBrush = SelectObject(dc, brush);
- for (i = 0; i < nrectangles; i++) {
- Rectangle(dc, rectangles[i].x, rectangles[i].y,
- rectangles[i].x + rectangles[i].width + 1,
- rectangles[i].y + rectangles[i].height + 1);
+ while (nrectangles-- > 0) {
+ Rectangle(dc, rectangles[0].x, rectangles[0].y,
+ rectangles[0].x + rectangles[0].width + 1,
+ rectangles[0].y + rectangles[0].height + 1);
+ ++rectangles;
}
SelectObject(dc, oldBrush);
@@ -1009,14 +1011,15 @@ XDrawRectangles(
XRectangle rects[],
int nrects)
{
- int n, ret;
+ int ret = Success;
- for (n = 0; n < nrects; n++) {
- ret = XDrawRectangle(display, d, gc, rects[n].x, rects[n].y,
- rects[n].width, rects[n].height);
+ while (nrects-- > 0) {
+ ret = XDrawRectangle(display, d, gc, rects[0].x, rects[0].y,
+ rects[0].width, rects[0].height);
if (ret != Success) {
break;
}
+ ++rects;
}
return ret;
}
@@ -1059,17 +1062,18 @@ XDrawArcs(
XArc *arcs,
int narcs)
{
- int n, ret;
+ int ret = Success;
display->request++;
- for (n = 0; n < narcs; n++) {
- ret = DrawOrFillArc(display, d, gc, arcs[n].x, arcs[n].y,
- arcs[n].width, arcs[n].height,
- arcs[n].angle1, arcs[n].angle2, 0);
+ while (narcs-- > 0) {
+ ret = DrawOrFillArc(display, d, gc, arcs[0].x, arcs[0].y,
+ arcs[0].width, arcs[0].height,
+ arcs[0].angle1, arcs[0].angle2, 0);
if (ret != Success) {
break;
}
+ ++arcs;
}
return ret;
}
@@ -1112,17 +1116,18 @@ XFillArcs(
XArc *arcs,
int narcs)
{
- int n, ret;
+ int ret = Success;
display->request++;
- for (n = 0; n < narcs; n++) {
- ret = DrawOrFillArc(display, d, gc, arcs[n].x, arcs[n].y,
- arcs[n].width, arcs[n].height,
- arcs[n].angle1, arcs[n].angle2, 1);
+ while (narcs-- > 0) {
+ ret = DrawOrFillArc(display, d, gc, arcs[0].x, arcs[0].y,
+ arcs[0].width, arcs[0].height,
+ arcs[0].angle1, arcs[0].angle2, 1);
if (ret != Success) {
break;
}
+ ++arcs;
}
return ret;
}
diff --git a/xlib/xgc.c b/xlib/xgc.c
index 1e720fb..78c7501 100644
--- a/xlib/xgc.c
+++ b/xlib/xgc.c
@@ -540,14 +540,15 @@ XDrawPoints(
int npoints,
int mode)
{
- int i;
- int result = Success;
+ int res = Success;
- for (i=0; (i<npoints) && (result == Success); i++) {
- result = XDrawLine(display, d, gc,
- points[i].x, points[i].y, points[i].x, points[i].y);
+ while (npoints-- > 0) {
+ res = XDrawLine(display, d, gc,
+ points[0].x, points[0].y, points[0].x, points[0].y);
+ if (res != Success) break;
+ ++points;
}
- return result;
+ return res;
}
#if !defined(MAC_OSX_TK)