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:
Adam Fedor 1999-05-06 02:59:26 +00:00
parent 907642ce43
commit 20fc62f76c
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>
* 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.
*/
- (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

View file

@ -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;

View file

@ -32,7 +32,6 @@
#include <Foundation/NSException.h>
#include <Foundation/NSData.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSZone.h>
#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];
}

View file

@ -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

View file

@ -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;