For anyone that comes across this in the future, the solution I wound up implementing is basically not rotating text constantly, but only by discrete values when the rotation angle passes a certain limit, ie a rough example would be, if it's > 45 degrees, rotate text by 90, < -45 , rotate by-90, so that it doesn't fill up the cache with a bazillion instances drawn at slightly different angles. It's not as pretty as before, but now the cache is not being thrashed, so will end up being prettier in the end :) Thanks again to Romain and Dianne for replying, I really appreciate your presence on these forums, and not just on this post, it's a big help.
On Mon, Jun 20, 2011 at 9:47 PM, Dianne Hackborn <[email protected]>wrote: > Yes, that will do it. Note that each angle you draw a glyph at needs a new > entry in the cache for the bitmap of the glyph drawn at that angle. > > On Mon, Jun 20, 2011 at 6:42 PM, Adam Ratana <[email protected]>wrote: > >> After seeing this response, I spent some time to figure out exactly what I >> was doing now that was causing this to appear in the logs so much. I was >> puzzled because I wasn't using many styles or colors, the same font, same >> color. I turned off alpha blending, and removed all the items I was drawing >> until I was left with 1, and it was still overloading the cache. I narrowed >> it down to doing: >> >> canvas.save(); >> canvas.rotate(rotationAngle, p.x, p.y); // this is the offending line >> canvas.drawText(text, p.x, p.y, paint); >> canvas.restore(); >> >> If I rotate and then draw text (this is an AR type implementation where >> the text is rotating with the phone), this is where the font cache fills up, >> with just 1 static piece of text. Commenting out the above line doesn't. >> Even with a large number of text items, NOT rotating the canvas before >> drawing the text, doesn't fill the cache. >> >> This seems kind of strange to me that this would fill the cache, but, is >> there another way to do this to not fill the cache? >> >> >> >> >> On Mon, Jun 20, 2011 at 7:43 PM, Dianne Hackborn <[email protected]>wrote: >> >>> Well having it printed every second or so indicates you are pretty >>> severely thrashing the cache, which can certainly impact performance. For >>> example drawing your UI may not be fitting in the cache so each frame you >>> draw requires re-rendering glyphs back in to the cache. If that is the >>> case, look at doing things like reducing the number of distinct font sizes >>> or families/styles you are using to have less impact on the cache. >>> >>> >>> >>> >> -- >> Adam Ratana >> [email protected] >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Adam Ratana [email protected] -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

