summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-07-03 10:13:22 +0000
committerManolo Gouy <Manolo>2010-07-03 10:13:22 +0000
commitc835c08bb35a23e5e8b63bfb19f53f39c8666f33 (patch)
treece76ed8938ad1ae905829cbcd329810a26c7e4f9 /src
parent3e52876736d9f0ec09be778448f9205a065ea8eb (diff)
Fixed fl_copy_offscreen when output goes to a Quartz printer context.
Output to a PostScript context still needs to be fixed. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7665 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Double_Window.cxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx
index 9c5e210b4..03e0240b8 100644
--- a/src/Fl_Double_Window.cxx
+++ b/src/Fl_Double_Window.cxx
@@ -188,6 +188,13 @@ Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) {
return (Fl_Offscreen)ctx;
}
+static void bmProviderRelease (void *src, const void *data, size_t size)
+{
+ CFIndex count = CFGetRetainCount(src);
+ CFRelease(src);
+ if(count == 1) free((void*)data);
+}
+
void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) {
CGContextRef src = (CGContextRef)osrc;
void *data = CGBitmapContextGetData(src);
@@ -195,7 +202,10 @@ void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int sr
int sh = CGBitmapContextGetHeight(src);
CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src);
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
- CGDataProviderRef src_bytes = CGDataProviderCreateWithData( 0L, data, sw*sh*4, 0L);
+ // when output goes to a Quartz printercontext, release of the bitmap must be
+ // delayed after the end of the print page
+ CFRetain(src);
+ CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data, sw*sh*4, bmProviderRelease);
CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha,
src_bytes, 0L, false, kCGRenderingIntentDefault);
// fl_push_clip();
@@ -211,9 +221,9 @@ void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int sr
void fl_delete_offscreen(Fl_Offscreen ctx) {
if (!ctx) return;
void *data = CGBitmapContextGetData((CGContextRef)ctx);
+ CFIndex count = CFGetRetainCount(ctx);
CGContextRelease((CGContextRef)ctx);
- if (!data) return;
- free(data);
+ if(count == 1) free(data);
}
const int stack_max = 16;