Implement method drawRect:(NSRect) for class FLViewGL

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@13083 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2018-10-26 07:44:29 +00:00
parent 8ceabc92ef
commit e89bdd8c82

View File

@ -2057,7 +2057,7 @@ static void handleUpdateEvent( Fl_Window *window )
if ( !window ) return; if ( !window ) return;
Fl_X *i = Fl_X::i( window ); Fl_X *i = Fl_X::i( window );
[(FLView*)[fl_xid(window) contentView] did_view_resolution_change]; [(FLView*)[fl_xid(window) contentView] did_view_resolution_change];
if (!views_use_CA) i->wait_for_expose = 0; i->wait_for_expose = 0;
if ( i->region ) { if ( i->region ) {
XDestroyRegion(i->region); XDestroyRegion(i->region);
i->region = 0; i->region = 0;
@ -2357,24 +2357,35 @@ static CGContextRef prepare_bitmap_for_layer(int w, int h ) {
@interface FLViewGL : FLView // only for layered GL windows @interface FLViewGL : FLView // only for layered GL windows
- (void)displayLayer:(CALayer *)layer; - (void)displayLayer:(CALayer *)layer;
- (void)drawRect:(NSRect)rect;
@end @end
@implementation FLViewGL @implementation FLViewGL
- (void)displayLayer:(CALayer *)layer { - (void)displayLayer:(CALayer *)layer {
if (!Fl::use_high_res_GL()) layer.contentsScale = 1.;
[self drawRect:[self frame]]; [self drawRect:[self frame]];
}
- (void)drawRect:(NSRect)rect {
fl_lock_function();
Fl_Window *window = [(FLWindow*)[self window] getFl_Window]; Fl_Window *window = [(FLWindow*)[self window] getFl_Window];
if (window->parent()) window->redraw(); // useful during resize of GL subwindow
Fl_X *i = Fl_X::i( window ); Fl_X *i = Fl_X::i( window );
if (!Fl::use_high_res_GL() && fl_mac_os_version < 101401) [self layer].contentsScale = 1.;
through_drawRect = YES;
[self did_view_resolution_change];
window->clear_damage(FL_DAMAGE_ALL);
i->flush();
window->clear_damage();
through_drawRect = NO;
if (window->parent() && fl_mac_os_version < 101401) window->redraw(); // useful during resize of GL subwindow
if (i->wait_for_expose) { if (i->wait_for_expose) {
// 1st drawing of GL window // 1st drawing of GL window
NSRect r = [[self window] frame]; NSRect r = [[self window] frame];
r.size.width -= 1; r.size.width -= 1;
[[self window] setFrame:r display:NO]; // very dirty but works. Should find something better. [[self window] setFrame:r display:NO]; // very dirty but works.
r.size.width += 1; r.size.width += 1;
[[self window] setFrame:r display:YES]; [[self window] setFrame:r display:YES];
i->wait_for_expose = 0; i->wait_for_expose = 0;
} }
fl_unlock_function();
} }
@end @end
#endif //>= MAC_OS_X_VERSION_10_8 #endif //>= MAC_OS_X_VERSION_10_8