2010-05-21 07:20:48 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-05-21 07:20:48 +04:00
|
|
|
|
|
|
|
#ifndef FRAMELAYERBUILDER_H_
|
|
|
|
#define FRAMELAYERBUILDER_H_
|
|
|
|
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2010-07-16 01:07:51 +04:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "nsIFrame.h"
|
2013-03-04 13:55:59 +04:00
|
|
|
#include "DisplayItemClip.h"
|
2015-12-03 02:52:00 +03:00
|
|
|
#include "mozilla/gfx/MatrixFwd.h"
|
2013-12-16 16:16:24 +04:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2014-08-06 09:19:25 +04:00
|
|
|
#include "LayerState.h"
|
2016-03-08 22:43:32 +03:00
|
|
|
#include "Layers.h"
|
2015-10-22 23:04:35 +03:00
|
|
|
#include "LayerUserData.h"
|
2017-08-07 07:07:43 +03:00
|
|
|
#include "nsDisplayItemTypes.h"
|
2010-05-21 07:20:48 +04:00
|
|
|
|
|
|
|
class nsDisplayListBuilder;
|
|
|
|
class nsDisplayList;
|
|
|
|
class nsDisplayItem;
|
2010-07-16 01:07:46 +04:00
|
|
|
class gfxContext;
|
2013-08-20 02:55:18 +04:00
|
|
|
class nsDisplayItemGeometry;
|
2016-11-07 17:32:43 +03:00
|
|
|
class nsDisplayMask;
|
2010-05-21 07:20:48 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2017-02-01 01:07:35 +03:00
|
|
|
struct ActiveScrolledRoot;
|
|
|
|
struct DisplayItemClipChain;
|
2012-07-18 20:31:40 +04:00
|
|
|
namespace layers {
|
|
|
|
class ContainerLayer;
|
2012-08-21 08:06:46 +04:00
|
|
|
class LayerManager;
|
2013-11-06 23:10:49 +04:00
|
|
|
class BasicLayerManager;
|
2014-09-26 21:06:08 +04:00
|
|
|
class PaintedLayer;
|
2015-10-23 00:02:14 +03:00
|
|
|
class ImageLayer;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
2010-05-21 07:20:48 +04:00
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
class FrameLayerBuilder;
|
2012-08-29 09:47:15 +04:00
|
|
|
class LayerManagerData;
|
2014-09-26 21:06:08 +04:00
|
|
|
class PaintedLayerData;
|
2014-06-23 08:24:00 +04:00
|
|
|
class ContainerState;
|
2012-07-17 21:03:51 +04:00
|
|
|
|
2017-05-10 06:07:37 +03:00
|
|
|
/**
|
|
|
|
* Retained data storage:
|
|
|
|
*
|
|
|
|
* Each layer manager (widget, and inactive) stores a LayerManagerData object
|
|
|
|
* that keeps a hash-set of DisplayItemData items that were drawn into it.
|
|
|
|
* Each frame also keeps a list of DisplayItemData pointers that were
|
|
|
|
* created for that frame. DisplayItemData objects manage these lists automatically.
|
|
|
|
*
|
|
|
|
* During layer construction we update the data in the LayerManagerData object, marking
|
|
|
|
* items that are modified. At the end we sweep the LayerManagerData hash-set and remove
|
|
|
|
* all items that haven't been modified.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retained data for a display item.
|
|
|
|
*/
|
|
|
|
class DisplayItemData final {
|
|
|
|
public:
|
|
|
|
friend class FrameLayerBuilder;
|
|
|
|
|
|
|
|
uint32_t GetDisplayItemKey() { return mDisplayItemKey; }
|
|
|
|
layers::Layer* GetLayer() { return mLayer; }
|
|
|
|
nsDisplayItemGeometry* GetGeometry() const { return mGeometry.get(); }
|
|
|
|
void Invalidate() { mIsInvalid = true; }
|
|
|
|
void ClearAnimationCompositorState();
|
|
|
|
|
|
|
|
static DisplayItemData* AssertDisplayItemData(DisplayItemData* aData);
|
|
|
|
|
|
|
|
void* operator new(size_t sz, nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// Check the recycle list first.
|
|
|
|
return aPresContext->PresShell()->
|
|
|
|
AllocateByObjectID(eArenaObjectID_DisplayItemData, sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt AddRef() {
|
|
|
|
if (mRefCnt == UINT32_MAX) {
|
|
|
|
NS_WARNING("refcount overflow, leaking object");
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
++mRefCnt;
|
|
|
|
NS_LOG_ADDREF(this, mRefCnt, "nsStyleContext", sizeof(nsStyleContext));
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt Release() {
|
|
|
|
if (mRefCnt == UINT32_MAX) {
|
|
|
|
NS_WARNING("refcount overflow, leaking object");
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
--mRefCnt;
|
|
|
|
NS_LOG_RELEASE(this, mRefCnt, "nsStyleContext");
|
|
|
|
if (mRefCnt == 0) {
|
|
|
|
Destroy();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
DisplayItemData(LayerManagerData* aParent,
|
|
|
|
uint32_t aKey,
|
|
|
|
layers::Layer* aLayer,
|
|
|
|
nsIFrame* aFrame = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes any references to this object from frames
|
|
|
|
* in mFrameList.
|
|
|
|
*/
|
|
|
|
~DisplayItemData();
|
|
|
|
|
|
|
|
void Destroy()
|
|
|
|
{
|
|
|
|
// Get the pres context.
|
|
|
|
RefPtr<nsPresContext> presContext = mFrameList[0]->PresContext();
|
|
|
|
|
|
|
|
// Call our destructor.
|
|
|
|
this->~DisplayItemData();
|
|
|
|
|
|
|
|
// Don't let the memory be freed, since it will be recycled
|
|
|
|
// instead. Don't call the global operator delete.
|
|
|
|
presContext->PresShell()->
|
|
|
|
FreeByObjectID(eArenaObjectID_DisplayItemData, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Associates this DisplayItemData with a frame, and adds it
|
|
|
|
* to the LayerManagerDataProperty list on the frame.
|
|
|
|
*/
|
|
|
|
void AddFrame(nsIFrame* aFrame);
|
|
|
|
void RemoveFrame(nsIFrame* aFrame);
|
2017-03-21 03:07:49 +03:00
|
|
|
const nsRegion& GetChangedFrameInvalidations();
|
2017-05-10 06:07:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the contents of this item to a new set of data, instead of allocating a new
|
|
|
|
* object.
|
|
|
|
* Set the passed in parameters, and clears the opt layer and inactive manager.
|
|
|
|
* Parent, and display item key are assumed to be the same.
|
|
|
|
*
|
|
|
|
* EndUpdate must be called before the end of the transaction to complete the update.
|
|
|
|
*/
|
|
|
|
void BeginUpdate(layers::Layer* aLayer, LayerState aState,
|
|
|
|
uint32_t aContainerLayerGeneration, nsDisplayItem* aItem = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Completes the update of this, and removes any references to data that won't live
|
|
|
|
* longer than the transaction.
|
|
|
|
*
|
|
|
|
* Updates the geometry, frame list and clip.
|
|
|
|
* For items within a PaintedLayer, a geometry object must be specified to retain
|
|
|
|
* until the next transaction.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void EndUpdate(nsAutoPtr<nsDisplayItemGeometry> aGeometry);
|
|
|
|
void EndUpdate();
|
|
|
|
|
|
|
|
uint32_t mRefCnt;
|
|
|
|
LayerManagerData* mParent;
|
|
|
|
RefPtr<layers::Layer> mLayer;
|
|
|
|
RefPtr<layers::Layer> mOptLayer;
|
|
|
|
RefPtr<layers::BasicLayerManager> mInactiveManager;
|
|
|
|
AutoTArray<nsIFrame*, 1> mFrameList;
|
|
|
|
nsAutoPtr<nsDisplayItemGeometry> mGeometry;
|
|
|
|
DisplayItemClip mClip;
|
|
|
|
uint32_t mDisplayItemKey;
|
|
|
|
uint32_t mContainerLayerGeneration;
|
|
|
|
LayerState mLayerState;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Temporary stoarage of the display item being referenced, only valid between
|
|
|
|
* BeginUpdate and EndUpdate.
|
|
|
|
*/
|
|
|
|
nsDisplayItem* mItem;
|
2017-03-21 03:07:49 +03:00
|
|
|
nsRegion mChangedFrameInvalidations;
|
2017-05-10 06:07:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to track if data currently stored in mFramesWithLayers (from an existing
|
|
|
|
* paint) has been updated in the current paint.
|
|
|
|
*/
|
|
|
|
bool mUsed;
|
|
|
|
bool mIsInvalid;
|
|
|
|
};
|
|
|
|
|
2014-04-14 23:04:24 +04:00
|
|
|
class RefCountedRegion {
|
2014-06-19 06:28:59 +04:00
|
|
|
private:
|
|
|
|
~RefCountedRegion() {}
|
2012-07-14 11:49:05 +04:00
|
|
|
public:
|
2014-04-14 23:04:24 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(RefCountedRegion)
|
|
|
|
|
2012-08-23 15:14:47 +04:00
|
|
|
RefCountedRegion() : mIsInfinite(false) {}
|
2012-07-14 11:49:05 +04:00
|
|
|
nsRegion mRegion;
|
2012-08-23 15:14:47 +04:00
|
|
|
bool mIsInfinite;
|
2012-07-14 11:49:05 +04:00
|
|
|
};
|
|
|
|
|
2013-09-27 10:01:16 +04:00
|
|
|
struct ContainerLayerParameters {
|
2014-06-23 08:24:00 +04:00
|
|
|
ContainerLayerParameters()
|
|
|
|
: mXScale(1)
|
|
|
|
, mYScale(1)
|
|
|
|
, mLayerContentsVisibleRect(nullptr)
|
2015-02-25 19:47:22 +03:00
|
|
|
, mBackgroundColor(NS_RGBA(0,0,0,0))
|
2017-02-01 01:07:35 +03:00
|
|
|
, mScrollMetadataASR(nullptr)
|
|
|
|
, mCompositorASR(nullptr)
|
2014-06-23 08:24:00 +04:00
|
|
|
, mInTransformedSubtree(false)
|
|
|
|
, mInActiveTransformedSubtree(false)
|
|
|
|
, mDisableSubpixelAntialiasingInDescendants(false)
|
2016-08-10 06:15:28 +03:00
|
|
|
, mForEventsAndPluginsOnly(false)
|
2016-03-08 22:43:32 +03:00
|
|
|
, mLayerCreationHint(layers::LayerManager::NONE)
|
2013-09-27 10:01:16 +04:00
|
|
|
{}
|
2014-06-23 08:24:00 +04:00
|
|
|
ContainerLayerParameters(float aXScale, float aYScale)
|
|
|
|
: mXScale(aXScale)
|
|
|
|
, mYScale(aYScale)
|
|
|
|
, mLayerContentsVisibleRect(nullptr)
|
2015-02-25 19:47:22 +03:00
|
|
|
, mBackgroundColor(NS_RGBA(0,0,0,0))
|
2017-02-01 01:07:35 +03:00
|
|
|
, mScrollMetadataASR(nullptr)
|
|
|
|
, mCompositorASR(nullptr)
|
2014-06-23 08:24:00 +04:00
|
|
|
, mInTransformedSubtree(false)
|
|
|
|
, mInActiveTransformedSubtree(false)
|
|
|
|
, mDisableSubpixelAntialiasingInDescendants(false)
|
2016-08-10 06:15:28 +03:00
|
|
|
, mForEventsAndPluginsOnly(false)
|
2016-03-08 22:43:32 +03:00
|
|
|
, mLayerCreationHint(layers::LayerManager::NONE)
|
2013-09-27 10:01:16 +04:00
|
|
|
{}
|
|
|
|
ContainerLayerParameters(float aXScale, float aYScale,
|
|
|
|
const nsIntPoint& aOffset,
|
2014-06-23 08:24:00 +04:00
|
|
|
const ContainerLayerParameters& aParent)
|
|
|
|
: mXScale(aXScale)
|
|
|
|
, mYScale(aYScale)
|
|
|
|
, mLayerContentsVisibleRect(nullptr)
|
|
|
|
, mOffset(aOffset)
|
2015-02-25 19:47:22 +03:00
|
|
|
, mBackgroundColor(aParent.mBackgroundColor)
|
2017-02-01 01:07:35 +03:00
|
|
|
, mScrollMetadataASR(aParent.mScrollMetadataASR)
|
|
|
|
, mCompositorASR(aParent.mCompositorASR)
|
2014-06-23 08:24:00 +04:00
|
|
|
, mInTransformedSubtree(aParent.mInTransformedSubtree)
|
|
|
|
, mInActiveTransformedSubtree(aParent.mInActiveTransformedSubtree)
|
|
|
|
, mDisableSubpixelAntialiasingInDescendants(aParent.mDisableSubpixelAntialiasingInDescendants)
|
2016-08-10 06:15:28 +03:00
|
|
|
, mForEventsAndPluginsOnly(aParent.mForEventsAndPluginsOnly)
|
2016-03-08 22:43:32 +03:00
|
|
|
, mLayerCreationHint(aParent.mLayerCreationHint)
|
2013-09-27 10:01:16 +04:00
|
|
|
{}
|
2015-04-08 04:55:28 +03:00
|
|
|
|
2013-09-27 10:01:16 +04:00
|
|
|
float mXScale, mYScale;
|
2015-04-08 04:55:28 +03:00
|
|
|
|
|
|
|
LayoutDeviceToLayerScale2D Scale() const {
|
|
|
|
return LayoutDeviceToLayerScale2D(mXScale, mYScale);
|
|
|
|
}
|
|
|
|
|
2013-09-27 10:01:16 +04:00
|
|
|
/**
|
2014-06-23 08:24:00 +04:00
|
|
|
* If non-null, the rectangle in which BuildContainerLayerFor stores the
|
|
|
|
* visible rect of the layer, in the coordinate system of the created layer.
|
2013-09-27 10:01:16 +04:00
|
|
|
*/
|
2014-06-23 08:24:00 +04:00
|
|
|
nsIntRect* mLayerContentsVisibleRect;
|
2015-04-08 04:55:28 +03:00
|
|
|
|
2013-09-27 10:01:16 +04:00
|
|
|
/**
|
2014-06-23 08:24:00 +04:00
|
|
|
* An offset to apply to all child layers created.
|
2013-09-27 10:01:16 +04:00
|
|
|
*/
|
|
|
|
nsIntPoint mOffset;
|
|
|
|
|
2015-04-08 04:55:28 +03:00
|
|
|
LayerIntPoint Offset() const {
|
2015-11-10 02:22:25 +03:00
|
|
|
return LayerIntPoint::FromUnknownPoint(mOffset);
|
2015-04-08 04:55:28 +03:00
|
|
|
}
|
|
|
|
|
2015-02-25 19:47:22 +03:00
|
|
|
nscolor mBackgroundColor;
|
2017-02-01 01:07:35 +03:00
|
|
|
const ActiveScrolledRoot* mScrollMetadataASR;
|
|
|
|
const ActiveScrolledRoot* mCompositorASR;
|
2016-02-26 03:29:41 +03:00
|
|
|
|
2013-09-27 10:01:16 +04:00
|
|
|
bool mInTransformedSubtree;
|
|
|
|
bool mInActiveTransformedSubtree;
|
|
|
|
bool mDisableSubpixelAntialiasingInDescendants;
|
2016-08-10 06:15:28 +03:00
|
|
|
bool mForEventsAndPluginsOnly;
|
2016-03-08 22:43:32 +03:00
|
|
|
layers::LayerManager::PaintedLayerCreationHint mLayerCreationHint;
|
|
|
|
|
2013-09-27 10:01:16 +04:00
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* When this is false, PaintedLayer coordinates are drawn to with an integer
|
2013-09-27 10:01:16 +04:00
|
|
|
* translation and the scale in mXScale/mYScale.
|
|
|
|
*/
|
|
|
|
bool AllowResidualTranslation()
|
|
|
|
{
|
|
|
|
// If we're in a transformed subtree, but no ancestor transform is actively
|
|
|
|
// changing, we'll use the residual translation when drawing into the
|
2014-09-26 21:06:08 +04:00
|
|
|
// PaintedLayer to ensure that snapping exactly matches the ideal transform.
|
2013-09-27 10:01:16 +04:00
|
|
|
return mInTransformedSubtree && !mInActiveTransformedSubtree;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* The FrameLayerBuilder is responsible for converting display lists
|
2012-08-29 09:47:15 +04:00
|
|
|
* into layer trees. Every LayerManager needs a unique FrameLayerBuilder
|
|
|
|
* to build layers.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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
|
2012-09-28 15:19:39 +04:00
|
|
|
* records the relationship between frames and layers.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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
|
2014-09-26 21:06:08 +04:00
|
|
|
* it, we also try to reuse its existing PaintedLayer children to render
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2014-09-26 21:07:06 +04:00
|
|
|
* FrameLayerBuilder sets up PaintedLayers so that 0,0 in the Painted layer
|
2013-09-26 01:07:26 +04:00
|
|
|
* corresponds to the (pixel-snapped) top-left of the aAnimatedGeometryRoot.
|
2010-07-16 01:07:51 +04:00
|
|
|
* It sets up ContainerLayers so that 0,0 in the container layer
|
2012-09-28 15:19:39 +04:00
|
|
|
* corresponds to the snapped top-left of the display item reference frame.
|
2011-06-22 16:11:27 +04:00
|
|
|
*
|
|
|
|
* When we construct a container layer, we know the transform that will be
|
|
|
|
* applied to the layer. If the transform scales the content, we can get
|
|
|
|
* better results when intermediate buffers are used by pushing some scale
|
2014-09-26 21:06:08 +04:00
|
|
|
* from the container's transform down to the children. For PaintedLayer
|
2011-06-22 16:11:27 +04:00
|
|
|
* children, the scaling can be achieved by changing the size of the layer
|
|
|
|
* and drawing into it with increased or decreased resolution. By convention,
|
|
|
|
* integer types (nsIntPoint/nsIntSize/nsIntRect/nsIntRegion) are all in layer
|
|
|
|
* coordinates, post-scaling, whereas appunit types are all pre-scaling.
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
2012-08-29 09:48:15 +04:00
|
|
|
class FrameLayerBuilder : public layers::LayerUserData {
|
2010-05-21 07:20:48 +04:00
|
|
|
public:
|
2012-08-21 08:06:46 +04:00
|
|
|
typedef layers::ContainerLayer ContainerLayer;
|
|
|
|
typedef layers::Layer Layer;
|
2014-09-26 21:06:08 +04:00
|
|
|
typedef layers::PaintedLayer PaintedLayer;
|
2012-09-25 00:31:30 +04:00
|
|
|
typedef layers::ImageLayer ImageLayer;
|
2010-07-16 01:07:51 +04:00
|
|
|
typedef layers::LayerManager LayerManager;
|
2013-11-06 23:10:49 +04:00
|
|
|
typedef layers::BasicLayerManager BasicLayerManager;
|
2013-12-16 16:16:24 +04:00
|
|
|
typedef layers::EventRegions EventRegions;
|
2010-07-16 01:07:51 +04:00
|
|
|
|
2015-10-23 00:00:16 +03:00
|
|
|
FrameLayerBuilder();
|
|
|
|
~FrameLayerBuilder();
|
2010-07-16 01:07:51 +04:00
|
|
|
|
2012-06-26 06:43:30 +04:00
|
|
|
static void Shutdown();
|
|
|
|
|
2013-12-16 16:16:24 +04:00
|
|
|
void Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
|
2017-04-29 03:32:05 +03:00
|
|
|
PaintedLayerData* aLayerData = nullptr,
|
|
|
|
const DisplayItemClip* aInactiveLayerClip = nullptr);
|
2010-09-17 23:09:08 +04:00
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
2011-01-19 11:27:54 +03:00
|
|
|
* Call this to notify that we have just started a transaction on the
|
2010-07-16 01:08:11 +04:00
|
|
|
* retained layer manager aManager.
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
2011-01-19 11:27:54 +03:00
|
|
|
void DidBeginRetainedLayerTransaction(LayerManager* aManager);
|
2010-07-16 01:07:51 +04:00
|
|
|
|
|
|
|
/**
|
2012-08-29 09:47:15 +04:00
|
|
|
* Call this just before we end a transaction.
|
2010-07-16 01:08:11 +04:00
|
|
|
*/
|
2012-08-29 09:47:15 +04:00
|
|
|
void WillEndTransaction();
|
2010-07-16 01:08:11 +04:00
|
|
|
|
|
|
|
/**
|
2012-08-29 09:47:15 +04:00
|
|
|
* Call this after we end a transaction.
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
2012-08-29 09:47:15 +04:00
|
|
|
void DidEndTransaction();
|
2010-05-21 07:20:48 +04:00
|
|
|
|
2013-03-22 06:17:29 +04:00
|
|
|
enum {
|
2015-02-25 19:47:22 +03:00
|
|
|
/**
|
|
|
|
* Set this when pulling an opaque background color from behind the
|
|
|
|
* container layer into the container doesn't change the visual results,
|
|
|
|
* given the effects you're going to apply to the container layer.
|
|
|
|
* For example, this is compatible with opacity or clipping/masking, but
|
|
|
|
* not with non-OVER blend modes or filters.
|
|
|
|
*/
|
2016-05-18 06:12:44 +03:00
|
|
|
CONTAINER_ALLOW_PULL_BACKGROUND_COLOR = 0x01
|
2013-03-22 06:17:29 +04:00
|
|
|
};
|
2010-05-21 07:20:48 +04:00
|
|
|
/**
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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.
|
2015-07-13 16:44:11 +03:00
|
|
|
* aContainerItem may be null, in which case we construct a root layer.
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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
|
2014-09-26 21:06:08 +04:00
|
|
|
* PaintedLayer children created and managed by the FrameLayerBuilder.
|
2010-07-16 01:07:51 +04:00
|
|
|
* Returns a layer with clip rect cleared; it is the
|
2011-02-23 08:38:09 +03:00
|
|
|
* caller's responsibility to add any clip rect. The visible region
|
|
|
|
* is set based on what's in the layer.
|
2011-06-22 16:11:27 +04:00
|
|
|
* The container layer is transformed by aTransform (if non-null), and
|
|
|
|
* the result is transformed by the scale factors in aContainerParameters.
|
2014-06-09 08:48:00 +04:00
|
|
|
* aChildren is modified due to display item merging and flattening.
|
2014-06-23 08:24:00 +04:00
|
|
|
* The visible region of the returned layer is set only if aContainerItem
|
|
|
|
* is null.
|
2010-05-21 07:20:48 +04:00
|
|
|
*/
|
2010-09-04 00:10:45 +04:00
|
|
|
already_AddRefed<ContainerLayer>
|
|
|
|
BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
nsIFrame* aContainerFrame,
|
|
|
|
nsDisplayItem* aContainerItem,
|
2014-06-09 08:48:00 +04:00
|
|
|
nsDisplayList* aChildren,
|
2013-09-27 10:01:16 +04:00
|
|
|
const ContainerLayerParameters& aContainerParameters,
|
2014-08-01 16:31:49 +04:00
|
|
|
const gfx::Matrix4x4* aTransform,
|
2013-03-22 06:17:29 +04:00
|
|
|
uint32_t aFlags = 0);
|
2010-07-16 01:07:46 +04:00
|
|
|
|
|
|
|
/**
|
2010-07-16 01:07:51 +04:00
|
|
|
* 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.
|
2010-07-16 01:07:46 +04:00
|
|
|
*/
|
|
|
|
Layer* GetLeafLayerFor(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem);
|
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
|
|
|
* Call this to force all retained layers to be discarded and recreated at
|
|
|
|
* the next paint.
|
|
|
|
*/
|
|
|
|
static void InvalidateAllLayers(LayerManager* aManager);
|
2012-08-29 09:48:45 +04:00
|
|
|
static void InvalidateAllLayersForFrame(nsIFrame *aFrame);
|
2010-07-16 01:07:53 +04:00
|
|
|
|
|
|
|
/**
|
2014-09-26 21:07:06 +04:00
|
|
|
* Call this to determine if a frame has a dedicated (non-Painted) layer
|
2011-03-28 03:59:47 +04:00
|
|
|
* for the given display item key. If there isn't one, we return null,
|
|
|
|
* otherwise we return the layer.
|
2010-07-16 01:07:53 +04:00
|
|
|
*/
|
2017-08-07 07:07:43 +03:00
|
|
|
static Layer* GetDedicatedLayer(nsIFrame* aFrame, DisplayItemType aDisplayItemType);
|
2012-07-04 04:24:55 +04:00
|
|
|
|
2010-05-21 07:20:48 +04:00
|
|
|
/**
|
|
|
|
* This callback must be provided to EndTransaction. The callback data
|
|
|
|
* must be the nsDisplayListBuilder containing this FrameLayerBuilder.
|
2012-07-06 21:57:47 +04:00
|
|
|
* This function can be called multiple times in a row to draw
|
2015-07-21 11:19:25 +03:00
|
|
|
* different regions. This will occur when, for example, progressive paint is
|
2015-09-15 16:41:42 +03:00
|
|
|
* enabled. In these cases aDirtyRegion can be used to specify a larger region
|
|
|
|
* than aRegionToDraw that will be drawn during the transaction, possibly
|
|
|
|
* allowing the callback to make optimizations.
|
2010-05-21 07:20:48 +04:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
static void DrawPaintedLayer(PaintedLayer* aLayer,
|
2010-05-21 07:20:48 +04:00
|
|
|
gfxContext* aContext,
|
|
|
|
const nsIntRegion& aRegionToDraw,
|
2015-09-15 16:41:42 +03:00
|
|
|
const nsIntRegion& aDirtyRegion,
|
2013-11-06 23:10:50 +04:00
|
|
|
mozilla::layers::DrawRegionClip aClip,
|
2010-03-04 00:37:04 +03:00
|
|
|
const nsIntRegion& aRegionToInvalidate,
|
2010-05-21 07:20:48 +04:00
|
|
|
void* aCallbackData);
|
2010-07-16 01:07:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dumps this FrameLayerBuilder's retained layer manager's retained
|
2012-08-07 21:57:26 +04:00
|
|
|
* layer tree. Defaults to dumping to stdout in non-HTML format.
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
2014-06-20 02:36:25 +04:00
|
|
|
static void DumpRetainedLayerTree(LayerManager* aManager, std::stringstream& aStream, bool aDumpHtml = false);
|
2010-07-16 01:07:51 +04:00
|
|
|
|
2015-02-05 00:50:56 +03:00
|
|
|
/**
|
|
|
|
* Returns the most recently allocated geometry item for the given display
|
|
|
|
* item.
|
|
|
|
*
|
|
|
|
* XXX(seth): The current implementation must iterate through all display
|
|
|
|
* items allocated for this display item's frame. This may lead to O(n^2)
|
|
|
|
* behavior in some situations.
|
|
|
|
*/
|
|
|
|
static nsDisplayItemGeometry* GetMostRecentGeometry(nsDisplayItem* aItem);
|
|
|
|
|
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/******* PRIVATE METHODS to FrameLayerBuilder.cpp ********/
|
|
|
|
/* These are only in the public section because they need
|
|
|
|
* to be called by file-scope helper functions in FrameLayerBuilder.cpp.
|
|
|
|
*/
|
2012-08-29 14:53:27 +04:00
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
|
|
|
* Record aItem as a display item that is rendered by aLayer.
|
2012-08-29 09:47:15 +04:00
|
|
|
*
|
|
|
|
* @param aLayer Layer that the display item will be rendered into
|
|
|
|
* @param aItem Display item to be drawn.
|
|
|
|
* @param aLayerState What LayerState the item is using.
|
|
|
|
* @param aManager If the layer is in the LAYER_INACTIVE state,
|
|
|
|
* then this is the temporary layer manager to draw with.
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
2012-12-14 02:50:57 +04:00
|
|
|
void AddLayerDisplayItem(Layer* aLayer,
|
|
|
|
nsDisplayItem* aItem,
|
|
|
|
LayerState aLayerState,
|
2014-07-23 10:03:24 +04:00
|
|
|
BasicLayerManager* aManager);
|
2012-08-29 14:53:27 +04:00
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* Record aItem as a display item that is rendered by the PaintedLayer
|
2010-07-16 01:07:51 +04:00
|
|
|
* aLayer, with aClipRect, where aContainerLayerFrame is the frame
|
|
|
|
* for the container layer this ThebesItem belongs to.
|
|
|
|
* aItem must have an underlying frame.
|
2012-09-28 15:19:39 +04:00
|
|
|
* @param aTopLeft offset from active scrolled root to reference frame
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
2014-09-26 21:07:06 +04:00
|
|
|
void AddPaintedDisplayItem(PaintedLayerData* aLayer,
|
2010-07-16 01:08:05 +04:00
|
|
|
nsDisplayItem* aItem,
|
2013-03-04 13:55:59 +04:00
|
|
|
const DisplayItemClip& aClip,
|
2015-01-20 17:49:30 +03:00
|
|
|
ContainerState& aContainerState,
|
2012-08-29 09:47:15 +04:00
|
|
|
LayerState aLayerState,
|
2014-07-23 10:03:24 +04:00
|
|
|
const nsPoint& aTopLeft);
|
2012-08-29 09:48:41 +04:00
|
|
|
|
2012-08-29 14:53:27 +04:00
|
|
|
/**
|
|
|
|
* Calls GetOldLayerForFrame on the underlying frame of the display item,
|
|
|
|
* and each subsequent merged frame if no layer is found for the underlying
|
|
|
|
* frame.
|
|
|
|
*/
|
2017-07-06 15:00:35 +03:00
|
|
|
Layer* GetOldLayerFor(nsDisplayItem* aItem,
|
|
|
|
nsDisplayItemGeometry** aOldGeometry = nullptr,
|
2014-07-23 10:03:24 +04:00
|
|
|
DisplayItemClip** aOldClip = nullptr);
|
|
|
|
|
|
|
|
void ClearCachedGeometry(nsDisplayItem* aItem);
|
2010-07-16 01:07:51 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static Layer* GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKey);
|
2012-08-29 09:47:15 +04:00
|
|
|
|
2015-03-11 21:51:59 +03:00
|
|
|
/**
|
|
|
|
* Return the layer that all display items of aFrame were assigned to in the
|
|
|
|
* last paint, or nullptr if there was no single layer assigned to all of the
|
|
|
|
* frame's display items (i.e. zero, or more than one).
|
|
|
|
* This function is for testing purposes and not performance sensitive.
|
|
|
|
*/
|
2017-04-25 06:02:48 +03:00
|
|
|
template<class T>
|
|
|
|
static T*
|
|
|
|
GetDebugSingleOldLayerForFrame(nsIFrame* aFrame)
|
|
|
|
{
|
2017-05-10 06:07:38 +03:00
|
|
|
SmallPointerArray<DisplayItemData>& array = aFrame->DisplayItemData();
|
2017-04-25 06:02:48 +03:00
|
|
|
|
|
|
|
Layer* layer = nullptr;
|
2017-05-10 06:07:38 +03:00
|
|
|
for (DisplayItemData* data : array) {
|
2017-04-25 06:02:48 +03:00
|
|
|
DisplayItemData::AssertDisplayItemData(data);
|
|
|
|
if (data->mLayer->GetType() != T::Type()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (layer && layer != data->mLayer) {
|
|
|
|
// More than one layer assigned, bail.
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
layer = data->mLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!layer) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<T*>(layer);
|
|
|
|
}
|
2015-03-11 21:51:59 +03:00
|
|
|
|
2010-09-18 15:28:49 +04:00
|
|
|
/**
|
2011-10-07 01:35:08 +04:00
|
|
|
* Destroy any stored LayerManagerDataProperty and the associated data for
|
|
|
|
* aFrame.
|
2010-09-18 15:28:49 +04:00
|
|
|
*/
|
2012-08-29 09:48:41 +04:00
|
|
|
static void DestroyDisplayItemDataFor(nsIFrame* aFrame);
|
2010-09-18 15:28:49 +04:00
|
|
|
|
2011-02-10 11:58:11 +03:00
|
|
|
LayerManager* GetRetainingLayerManager() { return mRetainingManager; }
|
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
/**
|
2012-12-14 02:51:00 +04:00
|
|
|
* Returns true if the given display item was rendered during the previous
|
|
|
|
* paint. Returns false otherwise.
|
2012-08-29 09:48:45 +04:00
|
|
|
*/
|
2012-12-14 02:51:00 +04:00
|
|
|
static bool HasRetainedDataFor(nsIFrame* aFrame, uint32_t aDisplayItemKey);
|
2012-08-29 09:48:45 +04:00
|
|
|
|
2012-11-07 02:04:53 +04:00
|
|
|
typedef void (*DisplayItemDataCallback)(nsIFrame *aFrame, DisplayItemData* aItem);
|
|
|
|
|
2012-12-14 02:50:57 +04:00
|
|
|
static void IterateRetainedDataFor(nsIFrame* aFrame, DisplayItemDataCallback aCallback);
|
2012-11-07 02:04:53 +04:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
/**
|
2012-08-29 09:47:15 +04:00
|
|
|
* Save transform that was in aLayer when we last painted, and the position
|
|
|
|
* of the active scrolled root frame. It must be an integer
|
2011-05-18 09:48:43 +04:00
|
|
|
* translation.
|
2011-05-17 03:05:56 +04:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
void SavePreviousDataForLayer(PaintedLayer* aLayer, uint32_t aClipCount);
|
2011-05-17 03:05:56 +04:00
|
|
|
/**
|
2011-05-18 09:48:43 +04:00
|
|
|
* Get the translation transform that was in aLayer when we last painted. It's either
|
2011-05-17 03:05:56 +04:00
|
|
|
* the transform saved by SaveLastPaintTransform, or else the transform
|
2011-05-18 09:48:43 +04:00
|
|
|
* that's currently in the layer (which must be an integer translation).
|
2011-05-17 03:05:56 +04:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
nsIntPoint GetLastPaintOffset(PaintedLayer* aLayer);
|
2011-05-17 03:05:56 +04:00
|
|
|
|
2012-05-10 09:24:18 +04:00
|
|
|
/**
|
2012-08-04 16:26:38 +04:00
|
|
|
* Return the resolution at which we expect to render aFrame's contents,
|
|
|
|
* assuming they are being painted to retained layers. This takes into account
|
|
|
|
* the resolution the contents of the ContainerLayer containing aFrame are
|
|
|
|
* being rendered at, as well as any currently-inactive transforms between
|
|
|
|
* aFrame and that container layer.
|
2012-05-10 09:24:18 +04:00
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
static gfxSize GetPaintedLayerScaleForFrame(nsIFrame* aFrame);
|
2012-05-10 09:24:18 +04:00
|
|
|
|
2012-09-25 00:31:30 +04:00
|
|
|
/**
|
|
|
|
* Stores a Layer as the dedicated layer in the DisplayItemData for a given frame/key pair.
|
|
|
|
*
|
2017-07-06 15:00:35 +03:00
|
|
|
* Used when we optimize a PaintedLayer into an ImageLayer and want to retroactively update the
|
2012-09-25 00:31:30 +04:00
|
|
|
* DisplayItemData so we can retrieve the layer from within layout.
|
|
|
|
*/
|
2012-10-12 06:39:46 +04:00
|
|
|
void StoreOptimizedLayerForFrame(nsDisplayItem* aItem, Layer* aLayer);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2017-05-10 06:07:38 +03:00
|
|
|
static void RemoveFrameFromLayerManager(const nsIFrame* aFrame,
|
|
|
|
SmallPointerArray<DisplayItemData>& aArray);
|
|
|
|
|
2012-11-07 02:04:53 +04:00
|
|
|
protected:
|
|
|
|
|
2012-07-04 04:17:01 +04:00
|
|
|
friend class LayerManagerData;
|
|
|
|
|
2012-10-12 03:38:24 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
2014-09-26 21:06:08 +04:00
|
|
|
* This could be a dedicated layer for the display item, or a PaintedLayer
|
2012-10-12 03:38:24 +04:00
|
|
|
* that renders many display items.
|
|
|
|
*/
|
|
|
|
DisplayItemData* GetOldLayerForFrame(nsIFrame* aFrame, uint32_t aDisplayItemKey);
|
|
|
|
|
2012-08-29 09:47:15 +04:00
|
|
|
/**
|
|
|
|
* Stores DisplayItemData associated with aFrame, stores the data in
|
|
|
|
* mNewDisplayItemData.
|
|
|
|
*/
|
2012-10-12 06:39:46 +04:00
|
|
|
DisplayItemData* StoreDataForFrame(nsDisplayItem* aItem, Layer* aLayer, LayerState aState);
|
|
|
|
void StoreDataForFrame(nsIFrame* aFrame,
|
|
|
|
uint32_t aDisplayItemKey,
|
|
|
|
Layer* aLayer,
|
|
|
|
LayerState aState);
|
2012-08-29 09:47:15 +04:00
|
|
|
|
2011-11-15 08:59:03 +04:00
|
|
|
// Flash the area within the context clip if paint flashing is enabled.
|
|
|
|
static void FlashPaint(gfxContext *aContext);
|
|
|
|
|
2011-10-07 01:35:08 +04:00
|
|
|
/*
|
|
|
|
* Get the DisplayItemData array associated with this frame, or null if one
|
|
|
|
* doesn't exist.
|
|
|
|
*
|
|
|
|
* Note that the pointer returned here is only valid so long as you don't
|
|
|
|
* poke the LayerManagerData's mFramesWithLayers hashtable.
|
|
|
|
*/
|
2012-10-12 03:38:24 +04:00
|
|
|
DisplayItemData* GetDisplayItemData(nsIFrame *aFrame, uint32_t aKey);
|
2012-08-29 09:47:15 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the DisplayItemData associated with this frame / display item pair,
|
|
|
|
* using the LayerManager instead of FrameLayerBuilder.
|
|
|
|
*/
|
2017-07-06 15:00:35 +03:00
|
|
|
static DisplayItemData* GetDisplayItemDataForManager(nsIFrame* aFrame,
|
|
|
|
uint32_t aDisplayItemKey,
|
2012-08-29 09:47:15 +04:00
|
|
|
LayerManager* aManager);
|
2017-07-06 15:00:35 +03:00
|
|
|
static DisplayItemData* GetDisplayItemDataForManager(nsIFrame* aFrame,
|
2012-08-29 09:48:45 +04:00
|
|
|
uint32_t aDisplayItemKey);
|
2012-08-29 09:47:15 +04:00
|
|
|
static DisplayItemData* GetDisplayItemDataForManager(nsDisplayItem* aItem, LayerManager* aManager);
|
2017-07-06 15:00:35 +03:00
|
|
|
static DisplayItemData* GetDisplayItemDataForManager(nsIFrame* aFrame,
|
|
|
|
uint32_t aDisplayItemKey,
|
2012-08-29 09:48:45 +04:00
|
|
|
LayerManagerData* aData);
|
2011-10-07 01:35:08 +04:00
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
|
|
|
* We store one of these for each display item associated with a
|
2014-09-26 21:06:08 +04:00
|
|
|
* PaintedLayer, in a hashtable that maps each PaintedLayer to an array
|
|
|
|
* of ClippedDisplayItems. (PaintedLayerItemsEntry is the hash entry
|
2010-07-16 01:07:51 +04:00
|
|
|
* for that hashtable.)
|
|
|
|
* These are only stored during the paint process, so that the
|
2014-09-26 21:06:08 +04:00
|
|
|
* DrawPaintedLayer callback can figure out which items to draw for the
|
|
|
|
* PaintedLayer.
|
2010-07-16 01:07:51 +04:00
|
|
|
*/
|
|
|
|
struct ClippedDisplayItem {
|
2015-10-23 00:00:16 +03:00
|
|
|
ClippedDisplayItem(nsDisplayItem* aItem, uint32_t aGeneration);
|
2012-08-29 09:47:15 +04:00
|
|
|
~ClippedDisplayItem();
|
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
nsDisplayItem* mItem;
|
2012-08-29 09:47:15 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the display item is being rendered as an inactive
|
|
|
|
* layer, then this stores the layer manager being
|
|
|
|
* used for the inactive transaction.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<LayerManager> mInactiveLayerManager;
|
2012-08-29 09:47:15 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mContainerLayerGeneration;
|
2014-07-23 10:03:24 +04:00
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
};
|
|
|
|
|
2013-11-06 23:10:49 +04:00
|
|
|
static void RecomputeVisibilityForItems(nsTArray<ClippedDisplayItem>& aItems,
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsIntRegion& aRegionToDraw,
|
|
|
|
const nsIntPoint& aOffset,
|
|
|
|
int32_t aAppUnitsPerDevPixel,
|
|
|
|
float aXScale,
|
|
|
|
float aYScale);
|
|
|
|
|
|
|
|
void PaintItems(nsTArray<ClippedDisplayItem>& aItems,
|
2013-11-06 23:10:50 +04:00
|
|
|
const nsIntRect& aRect,
|
2013-11-06 23:10:49 +04:00
|
|
|
gfxContext* aContext,
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsPresContext* aPresContext,
|
2013-11-06 23:10:50 +04:00
|
|
|
const nsIntPoint& aOffset,
|
|
|
|
float aXScale, float aYScale,
|
2013-11-06 23:10:49 +04:00
|
|
|
int32_t aCommonClipCount);
|
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
|
|
|
* We accumulate ClippedDisplayItem elements in a hashtable during
|
|
|
|
* the paint process. This is the hashentry for that hashtable.
|
|
|
|
*/
|
2012-02-08 02:27:44 +04:00
|
|
|
public:
|
2014-09-26 21:06:08 +04:00
|
|
|
class PaintedLayerItemsEntry : public nsPtrHashKey<PaintedLayer> {
|
2010-07-16 01:07:51 +04:00
|
|
|
public:
|
2015-10-23 00:00:16 +03:00
|
|
|
explicit PaintedLayerItemsEntry(const PaintedLayer *key);
|
|
|
|
PaintedLayerItemsEntry(const PaintedLayerItemsEntry&);
|
|
|
|
~PaintedLayerItemsEntry();
|
2010-07-16 01:07:51 +04:00
|
|
|
|
|
|
|
nsTArray<ClippedDisplayItem> mItems;
|
|
|
|
nsIFrame* mContainerLayerFrame;
|
2014-09-26 21:06:08 +04:00
|
|
|
// The translation set on this PaintedLayer before we started updating the
|
2011-05-17 03:05:56 +04:00
|
|
|
// layer tree.
|
2011-05-18 09:48:43 +04:00
|
|
|
nsIntPoint mLastPaintOffset;
|
2014-07-23 10:03:52 +04:00
|
|
|
uint32_t mLastCommonClipCount;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mContainerLayerGeneration;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHasExplicitLastPaintOffset;
|
2012-02-08 02:27:44 +04:00
|
|
|
/**
|
|
|
|
* The first mCommonClipCount rounded rectangle clips are identical for
|
2014-09-26 21:06:08 +04:00
|
|
|
* all items in the layer. Computed in PaintedLayerData.
|
2012-02-08 02:27:44 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mCommonClipCount;
|
2010-07-16 01:07:51 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
enum { ALLOW_MEMMOVE = true };
|
2010-07-16 01:07:51 +04:00
|
|
|
};
|
|
|
|
|
2012-02-08 02:27:44 +04:00
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* Get the PaintedLayerItemsEntry object associated with aLayer in this
|
2012-02-08 02:27:44 +04:00
|
|
|
* FrameLayerBuilder
|
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayerItemsEntry* GetPaintedLayerItemsEntry(PaintedLayer* aLayer)
|
2012-02-08 02:27:44 +04:00
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
return mPaintedLayerItems.GetEntry(aLayer);
|
2012-02-08 02:27:44 +04:00
|
|
|
}
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayerData* GetContainingPaintedLayerData()
|
2013-12-16 16:16:24 +04:00
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
return mContainingPaintedLayer;
|
2013-12-16 16:16:24 +04:00
|
|
|
}
|
|
|
|
|
2017-04-29 03:32:05 +03:00
|
|
|
const DisplayItemClip* GetInactiveLayerClip() const
|
|
|
|
{
|
|
|
|
return mInactiveLayerClip;
|
|
|
|
}
|
|
|
|
|
2014-06-23 08:24:00 +04:00
|
|
|
bool IsBuildingRetainedLayers()
|
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
return !mContainingPaintedLayer && mRetainingManager;
|
2014-06-23 08:24:00 +04:00
|
|
|
}
|
|
|
|
|
2014-01-30 09:41:17 +04:00
|
|
|
/**
|
|
|
|
* Attempt to build the most compressed layer tree possible, even if it means
|
|
|
|
* throwing away existing retained buffers.
|
|
|
|
*/
|
|
|
|
void SetLayerTreeCompressionMode() { mInLayerTreeCompressionMode = true; }
|
|
|
|
bool CheckInLayerTreeCompressionMode();
|
|
|
|
|
2014-07-23 10:03:24 +04:00
|
|
|
void ComputeGeometryChangeForItem(DisplayItemData* aData);
|
|
|
|
|
2012-02-08 02:27:44 +04:00
|
|
|
protected:
|
2010-09-17 23:09:08 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CheckDOMModified();
|
2010-09-17 23:09:08 +04:00
|
|
|
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
|
|
|
* The layer manager belonging to the widget that is being retained
|
|
|
|
* across paints.
|
|
|
|
*/
|
|
|
|
LayerManager* mRetainingManager;
|
2010-09-17 23:09:08 +04:00
|
|
|
/**
|
|
|
|
* The root prescontext for the display list builder reference frame
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsRootPresContext> mRootPresContext;
|
2012-08-29 09:47:15 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The display list builder being used.
|
|
|
|
*/
|
|
|
|
nsDisplayListBuilder* mDisplayListBuilder;
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
2014-09-26 21:06:08 +04:00
|
|
|
* A map from PaintedLayers to the list of display items (plus
|
2010-07-16 01:07:51 +04:00
|
|
|
* clipping data) to be rendered in the layer.
|
|
|
|
*/
|
2014-09-26 21:06:08 +04:00
|
|
|
nsTHashtable<PaintedLayerItemsEntry> mPaintedLayerItems;
|
2013-12-16 16:16:24 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When building layers for an inactive layer, this is where the
|
|
|
|
* inactive layer will be placed.
|
|
|
|
*/
|
2015-01-20 17:49:30 +03:00
|
|
|
PaintedLayerData* mContainingPaintedLayer;
|
|
|
|
|
2017-04-29 03:32:05 +03:00
|
|
|
/**
|
|
|
|
* When building layers for an inactive layer, this stores the clip
|
|
|
|
* of the display item that built the inactive layer.
|
|
|
|
*/
|
|
|
|
const DisplayItemClip* mInactiveLayerClip;
|
|
|
|
|
2010-09-17 23:09:08 +04:00
|
|
|
/**
|
|
|
|
* Saved generation counter so we can detect DOM changes.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mInitialDOMGeneration;
|
2010-09-17 23:09:08 +04:00
|
|
|
/**
|
|
|
|
* Set to true if we have detected and reported DOM modification during
|
|
|
|
* the current paint.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDetectedDOMModification;
|
2010-07-16 01:07:51 +04:00
|
|
|
/**
|
|
|
|
* Indicates that the entire layer tree should be rerendered
|
|
|
|
* during this paint.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInvalidateAllLayers;
|
2012-07-23 07:00:36 +04:00
|
|
|
|
2014-01-30 09:41:17 +04:00
|
|
|
bool mInLayerTreeCompressionMode;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mContainerLayerGeneration;
|
|
|
|
uint32_t mMaxContainerLayerGeneration;
|
2010-05-21 07:20:48 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2010-05-21 07:20:48 +04:00
|
|
|
|
|
|
|
#endif /* FRAMELAYERBUILDER_H_ */
|