What is an “misaligned image” in terms of Core Animation in iPhone OS?

时光毁灭记忆、已成空白 提交于 2019-12-06 17:52:59

问题


Instruments tells that there are "misaligned images" which are animated by core animation. What does that mean?

UPDATE: I've seen that in Instruments.app > Core Animation.


回答1:


I'd love more information about where you're seeing this, but my suspicion is that it's referring to an image that is not pixel-aligned. Quartz allows you to draw at fractional pixels (recall that CGPoint takes CGFloats, not NSIntegers), but it's more expensive and tends to create a bit of blurriness. You can't really draw on a fractional pixel, so Quartz has to do anti-aliasing to pull it off. That takes time and certainly would hurt Core Animation performance.

Quartz will not warn you that you're drawing on fractional pixels, and it's particularly unkind to text. So it's something you need to think about any time you're doing programmatic layout.




回答2:


Misaligned views force the renderer to anti-alias before they are drawn.

In this context, "misaligned" means that the requested display point does not map directly to a screen pixel (for example, it could be between two pixels), and therefore must be drawn to two neighbouring pixels and anti-aliased to give the illusion that it was drawn "between" the them.

This almost always happens when a view's frame is computed (rather than specified in Interface Builder) because a CGRect's X coordinate, Y coordinate, width, and height are CGFloats and therefore allow fractional values.

For example, a 100.8px by 50.1px box centered at (200.5, 35.5) is a valid frame and the OS will try to render it the best it can manage. The additional interpolation and anti-aliasing overhead required for just a single pixel is enough to severely hurt performance on older hardware.



来源:https://stackoverflow.com/questions/904918/what-is-an-misaligned-image-in-terms-of-core-animation-in-iphone-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!