Re: СoreGraphics text drawing performance
Re: СoreGraphics text drawing performance
- Subject: Re: СoreGraphics text drawing performance
- From: David Duncan <email@hidden>
- Date: Wed, 18 Jul 2012 10:43:12 -0700
On Jul 12, 2012, at 10:15 AM, Nazar Bartosik <email@hidden> wrote:
> In order to have my text visible at any background I draw it twice: once in stroke mode and then once in fill mode.
> Code sample below:
>
> CGContextSetTextDrawingMode(ctx, kCGTextStroke); // Stroke mode
> [string drawAtPoint:point withFont:font];
> CGContextSetTextDrawingMode(ctx, kCGTextFill); // Fill mode
> [string drawAtPoint:point withFont:font];
>
> The text of the string is changed frequently and the view to which the string is drawn is being redrawn about 10 times per second.
> It turns out that drawing text in stroke mode takes about 80% of drawing time, but the drawing in fill view happens very fast.
>
> I wonder if is there any more efficient way to draw the text in stroke mode, since this one seem to be quite slow.
The likely reason why stroke takes 80% of the drawing time here is that its being done first. I would suspect if you flipped the order then fill would take 80% of the drawing time. The reality is that its just the first attempt at drawing the string that is taking the majority of the time, not the manner in which it is drawn.
But as was stated by Graham, you can set the text drawing mode to both fill & stroke at the same time.
--
David Duncan
_______________________________________________
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