Re: Small animation
Re: Small animation
- Subject: Re: Small animation
- From: Shawn Erickson <email@hidden>
- Date: Thu, 22 Jan 2004 06:48:20 -0800
On Jan 22, 2004, at 12:20 AM, Glen Low wrote:
I guess you are attempting move an image over a constant colored
background... In your code snippet (which follows) you are using a
image view and moving that view element around inside of a containing
view that is set to paint a constant color background. So you are
incurring the extra work of moving a view element (sub-class of
NSView) around in its containing view when instead it quicker to just
draw the image at the location you want in your view directly. No
need to use an image view. Additionally your drawRect method below is
completely repainting the whole of the containing view bounds not
just the part that needs updating. Sure it is being clipped as needed
but you are doing extra filling that is just going to be thrown away.
I was just thinking...
In my Graphviz GUI I have an NSImageView sitting inside of a
NSScrollView. Obviously the image view is not opaque, but the drawRect
must not be drawing the background either. Do you really make things
faster / more flicker free by having a custom view declare isOpaque to
be YES, and drawing a background in the drawRect? -- because in either
case, the background has to be blanked: either the system does it when
isOpaque is NO, or you have to do it when isOpaque is YES. (Note I am
talking about 10.2 optimization which precludes the non-overlapping
rects optimization.)
From Apple's docs...
http://developer.apple.com/documentation/Performance/Conceptual/
Drawing/Concepts/DrawingTips.html
---
Declare Subviews as Opaque
If you are writing a Cocoa application using custom NSView objects, you
can accelerate the drawing performance by declaring your views as
opaque. An opaque view is one that fills its entire bounding rectangle
with content. The Cocoa drawing system does not send update messages to
a superview for areas covered by one or more opaque subviews.
The isOpaque method of NSView returns NO by default. To declare your
custom view object as opaque, override this method and returnYES. If
you create an opaque view, remember that your view object is
responsible for filling its bounding rectangle with content.
---
In other words it doesn't bother attempting to draw what may be behind
your view because your view is going to clobber it anyways.
In general you should always be flicker free because of the window
buffer you draw into assuming your drawing itself isn't doing something
funky. This buffer isn't flush to the screen until a drawing cycle is
done (again assuming normal drawing cycles).
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.