diff options
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx')
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 24 |
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(); |
