summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXDraw.c
diff options
context:
space:
mode:
authordas <das>2007-05-30 06:39:37 (GMT)
committerdas <das>2007-05-30 06:39:37 (GMT)
commit354d7ea3b9178402bf28ae063c5e62f647f7d087 (patch)
treebbd79c7a2b425288ac6c592cd05b8613c3dbdfd7 /macosx/tkMacOSXDraw.c
parent48d6dbc41b0b9cd9e07d7ad699bd0e90a90424c7 (diff)
downloadtk-354d7ea3b9178402bf28ae063c5e62f647f7d087.zip
tk-354d7ea3b9178402bf28ae063c5e62f647f7d087.tar.gz
tk-354d7ea3b9178402bf28ae063c5e62f647f7d087.tar.bz2
* macosx/tkMacOSXMenu.c (DrawMenuSeparator): use DrawingContext API.
* macosx/tkMacOSXWindowEvent.c (ClearPort): clip to updateRgn. * macosx/tkMacOSXDebug.c: factor out debug region flashing. * macosx/tkMacOSXDebug.h: * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXEvent.c: cleanup whitespace and formatting. * macosx/tkMacOSXFont.c: * macosx/tkMacOSXRegion.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * xlib/xgc.c:
Diffstat (limited to 'macosx/tkMacOSXDraw.c')
-rw-r--r--macosx/tkMacOSXDraw.c96
1 files changed, 41 insertions, 55 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 2f8464b..6d1d064 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.21 2007/04/29 02:26:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.22 2007/05/30 06:39:38 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -163,9 +163,7 @@ XCopyArea(
MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst;
CGrafPtr srcPort, dstPort, savePort;
Boolean portChanged;
- short tmode;
RGBColor origForeColor, origBackColor, whiteColor, blackColor;
- Rect clpRect;
dstPort = TkMacOSXGetDrawablePort(dst);
srcPort = TkMacOSXGetDrawablePort(src);
@@ -209,42 +207,36 @@ XCopyArea(
if (tkPictureIsOpen) {
/*
* When rendering into a picture, after a call to "OpenCPicture"
- * the clipping is seriously WRONG and also INCONSISTENT with the
- * clipping for single plane bitmaps.
- * To circumvent this problem, we clip to the whole window
- * In this case, would have also clipped to the srcRect
- * ClipRect(&srcRect);
+ * the drawable clipping is incorrect, so clip to the whole window.
*/
- GetPortBounds(dstPort,&clpRect);
- dstPtr = &srcRect;
+ Rect clpRect;
+
+ GetPortBounds(dstPort, &clpRect);
ClipRect(&clpRect);
}
if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type
== TKP_CLIP_REGION) {
- RgnHandle clipRgn = (RgnHandle)
+ RgnHandle gcClipRgn = (RgnHandle)
((TkpClipMask*)gc->clip_mask)->value.region;
- int xOffset = 0, yOffset = 0;
+ int xOffset = dstDraw->xOff + gc->clip_x_origin;
+ int yOffset = dstDraw->yOff + gc->clip_y_origin;
if (!tkPictureIsOpen) {
- xOffset = dstDraw->xOff + gc->clip_x_origin;
- yOffset = dstDraw->yOff + gc->clip_y_origin;
- OffsetRgn(clipRgn, xOffset, yOffset);
+ OffsetRgn(gcClipRgn, xOffset, yOffset);
}
TkMacOSXCheckTmpRgnEmpty(1);
GetClip(tkMacOSXtmpRgn1);
- SectRgn(tkMacOSXtmpRgn1, clipRgn, tkMacOSXtmpRgn1);
+ SectRgn(tkMacOSXtmpRgn1, gcClipRgn, tkMacOSXtmpRgn1);
SetClip(tkMacOSXtmpRgn1);
SetEmptyRgn(tkMacOSXtmpRgn1);
if (!tkPictureIsOpen) {
- OffsetRgn(clipRgn, -xOffset, -yOffset);
+ OffsetRgn(gcClipRgn, -xOffset, -yOffset);
}
}
srcBit = GetPortBitMapForCopyBits(srcPort);
dstBit = GetPortBitMapForCopyBits(dstPort);
- tmode = srcCopy;
-
- CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
+ CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL);
RGBForeColor(&origForeColor);
RGBBackColor(&origBackColor);
SetClip(tkMacOSXtmpRgn2);
@@ -310,13 +302,12 @@ XCopyPlane(
if (tkPictureIsOpen) {
/*
* When rendering into a picture, after a call to "OpenCPicture"
- * the clipping is seriously WRONG and also INCONSISTENT with the
- * clipping for color bitmaps.
- * To circumvent this problem, we clip to the whole window
+ * the drawable clipping is incorrect, so clip to the whole window.
*/
Rect clpRect;
- GetPortBounds(dstPort,&clpRect);
+
+ GetPortBounds(dstPort, &clpRect);
ClipRect(&clpRect);
dstPtr = &srcRect;
} else {
@@ -425,14 +416,12 @@ TkPutImage(
if (tkPictureIsOpen) {
/*
* When rendering into a picture, after a call to "OpenCPicture"
- * the clipping is seriously WRONG and also INCONSISTENT with the
- * clipping for single plane bitmaps.
- * To circumvent this problem, we clip to the whole window
+ * the drawable clipping is incorrect, so clip to the whole window.
*/
Rect clpRect;
- GetPortBounds(destPort,&clpRect);
+ GetPortBounds(destPort, &clpRect);
ClipRect(&clpRect);
destPtr = srcPtr;
} else {
@@ -1598,8 +1587,11 @@ TkMacOSXSetUpGraphicsPort(
*/
int
-TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
- TkMacOSXDrawingContext *dc)
+TkMacOSXSetupDrawingContext(
+ Drawable d,
+ GC gc,
+ int useCG, /* advisory only ! */
+ TkMacOSXDrawingContext *dc)
{
MacDrawable *macDraw = ((MacDrawable*)d);
CGContextRef context = macDraw->context;
@@ -1633,14 +1625,14 @@ TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1);
if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type
== TKP_CLIP_REGION) {
- RgnHandle clipRgn = (RgnHandle)
+ RgnHandle gcClipRgn = (RgnHandle)
((TkpClipMask*)gc->clip_mask)->value.region;
int xOffset = macDraw->xOff + gc->clip_x_origin;
int yOffset = macDraw->yOff + gc->clip_y_origin;
- OffsetRgn(clipRgn, xOffset, yOffset);
- SectRgn(clipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1);
- OffsetRgn(clipRgn, -xOffset, -yOffset);
+ OffsetRgn(gcClipRgn, xOffset, yOffset);
+ SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1);
+ OffsetRgn(gcClipRgn, -xOffset, -yOffset);
}
ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1);
SetEmptyRgn(tkMacOSXtmpRgn1);
@@ -1657,6 +1649,7 @@ TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
}
}
} else if (context) {
+ TkMacOSXCheckTmpRgnEmpty(1);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
if (!port
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
@@ -1671,8 +1664,6 @@ TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
r.origin.y + r.size.height + macDraw->yOff);
}
#endif
- CGContextSaveGState(context);
- TkMacOSXCheckTmpRgnEmpty(1);
RectRgn(tkMacOSXtmpRgn1, &portBounds);
if (port) {
TkMacOSXSetUpClippingRgn(d);
@@ -1685,21 +1676,25 @@ TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
}
if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type
== TKP_CLIP_REGION) {
- RgnHandle clipRgn = (RgnHandle)
+ RgnHandle gcClipRgn = (RgnHandle)
((TkpClipMask*)gc->clip_mask)->value.region;
int xOffset = macDraw->xOff + gc->clip_x_origin;
int yOffset = macDraw->yOff + gc->clip_y_origin;
- OffsetRgn(clipRgn, xOffset, yOffset);
- SectRgn(clipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1);
- OffsetRgn(clipRgn, -xOffset, -yOffset);
+ OffsetRgn(gcClipRgn, xOffset, yOffset);
+ SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1);
+ OffsetRgn(gcClipRgn, -xOffset, -yOffset);
}
+ CGContextSaveGState(context);
ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1);
SetEmptyRgn(tkMacOSXtmpRgn1);
port = NULL;
dc->portChanged = false;
dc->saveState = (void*)1;
useCG = 1;
+ } else {
+ Tcl_Panic("TkMacOSXSetupDrawingContext(): "
+ "no port or context to draw into !");
}
if (useCG) {
CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0,
@@ -1769,17 +1764,17 @@ TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
gPenPat = savePat;
if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type
== TKP_CLIP_REGION) {
- RgnHandle clipRgn = (RgnHandle)
+ RgnHandle gcClipRgn = (RgnHandle)
((TkpClipMask*)gc->clip_mask)->value.region;
int xOffset = macDraw->xOff + gc->clip_x_origin;
int yOffset = macDraw->yOff + gc->clip_y_origin;
- OffsetRgn(clipRgn, xOffset, yOffset);
+ OffsetRgn(gcClipRgn, xOffset, yOffset);
GetClip(tkMacOSXtmpRgn1);
- SectRgn(clipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1);
+ SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1);
SetClip(tkMacOSXtmpRgn1);
SetEmptyRgn(tkMacOSXtmpRgn1);
- OffsetRgn(clipRgn, -xOffset, -yOffset);
+ OffsetRgn(gcClipRgn, -xOffset, -yOffset);
}
} else {
TkMacOSXSetUpGraphicsPort(NULL, port);
@@ -1867,17 +1862,8 @@ TkMacOSXSetUpClippingRgn(
}
#ifdef TK_MAC_DEBUG_DRAWING
- TkMacOSXInitNamedDebugSymbol(HIToolbox, int, QDDebugFlashRegion,
- CGrafPtr port, RgnHandle region);
- if (QDDebugFlashRegion) {
- CGrafPtr grafPtr = TkMacOSXGetDrawablePort(drawable);
-
- /*
- * Carbon-internal region flashing SPI (c.f. Technote 2124)
- */
-
- QDDebugFlashRegion(grafPtr, macDraw->clipRgn);
- }
+ TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort(drawable),
+ macDraw->clipRgn);
#endif /* TK_MAC_DEBUG_DRAWING */
}