mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:10:48 +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
7c2e8efcd8
commit
74bcdbdd94
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>
|
||||
|
||||
* Source/NSSliderCell.m,
|
||||
|
|
|
@ -44,9 +44,13 @@ typedef enum {
|
|||
NSOpenGLPFAMaximumPolicy = 52,
|
||||
NSOpenGLPFAOffScreen = 53,
|
||||
NSOpenGLPFAFullScreen = 54,
|
||||
NSOpenGLPFASampleBuffers = 55,
|
||||
NSOpenGLPFASamples = 56,
|
||||
NSOpenGLPFAAuxDepthStencil = 57,
|
||||
NSOpenGLPFASampleBuffers = 55, // 10.2
|
||||
NSOpenGLPFASamples = 56, // 10.2
|
||||
NSOpenGLPFAAuxDepthStencil = 57, // 10.2
|
||||
NSOpenGLPFAColorFloat = 58, // 10.4
|
||||
NSOpenGLPFAMultisample = 59, // 10.4
|
||||
NSOpenGLPFASupersample = 60, // 10.4
|
||||
NSOpenGLPFASampleAlpha = 61, // 10.4
|
||||
NSOpenGLPFARendererID = 70,
|
||||
NSOpenGLPFASingleRenderer = 71,
|
||||
NSOpenGLPFANoRecovery = 72,
|
||||
|
@ -59,7 +63,9 @@ typedef enum {
|
|||
NSOpenGLPFAMultiScreen = 81,
|
||||
NSOpenGLPFACompliant = 83,
|
||||
NSOpenGLPFAScreenMask = 84,
|
||||
NSOpenGLPFAVirtualScreenCount = 128
|
||||
NSOpenGLPFAPixelBuffer = 90, // 10.3
|
||||
NSOpenGLPFAAllowOfflineRenderers = 96,// 10.5
|
||||
NSOpenGLPFAVirtualScreenCount = 128 // 10.2
|
||||
} NSOpenGLPixelFormatAttribute;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
{
|
||||
NSOpenGLContext *glcontext;
|
||||
NSOpenGLPixelFormat *pixel_format;
|
||||
BOOL attached;
|
||||
BOOL prepared;
|
||||
}
|
||||
|
||||
+ (NSOpenGLPixelFormat*) defaultPixelFormat;
|
||||
|
|
|
@ -136,6 +136,8 @@ typedef enum _NSFocusRingType {
|
|||
unsigned valid_rects:1; /* Some cursor rects may be ok. */
|
||||
unsigned needs_display:1; /* view needs display. */
|
||||
unsigned has_tooltips:1; /* The view has tooltips set. */
|
||||
unsigned ignores_backing:1; /* The view does not trigger */
|
||||
/* backing flush when drawn */
|
||||
} _rFlags;
|
||||
|
||||
BOOL _is_rotated_from_base;
|
||||
|
@ -588,6 +590,10 @@ typedef enum _NSFocusRingType {
|
|||
|
||||
- (NSAffineTransform*) _matrixToWindow;
|
||||
- (NSAffineTransform*) _matrixFromWindow;
|
||||
|
||||
- (void) _setIgnoresBacking: (BOOL) flag;
|
||||
- (BOOL) _ignoresBacking;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
@ -600,5 +606,6 @@ APPKIT_EXPORT NSArray *GSGetDragTypes(NSView* aView);
|
|||
APPKIT_EXPORT NSString *NSViewFrameDidChangeNotification;
|
||||
APPKIT_EXPORT NSString *NSViewBoundsDidChangeNotification;
|
||||
APPKIT_EXPORT NSString *NSViewFocusDidChangeNotification;
|
||||
APPKIT_EXPORT NSString *NSViewGlobalFrameDidChangeNotification;
|
||||
|
||||
#endif // _GNUstep_H_NSView
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
// Declare a private method of NSView
|
||||
@interface NSView (Private)
|
||||
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect;
|
||||
- (void) _viewWillMoveToWindow: (NSWindow*)newWindow;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -100,16 +101,17 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
|||
{
|
||||
[glcontext clearDrawable];
|
||||
DESTROY(glcontext);
|
||||
prepared = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setOpenGLContext: (NSOpenGLContext*)context
|
||||
{
|
||||
[self clearGLContext];
|
||||
ASSIGN(glcontext, context);
|
||||
[glcontext setView: self];
|
||||
[glcontext makeCurrentContext];
|
||||
[self prepareOpenGL];
|
||||
if ( context != glcontext )
|
||||
{
|
||||
[self clearGLContext];
|
||||
ASSIGN(glcontext, context);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) prepareOpenGL
|
||||
|
@ -128,6 +130,8 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
|||
shareContext: nil];
|
||||
|
||||
[self setOpenGLContext: context];
|
||||
[context setView: self];
|
||||
|
||||
RELEASE(context);
|
||||
}
|
||||
return glcontext;
|
||||
|
@ -152,6 +156,12 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
|||
|
||||
ASSIGN(pixel_format, format);
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_frameChanged:)
|
||||
name: NSViewGlobalFrameDidChangeNotification
|
||||
object: self];
|
||||
|
||||
[self setPostsFrameChangedNotifications: YES];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
|
@ -165,8 +175,8 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
|||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
[self clearGLContext];
|
||||
RELEASE(pixel_format);
|
||||
RELEASE(glcontext);
|
||||
NSDebugMLLog(@"GL", @"deallocating");
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -187,12 +197,22 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
|||
|
||||
- (void) update
|
||||
{
|
||||
[glcontext update];
|
||||
NSOpenGLContext *context;
|
||||
context = [self openGLContext];
|
||||
if ([context view] == self)
|
||||
{
|
||||
[context update];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) _frameChanged: (NSNotification *) aNot
|
||||
{
|
||||
NSDebugMLLog(@"GL", @"our frame has changed");
|
||||
[[self openGLContext] makeCurrentContext];
|
||||
[self update];
|
||||
[self reshape];
|
||||
}
|
||||
|
@ -201,8 +221,32 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
|||
*/
|
||||
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
|
||||
{
|
||||
NSOpenGLContext *context;
|
||||
context = [self openGLContext];
|
||||
|
||||
[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
|
||||
|
|
|
@ -2050,6 +2050,16 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
|
|||
GSWSetViewIsFlipped(ctxt, _rFlags.flipped_view);
|
||||
}
|
||||
|
||||
- (void) _setIgnoresBacking: (BOOL) flag
|
||||
{
|
||||
_rFlags.ignores_backing = flag;
|
||||
}
|
||||
|
||||
- (BOOL) _ignoresBacking
|
||||
{
|
||||
return _rFlags.ignores_backing;
|
||||
}
|
||||
|
||||
- (void) unlockFocusNeedsFlush: (BOOL)flush
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
@ -2078,7 +2088,7 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
|
|||
NSRect rect;
|
||||
struct NSWindow_struct *window_t;
|
||||
window_t = (struct NSWindow_struct *)_window;
|
||||
if (flush)
|
||||
if (flush && !_rFlags.ignores_backing)
|
||||
{
|
||||
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue];
|
||||
window_t->_rectNeedingFlush =
|
||||
|
|
|
@ -381,6 +381,8 @@ NSString *NSViewFrameDidChangeNotification
|
|||
= @"NSViewFrameDidChangeNotification";
|
||||
NSString *NSViewBoundsDidChangeNotification
|
||||
= @"NSViewBoundsDidChangeNotification";
|
||||
NSString *NSViewGlobalFrameDidChangeNotification
|
||||
= @"NSViewGlobalFrameDidChangeNotification";
|
||||
|
||||
// NSMenu notifications
|
||||
NSString* const NSMenuDidSendActionNotification = @"MenuDidSendAction";
|
||||
|
|
Loading…
Reference in a new issue