Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

mozilla::layers::LayerManager Class Reference

A LayerManager controls a tree of layers. More...

#include <Layers.h>

Inheritance diagram for mozilla::layers::LayerManager:
Collaboration diagram for mozilla::layers::LayerManager:

List of all members.

Public Types

enum  LayersBackend {
  LAYERS_NONE = 0, LAYERS_BASIC, LAYERS_OPENGL, LAYERS_D3D9,
  LAYERS_D3D10, LAYERS_LAST
}
typedef void(* DrawThebesLayerCallback )(ThebesLayer *aLayer, gfxContext *aContext, const nsIntRegion &aRegionToDraw, const nsIntRegion &aRegionToInvalidate, void *aCallbackData)
 Function called to draw the contents of each ThebesLayer.

Public Member Functions

 LayerManager ()
virtual ~LayerManager ()
virtual void Destroy ()
 Release layers and resources held by this layer manager, and mark it as destroyed.
PRBool IsDestroyed ()
virtual void BeginTransaction ()=0
 Start a new transaction.
virtual void BeginTransactionWithTarget (gfxContext *aTarget)=0
 Start a new transaction.
virtual bool EndEmptyTransaction ()
 Attempts to end an "empty transaction".
virtual void EndTransaction (DrawThebesLayerCallback aCallback, void *aCallbackData)=0
 Finish the construction phase of the transaction, perform the drawing phase, and end the transaction.
PRBool IsSnappingEffectiveTransforms ()
virtual void SetRoot (Layer *aLayer)=0
 CONSTRUCTION PHASE ONLY Set the root layer.
LayerGetRoot ()
 Can be called anytime.
virtual void Mutated (Layer *aLayer)
 CONSTRUCTION PHASE ONLY Called when a managee has mutated.
virtual already_AddRefed
< ThebesLayer
CreateThebesLayer ()=0
 CONSTRUCTION PHASE ONLY Create a ThebesLayer for this manager's layer tree.
virtual already_AddRefed
< ContainerLayer
CreateContainerLayer ()=0
 CONSTRUCTION PHASE ONLY Create a ContainerLayer for this manager's layer tree.
virtual already_AddRefed
< ImageLayer
CreateImageLayer ()=0
 CONSTRUCTION PHASE ONLY Create an ImageLayer for this manager's layer tree.
virtual already_AddRefed
< ColorLayer
CreateColorLayer ()=0
 CONSTRUCTION PHASE ONLY Create a ColorLayer for this manager's layer tree.
virtual already_AddRefed
< CanvasLayer
CreateCanvasLayer ()=0
 CONSTRUCTION PHASE ONLY Create a CanvasLayer for this manager's layer tree.
virtual already_AddRefed
< ImageContainer
CreateImageContainer ()=0
 Can be called anytime.
virtual LayersBackend GetBackendType ()=0
 Type of layer manager his is.
virtual already_AddRefed
< gfxASurface
CreateOptimalSurface (const gfxIntSize &aSize, gfxASurface::gfxImageFormat imageFormat)
 Creates a layer which is optimized for inter-operating with this layer manager.
virtual void GetBackendName (nsAString &aName)=0
 Return the name of the layer manager's backend.
void SetUserData (void *aKey, LayerUserData *aData)
 This setter can be used anytime.
nsAutoPtr< LayerUserDataRemoveUserData (void *aKey)
 This can be used anytime.
PRBool HasUserData (void *aKey)
 This getter can be used anytime.
LayerUserDataGetUserData (void *aKey)
 This getter can be used anytime.
virtual const char * Name () const
void Dump (FILE *aFile=NULL, const char *aPrefix="")
 Dump information about this layer manager and its managed tree to aFile, which defaults to stderr.
void DumpSelf (FILE *aFile=NULL, const char *aPrefix="")
 Dump information about just this layer manager itself to aFile, which defaults to stderr.
void Log (const char *aPrefix="")
 Log information about this layer manager and its managed tree to the NSPR log (if enabled for "Layers").
void LogSelf (const char *aPrefix="")
 Log information about just this layer manager itself to the NSPR log (if enabled for "Layers").

Static Public Member Functions

static bool IsLogEnabled ()
static PRLogModuleInfoGetLog ()

Protected Member Functions

virtual nsACStringPrintInfo (nsACString &aTo, const char *aPrefix)

Static Protected Member Functions

static void InitLog ()

Protected Attributes

nsRefPtr< LayermRoot
LayerUserDataSet mUserData
PRPackedBool mDestroyed
PRPackedBool mSnapEffectiveTransforms

Static Protected Attributes

