Move q_release_context() from class Fl_X to class Fl_Cocoa_Window_Driver

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11639 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-04-17 10:12:42 +00:00
parent 16beb869a5
commit a4e5dc0267
5 changed files with 8 additions and 9 deletions

View File

@ -144,8 +144,6 @@ public:
void changed_resolution(bool);// sets whether window just moved to display with another resolution
bool in_windowDidResize(); // is window performing windowDidResize?
void in_windowDidResize(bool); // sets whether window is performing windowDidResize
// Quartz additions:
static void q_release_context(Fl_X *x=0); // free all resources associated with gc
// Cocoa additions
static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*); // computes NSOpenGLPixelFormat from Gl window's mode
static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window);

View File

@ -875,7 +875,7 @@ double fl_mac_flush_and_wait(double time_to_wait) {
if (Fl::idle && !in_idle) // 'idle' may have been set within flush()
time_to_wait = 0.0;
double retval = fl_wait(time_to_wait);
Fl_X::q_release_context();
Fl_Cocoa_Window_Driver::q_release_context();
[pool release];
return retval;
}
@ -2876,7 +2876,7 @@ void Fl_X::flush()
through_Fl_X_flush = NO;
if (!through_drawRect) [[xid contentView] unlockFocus];
make_current_counts = 0;
Fl_X::q_release_context();
Fl_Cocoa_Window_Driver::q_release_context();
}
}
@ -3255,7 +3255,7 @@ void Fl_Cocoa_Window_Driver::make_current()
{
if (make_current_counts > 1) return;
if (make_current_counts) make_current_counts++;
Fl_X::q_release_context();
q_release_context();
Fl_X *i = Fl_X::i(pWindow);
fl_window = i->xid;
Fl_X::set_high_resolution( i->mapped_to_retina() );
@ -3295,9 +3295,9 @@ void Fl_Cocoa_Window_Driver::make_current()
}
// Give the Quartz context back to the system
void Fl_X::q_release_context(Fl_X *x) {
void Fl_Cocoa_Window_Driver::q_release_context(Fl_Cocoa_Window_Driver *x) {
CGContextRef gc = (CGContextRef)Fl_Display_Device::display_device()->driver()->gc();
if (x && ((Fl_Cocoa_Window_Driver*)x->w->pWindowDriver)->gc != gc) return;
if (x && x->shown() && x->gc != gc) return;
if (!gc) return;
CGContextRestoreGState(gc); // match the CGContextSaveGState's of make_current
CGContextRestoreGState(gc);

View File

@ -100,7 +100,7 @@ int Fl_Cocoa_Printer_Driver::start_job (int pagecount, int *frompage, int *topag
{
OSStatus status = 0;
fl_open_display();
Fl_X::q_release_context();
Fl_Cocoa_Window_Driver::q_release_context();
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= 100500) {
NSPrintInfo *info = [NSPrintInfo sharedPrintInfo];

View File

@ -69,6 +69,7 @@ public:
Fl_Cocoa_Window_Driver(Fl_Window*);
~Fl_Cocoa_Window_Driver();
CGContextRef gc; // graphics context
static void q_release_context(Fl_Cocoa_Window_Driver *x = 0); // free all resources associated with gc
// --- window data
virtual int decorated_w();

View File

@ -236,7 +236,7 @@ void Fl_Cocoa_Window_Driver::hide() {
// worst case, an invisible pointer
if (ip && !parent()) pWindow->cursor(FL_CURSOR_DEFAULT);
if ( hide_common() ) return;
Fl_X::q_release_context(ip);
q_release_context(this);
if ( ip->xid == fl_window )
fl_window = 0;
if (ip->region) Fl_Graphics_Driver::XDestroyRegion(ip->region);