什么是“未对准的图像”? iPhone OS 中的核心动画?
Instruments 表示存在由核心动画制作的“未对齐的图像”。 这意味着什么?
更新:我在 Instruments.app > 中看到了这一点 核心动画。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我希望了解有关您在哪里看到此内容的更多信息,但我怀疑它指的是未像素对齐的图像。 Quartz 允许您以分数像素进行绘制(回想一下 CGPoint 采用 CGFloats,而不是 NSIntegers),但它更昂贵并且往往会产生一点模糊。 您无法真正在小数像素上进行绘制,因此 Quartz 必须进行抗锯齿才能实现。 这需要时间,并且肯定会损害核心动画的性能。
Quartz 不会警告您正在使用小数像素进行绘图,而且它对文本尤其不友善。 因此,在进行程序化布局时,您需要考虑这一点。
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.
未对齐的视图会强制渲染器在绘制之前进行抗锯齿。
在这种情况下,“未对齐”意味着请求的显示点没有直接映射到屏幕像素(例如,它可能位于两个像素之间),因此必须绘制到两个相邻像素并进行抗锯齿以给出错觉它是在他们“之间”绘制的。
当计算视图的框架(而不是在 Interface Builder 中指定)时,这种情况几乎总是会发生,因为 CGRect 的 X 坐标、Y 坐标、宽度和高度都是 CGFloats,因此允许使用小数值。
例如,以 (200.5, 35.5) 为中心的 100.8px x 50.1px 框是一个有效的框架,操作系统将尝试以其可以管理的最佳方式渲染它。 仅单个像素所需的额外插值和抗锯齿开销就足以严重损害旧硬件上的性能。
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.