static PRLogModuleInfosLog

Detailed Description

A LayerManager controls a tree of layers.

All layers in the tree must use the same LayerManager.

All modifications to a layer tree must happen inside a transaction. Only the state of the layer tree at the end of a transaction is rendered. Transactions cannot be nested

Each transaction has two phases: 1) Construction: layers are created, inserted, removed and have properties set on them in this phase. BeginTransaction and BeginTransactionWithTarget start a transaction in the Construction phase. When the client has finished constructing the layer tree, it should call EndConstruction() to enter the drawing phase. 2) Drawing: ThebesLayers are rendered into in this phase, in tree order. When the client has finished drawing into the ThebesLayers, it should call EndTransaction to complete the transaction.

All layer API calls happen on the main thread.

Layers are refcounted. The layer manager holds a reference to the root layer, and each container layer holds a reference to its children.


Member Typedef Documentation

typedef void(* mozilla::layers::LayerManager::DrawThebesLayerCallback)(ThebesLayer *aLayer, gfxContext *aContext, const nsIntRegion &aRegionToDraw, const nsIntRegion &aRegionToInvalidate, void *aCallbackData)

Function called to draw the contents of each ThebesLayer.

aRegionToDraw contains the region that needs to be drawn. This would normally be a subregion of the visible region. The callee must draw all of aRegionToDraw. Drawing outside aRegionToDraw will be clipped out or ignored. The callee must draw all of aRegionToDraw. This region is relative to 0,0 in the ThebesLayer.

aRegionToInvalidate contains a region whose contents have been changed by the layer manager and which must therefore be invalidated. For example, this could be non-empty if a retained layer internally switches from RGBA to RGB or back ... we might want to repaint it to consistently use subpixel-AA or not. This region is relative to 0,0 in the ThebesLayer. aRegionToInvalidate may contain areas that are outside aRegionToDraw; the callee must ensure that these areas are repainted in the current layer manager transaction or in a later layer manager transaction.

aContext must not be used after the call has returned. We guarantee that buffered contents in the visible region are valid once drawing is complete.

The origin of aContext is 0,0 in the ThebesLayer.


Member Enumeration Documentation

Enumerator:
LAYERS_NONE 
LAYERS_BASIC 
LAYERS_OPENGL 
LAYERS_D3D9 
LAYERS_D3D10 
LAYERS_LAST 

Constructor & Destructor Documentation

mozilla::layers::LayerManager::LayerManager (  )  [inline]
virtual mozilla::layers::LayerManager::~LayerManager (  )  [inline, virtual]

Member Function Documentation

virtual void mozilla::layers::LayerManager::BeginTransaction (  )  [pure virtual]

Start a new transaction.

Nested transactions are not allowed so there must be no transaction currently in progress. This transaction will update the state of the window from which this LayerManager was obtained.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual void mozilla::layers::LayerManager::BeginTransactionWithTarget ( gfxContext aTarget  )  [pure virtual]

Start a new transaction.

Nested transactions are not allowed so there must be no transaction currently in progress. This transaction will render the contents of the layer tree to the given target context. The rendering will be complete when EndTransaction returns.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual already_AddRefed<CanvasLayer> mozilla::layers::LayerManager::CreateCanvasLayer (  )  [pure virtual]

CONSTRUCTION PHASE ONLY Create a CanvasLayer for this manager's layer tree.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual already_AddRefed<ColorLayer> mozilla::layers::LayerManager::CreateColorLayer (  )  [pure virtual]

CONSTRUCTION PHASE ONLY Create a ColorLayer for this manager's layer tree.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual already_AddRefed<ContainerLayer> mozilla::layers::LayerManager::CreateContainerLayer (  )  [pure virtual]

CONSTRUCTION PHASE ONLY Create a ContainerLayer for this manager's layer tree.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual already_AddRefed<ImageContainer> mozilla::layers::LayerManager::CreateImageContainer (  )  [pure virtual]

Can be called anytime.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual already_AddRefed<ImageLayer> mozilla::layers::LayerManager::CreateImageLayer (  )  [pure virtual]

CONSTRUCTION PHASE ONLY Create an ImageLayer for this manager's layer tree.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual already_AddRefed<gfxASurface> mozilla::layers::LayerManager::CreateOptimalSurface ( const gfxIntSize aSize,
gfxASurface::gfxImageFormat  imageFormat 
) [virtual]

Creates a layer which is optimized for inter-operating with this layer manager.

virtual already_AddRefed<ThebesLayer> mozilla::layers::LayerManager::CreateThebesLayer (  )  [pure virtual]

