Re: Optimising drawing / transparent views
Re: Optimising drawing / transparent views
- Subject: Re: Optimising drawing / transparent views
- From: Ricky Sharp <email@hidden>
- Date: Thu, 07 Apr 2005 09:53:25 -0500
On Thursday, April 07, 2005, at 09:45AM, Ken Tabb <email@hidden> wrote:
>Afternoon folks (well morning for most of you I guess),
>
>I have 2 custom views of equal sizes.
>
>View1 contains computationally expensive, but infrequently called,
>drawing... that said the things it's drawing do change, so it's not
>static enough that I could take a snapshot of them offscreen and use
>that as a basis for the drawing.
>
>View2 on the other hand contains computationally cheap and very
>frequently called drawing.
>
>I'd like to superimpose view2, which is transparent, on top of (i.e.
>show in front of) view1, which is opaque.
>
>My hope is that, by doing the cheap/frequently called drawing in view2,
>I don't have to keep redrawing the expensive bits in view1 each time
>view2 gets a -drawRect.
>
>However my initial testing has been unsuccessful; I add view2 as a
>subview to view1, but each time view2 gets a -setNeedsDisplayInRect, so
>does view1, causing the expensive drawing to start as they seem to be
>competing for area in the same graphics context. Needless to say I'm
>doing as much optimisation as I can within view1, as per Cocoa docs /
>detecting if something's in the rect before drawing it etc.
>
>If I were to add view2 to view1's superview (so they're sibling views
>sharing the same frame rect in the superview), instead of view2 being a
>subview of view1, would that mean view1 doesn't get called to update
>itself each time view2 does? Or is it not the done thing to have 2
>sibling views (entirely) overlapping?
>
>I considered using an overlay window (like they demod at last year's
>WWDC), where there is basically a transparent window sitting in front
>of my window. I presume this is how IB draws the blue connection lines
>from one window to another, but it seems like there must be a more
>elegant way of overlaying something on a given view; fair enough IB is
>going window <-> window, but I'm just needing to do it on 1 view so am
>thinking an extra window would be wasteful in terms of resources.
I would definitely use an overlay window for this; it's really not wasteful at all.
I use overlays for custom help tags, watermarks (for demo version of the app) and tutorial "overlays".
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden