diff --git a/ChangeLog b/ChangeLog index cc5eb54c5..ac4bb57a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jun 10 19:45:00 1999 Richard Frith-Macdonald + + * Source/NSView.m: Optimise display routines - avoid unneeded + re-displays. + Wed Jun 9 8:35:00 1999 Richard Frith-Macdonald * Headers/AppKit/DPSOperators.h: Add DPSmouselocation() diff --git a/Source/NSView.m b/Source/NSView.m index 38747225a..9f6da86e7 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -1175,6 +1175,8 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); if (coordinates_valid == NO) [self _rebuildCoordinates]; + + invalidRect = NSIntersectionRect(invalidRect, visibleRect); aRect = NSIntersectionRect(aRect, visibleRect); redrawRect = NSIntersectionRect(aRect, invalidRect); @@ -1244,17 +1246,20 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); } /* - * If our invalid rectangle is entirely contained with the area we - * have just redisplayed, then we set the invalid rectangle to zero + * If the rect we displayed contains the invalidRect for the view + * then we can empty invalidRect. All subviews will have been + * fully displayed, so the 'stillNeedsDisplay' flag will be NO. */ redrawRect = NSUnionRect(invalidRect, aRect); if (NSEqualRects(aRect, redrawRect) == YES) { invalidRect = NSZeroRect; - needs_display = stillNeedsDisplay; } else - needs_display = YES; + { + stillNeedsDisplay = YES; + } + needs_display = stillNeedsDisplay; [window flushWindow]; } @@ -1288,6 +1293,16 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); if (coordinates_valid == NO) [self _rebuildCoordinates]; + /* + * we limit the invalid rect to the visible area - since we can't + * display beyond that anyway. + */ + if (needs_display) + invalidRect = NSIntersectionRect(invalidRect, visibleRect); + + /* + * Now we draw this view. + */ ctxt = GSCurrentContext(); [ctxt lockFocusView: self inRect: aRect]; [self drawRect: aRect]; @@ -1329,8 +1344,9 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); } /* - * If the rect we displayed contains the invalidRect - * for the view then we can empty invalidRect. + * If the rect we displayed contains the invalidRect for the view + * then we can empty invalidRect. All subviews will have been + * fully displayed, so the 'stillNeedsDisplay' flag will be NO. */ rect = NSUnionRect(invalidRect, aRect); if (NSEqualRects(rect, aRect) == YES) @@ -1352,8 +1368,6 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); { if (coordinates_valid == NO) [self _rebuildCoordinates]; - if (needs_display) - invalidRect = NSIntersectionRect(invalidRect, visibleRect); return visibleRect; }