Re: Core Graphics optimisation
On 10/08/2012, at 6:09 PM, Fulbert Boussaton <4...@flubb.net> wrote: > CGContextSetShadow(Ctx, CGSizeMake(3, 4), 3.0f); As well as the advice you've received, do you have to have shadows? They drag performance into the gutter. Try losing this line and watch your code speed up dramatically. --Graham ___ 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: Core Graphics optimisation
A much faster and simpler approach to do exactly what you have here is CAShapeLayer. That will draw the path via OpenGL on your behalf without you having to study OpenGL. That said, copying and pasting from stack overflow or cocoa-dev list is never a good solution in the long run. You might not be looking to do that, but the question formulation below suggest that is your goal. > CGLayerRef only makes things better because you're not redrawing the shape. Much better IMO for you to spend the 56 minutes to watch a WWDC video on your fav subject, or better yet trick iTunes into thinking its a podcast so you can set the speed to 2x then you could watch 2 in the same hour. Good luck, -bd On Aug 10, 2012, at 4:09 AM, Fulbert Boussaton <4...@flubb.net> wrote: > Hi everyone, > > on iOS, I was using the following "immediate CG code" to display hundreds > procedural sprites : > > CGContextSetShadow(Ctx, CGSizeMake(3, 4), 3.0f); > CGMutablePathRef ShapePath = CGPathCreateMutable(); > CGPathAddArc(ShapePath, &CGAffineTransformIdentity, radius+3, radius+3, > radius, 0, deg2rad(360), YES); > CGContextSetStrokeColorWithColor(Ctx, [strokeColor CGColor]); > CGContextSetFillColorWithColor(Ctx, [fillColor CGColor]); > CGContextSetLineWidth(Ctx, strokeWidth); > CGContextAddPath(Ctx, ShapePath); > CGContextDrawPath(Ctx, kCGPathFillStroke); > CGPathRelease(ShapePath); > > Ctx is the current context and the sprite is a filled circle with a shadow. > > Of course, an iPad was *really* slow to draw all of these, even if each one > represents 32px * 32px. So I optimized it using CGLayerRef stored in a > NSdictionary and, yes, it was a lot faster. > > But still, it's not really satisfying, and I'm sure something better can be > done. Do any of you got any idea ? I'm kind of stuck in the CG documentation. > Is there a book specifically dedicated to CG optimisation ? (I know a WWDC 12 > presentation talks about CG optimisation but haven't had time to spare yet). > > My goal is to display and animate a thousand of these drawings without using > OpenGL. Do you think it's possible ? > > > Thanks. > > Fulbert. > ___ > > 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/bdudney%40mac.com > > This email sent to bdud...@mac.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: Core Graphics optimisation
You have no time to watch WWDC 2012 presentations and like to avoid OpenGL ES as an alternative, how on earth are you going to write a fast app with thousands of drawings on a device with (in worst case) 256 MB of internal memory? I am not sure OpenGL ES will help, and one session from WWDC will not change life either, but at least studying for a few days instead of writing code will help you find your direction! I am having some serious issues with memory and speed, especially on the iPod Touch family of devices, but before I ask anything here I will make sure to try and find out what is available and what has already been explained in books and online sessions. I wish I could help in answering your question, in spite of the above... [[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards]; Op 10 aug. 2012, om 10:09 heeft Fulbert Boussaton <4...@flubb.net> het volgende geschreven: > My goal is to display and animate a thousand of these drawings without using > OpenGL. Do you think it's possible ? ___ 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: Core Graphics optimisation
On 10 Aug 2012, at 09:09, Fulbert Boussaton <4...@flubb.net> wrote: > Hi everyone, > > on iOS, I was using the following "immediate CG code" to display hundreds > procedural sprites : > > CGContextSetShadow(Ctx, CGSizeMake(3, 4), 3.0f); > CGMutablePathRef ShapePath = CGPathCreateMutable(); > CGPathAddArc(ShapePath, &CGAffineTransformIdentity, radius+3, radius+3, > radius, 0, deg2rad(360), YES); > CGContextSetStrokeColorWithColor(Ctx, [strokeColor CGColor]); > CGContextSetFillColorWithColor(Ctx, [fillColor CGColor]); > CGContextSetLineWidth(Ctx, strokeWidth); > CGContextAddPath(Ctx, ShapePath); > CGContextDrawPath(Ctx, kCGPathFillStroke); > CGPathRelease(ShapePath); > > Ctx is the current context and the sprite is a filled circle with a shadow. > > Of course, an iPad was *really* slow to draw all of these, even if each one > represents 32px * 32px. So I optimized it using CGLayerRef stored in a > NSdictionary and, yes, it was a lot faster. > > But still, it's not really satisfying, and I'm sure something better can be > done. Do any of you got any idea ? I'm kind of stuck in the CG documentation. > Is there a book specifically dedicated to CG optimisation ? (I know a WWDC 12 > presentation talks about CG optimisation but haven't had time to spare yet). So you have a performance problem. You used Instruments to diagnose it, yes? What did you learn? ___ 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: Core Graphics optimisation
On 10 Aug 2012, at 09:09, Fulbert Boussaton <4...@flubb.net> wrote: > Hi everyone, > > on iOS, I was using the following "immediate CG code" to display hundreds > procedural sprites : I'd suggest simply dropping CG, and drawing them using OpenGL ES instead. Thanks Tom Davie ___ 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
Core Graphics optimisation
Hi everyone, on iOS, I was using the following "immediate CG code" to display hundreds procedural sprites : CGContextSetShadow(Ctx, CGSizeMake(3, 4), 3.0f); CGMutablePathRefShapePath = CGPathCreateMutable(); CGPathAddArc(ShapePath, &CGAffineTransformIdentity, radius+3, radius+3, radius, 0, deg2rad(360), YES); CGContextSetStrokeColorWithColor(Ctx, [strokeColor CGColor]); CGContextSetFillColorWithColor(Ctx, [fillColor CGColor]); CGContextSetLineWidth(Ctx, strokeWidth); CGContextAddPath(Ctx, ShapePath); CGContextDrawPath(Ctx, kCGPathFillStroke); CGPathRelease(ShapePath); Ctx is the current context and the sprite is a filled circle with a shadow. Of course, an iPad was *really* slow to draw all of these, even if each one represents 32px * 32px. So I optimized it using CGLayerRef stored in a NSdictionary and, yes, it was a lot faster. But still, it's not really satisfying, and I'm sure something better can be done. Do any of you got any idea ? I'm kind of stuck in the CG documentation. Is there a book specifically dedicated to CG optimisation ? (I know a WWDC 12 presentation talks about CG optimisation but haven't had time to spare yet). My goal is to display and animate a thousand of these drawings without using OpenGL. Do you think it's possible ? Thanks. Fulbert. ___ 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