From 8a2bbcaae2a4db90887d82dbeb0c0e1f61b8ffea Mon Sep 17 00:00:00 2001 From: fedor Date: Thu, 6 May 1999 02:59:26 +0000 Subject: [PATCH] flushWindow updates git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4201 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 +++++++++++ Headers/gnustep/gui/NSGraphicsContext.h | 7 ++----- Headers/gnustep/gui/NSWindow.h | 2 +- Source/NSGraphicsContext.m | 24 ++++++++++++++---------- Source/NSView.m | 5 +++-- Source/NSWindow.m | 3 ++- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 011284cb8..44dd0aed1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +1999-05-05 Adam Fedor + + * Headers/gnustep/gui/NSGraphicsContext.h: New lock focus methods + to replace old ones (lockFocusView:inRect:, + unlockFocusView:needsFlush:). + * Headers/gnustep/gui/NSWindow.h: New rectsBeingDrawn stack. + * Source/NSGraphicsContext.m (-lockFocusView:inRect:): Implement. + (-unlockFocusView:needsFlush:): Likewise. + * Source/NSView.m (-lockFocus): Use them. + (-unlockFocus): Likewise. + Tue May 4 18:00:00 1999 Richard Frith-Macdonald * Headers/AppKit/NSGraphicsContext.h: methods for event handling. diff --git a/Headers/gnustep/gui/NSGraphicsContext.h b/Headers/gnustep/gui/NSGraphicsContext.h index bdc18d8e0..bc78a8c86 100644 --- a/Headers/gnustep/gui/NSGraphicsContext.h +++ b/Headers/gnustep/gui/NSGraphicsContext.h @@ -123,11 +123,8 @@ typedef enum _NSWindowOrderingMode * in it's implementation of lockFocus and unlockFocus. */ - (NSView*) focusView; -- (void) lockFocusView: (NSView*)aView; -- (void) unlockFocusView: (NSView*)aView; - -/* Convert a rect in window coordinates to device space (Backend method) */ -- (NSRect) windowRectInDeviceSpace: (NSRect)windowRect; +- (void) lockFocusView: (NSView*)aView inRect: (NSRect)rect; +- (void) unlockFocusView: (NSView*)aView needsFlush: (BOOL)flush; @end #endif diff --git a/Headers/gnustep/gui/NSWindow.h b/Headers/gnustep/gui/NSWindow.h index 3ea078255..0ecbb9eff 100644 --- a/Headers/gnustep/gui/NSWindow.h +++ b/Headers/gnustep/gui/NSWindow.h @@ -106,8 +106,8 @@ extern NSSize NSTokenSize; NSBackingStoreType backing_type; unsigned style_mask; int window_level; - NSRect rectBeingDrawn; NSRect rectNeedingFlush; + NSMutableArray *rectsBeingDrawn; BOOL is_one_shot; BOOL needs_display; diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index 6500b4aeb..532a8412b 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -32,7 +32,6 @@ #include #include #include -#include #include #include "AppKit/NSGraphicsContext.h" #include "AppKit/NSAffineTransform.h" @@ -203,30 +202,35 @@ struct NSWindow_struct return [focus_stack lastObject]; } -- (void) lockFocusView: (NSView*)aView +- (void) lockFocusView: (NSView*)aView inRect: (NSRect)rect { - NSRect rect; struct NSWindow_struct *window; [focus_stack addObject: aView]; window = (struct NSWindow_struct *)[aView window]; /* Add aView's visible Rect to its Window's area to be flushed */ - rect = [aView convertRect: [aView visibleRect] toView: nil]; - window->rectBeingDrawn = NSUnionRect(window->rectBeingDrawn, rect); + if (NSIsEmptyRect(rect)) + rect = [aView visibleRect]; + rect = [aView convertRect: rect toView: nil]; + [window->rectsBeingDrawn addObject: [NSValue valueWithRect: rect]]; } -- (void) unlockFocusView: (NSView*)aView +- (void) unlockFocusView: (NSView*)aView needsFlush: (BOOL)flush { + NSRect rect; struct NSWindow_struct *window; NSView *v = [focus_stack lastObject]; NSAssert(v == aView, NSInvalidArgumentException); /* Set Window's flush rect so our view is properly flushed */ window = (struct NSWindow_struct *)[aView window]; - window->rectNeedingFlush = NSUnionRect(window->rectNeedingFlush, - window->rectBeingDrawn); - window->rectBeingDrawn = NSZeroRect; - window->needs_flush = YES; + if (flush) + { + rect = [[window->rectsBeingDrawn lastObject] rectValue]; + window->rectNeedingFlush = NSUnionRect(window->rectNeedingFlush, rect); + window->needs_flush = YES; + } + [window->rectsBeingDrawn removeLastObject]; [focus_stack removeLastObject]; } diff --git a/Source/NSView.m b/Source/NSView.m index bd171fb04..9ca242f48 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -1055,12 +1055,13 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); - (void) lockFocus { - [[NSGraphicsContext currentContext] lockFocusView: self]; + [[NSGraphicsContext currentContext] lockFocusView: self + inRect: [self visibleRect]]; } - (void) unlockFocus { - [[NSGraphicsContext currentContext] unlockFocusView: self]; + [[NSGraphicsContext currentContext] unlockFocusView: self needsFlush: YES ]; } - (BOOL) canDraw diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 52ab4a58c..a4c904359 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -159,6 +159,7 @@ [miniaturized_title release]; [miniaturized_image release]; [window_title release]; + [rectsBeingDrawn release]; [super dealloc]; } @@ -217,7 +218,7 @@ /* rectBeingDrawn is variable used to optimize flushing the backing store. It is set by NSGraphicContext during a lockFocus to tell NSWindow what part a view is drawing in, so NSWindow only has to flush that portion */ - rectBeingDrawn = NSZeroRect; + rectsBeingDrawn = [[NSMutableArray arrayWithCapacity: 10] retain]; NSDebugLog(@"NSWindow end of init\n"); return self;