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

mozilla::FrameLayerBuilder Class Reference

The FrameLayerBuilder belongs to an nsDisplayListBuilder and is responsible for converting display lists into layer trees. More...

#include <FrameLayerBuilder.h>

Collaboration diagram for mozilla::FrameLayerBuilder:

List of all members.

Classes

struct  Clip
 Clip represents the intersection of an optional rectangle with a list of rounded rectangles. More...
struct  ClippedDisplayItem
 We store one of these for each display item associated with a ThebesLayer, in a hashtable that maps each ThebesLayer to an array of ClippedDisplayItems. More...
class  DisplayItemData
 We store an array of these for each frame that is associated with one or more retained layers. More...
class  ThebesLayerItemsEntry
 We accumulate ClippedDisplayItem elements in a hashtable during the paint process. More...

Public Types

typedef layers::ContainerLayer ContainerLayer
typedef layers::Layer Layer
typedef layers::ThebesLayer ThebesLayer
typedef layers::LayerManager LayerManager

Public Member Functions

 FrameLayerBuilder ()
void Init (nsDisplayListBuilder *aBuilder)
void DidBeginRetainedLayerTransaction (LayerManager *aManager)
 Call this to notify that we have just started a transaction on the retained layer manager aManager.
void WillEndTransaction (LayerManager *aManager)
 Call this just before we end a transaction on aManager.
void DidEndTransaction (LayerManager *aManager)
 Call this after we end a transaction on aManager.
already_AddRefed< ContainerLayerBuildContainerLayerFor (nsDisplayListBuilder *aBuilder, LayerManager *aManager, nsIFrame *aContainerFrame, nsDisplayItem *aContainerItem, const nsDisplayList &aChildren)
 Build a container layer for a display item that contains a child list, either reusing an existing one or creating a new one.
