• 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: Core Graphics optimisation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Graphics optimisation


  • Subject: Re: Core Graphics optimisation
  • From: Bill Dudney <email@hidden>
  • Date: Mon, 13 Aug 2012 07:26:08 -0400

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 <email@hidden> 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 (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

_______________________________________________

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

References: 
 >Core Graphics optimisation (From: Fulbert Boussaton <email@hidden>)

  • Prev by Date: Re: Core Graphics optimisation
  • Next by Date: Re: Core Graphics optimisation
  • Previous by thread: Re: Core Graphics optimisation
  • Next by thread: Re: Core Graphics optimisation
  • Index(es):
    • Date
    • Thread