mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 08:41:00 +00:00
Some improvements and bux fix related to OpenGL
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28032 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2395ea184f
commit
b81c668496
7 changed files with 98 additions and 15 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2009-03-04 Xavier Glattard <xavier.glattard@online.fr>
|
||||||
|
|
||||||
|
* Headers/NSView.h,
|
||||||
|
Source/NSView.m: Add a flag 'ignoresBacking' that indicates the
|
||||||
|
receiver do not draw on the backing store, and so prevent the
|
||||||
|
backing store to be flushed by [-unlocFocus:]
|
||||||
|
* Headers/NSView.h,
|
||||||
|
Source/NSView.m,
|
||||||
|
Source/externs.m: Define NSViewGlobalFrameDidChangeNotification that
|
||||||
|
should be catched by NSOpenGLView (To Do)
|
||||||
|
* Headers/NSOpenGL.h,
|
||||||
|
Headers/NSOpenGLView.h: Some improvements, compatibility and/or bug
|
||||||
|
fix. NSOpenGLView catches NSViewGlobalFrameDidChangeNotification.
|
||||||
|
|
||||||
2009-03-02 Fred Kiefer <FredKiefer@gmx.de>
|
2009-03-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSSliderCell.m,
|
* Source/NSSliderCell.m,
|
||||||
|
|
|
@ -44,9 +44,13 @@ typedef enum {
|
||||||
NSOpenGLPFAMaximumPolicy = 52,
|
NSOpenGLPFAMaximumPolicy = 52,
|
||||||
NSOpenGLPFAOffScreen = 53,
|
NSOpenGLPFAOffScreen = 53,
|
||||||
NSOpenGLPFAFullScreen = 54,
|
NSOpenGLPFAFullScreen = 54,
|
||||||
NSOpenGLPFASampleBuffers = 55,
|
NSOpenGLPFASampleBuffers = 55, // 10.2
|
||||||
NSOpenGLPFASamples = 56,
|
NSOpenGLPFASamples = 56, // 10.2
|
||||||
NSOpenGLPFAAuxDepthStencil = 57,
|
NSOpenGLPFAAuxDepthStencil = 57, // 10.2
|
||||||
|
NSOpenGLPFAColorFloat = 58, // 10.4
|
||||||
|
NSOpenGLPFAMultisample = 59, // 10.4
|
||||||
|
NSOpenGLPFASupersample = 60, // 10.4
|
||||||
|
NSOpenGLPFASampleAlpha = 61, // 10.4
|
||||||
NSOpenGLPFARendererID = 70,
|
NSOpenGLPFARendererID = 70,
|
||||||
NSOpenGLPFASingleRenderer = 71,
|
NSOpenGLPFASingleRenderer = 71,
|
||||||
NSOpenGLPFANoRecovery = 72,
|
NSOpenGLPFANoRecovery = 72,
|
||||||
|
@ -59,7 +63,9 @@ typedef enum {
|
||||||
NSOpenGLPFAMultiScreen = 81,
|
NSOpenGLPFAMultiScreen = 81,
|
||||||
NSOpenGLPFACompliant = 83,
|
NSOpenGLPFACompliant = 83,
|
||||||
NSOpenGLPFAScreenMask = 84,
|
NSOpenGLPFAScreenMask = 84,
|
||||||
NSOpenGLPFAVirtualScreenCount = 128
|
NSOpenGLPFAPixelBuffer = 90, // 10.3
|
||||||
|
NSOpenGLPFAAllowOfflineRenderers = 96,// 10.5
|
||||||
|
NSOpenGLPFAVirtualScreenCount = 128 // 10.2
|
||||||
} NSOpenGLPixelFormatAttribute;
|
} NSOpenGLPixelFormatAttribute;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
{
|
{
|
||||||
NSOpenGLContext *glcontext;
|
NSOpenGLContext *glcontext;
|
||||||
NSOpenGLPixelFormat *pixel_format;
|
NSOpenGLPixelFormat *pixel_format;
|
||||||
BOOL attached;
|
BOOL prepared;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSOpenGLPixelFormat*) defaultPixelFormat;
|
+ (NSOpenGLPixelFormat*) defaultPixelFormat;
|
||||||
|
|
|
@ -136,6 +136,8 @@ typedef enum _NSFocusRingType {
|
||||||
unsigned valid_rects:1; /* Some cursor rects may be ok. */
|
unsigned valid_rects:1; /* Some cursor rects may be ok. */
|
||||||
unsigned needs_display:1; /* view needs display. */
|
unsigned needs_display:1; /* view needs display. */
|
||||||
unsigned has_tooltips:1; /* The view has tooltips set. */
|
unsigned has_tooltips:1; /* The view has tooltips set. */
|
||||||
|
unsigned ignores_backing:1; /* The view does not trigger */
|
||||||
|
/* backing flush when drawn */
|
||||||
} _rFlags;
|
} _rFlags;
|
||||||
|
|
||||||
BOOL _is_rotated_from_base;
|
BOOL _is_rotated_from_base;
|
||||||
|
@ -588,6 +590,10 @@ typedef enum _NSFocusRingType {
|
||||||
|
|
||||||
- (NSAffineTransform*) _matrixToWindow;
|
- (NSAffineTransform*) _matrixToWindow;
|
||||||
- (NSAffineTransform*) _matrixFromWindow;
|
- (NSAffineTransform*) _matrixFromWindow;
|
||||||
|
|
||||||
|
- (void) _setIgnoresBacking: (BOOL) flag;
|
||||||
|
- (BOOL) _ignoresBacking;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -600,5 +606,6 @@ APPKIT_EXPORT NSArray *GSGetDragTypes(NSView* aView);
|
||||||
APPKIT_EXPORT NSString *NSViewFrameDidChangeNotification;
|
APPKIT_EXPORT NSString *NSViewFrameDidChangeNotification;
|
||||||
APPKIT_EXPORT NSString *NSViewBoundsDidChangeNotification;
|
APPKIT_EXPORT NSString *NSViewBoundsDidChangeNotification;
|
||||||
APPKIT_EXPORT NSString *NSViewFocusDidChangeNotification;
|
APPKIT_EXPORT NSString *NSViewFocusDidChangeNotification;
|
||||||
|
APPKIT_EXPORT NSString *NSViewGlobalFrameDidChangeNotification;
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSView
|
#endif // _GNUstep_H_NSView
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
// Declare a private method of NSView
|
// Declare a private method of NSView
|
||||||
@interface NSView (Private)
|
@interface NSView (Private)
|
||||||
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect;
|
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect;
|
||||||
|
- (void) _viewWillMoveToWindow: (NSWindow*)newWindow;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,16 +101,17 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
{
|
{
|
||||||
[glcontext clearDrawable];
|
[glcontext clearDrawable];
|
||||||
DESTROY(glcontext);
|
DESTROY(glcontext);
|
||||||
|
prepared = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setOpenGLContext: (NSOpenGLContext*)context
|
- (void) setOpenGLContext: (NSOpenGLContext*)context
|
||||||
{
|
{
|
||||||
[self clearGLContext];
|
if ( context != glcontext )
|
||||||
ASSIGN(glcontext, context);
|
{
|
||||||
[glcontext setView: self];
|
[self clearGLContext];
|
||||||
[glcontext makeCurrentContext];
|
ASSIGN(glcontext, context);
|
||||||
[self prepareOpenGL];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) prepareOpenGL
|
- (void) prepareOpenGL
|
||||||
|
@ -128,6 +130,8 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
shareContext: nil];
|
shareContext: nil];
|
||||||
|
|
||||||
[self setOpenGLContext: context];
|
[self setOpenGLContext: context];
|
||||||
|
[context setView: self];
|
||||||
|
|
||||||
RELEASE(context);
|
RELEASE(context);
|
||||||
}
|
}
|
||||||
return glcontext;
|
return glcontext;
|
||||||
|
@ -152,6 +156,12 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
|
|
||||||
ASSIGN(pixel_format, format);
|
ASSIGN(pixel_format, format);
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
addObserver: self
|
||||||
|
selector: @selector(_frameChanged:)
|
||||||
|
name: NSViewGlobalFrameDidChangeNotification
|
||||||
|
object: self];
|
||||||
|
|
||||||
[self setPostsFrameChangedNotifications: YES];
|
[self setPostsFrameChangedNotifications: YES];
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: self
|
addObserver: self
|
||||||
|
@ -165,8 +175,8 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
[self clearGLContext];
|
||||||
RELEASE(pixel_format);
|
RELEASE(pixel_format);
|
||||||
RELEASE(glcontext);
|
|
||||||
NSDebugMLLog(@"GL", @"deallocating");
|
NSDebugMLLog(@"GL", @"deallocating");
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -187,12 +197,22 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
|
|
||||||
- (void) update
|
- (void) update
|
||||||
{
|
{
|
||||||
[glcontext update];
|
NSOpenGLContext *context;
|
||||||
|
context = [self openGLContext];
|
||||||
|
if ([context view] == self)
|
||||||
|
{
|
||||||
|
[context update];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) isOpaque
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _frameChanged: (NSNotification *) aNot
|
- (void) _frameChanged: (NSNotification *) aNot
|
||||||
{
|
{
|
||||||
NSDebugMLLog(@"GL", @"our frame has changed");
|
[[self openGLContext] makeCurrentContext];
|
||||||
[self update];
|
[self update];
|
||||||
[self reshape];
|
[self reshape];
|
||||||
}
|
}
|
||||||
|
@ -201,8 +221,32 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
*/
|
*/
|
||||||
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
|
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
|
NSOpenGLContext *context;
|
||||||
|
context = [self openGLContext];
|
||||||
|
|
||||||
[super _lockFocusInContext: ctxt inRect: rect];
|
[super _lockFocusInContext: ctxt inRect: rect];
|
||||||
[[self openGLContext] makeCurrentContext];
|
[context makeCurrentContext];
|
||||||
|
if ([context view] != self)
|
||||||
|
{
|
||||||
|
[context setView:self];
|
||||||
|
}
|
||||||
|
if (!prepared)
|
||||||
|
{
|
||||||
|
[self prepareOpenGL];
|
||||||
|
prepared = YES;
|
||||||
|
[self reshape];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) _viewWillMoveToWindow: (NSWindow *) newWindow
|
||||||
|
{
|
||||||
|
[super _viewWillMoveToWindow: newWindow];
|
||||||
|
|
||||||
|
if ([self window] != newWindow)
|
||||||
|
{
|
||||||
|
// the context will be recreated in the new window if needed
|
||||||
|
[[self openGLContext] clearDrawable];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -2050,6 +2050,16 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
|
||||||
GSWSetViewIsFlipped(ctxt, _rFlags.flipped_view);
|
GSWSetViewIsFlipped(ctxt, _rFlags.flipped_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _setIgnoresBacking: (BOOL) flag
|
||||||
|
{
|
||||||
|
_rFlags.ignores_backing = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) _ignoresBacking
|
||||||
|
{
|
||||||
|
return _rFlags.ignores_backing;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) unlockFocusNeedsFlush: (BOOL)flush
|
- (void) unlockFocusNeedsFlush: (BOOL)flush
|
||||||
{
|
{
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||||
|
@ -2078,7 +2088,7 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
struct NSWindow_struct *window_t;
|
struct NSWindow_struct *window_t;
|
||||||
window_t = (struct NSWindow_struct *)_window;
|
window_t = (struct NSWindow_struct *)_window;
|
||||||
if (flush)
|
if (flush && !_rFlags.ignores_backing)
|
||||||
{
|
{
|
||||||
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue];
|
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue];
|
||||||
window_t->_rectNeedingFlush =
|
window_t->_rectNeedingFlush =
|
||||||
|
|
|
@ -381,6 +381,8 @@ NSString *NSViewFrameDidChangeNotification
|
||||||
= @"NSViewFrameDidChangeNotification";
|
= @"NSViewFrameDidChangeNotification";
|
||||||
NSString *NSViewBoundsDidChangeNotification
|
NSString *NSViewBoundsDidChangeNotification
|
||||||
= @"NSViewBoundsDidChangeNotification";
|
= @"NSViewBoundsDidChangeNotification";
|
||||||
|
NSString *NSViewGlobalFrameDidChangeNotification
|
||||||
|
= @"NSViewGlobalFrameDidChangeNotification";
|
||||||
|
|
||||||
// NSMenu notifications
|
// NSMenu notifications
|
||||||
NSString* const NSMenuDidSendActionNotification = @"MenuDidSendAction";
|
NSString* const NSMenuDidSendActionNotification = @"MenuDidSendAction";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue