com.threerings.opengl.compositor
Class Compositor

java.lang.Object
  extended by com.threerings.opengl.compositor.Compositor

public class Compositor
extends Object

Handles the process of compositing the view from its various elements.


Nested Class Summary
static class Compositor.State
          Represents the saved state of the compositor.
 
Field Summary
protected  Color4f _backgroundColor
          The current background color, or null to use the default.
protected  Map<RenderEffectConfig,SoftReference<RenderEffect>> _cachedEffects
          Cached render effects.
protected  Camera _camera
          The camera.
protected  List<RenderEffect> _combinedEffects
          The combined list of render effects.
protected  GlContext _ctx
          The application context.
protected  Color4f _defaultBackgroundColor
          The default background color.
protected  Map<Dependency,Dependency> _dependencies
          The current set of dependencies.
protected  List<RenderEffect> _effects
          The non-dependency render effects.
protected  List<Enqueueable> _enqueueables
          The current set of enqueueables.
protected  RenderQueue.Group _group
          The base render queue group.
protected  List<Compositable> _roots
          The roots of the view.
protected  boolean _skipColorClear
          When set, indicates that we need not clear the color buffer.
protected  List<SoftReference<Compositor.State>> _statePool
          A pool of state objects to reuse.
protected  int _subrenderDepth
          The current subrender depth.
protected  Object _subrenderSource
          The source of the current subrender operation.
 
Constructor Summary
Compositor(GlContext ctx)
          Creates a new compositor.
 
Method Summary
 void addDependency(Dependency dependency)
          Adds an element to the set of render dependencies.
 void addDependencyEffect(RenderEffectConfig config)
          Adds an effect associated with a dependency.
 void addEffect(RenderEffect effect)
          Adds an effect to apply.
 void addEnqueueable(Enqueueable enqueueable)
          Adds an element to the list of render enqueueables.
 void addEnqueueable(Enqueueable enqueueable, int maxSubrenderDepth)
          Adds an element to the list of render enqueueables if the subrender depth is at or below the specified value.
 void addRoot(Compositable root)
          Adds an element to the list of view roots.
 void cleanupSubrender(Compositor.State ostate)
          Cleans up after the subrender operations.
 void clearDependencies()
          Cleans up and clears the current set of dependencies.
 void enqueueEnqueueables()
          Enqueues and clears the current list of enqueueables.
 Color4f getBackgroundColor()
          Returns the background color reference.
 Camera getCamera()
          Returns a reference to the camera.
 Color4f getDefaultBackgroundColor()
          Returns a reference to the default background color.
 Map<Dependency,Dependency> getDependencies()
          Returns a reference to the dependency map.
 RenderQueue.Group getGroup()
          Returns a reference to the base render queue group.
 RenderQueue getQueue(String name)
          Retrieves a reference to a render queue.
protected  Compositor.State getStateFromPool()
          Retrieves a state object from the shared pool.
 int getSubrenderDepth()
          Returns the currently number of subrender levels.
 Object getSubrenderSource()
          Returns a reference to the source of the current subrender operation.
 void performSubrender(Object source)
          Performs a subrender operation.
 Compositor.State prepareSubrender()
          Prepates for one or more subrender operations.
 void removeEffect(RenderEffect effect)
          Removes an effect.
 void removeRoot(Compositable root)
          Removes an element from the list of view roots.
 void renderPrevious(int idx)
          For the specified index within the list of combined effects, renders the previous contents.
protected  void renderQueues(int minPriority, int maxPriority)
          Renders the contents of the queues within the specified priority range.
 void renderView()
          Renders the composited view.
 void resetQueues()
          Resets the list of render queues.
 void setBackgroundColor(Color4f color)
          Sets the background color reference.
 void setCamera(Camera camera)
          Sets the camera reference.
 void setDependencies(Map<Dependency,Dependency> dependencies)
          Sets the dependency map reference.
 void setSkipColorClear()
          Sets the flag indicating that we need not clear the color buffer before rendering the frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ctx

protected GlContext _ctx
The application context.


_camera

protected Camera _camera
The camera.


_defaultBackgroundColor

protected Color4f _defaultBackgroundColor
The default background color.


_backgroundColor

protected Color4f _backgroundColor
The current background color, or null to use the default.


