subLayers - GPU - optimizing
subLayers - GPU - optimizing
- Subject: subLayers - GPU - optimizing
- From: rajesh <email@hidden>
- Date: Mon, 9 Mar 2009 14:43:42 +0100
Hi all,
sorry for bad subject line, again :)
I have a layer backed view, I am trying to add subLayers roughly sized
around 300 X 270 (in pixels ) to it,
its that the, sublayers count may reach upto the 1000 to 2000 in
number and not to mention each of sublayer is again scalable to
roughly 4280 X 1500 or more for starters.
So the problem is obviously that of a GPU constraint.
after adding around 100 subLayers sized 300 X 270 , there is a warning
" image is too large for GPU, ignoring" and that messing up with my
the layer display.
solution for such problem (from some mailing lists) was to use
CATiledLayer , but I can't make use of the tiledLayer due to the
complex requirement of the subLayer's display.
Is there a possibility of removingthe subLayers which don't fall under
VisibleRect of the view ?
I tried to "removeFromSuperlayer" and then adding it whenever
required , there's always a crash when I try to add the subLayer back.
Is there any solution for tackling the problem ?
any help is appreciated.
Thanks
Rajesh
@ViewClass
-(IBAction)addLayer:(id)sender
{
Layer *l = [[Layer alloc] init];
CALayer *layer = [l page];
[contentArray addObject:page];
[drawLayer addSublayer:layer];
[self layout];
}
-(void)layout
{
NSEnumerator *pageEnumr = [contentArray objectEnumerator];
float widthMargin = [self frame].size.width;
CGRect rect;
float zoom = [self zoomFactor];
while(obj = [contentEnmr nextObject] )
{
[obj setZoomFactor:zoom];
CALayer *pg =(CALayer *)[obj page] ;
rect = pg.bounds;
if ( x + pg.bounds.size.width > widthMargin )
{
x = xOffset;
y += rect.size.height + spacing ;
}
rect.origin = CGPointMake(x,y);
[pg setFrame:rect];
[obj changeBounds];
//this is where i am trying to remove and add the sublayer
// NSRect VisibleRect = [self visibleRect];
// NSRect result =
NSIntersectionRect(VisibleRect,NSRectFromCGRect( rect));
// if( NSEqualRects (result ,NSZeroRect) )
// {
// [pg removeFromSuperlayer];
// }else
// {
// [drawLayer addSublayer:pg];
// [pg setFrame:rect];
// [pg setNeedsDisplay];
// }
x += ( rect.size.width + spacing);
}
NSRect viewRect = [self frame];
if(viewRect.size.height < ( y + rect.size.height + spacing ) )
viewRect.size.height = ( y + rect.size.height + spacing) ;
[self setFrameSize: viewRect.size];
}
@interface Layer : NSObject {
CALayer *page;
}
@property (retain) CALayer *page;
_______________________________________________
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