flushWindow updates

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4201 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1999-05-06 02:59:26 +00:00
parent a14735b7e9
commit 8a2bbcaae2
6 changed files with 33 additions and 19 deletions

View file

@ -1,3 +1,14 @@
1999-05-05 Adam Fedor <fedor@gnu.org>
* 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 <richard@brainstorm.co.uk> Tue May 4 18:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Headers/AppKit/NSGraphicsContext.h: methods for event handling. * Headers/AppKit/NSGraphicsContext.h: methods for event handling.

View file

@ -123,11 +123,8 @@ typedef enum _NSWindowOrderingMode
* in it's implementation of lockFocus and unlockFocus. * in it's implementation of lockFocus and unlockFocus.
*/ */
- (NSView*) focusView; - (NSView*) focusView;
- (void) lockFocusView: (NSView*)aView; - (void) lockFocusView: (NSView*)aView inRect: (NSRect)rect;
- (void) unlockFocusView: (NSView*)aView; - (void) unlockFocusView: (NSView*)aView needsFlush: (BOOL)flush;
/* Convert a rect in window coordinates to device space (Backend method) */
- (NSRect) windowRectInDeviceSpace: (NSRect)windowRect;
@end @end
#endif #endif

View file

@ -106,8 +106,8 @@ extern NSSize NSTokenSize;
NSBackingStoreType backing_type; NSBackingStoreType backing_type;
unsigned style_mask; unsigned style_mask;
int window_level; int window_level;
NSRect rectBeingDrawn;
NSRect rectNeedingFlush; NSRect rectNeedingFlush;
NSMutableArray *rectsBeingDrawn;
BOOL is_one_shot; BOOL is_one_shot;
BOOL needs_display; BOOL needs_display;

View file

@ -32,7 +32,6 @@
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSData.h> #include <Foundation/NSData.h>
#include <Foundation/NSLock.h> #include <Foundation/NSLock.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSZone.h> #include <Foundation/NSZone.h>
#include "AppKit/NSGraphicsContext.h" #include "AppKit/NSGraphicsContext.h"
#include "AppKit/NSAffineTransform.h" #include "AppKit/NSAffineTransform.h"
@ -203,30 +202,35 @@ struct NSWindow_struct
return [focus_stack lastObject]; return [focus_stack lastObject];
} }
- (void) lockFocusView: (NSView*)aView - (void) lockFocusView: (NSView*)aView inRect: (NSRect)rect
{ {
NSRect rect;
struct NSWindow_struct *window; struct NSWindow_struct *window;
[focus_stack addObject: aView]; [focus_stack addObject: aView];
window = (struct NSWindow_struct *)[aView window]; window = (struct NSWindow_struct *)[aView window];
/* Add aView's visible Rect to its Window's area to be flushed */ /* Add aView's visible Rect to its Window's area to be flushed */
rect = [aView convertRect: [aView visibleRect] toView: nil]; if (NSIsEmptyRect(rect))
window->rectBeingDrawn = NSUnionRect(window->rectBeingDrawn, 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; struct NSWindow_struct *window;
NSView *v = [focus_stack lastObject]; NSView *v = [focus_stack lastObject];
NSAssert(v == aView, NSInvalidArgumentException); NSAssert(v == aView, NSInvalidArgumentException);
/* Set Window's flush rect so our view is properly flushed */ /* Set Window's flush rect so our view is properly flushed */
window = (struct NSWindow_struct *)[aView window]; window = (struct NSWindow_struct *)[aView window];
window->rectNeedingFlush = NSUnionRect(window->rectNeedingFlush, if (flush)
window->rectBeingDrawn); {
window->rectBeingDrawn = NSZeroRect; rect = [[window->rectsBeingDrawn lastObject] rectValue];
window->needs_flush = YES; window->rectNeedingFlush = NSUnionRect(window->rectNeedingFlush, rect);
window->needs_flush = YES;
}
[window->rectsBeingDrawn removeLastObject];
[focus_stack removeLastObject]; [focus_stack removeLastObject];
} }

View file

@ -1055,12 +1055,13 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
- (void) lockFocus - (void) lockFocus
{ {
[[NSGraphicsContext currentContext] lockFocusView: self]; [[NSGraphicsContext currentContext] lockFocusView: self
inRect: [self visibleRect]];
} }
- (void) unlockFocus - (void) unlockFocus
{ {
[[NSGraphicsContext currentContext] unlockFocusView: self]; [[NSGraphicsContext currentContext] unlockFocusView: self needsFlush: YES ];
} }
- (BOOL) canDraw - (BOOL) canDraw

View file

@ -159,6 +159,7 @@
[miniaturized_title release]; [miniaturized_title release];
[miniaturized_image release]; [miniaturized_image release];
[window_title release]; [window_title release];
[rectsBeingDrawn release];
[super dealloc]; [super dealloc];
} }
@ -217,7 +218,7 @@
/* rectBeingDrawn is variable used to optimize flushing the backing store. /* rectBeingDrawn is variable used to optimize flushing the backing store.
It is set by NSGraphicContext during a lockFocus to tell NSWindow what 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 */ 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"); NSDebugLog(@"NSWindow end of init\n");
return self; return self;