_roots

protected List<Compositable> _roots
The roots of the view.


_effects

protected List<RenderEffect> _effects
The non-dependency render effects.


_dependencies

protected Map<Dependency,Dependency> _dependencies
The current set of dependencies.


_enqueueables

protected List<Enqueueable> _enqueueables
The current set of enqueueables.


_combinedEffects

protected List<RenderEffect> _combinedEffects
The combined list of render effects.


_skipColorClear

protected boolean _skipColorClear
When set, indicates that we need not clear the color buffer.


_group

protected RenderQueue.Group _group
The base render queue group.


_subrenderDepth

protected int _subrenderDepth
The current subrender depth.


_subrenderSource

protected Object _subrenderSource
The source of the current subrender operation.


_cachedEffects

protected Map<RenderEffectConfig,SoftReference<RenderEffect>> _cachedEffects
Cached render effects.


_statePool

protected List<SoftReference<Compositor.State>> _statePool
A pool of state objects to reuse.

Constructor Detail

Compositor

public Compositor(GlContext ctx)
Creates a new compositor.

Method Detail

setCamera

public void setCamera(Camera camera)
Sets the camera reference.


getCamera

public Camera getCamera()
Returns a reference to the camera.


getDefaultBackgroundColor

public Color4f getDefaultBackgroundColor()
Returns a reference to the default background color.


setBackgroundColor

public void setBackgroundColor(Color4f color)
Sets the background color reference.

Parameters:
color - the background color, or null to use the default.

getBackgroundColor

public Color4f getBackgroundColor()
Returns the background color reference.


addRoot

public void addRoot(Compositable root)
Adds an element to the list of view roots.


removeRoot

public void removeRoot(Compositable root)
Removes an element from the list of view roots.


addEffect

public void addEffect(RenderEffect effect)
Adds an effect to apply.


removeEffect

public void removeEffect(RenderEffect effect)
Removes an effect.


renderView

public void renderView()
Renders the composited view.


prepareSubrender

public Compositor.State prepareSubrender()
Prepates for one or more subrender operations.

Returns:
the stored compositor state.

performSubrender

public void performSubrender(Object source)
Performs a subrender operation.

Parameters:
source - the source of the subrender operation.

cleanupSubrender

public void cleanupSubrender(Compositor.State ostate)
Cleans up after the subrender operations.

Parameters:
ostate - the state to restore.

getSubrenderDepth

public int getSubrenderDepth()
Returns the currently number of subrender levels.


getSubrenderSource

public Object getSubrenderSource()
Returns a reference to the source of the current subrender operation.


addDependency

public void addDependency(Dependency dependency)
Adds an element to the set of render dependencies.


clearDependencies

public void clearDependencies()
Cleans up and clears the current set of dependencies.


setDependencies

public void setDependencies(Map<Dependency,Dependency> dependencies)
Sets the dependency map reference.


getDependencies

public Map<Dependency,Dependency> getDependencies()
Returns a reference to the dependency map.


addEnqueueable

public void addEnqueueable(Enqueueable enqueueable)
Adds an element to the list of render enqueueables.


addEnqueueable

public void addEnqueueable(Enqueueable enqueueable,
                           int maxSubrenderDepth)
Adds an element to the list of render enqueueables if the subrender depth is at or below the specified value.


enqueueEnqueueables

public void enqueueEnqueueables()
Enqueues and clears the current list of enqueueables.


setSkipColorClear

public void setSkipColorClear()
Sets the flag indicating that we need not clear the color buffer before rendering the frame.


addDependencyEffect

public void addDependencyEffect(RenderEffectConfig config)
Adds an effect associated with a dependency.


renderPrevious

public void renderPrevious(int idx)
For the specified index within the list of combined effects, renders the previous contents.


getQueue

public RenderQueue getQueue(String name)
Retrieves a reference to a render queue.


resetQueues

public void resetQueues()
Resets the list of render queues.


getGroup

public RenderQueue.Group getGroup()
Returns a reference to the base render queue group.


renderQueues

protected void renderQueues(int minPriority,
                            int maxPriority)
Renders the contents of the queues within the specified priority range.


getStateFromPool

protected Compositor.State getStateFromPool()
Retrieves a state object from the shared pool.