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

mozilla::layers::Layer Class Reference

A Layer represents anything that can be rendered onto a destination surface. More...

#include <Layers.h>

Inheritance diagram for mozilla::layers::Layer:
Collaboration diagram for mozilla::layers::Layer:

List of all members.

Public Types

enum  LayerType {
  TYPE_THEBES, TYPE_CONTAINER, TYPE_IMAGE, TYPE_COLOR,
  TYPE_CANVAS, TYPE_SHADOW
}
enum  { CONTENT_OPAQUE = 0x01, CONTENT_COMPONENT_ALPHA = 0x02 }
enum  SurfaceMode { SURFACE_OPAQUE, SURFACE_SINGLE_CHANNEL_ALPHA, SURFACE_COMPONENT_ALPHA }

Public Member Functions

virtual ~Layer ()
LayerManagerManager ()
 Returns the LayerManager this Layer belongs to.
void SetContentFlags (PRUint32 aFlags)
 CONSTRUCTION PHASE ONLY This lets layout make some promises about what will be drawn into the visible region of the ThebesLayer.
virtual void SetVisibleRegion (const nsIntRegion &aRegion)
 CONSTRUCTION PHASE ONLY Tell this layer which region will be visible.
void SetOpacity (float aOpacity)
 CONSTRUCTION PHASE ONLY Set the opacity which will be applied to this layer as it is composited to the destination.
void SetClipRect (const nsIntRect *aRect)
 CONSTRUCTION PHASE ONLY Set a clip rect which will be applied to this layer as it is composited to the destination.
void IntersectClipRect (const nsIntRect &aRect)
 CONSTRUCTION PHASE ONLY Set a clip rect which will be applied to this layer as it is composited to the destination.
void SetTransform (const gfx3DMatrix &aMatrix)
 CONSTRUCTION PHASE ONLY Tell this layer what its transform should be.
void SetTileSourceRect (const nsIntRect *aRect)
 CONSTRUCTION PHASE ONLY.
float GetOpacity ()
const nsIntRectGetClipRect ()
PRUint32 GetContentFlags ()
const nsIntRegionGetVisibleRegion ()
ContainerLayerGetParent ()
LayerGetNextSibling ()
LayerGetPrevSibling ()
virtual LayerGetFirstChild ()
virtual LayerGetLastChild ()
const gfx3DMatrixGetTransform ()
const nsIntRectGetTileSourceRect ()
virtual void FillSpecificAttributes (SpecificLayerAttributes &aAttrs)
 DRAWING PHASE ONLY.
PRBool CanUseOpaqueSurface ()
SurfaceMode GetSurfaceMode ()
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 void Disconnect ()
 |Disconnect()| is used by layers hooked up over IPC.
virtual ThebesLayerAsThebesLayer ()
 Dynamic downcast to a Thebes layer.
virtual ShadowLayerAsShadowLayer ()
 Dynamic cast to a ShadowLayer.
const nsIntRectGetEffectiveClipRect ()
const nsIntRegionGetEffectiveVisibleRegion ()
float GetEffectiveOpacity ()
 Returns the product of the opacities of this layer and all ancestors up to and excluding the nearest ancestor that has UseIntermediateSurface() set.
const gfx3DMatrixGetEffectiveTransform () const
 This returns the effective transform computed by ComputeEffectiveTransforms.
virtual void ComputeEffectiveTransforms (const gfx3DMatrix &aTransformToSurface)=0
virtual const char * Name () const =0
virtual LayerType GetType () const =0
void * ImplData ()
 Only the implementation should call this.
void SetParent (ContainerLayer *aParent)
 Only the implementation should use these methods.
void SetNextSibling (Layer *aSibling)
void SetPrevSibling (Layer *aSibling)
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 ()

Protected Member Functions

 Layer (LayerManager *aManager, void *aImplData)
void Mutated ()
virtual nsACStringPrintInfo (nsACString &aTo, const char *aPrefix)
const gfx3DMatrixGetLocalTransform ()
 Returns the local transform for this layer: either mTransform or, for shadow layers, GetShadowTransform().
gfx3DMatrix SnapTransform (const gfx3DMatrix &aTransform, const gfxRect &aSnapRect, gfxMatrix *aResidualTransform)
 Computes a tweaked version of aTransform that snaps a point or a rectangle to pixel boundaries.

Protected Attributes

LayerManagermManager
ContainerLayermParent
LayermNextSibling
LayermPrevSibling
void * mImplData
LayerUserDataSet mUserData
nsIntRegion mVisibleRegion
gfx3DMatrix mTransform
gfx3DMatrix mEffectiveTransform
float mOpacity
nsIntRect mClipRect
nsIntRect mTileSourceRect
PRUint32 mContentFlags
PRPackedBool mUseClipRect
PRPackedBool mUseTileSourceRect

Detailed Description

A Layer represents anything that can be rendered onto a destination surface.


Member Enumeration Documentation

anonymous enum
Enumerator:
CONTENT_OPAQUE 

If this is set, the caller is promising that by the end of this transaction the entire visible region (as specified by SetVisibleRegion) will be filled with opaque content.

