diff options
| author | Manolo Gouy <Manolo> | 2017-12-26 16:07:51 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-12-26 16:07:51 +0000 |
| commit | 7758d472c2356f6908bce9fec6aa3e6d7e6a63e1 (patch) | |
| tree | 0bac011dc51e12d811f249855e91ba60addce2e8 /src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx | |
| parent | 8ee87d15e3c369d74752736a9c3e6614e2950cb0 (diff) | |
Continue support for GUI rescaling under MacOS: fix fl_XXX_offscreen() functions and Fl_Image_Surface class
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12605 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx')
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx index 59a4c538c..d46134c87 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx @@ -26,7 +26,6 @@ #include <FL/fl_draw.H> #include <FL/Fl.H> #include <FL/x.H> -#include <ApplicationServices/ApplicationServices.h> Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w) { @@ -66,32 +65,20 @@ void Fl_Cocoa_Window_Driver::flush_overlay() if (!oWindow->shown()) return; pWindow->make_current(); // make sure fl_gc is non-zero - Fl_Quartz_Graphics_Driver *g_driver = (Fl_Quartz_Graphics_Driver*)&Fl_Graphics_Driver::default_driver(); - float s = g_driver->scale() * (mapped_to_retina() ? 2 : 1); - if (!other_xid) { // create offscreen accounting for GUI scaling and retina - other_xid = (Fl_Offscreen)new Fl_Image_Surface(s * oWindow->w(), s * oWindow->h()); + if (!other_xid) { + other_xid = fl_create_offscreen(oWindow->w(), oWindow->h()); oWindow->clear_damage(FL_DAMAGE_ALL); - // scale the offscreen buffer's graphics context - Fl_Surface_Device::push_current((Fl_Image_Surface*)other_xid); - CGContextRestoreGState(fl_gc); - CGContextScaleCTM(fl_gc, s, s); - CGContextSaveGState(fl_gc); - Fl_Surface_Device::pop_current(); } if (oWindow->damage() & ~FL_DAMAGE_EXPOSE) { Fl_X *myi = Fl_X::i(pWindow); fl_clip_region(myi->region); myi->region = 0; - Fl_Surface_Device::push_current((Fl_Image_Surface*)other_xid); + fl_begin_offscreen(other_xid); draw(); - Fl_Surface_Device::pop_current(); + fl_end_offscreen(); } if (erase_overlay) fl_clip_region(0); if (other_xid) { - CGContextSaveGState(fl_gc); - CGContextScaleCTM(fl_gc, 1/s, 1/s); - // copy offscreen to window using adequate scaling - fl_copy_offscreen(0, 0, s * oWindow->w(),s * oWindow->h(), ((Fl_Image_Surface*)other_xid)->offscreen(), 0, 0); - CGContextRestoreGState(fl_gc); + fl_copy_offscreen(0, 0, oWindow->w(), oWindow->h(), other_xid, 0, 0); } if (overlay() == oWindow) oWindow->draw_overlay(); } @@ -99,7 +86,7 @@ void Fl_Cocoa_Window_Driver::flush_overlay() void Fl_Cocoa_Window_Driver::destroy_double_buffer() { - if (pWindow->as_overlay_window()) delete (Fl_Image_Surface*)other_xid; + if (pWindow->as_overlay_window()) fl_delete_offscreen(other_xid); other_xid = 0; } |
