summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-02-18 16:21:51 +0000
committerManolo Gouy <Manolo>2016-02-18 16:21:51 +0000
commitf33b45f1d30653fb5da4817089e38ff0a2413cfb (patch)
tree9edc759690defa581b00b6ada80bb334f4ac5da8 /src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
parent6ce27012a9412c4964e0ae40c81ea92ff39a61d3 (diff)
Remove all uses of the fl_gc global variable. Towards a clean driver model.
fl_gc remains usable by the application as a hook into the system. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11189 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
index 44fe57403..657e7eb26 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
@@ -23,6 +23,16 @@
const char *Fl_Quartz_Graphics_Driver::class_id = "Fl_Quartz_Graphics_Driver";
+/* Reference to the current CGContext
+ For back-compatibility only. The preferred procedure to get this reference is
+ Fl_Surface_Device::surface()->driver()->get_gc().
+ */
+CGContextRef fl_gc = 0;
+
+void Fl_Graphics_Driver::global_gc()
+{
+ fl_gc = (CGContextRef)get_gc();
+}
/*
* By linking this module, the following static method will instatiate the
@@ -118,15 +128,15 @@ void fl_begin_offscreen(Fl_Offscreen ctx) {
_ss = Fl_Surface_Device::surface();
Fl_Display_Device::display_device()->set_current();
if (stack_ix<stack_max) {
- stack_gc[stack_ix] = fl_gc;
+ stack_gc[stack_ix] = (CGContextRef)fl_graphics_driver->get_gc();
stack_window[stack_ix] = fl_window;
} else
fprintf(stderr, "FLTK CGContext Stack overflow error\n");
stack_ix++;
- fl_gc = (CGContextRef)ctx;
+ fl_graphics_driver->set_gc(ctx);
fl_window = 0;
- CGContextSaveGState(fl_gc);
+ CGContextSaveGState(ctx);
fl_graphics_driver->push_no_clip();
}
@@ -135,14 +145,16 @@ void fl_begin_offscreen(Fl_Offscreen ctx) {
*/
void fl_end_offscreen() {
fl_graphics_driver->pop_clip();
- CGContextRestoreGState(fl_gc); // matches CGContextSaveGState in fl_begin_offscreen()
- CGContextFlush(fl_gc);
+ CGContextRef gc = (CGContextRef)fl_graphics_driver->get_gc();
+
+ CGContextRestoreGState(gc); // matches CGContextSaveGState in fl_begin_offscreen()
+ CGContextFlush(gc);
if (stack_ix>0)
stack_ix--;
else
fprintf(stderr, "FLTK CGContext Stack underflow error\n");
if (stack_ix<stack_max) {
- fl_gc = stack_gc[stack_ix];
+ fl_graphics_driver->set_gc(stack_gc[stack_ix]);
fl_window = stack_window[stack_ix];
}
_ss->set_current();