• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: subLayers - GPU - optimizing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subLayers - GPU - optimizing


  • Subject: Re: subLayers - GPU - optimizing
  • From: Matt Long <email@hidden>
  • Date: Mon, 9 Mar 2009 08:24:51 -0600

A crash when trying to add your layer again after a call to removeFromSuperlayer suggests that you're not retaining the layer and it's been autoreleased. You either need to re-allocate each time or retain it yourself. How are you allocating your CALayer inside of your Layer object?

-Matt



On Mar 9, 2009, at 7:43 AM, rajesh wrote:

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


  • Follow-Ups:
    • Re: subLayers - GPU - optimizing
      • From: rajesh <email@hidden>
References: 
 >subLayers - GPU - optimizing (From: rajesh <email@hidden>)

  • Prev by Date: Re: Why don't only these images don't show on the device?
  • Next by Date: Re: subLayers - GPU - optimizing
  • Previous by thread: subLayers - GPU - optimizing
  • Next by thread: Re: subLayers - GPU - optimizing
  • Index(es):
    • Date
    • Thread