CONTENT_COMPONENT_ALPHA 

If this is set, the caller is notifying that the contents of this layer require per-component alpha for optimal fidelity.

However, there is no guarantee that component alpha will be supported for this layer at paint time. This should never be set at the same time as CONTENT_OPAQUE.

Enumerator:
TYPE_THEBES 
TYPE_CONTAINER 
TYPE_IMAGE 
TYPE_COLOR 
TYPE_CANVAS 
TYPE_SHADOW 
Enumerator:
SURFACE_OPAQUE 
SURFACE_SINGLE_CHANNEL_ALPHA 
SURFACE_COMPONENT_ALPHA 

Constructor & Destructor Documentation

virtual mozilla::layers::Layer::~Layer (  )  [inline, virtual]
mozilla::layers::Layer::Layer ( LayerManager aManager,
void *  aImplData 
) [inline, protected]

Member Function Documentation

virtual ShadowLayer* mozilla::layers::Layer::AsShadowLayer (  )  [inline, virtual]
virtual ThebesLayer* mozilla::layers::Layer::AsThebesLayer (  )  [inline, virtual]

Dynamic downcast to a Thebes layer.

Returns null if this is not a ThebesLayer.

Reimplemented in mozilla::layers::ThebesLayer.

PRBool mozilla::layers::Layer::CanUseOpaqueSurface (  ) 
virtual void mozilla::layers::Layer::ComputeEffectiveTransforms ( const gfx3DMatrix aTransformToSurface  )  [pure virtual]
Parameters:
aTransformToSurface the composition of the transforms from the parent layer (if any) to the destination pixel grid.

Computes mEffectiveTransform for this layer and all its descendants. mEffectiveTransform transforms this layer up to the destination pixel grid (whatever aTransformToSurface is relative to).

We promise that when this is called on a layer, all ancestor layers have already had ComputeEffectiveTransforms called.

Implemented in mozilla::layers::ImageLayer, mozilla::layers::ThebesLayer, mozilla::layers::ContainerLayer, mozilla::layers::ColorLayer, and mozilla::layers::CanvasLayer.

virtual void mozilla::layers::Layer::Disconnect (  )  [inline, virtual]

|Disconnect()| is used by layers hooked up over IPC.

It may be called at any time, and may not be called at all. Using an IPC-enabled layer after Destroy() (drawing etc.) results in a safe no-op; no crashy or uaf etc.

XXX: this interface is essentially LayerManager::Destroy, but at Layer granularity. It might be beneficial to unify them.

void mozilla::layers::Layer::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::Layer::DumpSelf ( FILE *  aFile = NULL,
const char *  aPrefix = "" 
)

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

virtual void mozilla::layers::Layer::FillSpecificAttributes ( SpecificLayerAttributes &  aAttrs  )  [inline, virtual]

DRAWING PHASE ONLY.

Write layer-subtype-specific attributes into aAttrs. Used to synchronize layer attributes to their shadows'.

const nsIntRect* mozilla::layers::Layer::GetClipRect (  )  [inline]
PRUint32 mozilla::layers::Layer::GetContentFlags (  )  [inline]
const nsIntRect* mozilla::layers::Layer::GetEffectiveClipRect (  ) 
float mozilla::layers::Layer::GetEffectiveOpacity (  ) 

Returns the product of the opacities of this layer and all ancestors up to and excluding the nearest ancestor that has UseIntermediateSurface() set.

const gfx3DMatrix& mozilla::layers::Layer::GetEffectiveTransform (  )  const [inline]

This returns the effective transform computed by ComputeEffectiveTransforms.

Typically this is a transform that transforms this layer all the way to some intermediate surface or destination surface. For non-BasicLayers this will be a transform to the nearest ancestor with UseIntermediateSurface() (or to the root, if there is no such ancestor), but for BasicLayers it's different.

const nsIntRegion& mozilla::layers::Layer::GetEffectiveVisibleRegion (  ) 
virtual Layer* mozilla::layers::Layer::GetFirstChild (  )  [inline, virtual]
virtual Layer* mozilla::layers::Layer::GetLastChild (  )  [inline, virtual]
const gfx3DMatrix& mozilla::layers::Layer::GetLocalTransform (  )  [protected]

Returns the local transform for this layer: either mTransform or, for shadow layers, GetShadowTransform().

Layer* mozilla::layers::Layer::GetNextSibling (  )  [inline]
float mozilla::layers::Layer::GetOpacity (  )  [inline]
ContainerLayer* mozilla::layers::Layer::GetParent (  )  [inline]
Layer* mozilla::layers::Layer::GetPrevSibling (  )  [inline]
SurfaceMode mozilla::layers::Layer::GetSurfaceMode (  )  [inline]
const nsIntRect* mozilla::layers::Layer::GetTileSourceRect (  )  [inline]
const gfx3DMatrix& mozilla::layers::Layer::GetTransform (  )  [inline]
virtual LayerType mozilla::layers::Layer::GetType (  )  const [pure virtual]
LayerUserData* mozilla::layers::Layer::GetUserData ( void *  aKey  )  [inline]

