next up previous
Next: The SWController Up: Animation and Compositing Previous: Animation and Compositing

The SWCompositor Class

The SWCompositor class provides the capability to compose a complex image from disparate image sources and then treat the result as a single image, which is presented to the user. It also provides a time base that controls the rendering cycle and allows your application to attach time-based behaviors or actions.

The SWCompositor uses the QuickTime SpriteWorld internally to perform its compositing tasks and its TimeBase for its timing services. All of the actual drawing of the members of a SWCompositor is handled through the interaction between the SpriteWorld and Sprite classes of QuickTime.

The SpriteWorld itself is wrapped by the SWCompositor class, and to represent the Sprite class it uses the TwoDSprite. The TwoDSprite is a presenter, that is it presents image information. The presentation of image information within the context of the SWCompositor SpriteWorld is determined by the matrix, graphics mode, layer, and visibility of the Sprite object.

To create a Sprite, you need a valid SpriteWorld. To create a SpriteWorld, you need a valid QDGraphics destination. Depending on whether a SWCompositor is visible, you may or may not have a valid destination QDGraphics. The interaction between the SWCompositor and its TwoDSprite presenters handles the saving and creating of SpriteWorld and Sprite objects -- your application does not need to deal specifically with this issue.

The SWCompositor object presents the functionality of the SpriteWorld within the context of the QTDisplaySpace interface. The TwoDSprite object wraps the QuickTime Sprite object, giving it a Transformable interface so that its visual characteristics can have matrix transformations applied to them. It also implements the Compositable interface, as graphics modes can be applied when a sprite's image data is rendered. You can save the current display state of an individual sprite and recreate a sprite from the information you saved; the TwoDSpriteInfo object is a helper class created for this purpose.

The SWCompositor supports two important characteristics of members. If the member implements a DynamicImage, this indicates to the Compositor that the image being presented by the member is apt to change. For example, the member is a QTImageProducer, in which case the member needs to create a special object -- an Invalidator -- that will invalidate the sprite that is presenting the member, so that the composite cycle will redraw that sprite, and you will see the changing image data of a movie as it plays back. This is discussed in more detail below. A further service that the SWCompositor renders to its new members is the handling of members that implement the Notifier interface. If a member implements this interface, the Compositor establishes the connection between the Notifier (the new member) and its NotifyListener (the new member's TwoDSprite). When the new member's image data is complete, it can then automatically notify its registered NotifyListener -- its TwoDSprite. This is used with QTImageDrawer members where the QTImageDrawer won't have valid image data until the Java offscreen image is created. It could also be used with images that may reside on a remote server, or interactively where the user may choose or draw an image that is part of an animation.


next up previous
Next: The SWController Up: Animation and Compositing Previous: Animation and Compositing
Dave Marshall
10/4/2001