Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Animation

Animation

These changes to the rendering model make animation easy. Previously, moving, resizing, rotating, or otherwise transforming a view required redrawing everything under it, applying the changes to the graphics context's transform matrix, and then redrawing. Now, it just requires telling the GPU to move texture (possibly after running some simple shader programs on it).

CoreAnimation uses key-value observing for animation, which should give you some idea of how efficient it is. Key-value observing and key-value coding add an extra layer of indirection—on top of Objective-C message sends—for animation. When you change a property that supports animation, the CoreAnimation framework gets a notification and runs an animation that changes this property (via key-value coding) from the old value to the new. Even with the overhead of these two layers of indirection, CoreAnimation is still fast enough (even on the iPhone) for fluid animations.

You can do the same sort of animations with the old drawing model, but expect your desktop CPU usage to jump close to 100 percent until they finish. Apple has slowly but surely evolved the rendering model for Quartz from Display PostScript to its current level. The current rendering model is much simpler than Display PostScript, and very similar to a modern X11 implementation with the render and composite extensions (both inspired by OS X).

In some respects, CoreAnimation and Quartz represent a step backwards. The data sent to the window server is resolution-dependent, while the PostScript programs sent to the DPS server were resolution-independent. You could scale a DPS window arbitrarily without getting any more data from the program and without introducing aliasing. If you zoom a CoreAnimation window or an OS X window, you will see pixelation. It's possible that a future version of Quartz will take the PDF drawing commands and send them to the display server as OpenGL vertex arrays, rather than drawing them to a bitmap. This would combine the benefits of both approaches but would add a lot of complexity.

  • + Share This
  • 🔖 Save To Your Account