Instance Methods | Class Methods | Properties | List of all members
CC3SurfaceManager Class Reference

#import <CC3RenderSurfaces.h>

Inheritance diagram for CC3SurfaceManager:
Inheritance graph

Instance Methods

(void) - addSurface:
(void) - removeSurface:
(void) - retainSurface:inIvar:

Class Methods

(instancetype) + surfaceManager


CC3IntSize size

Detailed Description

CC3SurfaceManager manages a collection of related resizable surfaces, and ensures that all surfaces are resized together.

A sophisticated app may use a number of renderable surfaces, and in many cases, several surfaces may be related, and should all have the same size. In a dynamic app (such as one that supports resizing a layer or view, there will be the requirement to resize all of the related surfaces together.

For example, post-processing techniques might be used, where one surface is rendered to another, and for best fidelity, both surfaces should be the same size. If these surfaces can be resized, they should be resized together.

Another example is the surfaces used to render for the primary view. Under OSX, the view will be resized as the containing window is resized. Under iOS, the view will be resized if the device rotates between Landscape and Portrait orientation. In either cases, all surfaces that are sized to the view's size, must be resized.

In both of these cases, a CC3SurfaceManager can be used to ensure that all of the related surfaces are resized together.

You can add surfaces to an instance of this manager, using the addSurface: method, and then invoke the size property on this instance to resize all of the surfaces together.

Specialized subclasses include CC3SceneDrawingSurfaceManager, for managing surfaces used by a CC3Layer to render a CC3Scene, and CC3ViewSurfaceManager, used by the system to manage the surfaces used to render to the OS view.

You can create your own subclasses of this class to manage off-screen surfaces used by your application, if you have several surfaces whose sizes can change dynamically, and you want to ensure that they all retain consistent sizing. In doing so, you can use the retainSurface:inIvar: method as a convenient way of creating property accessors for your surfaces, while ensuring that they will also be resized automatically.

Method Documentation

- (void) addSurface: (id< CC3RenderSurface >)  surface

Registers the specified surface to be resized when the resizeTo: method of this surface manager is invoked.

It is safe to register the same surface more than once, and it is safe to register two surfaces that share one or more attachments. This implementation will ensure that each attachment is resized only once during each resizing action.

- (void) removeSurface: (id< CC3RenderSurface >)  surface

Removes the specified surface previously added with the addSurface: method.

It is safe to invoke this method even if the specified surface has never been added, or has already been removed.

- (void) retainSurface: (id< CC3RenderSurface >)  surface
inIvar: (NSString *)  ivarName 

Sets the specified surface into the instance variable with the specified name.

This is a convenience method that performs the following operations:

  • Retieives the surface currently in the instance variable with the specified name.
  • Invokes the removeSurface: method, passing that existing surface.
  • Sets the specified surface into the instance variable with the specified name.
  • Invokes the addSurface: method, passing the specified surface.
  • Ensures that the old surface is released and the new surface is retained.

Subclasses that hold a reference to a surface in an instance variable can use this method to conveniently set the surface in the instance variable, while ensuring that the old surface is removed from the collection of surfaces, and the new surface is added.

+ (instancetype) surfaceManager

Returns an instance initialized with an empty collection of surfaces.

Property Documentation

- (CC3IntSize) size

The size of the rendering surfaces contained in this manager, in pixels.

Setting the value of this property resizes all of the surfaces managed by this instance to the specified size.

The documentation for this class was generated from the following file: