Re: Quickest Drawing Method
Re: Quickest Drawing Method
- Subject: Re: Quickest Drawing Method
- From: Uli Kusterer <email@hidden>
- Date: Sun, 22 Jul 2007 17:11:17 +0200
On 22.07.2007, at 16:08, spiderlama wrote:
What I am attempting is to make the Leopard Dock (in Tiger) by
first hiding the Dock's background and drawing the new image behind
it. I am using the Accessibility framework to get the Dock's
position, size and orientation so this is why I need it to
constantly update (as I don't know when the Dock will change).
Well, you don't need to constantly redraw, however. Just keep
around the old rect and size, and only when it changes, redraw. I
think that's your main issue. Only draw when something actually
changes. The OS caches each window in a buffer, so you don't
generally have to redraw when the dock changes, unless it actually
changes in a way that makes you need to change your drawings.
Can you do this beforehand, perhaps? Or composite the images into
each other, and thus only scale the final image once? There are
numerous ways to optimize stuff like that in general. Are you
cacheing your images, or recreating each time? And what are you
actually using this for? Animations? A status display? Graphing?
What?
Two images are dynamically taken from the system, another is an
image with alpha channel, and another made using a multiple of a
smaller image. All of these depend on the size of the Dock, so no
pre-composing.
None of these should take very long to draw, if you do it
correctly. You *can* pre-scale all of them, though, and only recreate
the scaled versions from the larger versions when the size actually
changes. The less pixels in need of being scaled, the faster your
drawing will be. But as I said above, I doubt that's your problem.
Not much masking is happening, the bare minimum is used. I use
[NSImage drawInRect...] with operation NSCompositeDestinationIn to
draw the mask (alpha image). I don't know if this is CG or what (as
I am new to this).
I think another compositing operation might be a little faster. I
think using a mask on the actual images while drawing should be
faster that using a compositing mode here. But even without that I
can't see why you would need it to draw faster.
So is it feasible to copy this methodology? I want (need) lightning
fast resizing of the window (and therefore drawing of the image).
You must be doing something else wrong. Have you timed your code in
Shark? I would be very surprised if the window resized too slowly.
Keep in mind that each scrollbar is made up of several images, some
of them drawn repeating, and they resize fast enough while dragging
and resizing movies.
I know this sucks, but as the nature of the program is to follow
Dock size and I don't know of any callbacks that I can use.
As I said, resize only when needed.
Sorry, but I am trying to keep my project pretty need-to-know, to
deter the real programmers from stealing my idea!
Thanks for believing in our honesty this much, I guess ...? You
think nobody before you had the idea of copying the Leopard Dock?
Gee, we must not only be dishonest, but stupid, too.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden