summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2007-11-08 14:24:47 (GMT)
committerdas <das>2007-11-08 14:24:47 (GMT)
commitc08f2e1d5f2562b82353e92ed9c8e4243de8664c (patch)
treeaddebaf6715f8d5dccdc5296f9984f43d180217d
parenta8883697879f79d69b50fd4ccb658401d3c19b64 (diff)
downloadtk-c08f2e1d5f2562b82353e92ed9c8e4243de8664c.zip
tk-c08f2e1d5f2562b82353e92ed9c8e4243de8664c.tar.gz
tk-c08f2e1d5f2562b82353e92ed9c8e4243de8664c.tar.bz2
* macosx/tkMacOSXSubwindows.c: add pixmap size field to MacDrawable
* macosx/tkMacOSXInt.h: struct; add flag for B&W pixmaps. * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXEmbed.c: * macosx/tkMacOSXMenu.c:
-rw-r--r--macosx/tkMacOSXDraw.c38
-rw-r--r--macosx/tkMacOSXEmbed.c4
-rw-r--r--macosx/tkMacOSXInt.h4
-rw-r--r--macosx/tkMacOSXMenu.c3
-rw-r--r--macosx/tkMacOSXSubwindows.c27
5 files changed, 50 insertions, 26 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 06b09fb..e5b39d1 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.30 2007/10/12 03:14:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.31 2007/11/08 14:24:47 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -41,6 +41,8 @@ RgnHandle tkMacOSXtmpQdRgn = NULL;
int tkMacOSXUseCGDrawing = 1;
+int tkPictureIsOpen;
+
static PixPatHandle penPat = NULL;
static int cgAntiAliasLimit = 0;
@@ -151,7 +153,7 @@ XCopyArea(
GC gc, /* GC to use. */
int src_x, /* X & Y, width & height */
int src_y, /* define the source rectangle */
- unsigned int width, /* the will be copied. */
+ unsigned int width, /* that will be copied. */
unsigned int height,
int dest_x, /* Dest X & Y on dest rect. */
int dest_y)
@@ -234,7 +236,7 @@ XCopyPlane(
GC gc, /* GC to use. */
int src_x, /* X & Y, width & height */
int src_y, /* define the source rectangle */
- unsigned int width, /* the will be copied. */
+ unsigned int width, /* that will be copied. */
unsigned int height,
int dest_x, /* Dest X & Y on dest rect. */
int dest_y,
@@ -1573,21 +1575,29 @@ TkMacOSXSetupDrawingContext(
}
goto end;
}
- dc.port = TkMacOSXGetDrawablePort(d);
- if (dc.port) {
- GetPortBounds(dc.port, &dc.portBounds);
+ if (useCG) {
+ dc.context = macDraw->context;;
+ }
+ if (!dc.context || !(macDraw->flags & TK_IS_PIXMAP)) {
+ dc.port = TkMacOSXGetDrawablePort(d);
+ if (dc.port) {
+ GetPortBounds(dc.port, &dc.portBounds);
+ }
}
- dc.context = macDraw->context;
- if (dc.context && useCG) {
+ if (dc.context) {
if (!dc.port) {
- TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
- CGRect r = CGContextGetClipBoundingBox(dc.context);
+ CGRect r;
- SetRect(&dc.portBounds, r.origin.x + macDraw->xOff,
- r.origin.y + macDraw->yOff,
- r.origin.x + r.size.width + macDraw->xOff,
- r.origin.y + r.size.height + macDraw->yOff);
+ TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
+ r = CGContextGetClipBoundingBox(dc.context);
+ ) TK_ELSE_MAC_OS_X (3,
+ r.origin = CGPointZero;
+ r.size = macDraw->size;
) TK_ENDIF
+ SetRect(&dc.portBounds, r.origin.x + macDraw->xOff,
+ r.origin.y + macDraw->yOff,
+ r.origin.x + r.size.width + macDraw->xOff,
+ r.origin.y + r.size.height + macDraw->yOff);
}
CGContextSaveGState(dc.context);
dc.saveState = (void*)1;
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 8219c8e..bffd130 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.14 2007/10/12 03:14:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.15 2007/11/08 14:24:47 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -155,6 +155,7 @@ TkpMakeWindow(
macWin->flags = TK_CLIP_INVALID;
macWin->grafPtr = NULL;
macWin->context = NULL;
+ macWin->size = CGSizeZero;
if (Tk_IsTopLevel(macWin->winPtr)) {
/*
*This will be set when we are mapped.
@@ -298,6 +299,7 @@ TkpUseWindow(
macWin->grafPtr = NULL;
macWin->context = NULL;
+ macWin->size = CGSizeZero;
macWin->visRgn = NULL;
macWin->aboveVisRgn = NULL;
macWin->drawRect = CGRectNull;
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 458e003..a0aace6 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXInt.h,v 1.30 2007/10/12 03:14:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.31 2007/11/08 14:24:47 das Exp $
*/
#ifndef _TKMACINT
@@ -39,6 +39,7 @@ struct TkWindowPrivate {
ControlRef rootControl;
int xOff; /* X offset from toplevel window */
int yOff; /* Y offset from toplevel window */
+ CGSize size;
HIShapeRef visRgn; /* Visible region of window */
HIShapeRef aboveVisRgn; /* Visible region of window & its children */
CGRect drawRect; /* Clipped drawing rect */
@@ -72,6 +73,7 @@ typedef struct TkMacOSXWindowList {
#define TK_DRAWN_UNDER_MENU 0x08
#define TK_CLIPPED_DRAW 0x10
#define TK_IS_PIXMAP 0x20
+#define TK_IS_BW_PIXMAP 0x40
/*
* I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index ef069f8..2a80a9b 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.43 2007/10/12 03:14:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.44 2007/11/08 14:24:47 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -3993,6 +3993,7 @@ TkpMenuInit(void)
macMDEFDrawable.flags = 0;
macMDEFDrawable.grafPtr = NULL;
macMDEFDrawable.context = NULL;
+ macMDEFDrawable.size = CGSizeZero;
#endif
ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth,
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 6810519..dc21a3d 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.24 2007/10/12 03:14:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.25 2007/11/08 14:24:47 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -1016,6 +1016,17 @@ TkMacOSXGetDrawablePort(
resultPort = macWin->toplevel->grafPtr;
}
} else {
+ if ((macWin->flags & TK_IS_PIXMAP) && !macWin->grafPtr) {
+ Rect bounds = {0, 0, macWin->size.height, macWin->size.width};
+
+ ChkErr(NewGWorld, &macWin->grafPtr,
+ (macWin->flags & TK_IS_BW_PIXMAP) ? 1 : 0,
+ &bounds, NULL, NULL, 0
+#ifdef __LITTLE_ENDIAN__
+ | kNativeEndianPixMap
+#endif
+ );
+ }
resultPort = macWin->grafPtr;
}
}
@@ -1301,24 +1312,19 @@ Tk_GetPixmap(
macPix->drawRect = CGRectNull;
macPix->referenceCount = 0;
macPix->toplevel = NULL;
- macPix->flags = TK_IS_PIXMAP;
+ macPix->flags = TK_IS_PIXMAP | (depth == 1 ? TK_IS_BW_PIXMAP : 0);
macPix->grafPtr = NULL;
macPix->context = NULL;
+ macPix->size = CGSizeMake(width, height);
{
- OSStatus err;
- GWorldPtr gWorld;
Rect bounds = {0, 0, height, width};
- err = ChkErr(NewGWorld, &gWorld, depth == 1 ? 1 : 0, &bounds, NULL,
+ ChkErr(NewGWorld, &macPix->grafPtr, depth == 1 ? 1 : 0, &bounds, NULL,
NULL, 0
#ifdef __LITTLE_ENDIAN__
| kNativeEndianPixMap
#endif
);
- if (err != noErr) {
- Tcl_Panic("Out of memory: NewGWorld failed in Tk_GetPixmap");
- }
- macPix->grafPtr = gWorld;
}
return (Pixmap) macPix;
@@ -1351,5 +1357,8 @@ Tk_FreePixmap(
if (macPix->grafPtr) {
DisposeGWorld(macPix->grafPtr);
}
+ if (macPix->context) {
+ TkMacOSXDbgMsg("Cannot free CG backed Pixmap");
+ }
ckfree((char *) macPix);
}