gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBackingStoreNonretained


From: Frederic De Jaeger
Subject: NSBackingStoreNonretained
Date: 04 Jul 2002 21:28:03 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Hi list.

I'm playing a little bit with windows of type
NSBackingStoreNonretained.  I suppose that few people create windows
this way because the code is quite inefficient.  
By the way, I don't see any good reasons  for creating  windows with
this type by default.  A lot of memory is wasted in the X server.  I
understand that this was a good scheme is the good old days of
NeXTStep, when cpu's were slow and the graphic bus was relatively
fast.  


In the current implementation, there are three problems: 
   - there is no compression of expose events.  
   - when an expose event arrives, all the content of the window is
refreshed instead of the necessary parts.  
   - when the window is refreshed, it begins by repainting its content
with the background color (which is already done by the Xserver (but
it does it with the wrong color))

If you combine all these 3 problems, you get terrible performance when
you try to "opaque move" something on top of a gnustep window.

I solve the first problem very easily.  Instead of refreshing the
window when the expose event arrives, I post a notification with 

  [[NSNotificationQueue defaultQueue]
    enqueueNotification:  [NSNotification notificationWithName: @"NSRedisplay"
                                          object: gui_win]
    postingStyle: NSPostWhenIdle
    coalesceMask:NSNotificationCoalescingOnName|NSNotificationCoalescingOnSender
    forModes: [NSArray arrayWithObjects: NSDefaultRunLoopMode,
                       NSModalPanelRunLoopMode,
                       NSEventTrackingRunLoopMode,
                       nil]];

Then the refresh occurs when the mainloop is idle.  

For the second problem, I want to compute the smallest rect containing
all the invalidated rectangles (maybe simply by calling
[contentView setNeedsDisplayInRect: rect] for every invalidated rect)

The third problem needs modification of the backend API (Maybe the API
is here and I don't know it).  We should have a notion of the default
background color (or image) and the clear operator.  It would be more
efficient than what [GSWindowView drawRect:] is doing :

- (void) drawRect: (NSRect)rect
{
  NSColor *c = [[self window] backgroundColor];
  
  [c set];
  NSRectFill(rect);
}

        
any suggestions ?

        Fred



reply via email to

[Prev in Thread] Current Thread [Next in Thread]