This getter can be used anytime.

Ownership is retained by the layer manager.

const nsIntRegion& mozilla::layers::Layer::GetVisibleRegion (  )  [inline]
PRBool mozilla::layers::Layer::HasUserData ( void *  aKey  )  [inline]

This getter can be used anytime.

void* mozilla::layers::Layer::ImplData (  )  [inline]

Only the implementation should call this.

This is per-implementation private data. Normally, all layers with a given layer manager use the same type of ImplData.

void mozilla::layers::Layer::IntersectClipRect ( const nsIntRect aRect  )  [inline]

CONSTRUCTION PHASE ONLY Set a clip rect which will be applied to this layer as it is composited to the destination.

The coordinates are relative to the parent layer (i.e. the contents of this layer are transformed before this clip rect is applied). For the root layer, the coordinates are relative to the widget, in device pixels. The provided rect is intersected with any existing clip rect.

static bool mozilla::layers::Layer::IsLogEnabled (  )  [inline, static]
void mozilla::layers::Layer::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::Layer::LogSelf ( const char *  aPrefix = ""  ) 

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

LayerManager* mozilla::layers::Layer::Manager (  )  [inline]

Returns the LayerManager this Layer belongs to.

Note that the layer manager might be in a destroyed state, at which point it's only valid to set/get user data from it.

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

This can be used anytime.

Ownership passes to the caller!

void mozilla::layers::Layer::SetClipRect ( const nsIntRect aRect  )  [inline]

CONSTRUCTION PHASE ONLY Set a clip rect which will be applied to this layer as it is composited to the destination.

The coordinates are relative to the parent layer (i.e. the contents of this layer are transformed before this clip rect is applied). For the root layer, the coordinates are relative to the widget, in device pixels. If aRect is null no clipping will be performed.

void mozilla::layers::Layer::SetContentFlags ( PRUint32  aFlags  )  [inline]

CONSTRUCTION PHASE ONLY This lets layout make some promises about what will be drawn into the visible region of the ThebesLayer.

This enables internal quality and performance optimizations.

void mozilla::layers::Layer::SetNextSibling ( Layer aSibling  )  [inline]
void mozilla::layers::Layer::SetOpacity ( float  aOpacity  )  [inline]

CONSTRUCTION PHASE ONLY Set the opacity which will be applied to this layer as it is composited to the destination.

void mozilla::layers::Layer::SetParent ( ContainerLayer aParent  )  [inline]

Only the implementation should use these methods.

void mozilla::layers::Layer::SetPrevSibling ( Layer aSibling  )  [inline]
void mozilla::layers::Layer::SetTileSourceRect ( const nsIntRect aRect  )  [inline]

CONSTRUCTION PHASE ONLY.

Define a subrect of this layer that will be used as the source image for tiling this layer's visible region. The coordinates are in the un-transformed space of this layer (i.e. the visible region of this this layer is tiled before being transformed). The visible region is tiled "outwards" from the source rect; that is, the source rect is drawn "in place", then repeated to cover the layer's visible region.

The interpretation of the source rect varies depending on underlying layer type. For ImageLayers and CanvasLayers, it doesn't make sense to set a source rect not fully contained by the bounds of their underlying images. For ThebesLayers, thebes content may need to be rendered to fill the source rect. For ColorLayers, a source rect for tiling doesn't make sense at all.

If aRect is null no tiling will be performed.

NB: this interface is only implemented for BasicImageLayers, and then only for source rects the same size as the layers' underlying images.

void mozilla::layers::Layer::SetTransform ( const gfx3DMatrix aMatrix  )  [inline]

CONSTRUCTION PHASE ONLY Tell this layer what its transform should be.

The transformation is applied when compositing the layer into its parent container. XXX Currently only transformations corresponding to 2D affine transforms are supported.

void mozilla::layers::Layer::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.

virtual void mozilla::layers::Layer::SetVisibleRegion ( const nsIntRegion aRegion  )  [inline, virtual]

CONSTRUCTION PHASE ONLY Tell this layer which region will be visible.

The visible region is a region which contains all the contents of the layer that can actually affect the rendering of the window. It can exclude areas that are covered by opaque contents of other layers, and it can exclude areas where this layer simply contains no content at all. (This can be an overapproximation to the "true" visible region.)

There is no general guarantee that drawing outside the bounds of the visible region will be ignored. So if a layer draws outside the bounds of its visible region, it needs to ensure that what it draws is valid.

gfx3DMatrix mozilla::layers::Layer::SnapTransform ( const gfx3DMatrix aTransform,
const gfxRect aSnapRect,
gfxMatrix aResidualTransform 
) [protected]

Computes a tweaked version of aTransform that snaps a point or a rectangle to pixel boundaries.

Snapping is only performed if this layer's layer manager has enabled snapping (which is the default).

Parameters:
aSnapRect a rectangle whose edges should be snapped to pixel boundaries in the destination surface. If the rectangle is empty, then the snapping process should preserve the scale factors of the transform matrix
aResidualTransform a transform to apply before mEffectiveTransform in order to get the results to completely match aTransform

Member Data Documentation


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