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

Core Graphics optimisation


  • Subject: Core Graphics optimisation
  • From: Fulbert Boussaton <email@hidden>
  • Date: Fri, 10 Aug 2012 10:09:42 +0200

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

  • Follow-Ups:
    • Re: Core Graphics optimisation
      • From: Graham Cox <email@hidden>
    • Re: Core Graphics optimisation
      • From: Bill Dudney <email@hidden>
    • Re: Core Graphics optimisation
      • From: "Richard Altenburg (Brainchild)" <email@hidden>
    • Re: Core Graphics optimisation
      • From: Mike Abdullah <email@hidden>
    • Re: Core Graphics optimisation
      • From: Thomas Davie <email@hidden>
  • Prev by Date: Re: __weak pointer collection firing prematurely???
  • Next by Date: Sending keyboard events with unicode strings causes Pages/Keynote/Numbers to hang
  • Previous by thread: Re: __weak pointer collection firing prematurely???
  • Next by thread: Re: Core Graphics optimisation
  • Index(es):
    • Date
    • Thread