Re: Simulating sublayers in CATiledLayer
Finally it works! I now have a CALayer backed UIView with CATiledLayer sublayers with full zooming support. I'm not entirely sure what change actually turned it into something working, but I'm happy it does work now. Thanks for all support. Remco Graham Cox schreef op 26-3-2014 1:04: Did you notice what David Duncan said?: For CATiledLayer you need to ensure the levelOfDetail and levelOfDetailBias is set correctly This is crucial to being able to zoom properly. It's also not that obvious what these mean or the proper values to use, but there was a discussion about this back in December or so if I recall correctly (search for 'Threaded drawing'), which expounded on this. I got CATiledLayer zooming to work as expected with vector content remaining sharp, but only once these properties had been understood and set. --Graham On 26 Mar 2014, at 4:55 am, Remco Poelstra re...@beryllium.net wrote: Well, the parent CATiledLayer (the UIViews's layer) uses transforms for zooming, but that isn't communicated down the sublayers. The context of the sublayers is simply scaled. All I've done is set the UIView layer class to CATiledLayer. Add the UIView to a UIScrollview. And added sub CA(Tiled)Layers to the CATiledLayer of the UIView. The transform is applied to the root layer, and not to the sublayers. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
David Duncan schreef op 24-3-2014 20:41: On Mar 22, 2014, at 2:18 AM, Remco Poelstra re...@beryllium.net mailto:re...@beryllium.net wrote: How can I make sure that some custom drawing method get's called? Call -setNeedsDisplay on the layer (layers are valid by default) Hi, I tried that, but it only draws the layer once. When I zoom in, the content becomes pixelated. I tried to subclass CATiledLayer and override -setAffineTransform to set the contentsScale of all sub layers depending on the current transform, but that gives all sorts of drawing errors. Is there a way to keep the custom drawn content sharp? Like with CAShapeLayers? Thanks in advance. Kind regards, Remco Poelstra ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Remco, I don't know if zooming the layer counts as a change in the layer's bounds, but if your not already doing so, you could try calling -setNeedsDisplayOnBoundsChange: with YES. Sandor On Mar 25, 2014, at 4:56, Remco Poelstra re...@beryllium.net wrote: David Duncan schreef op 24-3-2014 20:41: On Mar 22, 2014, at 2:18 AM, Remco Poelstra re...@beryllium.net mailto:re...@beryllium.net wrote: How can I make sure that some custom drawing method get's called? Call -setNeedsDisplay on the layer (layers are valid by default) Hi, I tried that, but it only draws the layer once. When I zoom in, the content becomes pixelated. I tried to subclass CATiledLayer and override -setAffineTransform to set the contentsScale of all sub layers depending on the current transform, but that gives all sorts of drawing errors. Is there a way to keep the custom drawn content sharp? Like with CAShapeLayers? Thanks in advance. Kind regards, Remco Poelstra ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com This email sent to admin.szatmari@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Hi, No, it doesn't. The zooming is done by changing the transform of the tiled layer, scrolling changes the bounds of the tiled layer. Remco Sandor Szatmari schreef op 25-3-2014 12:14: Remco, I don't know if zooming the layer counts as a change in the layer's bounds, but if your not already doing so, you could try calling -setNeedsDisplayOnBoundsChange: with YES. Sandor On Mar 25, 2014, at 4:56, Remco Poelstra re...@beryllium.net wrote: David Duncan schreef op 24-3-2014 20:41: On Mar 22, 2014, at 2:18 AM, Remco Poelstra re...@beryllium.net mailto:re...@beryllium.net wrote: How can I make sure that some custom drawing method get's called? Call -setNeedsDisplay on the layer (layers are valid by default) Hi, I tried that, but it only draws the layer once. When I zoom in, the content becomes pixelated. I tried to subclass CATiledLayer and override -setAffineTransform to set the contentsScale of all sub layers depending on the current transform, but that gives all sorts of drawing errors. Is there a way to keep the custom drawn content sharp? Like with CAShapeLayers? Thanks in advance. Kind regards, Remco Poelstra ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com This email sent to admin.szatmari@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
On Mar 25, 2014, at 1:56 AM, Remco Poelstra re...@beryllium.net wrote: David Duncan schreef op 24-3-2014 20:41: On Mar 22, 2014, at 2:18 AM, Remco Poelstra re...@beryllium.net wrote: How can I make sure that some custom drawing method get's called? Call -setNeedsDisplay on the layer (layers are valid by default) Hi, I tried that, but it only draws the layer once. When I zoom in, the content becomes pixelated. I tried to subclass CATiledLayer and override -setAffineTransform to set the contentsScale of all sub layers depending on the current transform, but that gives all sorts of drawing errors. Is there a way to keep the custom drawn content sharp? Like with CAShapeLayers? Is this a CATiledLayer or a CALayer? CALayers don’t redraw like this when you zoom, and while there are a few techniques for doing this yourself, you have to be fairly careful to avoid huge memory spikes. For CATiledLayer you need to ensure the levelOfDetail and levelOfDetailBias is set correctly, but that should be about it. CAShapeLayers redraw automatically because they are vector content and as such can be resized. CALayers and CATiledLayers display bitmap content – tiled layers only get shaper because they are designed to maintain multiple levels of detail. -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Op 25 mrt. 2014 om 17:25 heeft David Duncan david.dun...@apple.com het volgende geschreven: On Mar 25, 2014, at 1:56 AM, Remco Poelstra re...@beryllium.net wrote: David Duncan schreef op 24-3-2014 20:41: On Mar 22, 2014, at 2:18 AM, Remco Poelstra re...@beryllium.net wrote: How can I make sure that some custom drawing method get's called? Call -setNeedsDisplay on the layer (layers are valid by default) Hi, I tried that, but it only draws the layer once. When I zoom in, the content becomes pixelated. I tried to subclass CATiledLayer and override -setAffineTransform to set the contentsScale of all sub layers depending on the current transform, but that gives all sorts of drawing errors. Is there a way to keep the custom drawn content sharp? Like with CAShapeLayers? Is this a CATiledLayer or a CALayer? CALayers don’t redraw like this when you zoom, and while there are a few techniques for doing this yourself, you have to be fairly careful to avoid huge memory spikes. For CATiledLayer you need to ensure the levelOfDetail and levelOfDetailBias is set correctly, but that should be about it. CAShapeLayers redraw automatically because they are vector content and as such can be resized. CALayers and CATiledLayers display bitmap content – tiled layers only get shaper because they are designed to maintain multiple levels of detail. I've tried with both CALayer and CATiledLayer sublayers, but the CATiledLayer also did not redraw (at higher resolution) when its parent layer has a transform. I think because the sublayer knows nothing about the transform of the parent layer. I'm also uncertain about the best moment to call setneedsdisplay on the sublayers when zooming and panning. Remco ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
On Mar 25, 2014, at 9:50 AM, Remco Poelstra re...@beryllium.net wrote: I've tried with both CALayer and CATiledLayer sublayers, but the CATiledLayer also did not redraw (at higher resolution) when its parent layer has a transform. Sounds like your solution involves ceasing the use of transforms for zooming. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Op 25 mrt. 2014 om 17:59 heeft Kyle Sluder k...@ksluder.com het volgende geschreven: On Mar 25, 2014, at 9:50 AM, Remco Poelstra re...@beryllium.net wrote: I've tried with both CALayer and CATiledLayer sublayers, but the CATiledLayer also did not redraw (at higher resolution) when its parent layer has a transform. Sounds like your solution involves ceasing the use of transforms for zooming. Well, the parent CATiledLayer (the UIViews's layer) uses transforms for zooming, but that isn't communicated down the sublayers. The context of the sublayers is simply scaled. All I've done is set the UIView layer class to CATiledLayer. Add the UIView to a UIScrollview. And added sub CA(Tiled)Layers to the CATiledLayer of the UIView. The transform is applied to the root layer, and not to the sublayers. Remco ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Did you notice what David Duncan said?: For CATiledLayer you need to ensure the levelOfDetail and levelOfDetailBias is set correctly This is crucial to being able to zoom properly. It's also not that obvious what these mean or the proper values to use, but there was a discussion about this back in December or so if I recall correctly (search for 'Threaded drawing'), which expounded on this. I got CATiledLayer zooming to work as expected with vector content remaining sharp, but only once these properties had been understood and set. --Graham On 26 Mar 2014, at 4:55 am, Remco Poelstra re...@beryllium.net wrote: Well, the parent CATiledLayer (the UIViews's layer) uses transforms for zooming, but that isn't communicated down the sublayers. The context of the sublayers is simply scaled. All I've done is set the UIView layer class to CATiledLayer. Add the UIView to a UIScrollview. And added sub CA(Tiled)Layers to the CATiledLayer of the UIView. The transform is applied to the root layer, and not to the sublayers. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
On Mar 22, 2014, at 2:18 AM, Remco Poelstra re...@beryllium.net wrote: How can I make sure that some custom drawing method get's called? Call -setNeedsDisplay on the layer (layers are valid by default) -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Hi, So, I've been experimenting with sublayers of CATiledLayer and this indeed does work. I've created a CALayer which contains CAShapeLayers for all the paths. It all looks great, but the performance is horrible. It seems there is no bounds checking on the CAShapeLayers, so it tries to draw them all for each tile. I've tried to draw the paths directly into the sublayers, but for some reason none of the custom drawing functions is called. Not for a CALayer subclass, nor if I set a delegate for the sublayer. I create the sublayers in the following way: - CustomLayer *subLayer=[CustomLayer new]; subLayer.bounds=bounds; //bounds is calculated somewhere above //let the anchorpoint correspond to (0,0) in our space subLayer.anchorPoint=CGPointMake(-bounds.origin.x/bounds.size.width, -bounds.origin.y/bounds.size.height); //Add a cross at (0,0), for debugging purposes CAShapeLayer *shape=[CAShapeLayer new]; CGMutablePathRef path=CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, -5, 0); CGPathAddLineToPoint(path, NULL, 5, 0); CGPathMoveToPoint(path, NULL, 0, -5); CGPathAddLineToPoint(path, NULL, 0, 5); shape.path=path; shape.fillColor=nil; shape.strokeColor=[UIColor yellowColor].CGColor; subLayer.sublayers=subLayers; //subLayers is an array of CAShapeLayers [subLayer addSublayer:shape]; return subLayer; - How can I make sure that some custom drawing method get's called? Thanks in advance. Kind regards, Remco Poelstra Op 21 mrt. 2014, om 21:22 heeft Remco Poelstra re...@beryllium.net het volgende geschreven: I'm working on an iOS app which needs to draw paths. Drawing is performed in layers, each layer having its own color. Some paths add (opaque) content, while some paths remove content (i.e. draw in a clear color). Content removal should only happen on a per layer basis. This model fits exactly with CALayer, with a CALayer for each drawing layer. The drawing layers can contain up to 3 paths. Since I want to be able to zoom in, I'm using CATiledLayer. Unfortunately CATiledLayer does not allow sub layers. Thats news. What makes you believe this? The internet did. But it is not true, is it? At least apple docs don't say it is not possible. Then I wonder will it solve the problem of trying to draw everything for each tile? Seems I've new options to try tomorrow :) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
On Mar 21, 2014, at 3:53 AM, Remco Poelstra re...@beryllium.net wrote: Hi, I'm working on an iOS app which needs to draw paths. Drawing is performed in layers, each layer having its own color. Some paths add (opaque) content, while some paths remove content (i.e. draw in a clear color). Content removal should only happen on a per layer basis. This model fits exactly with CALayer, with a CALayer for each drawing layer. The drawing layers can contain up to 3 paths. Since I want to be able to zoom in, I'm using CATiledLayer. Unfortunately CATiledLayer does not allow sub layers. Thats news. What makes you believe this? Now I can create a container layer which contains all the drawing layers as sublayers and call [containerLayer renderInContext:], to render it to the CATiledLayer, but it will render the complete layer for each and every tile. So performance drops considerably. I also noticed that this route only works with CAShapeLayers for each path. A custom drawInContext: does not get invoked. If I render all paths directly to the CATiledLayer and check the bounding boxes against the clipbox I get reasonable performance, but paths drawn in clear color will remove all content below them, not only content from the same drawing layer. Is there some way to render a container layer to a CATiledLayer while keeping any knowledge about the clipping path (i.e. skipping over any paths which are outside the clip bounds)? Thanks in advance. Kind regards, Remco Poelstra ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com This email sent to david.dun...@apple.com -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating sublayers in CATiledLayer
Op 21 mrt. 2014 om 17:28 heeft David Duncan david.dun...@apple.com het volgende geschreven: On Mar 21, 2014, at 3:53 AM, Remco Poelstra re...@beryllium.net wrote: Hi, I'm working on an iOS app which needs to draw paths. Drawing is performed in layers, each layer having its own color. Some paths add (opaque) content, while some paths remove content (i.e. draw in a clear color). Content removal should only happen on a per layer basis. This model fits exactly with CALayer, with a CALayer for each drawing layer. The drawing layers can contain up to 3 paths. Since I want to be able to zoom in, I'm using CATiledLayer. Unfortunately CATiledLayer does not allow sub layers. Thats news. What makes you believe this? The internet did. But it is not true, is it? At least apple docs don't say it is not possible. Then I wonder will it solve the problem of trying to draw everything for each tile? Seems I've new options to try tomorrow :) Regards, Remco Poelstra ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com