Re: display optimization / display rectangles
Re: display optimization / display rectangles
- Subject: Re: display optimization / display rectangles
- From: Alastair Houghton <email@hidden>
- Date: Thu, 14 May 2009 22:51:14 +0100
On 14 May 2009, at 18:09, David Harper wrote:
I'm working on optimizing a document based application, and I've
found that overdrawing is a significant contributor to the
(tolerable, but non-ideal) performance issues I am experiencing.
[snip]
It sounds from your description as if the actual problem is not
overdrawing per se, but the fact that drawing a shadow for a large
rectangle isn't terribly well optimised in the Quartz code (IMO).
My impression (from doing something similar myself) is that the system
renders shadows by drawing the same shapes into a separate image, then
applying some kind of blur filter to the image before rendering it
behind the actual output.
If you draw a very large object, it unfortunately seems to generate
and blur a very large image. At least, that's what I assume since
shadow rendering performance seems to be very dependent on the overall
size of the thing that you're rendering.
Anyway, if you're trying to draw a page background with a shadow, the
naïve approach using NSShadow probably isn't the best way, because the
page is going to be a very large object at typical zoom factors.
There are a few things you might consider doing instead; e.g.:
- You might only render the edges of the page using NSShadow, and
just draw a plain white rectangle for the centre. You might still
have performance problems if the width or height of the shadowed
regions becomes too large.
- You might use images to render the page edges (essentially the same
way you would achieve a similar effect in HTML, if you've ever
tried). The downside is that you can't zoom the shadow itself (but
you probably don't need to, in this type of application).
- Or you could use a hybrid approach; essentially build the images at
render time if their size is now wrong. Remember you only need to
render the corners plus a 1px wide image for the top, a 1px wide image
at the bottom, and two 1px high images for the left and right. That
would let you zoom in on the shadow if you need to do that, but it's
more complicated than pre-rendered shadow images drawn in e.g.
Photoshop.
Personally I'd probably use images.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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