Re: Possible blunder with CALayers
Re: Possible blunder with CALayers
- Subject: Re: Possible blunder with CALayers
- From: rajesh <email@hidden>
- Date: Fri, 27 Feb 2009 12:21:47 +0100
Hi Patrick,
I did change the code and tried some possible ways
resizing seems no longer to be a problem (indeed you are an expert)
but...
When ever I add a Layer my "first" layer flickers and
one more thing , how do I set the Flip flag , I am overriding the
"isFlipped" in myView , still drawing starts from bottom-left.
Thanks
Rajesh
On Feb 27, 2009, at 12:07 PM, Patrick Mau wrote:
Hallo rajesh
I'm no expert and just took a brief look at your code.
You are being notified on your NSView frame change and add all your
layers
to your NSView again in 'layout'. This happens on each resize.
This looks very suspicious, because you should only add your layers
once
and later change the layer frames in 'layout'.
You should also think about checking if the NSView is in "live
resize" mode
and limit your number of calls calls to 'layout'.
Also note that modifying a layer frame will fire implicit CAAnimation.
This is all from the top of my head after looking at your mail.
I hope I could give youu some ideas.
All the best
Patrick
On 27.02.2009, at 10:29, rajesh wrote:
Sorry forgot to mention: the gray boxes flicker a lot could be Root
Layer delayed resizing.
On Feb 27, 2009, at 10:25 AM, rajesh wrote:
Hi All,
I recently posted a message with subject "View with Subviews +
Drawing on top of everything" and I got convinced to use CALayers
in my view instead of NSView's.
summary: I added few CALayers to myView and tried to resize myView
and result was rusty and snaggy.
When I used NSView's (initially) even adding 120-150 NSView's was
faster and responsive.
I assumed using CALayer (instead of NSView's) makes my app faster
and more responsive with appealing looks and animations but my code
seems made the opposite of fast (http://theocacao.com/document.page/595
)
There could be some possible flaw or I misunderstood the concept.
but the code is simple as of now ( I have to do lot of animation
and image additions in future ) still myView is slow ,
- (void)handleFrameChange:(NSNotification *)aNotification
{
[self layout];
}
-(void)layout
{
NSEnumerator *pageEnumr = [pages objectEnumerator];
id pg;
float widthMargin = [self frame].size.width;
NSRect rect;
while(pg = [pageEnumr nextObject])
{
rect = [pg bounds];
rect.origin.x = x;
rect.origin.y = y;
[pg setFrame:rect];
x += rect.size.width + spacing;
if ( x >= widthMargin )
{
x = xOffset;
y += rect.size.height + spacing ;
}
[rootLayer addSublayer:pg];
}
}
@end
_______________________________________________
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