mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Revamp flushWindow code
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4180 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8d3ef364d3
commit
ae7f99c597
5 changed files with 42 additions and 4 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
1999-05-01 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Headers/gnustep/gui/NSGraphicsContext.h
|
||||
(-windowRectInDeviceSpace:): New method.
|
||||
* Headers/gnustep/gui/NSWindow.h: Removed old flush ivar, added
|
||||
new one.
|
||||
* Source/NSGraphicsContext.m (-lockFocusView:): Set focus window's
|
||||
rectBeingDrawn ivar for flushing performance.
|
||||
(-unlockFOcusView:): Set rectNeedsFlush from rectBeingDrawn.
|
||||
|
||||
Thu Apr 29 13:10:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSControl.m: ([-drawRect:]) implemented to call ([-drawCell:])
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define _NSGraphicsContext_h_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
|
||||
#include <AppKit/GSMethodTable.h>
|
||||
|
||||
|
@ -121,6 +122,10 @@ typedef enum _NSWindowOrderingMode
|
|||
- (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;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ extern NSSize NSTokenSize;
|
|||
NSBackingStoreType backing_type;
|
||||
unsigned int style_mask;
|
||||
int window_level;
|
||||
NSMutableArray* _flushRectangles;
|
||||
NSRect rectBeingDrawn;
|
||||
NSRect rectNeedingFlush;
|
||||
|
||||
BOOL is_one_shot;
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSZone.h>
|
||||
#include "AppKit/NSGraphicsContext.h"
|
||||
#include "AppKit/NSAffineTransform.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include "AppKit/NSView.h"
|
||||
|
||||
/* The memory zone where all global objects are allocated from (Contexts
|
||||
are also allocated from this zone) */
|
||||
|
@ -58,6 +61,11 @@ static NSString *NSGraphicsContextThredKey = @"NSGraphicsContextThredKey";
|
|||
+ (gsMethodTable *) _initializeMethodTable;
|
||||
@end
|
||||
|
||||
struct NSWindow_struct
|
||||
{
|
||||
@defs(NSWindow)
|
||||
};
|
||||
|
||||
@implementation NSGraphicsContext
|
||||
|
||||
+ (void) initialize
|
||||
|
@ -197,14 +205,28 @@ static NSString *NSGraphicsContextThredKey = @"NSGraphicsContextThredKey";
|
|||
|
||||
- (void) lockFocusView: (NSView*)aView
|
||||
{
|
||||
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 _matrixToWindow] rectInMatrixSpace: [aView visibleRect]];
|
||||
window->rectBeingDrawn = NSUnionRect(window->rectBeingDrawn, rect);
|
||||
|
||||
}
|
||||
|
||||
- (void) unlockFocusView: (NSView*)aView
|
||||
{
|
||||
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];
|
||||
rect = [self windowRectInDeviceSpace: window->rectBeingDrawn];
|
||||
window->rectNeedingFlush = NSUnionRect(window->rectNeedingFlush, rect);
|
||||
window->rectBeingDrawn = NSZeroRect;
|
||||
[focus_stack removeLastObject];
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,6 @@
|
|||
[miniaturized_title release];
|
||||
[miniaturized_image release];
|
||||
[window_title release];
|
||||
[_flushRectangles release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -215,8 +214,10 @@
|
|||
cframe.size = frame.size;
|
||||
[self setContentView: [[[NSView alloc] initWithFrame: cframe] autorelease]];
|
||||
|
||||
_flushRectangles = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
|
||||
/* 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;
|
||||
NSDebugLog(@"NSWindow end of init\n");
|
||||
|
||||
return self;
|
||||
|
|
Loading…
Reference in a new issue