Optimising drawing / transparent views
Optimising drawing / transparent views
- Subject: Optimising drawing / transparent views
- From: Ken Tabb <email@hidden>
- Date: Thu, 7 Apr 2005 15:43:09 +0100
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.
So in summary is there a way to do this or am I forever destined to
have to draw view1 stuff each time I update view2? View2 has to be
transparent, more's the pity.
If anyone has any ideas, I'd love to hear them!
Thanks in advance,
Ken
- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Developer - Health & Human Sciences
Machine Vision & Neural Network researcher - School of Computer Science
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider
_______________________________________________
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