diff options
author | culler <culler> | 2021-04-22 17:07:28 (GMT) |
---|---|---|
committer | culler <culler> | 2021-04-22 17:07:28 (GMT) |
commit | 019923f12e5ac43053840de0701390146ae57907 (patch) | |
tree | 062dab0df9da68356ef83a19f89394751ccdc920 | |
parent | 66304f744b14ffc5eb42724284c279e91de9444d (diff) | |
download | tk-019923f12e5ac43053840de0701390146ae57907.zip tk-019923f12e5ac43053840de0701390146ae57907.tar.gz tk-019923f12e5ac43053840de0701390146ae57907.tar.bz2 |
Remove unneeded portBounds field from TkMacOSXDrawingContext; add more graphics debugging tools.
-rw-r--r-- | macosx/tkMacOSXDraw.c | 53 | ||||
-rw-r--r-- | macosx/tkMacOSXFont.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 1 | ||||
-rw-r--r-- | macosx/tkMacOSXRegion.c | 2 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 2 |
5 files changed, 45 insertions, 15 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index bf6a4a7..aa7523a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -27,6 +27,7 @@ #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_DRAWING #define TK_MAC_DEBUG_IMAGE_DRAWING +#define TK_MAC_DEBUG_CG #endif */ @@ -1266,6 +1267,11 @@ TkMacOSXSetupDrawingContext( TKContentView *view = nil; TkMacOSXDrawingContext dc = {}; +#ifdef TK_MAC_DEBUG_CG + fprintf(stderr, "TkMacOSXSetupDrawingContext: %s\n", + macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); +#endif + /* * If the drawable is not a pixmap, get the associated NSView. */ @@ -1296,13 +1302,10 @@ TkMacOSXSetupDrawingContext( */ dc.context = TkMacOSXGetCGContextForDrawable(d); - if (dc.context) { - dc.portBounds = CGContextGetClipBoundingBox(dc.context); - } else { + if (!dc.context) { NSRect drawingBounds, currentBounds; dc.view = view; dc.context = GET_CGCONTEXT; - dc.portBounds = NSRectToCGRect([view bounds]); if (dc.clipRgn) { CGRect clipBounds; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, @@ -1358,11 +1361,14 @@ TkMacOSXSetupDrawingContext( .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, - .ty = dc.portBounds.size.height + .ty = [view bounds].size.height }; - dc.portBounds.origin.x += macDraw->xOff; - dc.portBounds.origin.y += macDraw->yOff; +#ifdef TK_MAC_DEBUG_CG + fprintf(stderr, "TkMacOSXSetupDrawingContext: pushing GState for %s\n", + macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); +#endif + CGContextSaveGState(dc.context); CGContextSetTextDrawingMode(dc.context, kCGTextFill); CGContextConcatCTM(dc.context, t); @@ -1388,11 +1394,26 @@ TkMacOSXSetupDrawingContext( */ ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); + +#ifdef TK_MAC_DEBUG_CG + fprintf(stderr, "Setting complex clip for %s to:\n", + macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); + TkMacOSXPrintRectsInRegion(dc.clipRgn); +#endif + CGContextEOClip(dc.context); - } - else { + } else { CGRect r; HIShapeGetBounds(dc.clipRgn, &r); + +#ifdef TK_MAC_DEBUG_CG + fprintf(stderr, "Current clip BBox is %s\n", + NSStringFromRect(CGContextGetClipBoundingBox(GET_CGCONTEXT)).UTF8String); + fprintf(stderr, "Setting clip for %s to rect %s:\n", + macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None", + NSStringFromRect(r).UTF8String); +#endif + CGContextClipToRect(dc.context, r); } } @@ -1413,8 +1434,8 @@ TkMacOSXSetupDrawingContext( TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); if (view) { - CGContextSetPatternPhase(dc.context, - CGSizeMake(dc.portBounds.size.width, dc.portBounds.size.height)); + NSSize size = [view bounds].size; + CGContextSetPatternPhase(dc.context, size); } if (gc->function != GXcopy) { TkMacOSXDbgMsg("Logical functions other than GXcopy are " @@ -1491,13 +1512,21 @@ TkMacOSXRestoreDrawingContext( if (dcPtr->context) { CGContextSynchronize(dcPtr->context); CGContextRestoreGState(dcPtr->context); + +#ifdef TK_MAC_DEBUG_CG + fprintf(stderr, "TkMacOSXRestoreDrawingContext: popped GState\n"); +#endif + } if (dcPtr->clipRgn) { CFRelease(dcPtr->clipRgn); + dcPtr->clipRgn = NULL; } + #ifdef TK_MAC_DEBUG bzero(dcPtr, sizeof(TkMacOSXDrawingContext)); -#endif /* TK_MAC_DEBUG */ +#endif + } /* diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 2a28f73..8189bdb 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1217,7 +1217,7 @@ TkpDrawAngledCharsInContext( (CFAttributedStringRef)attributedString); textX += (CGFloat) macWin->xOff; textY += (CGFloat) macWin->yOff; - height = drawingContext.portBounds.size.height; + height = [drawingContext.view bounds].size.height; textY = height - textY; t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, height); if (angle != 0.0) { diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 0bd46c6..29e7c53 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -203,7 +203,6 @@ typedef struct TkMacOSXDrawingContext { CGContextRef context; NSView *view; HIShapeRef clipRgn; - CGRect portBounds; } TkMacOSXDrawingContext; /* diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 3c168f1..fbb41cb 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -575,7 +575,7 @@ rectPrinter( void *ref) { if (rect) { - printf(" %s\n", NSStringFromRect(*rect).UTF8String); + fprintf(stderr, " %s\n", NSStringFromRect(*rect).UTF8String); } return noErr; } diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 8379812..6b1aff6 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -555,6 +555,8 @@ static void SolidFillRoundedRectangle( CGContextSetFillColorWithColor(context, CGCOLOR(color)); CGContextBeginPath(context); CGContextAddPath(context, path); + fprintf(stderr, "Filling rounded rectangle at %s\n", + NSStringFromRect(bounds).UTF8String); CGContextFillPath(context); CFRelease(path); } |