CONSTRUCTION PHASE ONLY Create a ThebesLayer for this manager's layer tree.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual void mozilla::layers::LayerManager::Destroy (  )  [inline, virtual]

Release layers and resources held by this layer manager, and mark it as destroyed.

Should do any cleanup necessary in preparation for its widget going away. After this call, only user data calls are valid on the layer manager.

Reimplemented in mozilla::layers::LayerManagerOGL.

void mozilla::layers::LayerManager::Dump ( FILE *  aFile = NULL,
const char *  aPrefix = "" 
)

Dump information about this layer manager and its managed tree to aFile, which defaults to stderr.

void mozilla::layers::LayerManager::DumpSelf ( FILE *  aFile = NULL,
const char *  aPrefix = "" 
)

Dump information about just this layer manager itself to aFile, which defaults to stderr.

virtual bool mozilla::layers::LayerManager::EndEmptyTransaction (  )  [inline, virtual]

Attempts to end an "empty transaction".

There must have been no changes to the layer tree since the BeginTransaction(). It's possible for this to fail; ThebesLayers may need to be updated due to VRAM data being lost, for example. In such cases this method returns false, and the caller must proceed with a normal layer tree update and EndTransaction.

Reimplemented in mozilla::layers::BasicLayerManager.

virtual void mozilla::layers::LayerManager::EndTransaction ( DrawThebesLayerCallback  aCallback,
void *  aCallbackData 
) [pure virtual]

Finish the construction phase of the transaction, perform the drawing phase, and end the transaction.

During the drawing phase, all ThebesLayers in the tree are drawn in tree order, exactly once each, except for those layers where it is known that the visible region is empty.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

virtual void mozilla::layers::LayerManager::GetBackendName ( nsAString aName  )  [pure virtual]

Return the name of the layer manager's backend.

Implemented in mozilla::layers::BasicLayerManager, mozilla::layers::LayerManagerOGL, and mozilla::layers::ShadowLayerManager.

virtual LayersBackend mozilla::layers::LayerManager::GetBackendType (  )  [pure virtual]

Type of layer manager his is.

This is to be used sparsely in order to avoid a lot of Layers backend specific code. It should be used only when Layers backend specific functionality is necessary.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

static PRLogModuleInfo* mozilla::layers::LayerManager::GetLog (  )  [inline, static]
Layer* mozilla::layers::LayerManager::GetRoot (  )  [inline]

Can be called anytime.

LayerUserData* mozilla::layers::LayerManager::GetUserData ( void *  aKey  )  [inline]

This getter can be used anytime.

Ownership is retained by the layer manager.

PRBool mozilla::layers::LayerManager::HasUserData ( void *  aKey  )  [inline]

This getter can be used anytime.

static void mozilla::layers::LayerManager::InitLog (  )  [static, protected]
PRBool mozilla::layers::LayerManager::IsDestroyed (  )  [inline]
static bool mozilla::layers::LayerManager::IsLogEnabled (  )  [static]
PRBool mozilla::layers::LayerManager::IsSnappingEffectiveTransforms (  )  [inline]
void mozilla::layers::LayerManager::Log ( const char *  aPrefix = ""  ) 

Log information about this layer manager and its managed tree to the NSPR log (if enabled for "Layers").

void mozilla::layers::LayerManager::LogSelf ( const char *  aPrefix = ""  ) 

Log information about just this layer manager itself to the NSPR log (if enabled for "Layers").

virtual void mozilla::layers::LayerManager::Mutated ( Layer aLayer  )  [inline, virtual]

CONSTRUCTION PHASE ONLY Called when a managee has mutated.

Subclasses overriding this method must first call their superclass's impl

virtual const char* mozilla::layers::LayerManager::Name (  )  const [inline, virtual]
virtual nsACString& mozilla::layers::LayerManager::PrintInfo ( nsACString aTo,
const char *  aPrefix 
) [protected, virtual]
nsAutoPtr<LayerUserData> mozilla::layers::LayerManager::RemoveUserData ( void *  aKey  )  [inline]

This can be used anytime.

Ownership passes to the caller!

virtual void mozilla::layers::LayerManager::SetRoot ( Layer aLayer  )  [pure virtual]

CONSTRUCTION PHASE ONLY Set the root layer.

Implemented in mozilla::layers::BasicLayerManager, and mozilla::layers::LayerManagerOGL.

void mozilla::layers::LayerManager::SetUserData ( void *  aKey,
LayerUserData aData 
) [inline]

This setter can be used anytime.

The user data for all keys is initially null. Ownership pases to the layer manager.


Member Data Documentation


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