summaryrefslogtreecommitdiff
path: root/src/Fl_Double_Window.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2004-08-31 00:27:40 +0000
committerMatthias Melcher <fltk@matthiasm.com>2004-08-31 00:27:40 +0000
commit57193e52c0ea34a6af53289b72b232e226466bc1 (patch)
tree01532958535af427ce9d473f2b1b739ab501d5ea /src/Fl_Double_Window.cxx
parent62e1ae69768156c1f4db4a7193f74af944ab34f6 (diff)
Quartz for FLTK 1.1:
- added pixmap drawing (no masking yet) - added bitmap drawing - added line styles (complete) todo: - missing refresh (double test, fluid, others) - missing pixmap mask - color_chooser has alignment issues - images scale instead of beeing scissored - fonts git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3798 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Double_Window.cxx')
-rw-r--r--src/Fl_Double_Window.cxx106
1 files changed, 49 insertions, 57 deletions
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx
index a14aac216..4c597b110 100644
--- a/src/Fl_Double_Window.cxx
+++ b/src/Fl_Double_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.10 2004/08/25 00:20:25 matthiaswm Exp $"
+// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.11 2004/08/31 00:27:40 matthiaswm Exp $"
//
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
//
@@ -164,70 +164,62 @@ void fl_end_offscreen() {
extern void fl_restore_clip();
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
-GWorldPtr fl_create_offscreen(int w, int h) {
- GWorldPtr gw;
- Rect bounds;
- bounds.left=0; bounds.right=w; bounds.top=0; bounds.bottom=h;
- QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, 0); // 'useTempMem' should not be used (says the Carbon port manual)
- if ( err == -108 )
- { }
-// fl_message( "The application memory is low. Please increase the initial memory assignment.\n" );
- if (err!=noErr || gw==0L) return 0L;
- return gw;
-}
-void fl_copy_offscreen(int x,int y,int w,int h,GWorldPtr gWorld,int srcx,int srcy) {
- Rect src;
- if ( !gWorld ) return;
- src.top = srcy; src.left = srcx; src.bottom = srcy+h; src.right = srcx+w;
- Rect dst;
- GrafPtr dstPort; GetPort(&dstPort);
- dst.top = y; dst.left = x; dst.bottom = y+h; dst.right = x+w;
- RGBColor rgb;
- rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff;
- RGBBackColor( &rgb );
- rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000;
- RGBForeColor( &rgb );
- CopyBits(GetPortBitMapForCopyBits(gWorld), GetPortBitMapForCopyBits(dstPort), &src, &dst, srcCopy, 0L);
+Fl_Offscreen fl_create_offscreen(int w, int h) {
+ void *data = malloc(w*h*4);
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGContextRef ctx = CGBitmapContextCreate(
+ data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast);
+ CGColorSpaceRelease(lut);
+ return (Fl_Offscreen)ctx;
}
-void fl_delete_offscreen(GWorldPtr gWorld) {
- DisposeGWorld(gWorld);
+void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) {
+#warning : test this implementation!
+ CGContextRef src = (CGContextRef)osrc;
+ void *data = CGBitmapContextGetData(src);
+ int sw = CGBitmapContextGetWidth(src);
+ int sh = CGBitmapContextGetHeight(src);
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGDataProviderRef src_bytes = CGDataProviderCreateWithData( 0L, data, sw*sh*4, 0L);
+ CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, kCGImageAlphaNoneSkipLast,
+ src_bytes, 0L, false, kCGRenderingIntentDefault);
+ // fl_push_clip();
+ CGRect rect = { x, y, w, h };
+ Fl_X::q_begin_image(rect, srcx, srcy);
+ CGContextDrawImage(fl_gc, rect, img);
+ Fl_X::q_end_image();
+ CGImageRelease(img);
+ CGColorSpaceRelease(lut);
+ CGDataProviderRelease(src_bytes);
}
-static GrafPtr prevPort;
-static GDHandle prevGD;
+void fl_delete_offscreen(Fl_Offscreen ctx) {
+ if (!ctx) return;
+ void *data = CGBitmapContextGetData((CGContextRef)ctx);
+ CGContextRelease((CGContextRef)ctx);
+ if (!data) return;
+ free(data);
+}
-void fl_begin_offscreen(GWorldPtr gWorld) {
- GetGWorld( &prevPort, &prevGD );
- if ( gWorld )
- {
- SetGWorld( gWorld, 0 ); // sets the correct port
- PixMapHandle pm = GetGWorldPixMap(gWorld);
- Boolean ret = LockPixels(pm);
- if ( ret == false )
- {
- Rect rect;
- GetPortBounds( gWorld, &rect );
- UpdateGWorld( &gWorld, 0, &rect, 0, 0, 0 );
- pm = GetGWorldPixMap( gWorld );
- LockPixels( pm );
- }
- fl_window = 0;
- }
- fl_push_no_clip();
+static CGContextRef prev_gc = 0;
+static Window prev_window = 0;
+
+void fl_begin_offscreen(Fl_Offscreen ctx) {
+ prev_gc = fl_gc;
+ prev_window = fl_window;
+ fl_gc = (CGContextRef)ctx;
+ fl_window = 0;
+ //fl_push_no_clip();
+ CGContextSaveGState(fl_gc);
+ Fl_X::q_fill_context();
}
void fl_end_offscreen() {
- GWorldPtr currPort;
- GDHandle currGD;
- GetGWorld( &currPort, &currGD );
- fl_pop_clip();
- PixMapHandle pm = GetGWorldPixMap(currPort);
- UnlockPixels(pm);
- SetGWorld( prevPort, prevGD );
- fl_window = GetWindowFromPort( prevPort );
+ Fl_X::q_release_context();
+ //fl_pop_clip();
+ fl_gc = prev_gc;
+ fl_window = prev_window;
}
extern void fl_restore_clip();
@@ -375,5 +367,5 @@ Fl_Double_Window::~Fl_Double_Window() {
}
//
-// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.10 2004/08/25 00:20:25 matthiaswm Exp $".
+// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.11 2004/08/31 00:27:40 matthiaswm Exp $".
//