LayerGetLeafLayerFor (nsDisplayListBuilder *aBuilder, LayerManager *aManager, nsDisplayItem *aItem)
 Get a retained layer for a display item that needs to create its own layer for rendering (i.e.
void AddLayerDisplayItem (Layer *aLayer, nsDisplayItem *aItem)
 Record aItem as a display item that is rendered by aLayer.
void AddThebesDisplayItem (ThebesLayer *aLayer, nsDisplayItem *aItem, const Clip &aClip, nsIFrame *aContainerLayerFrame, LayerState aLayerState, LayerManager *aTempManager)
LayerGetOldLayerFor (nsIFrame *aFrame, PRUint32 aDisplayItemKey)
 Given a frame and a display item key that uniquely identifies a display item for the frame, find the layer that was last used to render that display item.
nscolor FindOpaqueColorCovering (nsDisplayListBuilder *aBuilder, ThebesLayer *aLayer, const nsRect &aRect)
 Try to determine whether the ThebesLayer aLayer paints an opaque single color everywhere it's visible in aRect.

Static Public Member Functions

static void InvalidateThebesLayerContents (nsIFrame *aFrame, const nsRect &aRect)
 Call this during invalidation if aFrame has the NS_FRAME_HAS_CONTAINER_LAYER state bit.
static void InvalidateThebesLayersInSubtree (nsIFrame *aFrame)
 For any descendant frame of aFrame (including across documents) that has an associated container layer, invalidate all the contents of all ThebesLayer children of the container.
static void InvalidateAllThebesLayerContents (LayerManager *aManager)
 Call this to force *all* retained layer contents to be discarded at the next paint.
static void InvalidateAllLayers (LayerManager *aManager)
 Call this to force all retained layers to be discarded and recreated at the next paint.
static PRBool HasDedicatedLayer (nsIFrame *aFrame, PRUint32 aDisplayItemKey)
 Call this to determine if a frame has a dedicated (non-Thebes) layer for the given display item key.
static void DrawThebesLayer (ThebesLayer *aLayer, gfxContext *aContext, const nsIntRegion &aRegionToDraw, const nsIntRegion &aRegionToInvalidate, void *aCallbackData)
 This callback must be provided to EndTransaction.
static PLDHashOperator RemoveDisplayItemDataForFrame (nsPtrHashKey< nsIFrame > *aEntry, void *aClosure)
 A useful hashtable iteration function that removes the DisplayItemData property for the frame, clears its NS_FRAME_HAS_CONTAINER_LAYER bit and returns PL_DHASH_REMOVE.
static void DestroyDisplayItemDataFor (nsIFrame *aFrame)
 Destroy any stored DisplayItemDataProperty for aFrame.

Protected Member Functions

 NS_DECLARE_FRAME_PROPERTY_WITH_FRAME_IN_DTOR (DisplayItemDataProperty, DestroyDisplayItemData) class DisplayItemDataEntry
 For DisplayItemDataProperty, the property value *is* an nsTArray<DisplayItemData>, not a pointer to an array.
void RemoveThebesItemsForLayerSubtree (Layer *aLayer)
PRBool CheckDOMModified ()
 Returns true if the DOM has been modified since we started painting, in which case we should bail out and not paint anymore.

Static Protected Member Functions

static void InternalDestroyDisplayItemData (nsIFrame *aFrame, void *aPropertyValue, PRBool aRemoveFromFramesWithLayers)
static void DestroyDisplayItemData (nsIFrame *aFrame, void *aPropertyValue)
static PLDHashOperator UpdateDisplayItemDataForFrame (nsPtrHashKey< nsIFrame > *aEntry, void *aUserArg)
static PLDHashOperator StoreNewDisplayItemData (DisplayItemDataEntry *aEntry, void *aUserArg)

Protected Attributes

LayerManagermRetainingManager
 The layer manager belonging to the widget that is being retained across paints.
nsRootPresContextmRootPresContext
 The root prescontext for the display list builder reference frame.
nsTHashtable
< DisplayItemDataEntry > 
mNewDisplayItemData
 A map from frames to a list of (display item key, layer) pairs that describes what layers various parts of the frame are assigned to.
nsTHashtable
< ThebesLayerItemsEntry
mThebesLayerItems
 A map from ThebesLayers to the list of display items (plus clipping data) to be rendered in the layer.
PRUint32 mInitialDOMGeneration
 Saved generation counter so we can detect DOM changes.
PRPackedBool mDetectedDOMModification
 Set to true if we have detected and reported DOM modification during the current paint.
PRPackedBool mInvalidateAllThebesContent
 Indicates that the contents of all ThebesLayers should be rerendered during this paint.
PRPackedBool mInvalidateAllLayers
 Indicates that the entire layer tree should be rerendered during this paint.

Detailed Description

The FrameLayerBuilder belongs to an nsDisplayListBuilder and is responsible for converting display lists into layer trees.

The most important API in this class is BuildContainerLayerFor. This method takes a display list as input and constructs a ContainerLayer with child layers that render the contents of the display list. It also updates userdata for the retained layer manager, and DisplayItemDataProperty data for frames, to record the relationship between frames and layers.

That data enables us to retain layer trees. When constructing a ContainerLayer, we first check to see if there's an existing ContainerLayer for the same frame that can be recycled. If we recycle it, we also try to reuse its existing ThebesLayer children to render the display items without layers of their own. The idea is that by recycling layers deterministically, we can ensure that when nothing changes in a display list, we will reuse the existing layers without changes.

We expose a GetLeafLayerFor method that can be called by display items that make their own layers (e.g. canvas and video); this method locates the last layer used to render the display item, if any, and return it as a candidate for recycling.

FrameLayerBuilder sets up ThebesLayers so that 0,0 in the Thebes layer corresponds to the (pixel-snapped) top-left of the aActiveScrolledRoot. It sets up ContainerLayers so that 0,0 in the container layer corresponds to the snapped top-left of the display list reference frame.


Member Typedef Documentation


Constructor & Destructor Documentation

mozilla::FrameLayerBuilder::FrameLayerBuilder (  )  [inline]

Member Function Documentation

void mozilla::FrameLayerBuilder::AddLayerDisplayItem ( Layer aLayer,
nsDisplayItem aItem 
)

Record aItem as a display item that is rendered by aLayer.

void mozilla::FrameLayerBuilder::AddThebesDisplayItem ( ThebesLayer aLayer,
nsDisplayItem aItem,
const Clip aClip,
nsIFrame *  aContainerLayerFrame,
LayerState  aLayerState,
LayerManager aTempManager 
)
already_AddRefed<ContainerLayer> mozilla::FrameLayerBuilder::BuildContainerLayerFor ( nsDisplayListBuilder aBuilder,
LayerManager aManager,
nsIFrame *  aContainerFrame,
nsDisplayItem aContainerItem,
const nsDisplayList aChildren 
)

Build a container layer for a display item that contains a child list, either reusing an existing one or creating a new one.

It sets the container layer children to layers which together render the contents of the display list. It reuses existing layers from the retained layer manager if possible. aContainer may be null, in which case we construct a root layer. This gets called by display list code. It calls BuildLayer on the items in the display list, making items with their own layers children of the new container, and assigning all other items to ThebesLayer children created and managed by the FrameLayerBuilder. Returns a layer with clip rect cleared; it is the caller's responsibility to add any clip rect and set the visible region.

PRBool mozilla::FrameLayerBuilder::CheckDOMModified (  )  [protected]

Returns true if the DOM has been modified since we started painting, in which case we should bail out and not paint anymore.

This should never happen, but plugins can trigger it in some cases.

static void mozilla::FrameLayerBuilder::DestroyDisplayItemData ( nsIFrame *  aFrame,
void *  aPropertyValue 
) [static, protected]
static void mozilla::FrameLayerBuilder::DestroyDisplayItemDataFor ( nsIFrame *  aFrame  )  [inline, static]

Destroy any stored DisplayItemDataProperty for aFrame.

void mozilla::FrameLayerBuilder::DidBeginRetainedLayerTransaction ( LayerManager aManager  ) 

Call this to notify that we have just started a transaction on the retained layer manager aManager.

void mozilla::FrameLayerBuilder::DidEndTransaction ( LayerManager aManager  ) 

Call this after we end a transaction on aManager.

If aManager is not the retained layer manager then it must be a temporary layer manager that will not be used again.

static void mozilla::FrameLayerBuilder::DrawThebesLayer ( ThebesLayer aLayer,
gfxContext aContext,
const nsIntRegion aRegionToDraw,
const nsIntRegion aRegionToInvalidate,
void *  aCallbackData 
) [static]

This callback must be provided to EndTransaction.

The callback data must be the nsDisplayListBuilder containing this FrameLayerBuilder.

nscolor mozilla::FrameLayerBuilder::FindOpaqueColorCovering ( nsDisplayListBuilder aBuilder,
ThebesLayer aLayer,
const nsRect aRect 
)

Try to determine whether the ThebesLayer aLayer paints an opaque single color everywhere it's visible in aRect.

If successful, return that color, otherwise return NS_RGBA(0,0,0,0).

Layer* mozilla::FrameLayerBuilder::GetLeafLayerFor ( nsDisplayListBuilder aBuilder,
LayerManager aManager,
nsDisplayItem aItem 
)

Get a retained layer for a display item that needs to create its own layer for rendering (i.e.

under nsDisplayItem::BuildLayer). Returns null if no retained layer is available, which usually means that this display item didn't have a layer before so the caller will need to create one. Returns a layer with clip rect cleared; it is the caller's responsibility to add any clip rect and set the visible region.

Layer* mozilla::FrameLayerBuilder::GetOldLayerFor ( nsIFrame *  aFrame,
PRUint32  aDisplayItemKey 
)

Given a frame and a display item key that uniquely identifies a display item for the frame, find the layer that was last used to render that display item.

Returns null if there is no such layer. This could be a dedicated layer for the display item, or a ThebesLayer that renders many display items.

static PRBool mozilla::FrameLayerBuilder::HasDedicatedLayer ( nsIFrame *  aFrame,
PRUint32  aDisplayItemKey 
) [static]

Call this to determine if a frame has a dedicated (non-Thebes) layer for the given display item key.

void mozilla::FrameLayerBuilder::Init ( nsDisplayListBuilder aBuilder  ) 
static void mozilla::FrameLayerBuilder::InternalDestroyDisplayItemData ( nsIFrame *  aFrame,
void *  aPropertyValue,
PRBool  aRemoveFromFramesWithLayers 
) [static, protected]
static void mozilla::FrameLayerBuilder::InvalidateAllLayers ( LayerManager aManager  )  [static]

Call this to force all retained layers to be discarded and recreated at the next paint.

static void mozilla::FrameLayerBuilder::InvalidateAllThebesLayerContents ( LayerManager aManager  )  [static]

Call this to force *all* retained layer contents to be discarded at the next paint.

static void mozilla::FrameLayerBuilder::InvalidateThebesLayerContents ( nsIFrame *  aFrame,
const nsRect aRect 
) [static]

Call this during invalidation if aFrame has the NS_FRAME_HAS_CONTAINER_LAYER state bit.

Only the nearest ancestor frame of the damaged frame that has NS_FRAME_HAS_CONTAINER_LAYER needs to be invalidated this way.

static void mozilla::FrameLayerBuilder::InvalidateThebesLayersInSubtree ( nsIFrame *  aFrame  )  [static]

For any descendant frame of aFrame (including across documents) that has an associated container layer, invalidate all the contents of all ThebesLayer children of the container.

Useful when aFrame is being moved and we need to invalidate everything in aFrame's subtree.

mozilla::FrameLayerBuilder::NS_DECLARE_FRAME_PROPERTY_WITH_FRAME_IN_DTOR ( DisplayItemDataProperty  ,
DestroyDisplayItemData   
) [inline, protected]

For DisplayItemDataProperty, the property value *is* an nsTArray<DisplayItemData>, not a pointer to an array.

This works because sizeof(nsTArray<T>) == sizeof(void*). We accumulate DisplayItemData elements in a hashtable during the paint process, and store them in the frame property only when paint is complete. This is the hashentry for that hashtable.

static PLDHashOperator mozilla::FrameLayerBuilder::RemoveDisplayItemDataForFrame ( nsPtrHashKey< nsIFrame > *  aEntry,
void *  aClosure 
) [inline, static]

A useful hashtable iteration function that removes the DisplayItemData property for the frame, clears its NS_FRAME_HAS_CONTAINER_LAYER bit and returns PL_DHASH_REMOVE.

aClosure is ignored.

void mozilla::FrameLayerBuilder::RemoveThebesItemsForLayerSubtree ( Layer aLayer  )  [protected]
static PLDHashOperator mozilla::FrameLayerBuilder::StoreNewDisplayItemData ( DisplayItemDataEntry *  aEntry,
void *  aUserArg 
) [static, protected]
static PLDHashOperator mozilla::FrameLayerBuilder::UpdateDisplayItemDataForFrame ( nsPtrHashKey< nsIFrame > *  aEntry,
void *  aUserArg 
) [static, protected]
void mozilla::FrameLayerBuilder::WillEndTransaction ( LayerManager aManager  ) 

Call this just before we end a transaction on aManager.

If aManager is not the retained layer manager then it must be a temporary layer manager that will not be used again.


Member Data Documentation

Set to true if we have detected and reported DOM modification during the current paint.

Saved generation counter so we can detect DOM changes.

Indicates that the entire layer tree should be rerendered during this paint.

Indicates that the contents of all ThebesLayers should be rerendered during this paint.

A map from frames to a list of (display item key, layer) pairs that describes what layers various parts of the frame are assigned to.

The layer manager belonging to the widget that is being retained across paints.

The root prescontext for the display list builder reference frame.

A map from ThebesLayers to the list of display items (plus clipping data) to be rendered in the layer.


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