Bug 1687263: part 4) Defer and in some cases avoid removing spellchecking-ranges...
[gecko.git] / layout / painting / FrameLayerBuilder.h
blob99bdfc0720b9400987c8b738ddefca432838c142
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef FRAMELAYERBUILDER_H_
8 #define FRAMELAYERBUILDER_H_
10 #include <cstddef> // for size_t
11 #include <cstdint> // for uint32_t, UINT32_MAX, int32_t, uint64_t, uint8_t
12 #include <iosfwd> // for stringstream
13 #include <vector> // for vector
14 #include "DisplayItemClip.h" // for DisplayItemClip
15 #include "LayerState.h" // for LayerState
16 #include "LayerUserData.h" // for LayerUserData
17 #include "Units.h" // for LayerIntPoint, LayoutDeviceToLayerScale2D
18 #include "gfxPoint.h" // for gfxSize
19 #include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
20 #include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT_HELPER2
21 #include "mozilla/FunctionRef.h" // for FunctionRef
22 #include "mozilla/RefPtr.h" // for RefPtr
23 #include "mozilla/UniquePtr.h" // for UniquePtr
24 #include "mozilla/gfx/Matrix.h" // for Matrix, Matrix4x4
25 #include "mozilla/gfx/Point.h" // for Size
26 #include "mozilla/layers/LayerManager.h" // for LayerManager, LayerManager::NONE, LayerManager::PaintedLayerCreationHint, LayerMetricsW...
27 #include "mozilla/layers/LayersTypes.h" // for DrawRegionClip, EventRegions
28 #include "nsColor.h" // for NS_RGBA, nscolor
29 #include "nsDebug.h" // for NS_WARNING
30 #include "nsDisplayItemTypes.h" // for DisplayItemType
31 #include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING, NS_LOG_ADDREF, NS_LOG_RELEASE
32 #include "nsPoint.h" // for nsIntPoint
33 #include "nsRect.h" // for nsRect (ptr only), nsIntRect
34 #include "nsRegion.h" // for nsIntRegion, nsRegion
35 #include "nsTArray.h" // for AutoTArray, nsTArray_Impl
36 #include "nscore.h" // for nsrefcnt
38 class gfxContext;
39 class nsDisplayItem;
40 class nsDisplayItemGeometry;
41 class nsDisplayList;
42 class nsDisplayListBuilder;
43 class nsDisplayMasksAndClipPaths;
44 class nsIFrame;
45 class nsPaintedDisplayItem;
46 class nsPresContext;
47 class nsRootPresContext;
49 namespace mozilla {
50 struct ActiveScrolledRoot;
51 struct DisplayItemClipChain;
52 class TransformClipNode;
53 template <class T>
54 class Maybe;
55 template <typename T>
56 class SmallPointerArray;
58 namespace layers {
59 class ContainerLayer;
60 class Layer;
61 class BasicLayerManager;
62 class PaintedLayer;
63 class ImageLayer;
64 struct LayerProperties;
65 } // namespace layers
67 class FrameLayerBuilder;
68 class LayerManagerData;
69 class PaintedLayerData;
70 class ContainerState;
71 class PaintedDisplayItemLayerUserData;
73 enum class DisplayItemEntryType : uint8_t {
74 Item,
75 PushOpacity,
76 PushOpacityWithBg,
77 PopOpacity,
78 PushTransform,
79 PopTransform,
82 /**
83 * Retained data storage:
85 * Each layer manager (widget, and inactive) stores a LayerManagerData object
86 * that keeps a hash-set of DisplayItemData items that were drawn into it.
87 * Each frame also keeps a list of DisplayItemData pointers that were
88 * created for that frame. DisplayItemData objects manage these lists
89 * automatically.
91 * During layer construction we update the data in the LayerManagerData object,
92 * marking items that are modified. At the end we sweep the LayerManagerData
93 * hash-set and remove all items that haven't been modified.
96 /**
97 * Retained data for a display item.
99 class DisplayItemData final {
100 public:
101 friend class FrameLayerBuilder;
102 friend class ContainerState;
104 uint32_t GetDisplayItemKey() { return mDisplayItemKey; }
105 layers::Layer* GetLayer() const { return mLayer; }
106 nsDisplayItemGeometry* GetGeometry() const { return mGeometry.get(); }
107 const DisplayItemClip& GetClip() const { return mClip; }
108 void Invalidate() { mIsInvalid = true; }
109 void NotifyRemoved();
110 nsIFrame* FirstFrame() const { return mFrameList[0]; }
111 layers::BasicLayerManager* InactiveManager() const {
112 return mInactiveManager;
115 bool HasMergedFrames() const { return mFrameList.Length() > 1; }
117 static DisplayItemData* AssertDisplayItemData(DisplayItemData* aData);
119 void* operator new(size_t sz, nsPresContext* aPresContext);
121 nsrefcnt AddRef() {
122 if (mRefCnt == UINT32_MAX) {
123 NS_WARNING("refcount overflow, leaking object");
124 return mRefCnt;
126 ++mRefCnt;
127 NS_LOG_ADDREF(this, mRefCnt, "DisplayItemData", sizeof(DisplayItemData));
128 return mRefCnt;
131 nsrefcnt Release() {
132 if (mRefCnt == UINT32_MAX) {
133 NS_WARNING("refcount overflow, leaking object");
134 return mRefCnt;
136 --mRefCnt;
137 NS_LOG_RELEASE(this, mRefCnt, "DisplayItemData");
138 if (mRefCnt == 0) {
139 Destroy();
140 return 0;
142 return mRefCnt;
145 RefPtr<TransformClipNode> mTransform;
146 RefPtr<TransformClipNode> mOldTransform;
148 private:
149 DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
150 layers::Layer* aLayer, nsIFrame* aFrame = nullptr);
153 * Removes any references to this object from frames
154 * in mFrameList.
156 ~DisplayItemData();
158 void Destroy();
161 * Associates this DisplayItemData with a frame, and adds it
162 * to the LayerManagerDataProperty list on the frame.
164 void AddFrame(nsIFrame* aFrame);
165 void RemoveFrame(nsIFrame* aFrame);
166 const nsRegion& GetChangedFrameInvalidations();
169 * Updates the contents of this item to a new set of data, instead of
170 * allocating a new object. Set the passed in parameters, and clears the opt
171 * layer and inactive manager. Parent, and display item key are assumed to be
172 * the same.
174 * EndUpdate must be called before the end of the transaction to complete the
175 * update.
177 void BeginUpdate(layers::Layer* aLayer, LayerState aState, bool aFirstUpdate,
178 nsPaintedDisplayItem* aItem = nullptr);
179 void BeginUpdate(layers::Layer* aLayer, LayerState aState,
180 nsPaintedDisplayItem* aItem, bool aIsReused, bool aIsMerged);
183 * Completes the update of this, and removes any references to data that won't
184 * live longer than the transaction.
186 * Updates the geometry, frame list and clip.
187 * For items within a PaintedLayer, a geometry object must be specified to
188 * retain until the next transaction.
191 void EndUpdate(mozilla::UniquePtr<nsDisplayItemGeometry>&& aGeometry);
192 void EndUpdate();
194 uint32_t mRefCnt;
195 LayerManagerData* mParent;
196 RefPtr<layers::Layer> mLayer;
197 RefPtr<layers::Layer> mOptLayer;
198 RefPtr<layers::BasicLayerManager> mInactiveManager;
199 AutoTArray<nsIFrame*, 1> mFrameList;
200 mozilla::UniquePtr<nsDisplayItemGeometry> mGeometry;
201 DisplayItemClip mClip;
202 uint32_t mDisplayItemKey;
203 LayerState mLayerState;
206 * Temporary stoarage of the display item being referenced, only valid between
207 * BeginUpdate and EndUpdate.
209 nsPaintedDisplayItem* mItem;
210 nsRegion mChangedFrameInvalidations;
213 * Used to track if data currently stored in mFramesWithLayers (from an
214 * existing paint) has been updated in the current paint.
216 bool mUsed;
217 bool mIsInvalid;
218 bool mReusedItem;
221 class RefCountedRegion {
222 private:
223 ~RefCountedRegion() = default;
225 public:
226 NS_INLINE_DECL_REFCOUNTING(RefCountedRegion)
228 RefCountedRegion() : mIsInfinite(false) {}
229 nsRegion mRegion;
230 bool mIsInfinite;
233 struct AssignedDisplayItem;
235 struct ContainerLayerParameters {
236 ContainerLayerParameters()
237 : mXScale(1),
238 mYScale(1),
239 mLayerContentsVisibleRect(nullptr),
240 mBackgroundColor(NS_RGBA(0, 0, 0, 0)),
241 mScrollMetadataASR(nullptr),
242 mCompositorASR(nullptr),
243 mInTransformedSubtree(false),
244 mInActiveTransformedSubtree(false),
245 mDisableSubpixelAntialiasingInDescendants(false),
246 mLayerCreationHint(layers::LayerManager::NONE) {}
247 ContainerLayerParameters(float aXScale, float aYScale)
248 : mXScale(aXScale),
249 mYScale(aYScale),
250 mLayerContentsVisibleRect(nullptr),
251 mItemVisibleRect(nullptr),
252 mBackgroundColor(NS_RGBA(0, 0, 0, 0)),
253 mScrollMetadataASR(nullptr),
254 mCompositorASR(nullptr),
255 mInTransformedSubtree(false),
256 mInActiveTransformedSubtree(false),
257 mDisableSubpixelAntialiasingInDescendants(false),
258 mLayerCreationHint(layers::LayerManager::NONE) {}
259 ContainerLayerParameters(float aXScale, float aYScale,
260 const nsIntPoint& aOffset,
261 const ContainerLayerParameters& aParent)
262 : mXScale(aXScale),
263 mYScale(aYScale),
264 mLayerContentsVisibleRect(nullptr),
265 mItemVisibleRect(nullptr),
266 mOffset(aOffset),
267 mBackgroundColor(aParent.mBackgroundColor),
268 mScrollMetadataASR(aParent.mScrollMetadataASR),
269 mCompositorASR(aParent.mCompositorASR),
270 mInTransformedSubtree(aParent.mInTransformedSubtree),
271 mInActiveTransformedSubtree(aParent.mInActiveTransformedSubtree),
272 mDisableSubpixelAntialiasingInDescendants(
273 aParent.mDisableSubpixelAntialiasingInDescendants),
274 mLayerCreationHint(aParent.mLayerCreationHint) {}
276 float mXScale, mYScale;
278 LayoutDeviceToLayerScale2D Scale() const {
279 return LayoutDeviceToLayerScale2D(mXScale, mYScale);
283 * If non-null, the rectangle in which BuildContainerLayerFor stores the
284 * visible rect of the layer, in the coordinate system of the created layer.
286 nsIntRect* mLayerContentsVisibleRect;
289 * If non-null, the rectangle which stores the item's visible rect.
291 nsRect* mItemVisibleRect;
294 * An offset to apply to all child layers created.
296 nsIntPoint mOffset;
298 LayerIntPoint Offset() const {
299 return LayerIntPoint::FromUnknownPoint(mOffset);
302 nscolor mBackgroundColor;
303 const ActiveScrolledRoot* mScrollMetadataASR;
304 const ActiveScrolledRoot* mCompositorASR;
306 bool mInTransformedSubtree;
307 bool mInActiveTransformedSubtree;
308 bool mDisableSubpixelAntialiasingInDescendants;
309 layers::LayerManager::PaintedLayerCreationHint mLayerCreationHint;
312 * When this is false, PaintedLayer coordinates are drawn to with an integer
313 * translation and the scale in mXScale/mYScale.
315 bool AllowResidualTranslation() {
316 // If we're in a transformed subtree, but no ancestor transform is actively
317 // changing, we'll use the residual translation when drawing into the
318 // PaintedLayer to ensure that snapping exactly matches the ideal transform.
319 return mInTransformedSubtree && !mInActiveTransformedSubtree;
324 * The FrameLayerBuilder is responsible for converting display lists
325 * into layer trees. Every LayerManager needs a unique FrameLayerBuilder
326 * to build layers.
328 * The most important API in this class is BuildContainerLayerFor. This
329 * method takes a display list as input and constructs a ContainerLayer
330 * with child layers that render the contents of the display list. It
331 * records the relationship between frames and layers.
333 * That data enables us to retain layer trees. When constructing a
334 * ContainerLayer, we first check to see if there's an existing
335 * ContainerLayer for the same frame that can be recycled. If we recycle
336 * it, we also try to reuse its existing PaintedLayer children to render
337 * the display items without layers of their own. The idea is that by
338 * recycling layers deterministically, we can ensure that when nothing
339 * changes in a display list, we will reuse the existing layers without
340 * changes.
342 * We expose a GetLeafLayerFor method that can be called by display items
343 * that make their own layers (e.g. canvas and video); this method
344 * locates the last layer used to render the display item, if any, and
345 * return it as a candidate for recycling.
347 * FrameLayerBuilder sets up PaintedLayers so that 0,0 in the Painted layer
348 * corresponds to the (pixel-snapped) top-left of the aAnimatedGeometryRoot.
349 * It sets up ContainerLayers so that 0,0 in the container layer
350 * corresponds to the snapped top-left of the display item reference frame.
352 * When we construct a container layer, we know the transform that will be
353 * applied to the layer. If the transform scales the content, we can get
354 * better results when intermediate buffers are used by pushing some scale
355 * from the container's transform down to the children. For PaintedLayer
356 * children, the scaling can be achieved by changing the size of the layer
357 * and drawing into it with increased or decreased resolution. By convention,
358 * integer types (nsIntPoint/nsIntSize/nsIntRect/nsIntRegion) are all in layer
359 * coordinates, post-scaling, whereas appunit types are all pre-scaling.
361 class FrameLayerBuilder : public layers::LayerUserData {
362 public:
363 typedef layers::ContainerLayer ContainerLayer;
364 typedef layers::Layer Layer;
365 typedef layers::PaintedLayer PaintedLayer;
366 typedef layers::ImageLayer ImageLayer;
367 typedef layers::LayerManager LayerManager;
368 typedef layers::BasicLayerManager BasicLayerManager;
369 typedef layers::EventRegions EventRegions;
371 FrameLayerBuilder();
372 ~FrameLayerBuilder() override;
374 static gfx::Size ChooseScale(nsIFrame* aContainerFrame,
375 nsDisplayItem* aContainerItem,
376 const nsRect& aVisibleRect, float aXScale,
377 float aYScale, const gfx::Matrix& aTransform2d,
378 bool aCanDraw2D);
380 static void Shutdown();
382 void Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
383 PaintedLayerData* aLayerData = nullptr,
384 bool aIsInactiveLayerManager = false,
385 const DisplayItemClip* aInactiveLayerClip = nullptr);
388 * Call this to notify that we have just started a transaction on the
389 * retained layer manager aManager.
391 void DidBeginRetainedLayerTransaction(LayerManager* aManager);
394 * Call this just before we end a transaction.
396 void WillEndTransaction();
399 * Call this after we end a transaction.
401 void DidEndTransaction();
403 enum {
405 * Set this when pulling an opaque background color from behind the
406 * container layer into the container doesn't change the visual results,
407 * given the effects you're going to apply to the container layer.
408 * For example, this is compatible with opacity or clipping/masking, but
409 * not with non-OVER blend modes or filters.
411 CONTAINER_ALLOW_PULL_BACKGROUND_COLOR = 0x01
414 * Build a container layer for a display item that contains a child
415 * list, either reusing an existing one or creating a new one. It
416 * sets the container layer children to layers which together render
417 * the contents of the display list. It reuses existing layers from
418 * the retained layer manager if possible.
419 * aContainerItem may be null, in which case we construct a root layer.
420 * This gets called by display list code. It calls BuildLayer on the
421 * items in the display list, making items with their own layers
422 * children of the new container, and assigning all other items to
423 * PaintedLayer children created and managed by the FrameLayerBuilder.
424 * Returns a layer with clip rect cleared; it is the
425 * caller's responsibility to add any clip rect. The visible region
426 * is set based on what's in the layer.
427 * The container layer is transformed by aTransform (if non-null), and
428 * the result is transformed by the scale factors in aContainerParameters.
429 * aChildren is modified due to display item merging and flattening.
430 * The visible region of the returned layer is set only if aContainerItem
431 * is null.
433 already_AddRefed<ContainerLayer> BuildContainerLayerFor(
434 nsDisplayListBuilder* aBuilder, LayerManager* aManager,
435 nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
436 nsDisplayList* aChildren,
437 const ContainerLayerParameters& aContainerParameters,
438 const gfx::Matrix4x4* aTransform, uint32_t aFlags = 0);
441 * Get a retained layer for a display item that needs to create its own
442 * layer for rendering (i.e. under nsDisplayItem::BuildLayer). Returns
443 * null if no retained layer is available, which usually means that this
444 * display item didn't have a layer before so the caller will
445 * need to create one.
446 * Returns a layer with clip rect cleared; it is the
447 * caller's responsibility to add any clip rect and set the visible
448 * region.
450 Layer* GetLeafLayerFor(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
453 * Call this to force all retained layers to be discarded and recreated at
454 * the next paint.
456 static void InvalidateAllLayers(LayerManager* aManager);
457 static void InvalidateAllLayersForFrame(nsIFrame* aFrame);
460 * Call this to determine if a frame has a dedicated (non-Painted) layer
461 * for the given display item key. If there isn't one, we return null,
462 * otherwise we return the layer.
464 static Layer* GetDedicatedLayer(nsIFrame* aFrame,
465 DisplayItemType aDisplayItemType);
467 using AnimationGenerationCallback = FunctionRef<bool(
468 const Maybe<uint64_t>& aGeneration, DisplayItemType aDisplayItemType)>;
470 * Enumerates layers for the all display item types that correspond to
471 * properties we can animate on layers and calls |aCallback|
472 * with the animation generation for the layer. If there is no corresponding
473 * layer for the display item or the layer has no animation, the animation
474 * generation is Nothing().
476 * The enumeration stops if |aCallback| returns false.
478 static void EnumerateGenerationForDedicatedLayers(
479 const nsIFrame* aFrame, AnimationGenerationCallback);
482 * This callback must be provided to EndTransaction. The callback data
483 * must be the nsDisplayListBuilder containing this FrameLayerBuilder.
484 * This function can be called multiple times in a row to draw
485 * different regions. This will occur when, for example, progressive paint is
486 * enabled. In these cases aDirtyRegion can be used to specify a larger region
487 * than aRegionToDraw that will be drawn during the transaction, possibly
488 * allowing the callback to make optimizations.
490 static void DrawPaintedLayer(PaintedLayer* aLayer, gfxContext* aContext,
491 const nsIntRegion& aRegionToDraw,
492 const nsIntRegion& aDirtyRegion,
493 mozilla::layers::DrawRegionClip aClip,
494 const nsIntRegion& aRegionToInvalidate,
495 void* aCallbackData);
498 * Dumps this FrameLayerBuilder's retained layer manager's retained
499 * layer tree. Defaults to dumping to stdout in non-HTML format.
501 static void DumpRetainedLayerTree(LayerManager* aManager,
502 std::stringstream& aStream,
503 bool aDumpHtml = false);
506 * Returns the most recently allocated geometry item for the given display
507 * item.
509 * XXX(seth): The current implementation must iterate through all display
510 * items allocated for this display item's frame. This may lead to O(n^2)
511 * behavior in some situations.
513 static nsDisplayItemGeometry* GetMostRecentGeometry(nsDisplayItem* aItem);
515 /******* PRIVATE METHODS to FrameLayerBuilder.cpp ********/
516 /* These are only in the public section because they need
517 * to be called by file-scope helper functions in FrameLayerBuilder.cpp.
521 * Record aItem as a display item that is rendered by the PaintedLayer
522 * aLayer, with aClipRect, where aContainerLayerFrame is the frame
523 * for the container layer this ThebesItem belongs to.
524 * aItem must have an underlying frame.
525 * @param aTopLeft offset from active scrolled root to reference frame
527 void AddPaintedDisplayItem(PaintedLayerData* aLayerData,
528 AssignedDisplayItem& aAssignedDisplayItem,
529 Layer* aLayer);
532 * Calls GetOldLayerForFrame on the underlying frame of the display item,
533 * and each subsequent merged frame if no layer is found for the underlying
534 * frame.
536 Layer* GetOldLayerFor(nsDisplayItem* aItem,
537 nsDisplayItemGeometry** aOldGeometry = nullptr,
538 DisplayItemClip** aOldClip = nullptr);
540 static DisplayItemData* GetOldDataFor(nsDisplayItem* aItem);
543 * Destroy any stored LayerManagerDataProperty and the associated data for
544 * aFrame.
546 static void DestroyDisplayItemDataFor(nsIFrame* aFrame);
548 LayerManager* GetRetainingLayerManager() { return mRetainingManager; }
551 * Returns true if the given display item was rendered during the previous
552 * paint. Returns false otherwise.
554 static bool HasRetainedDataFor(const nsIFrame* aFrame,
555 uint32_t aDisplayItemKey);
558 * Return the resolution at which we expect to render aFrame's contents,
559 * assuming they are being painted to retained layers. This takes into account
560 * the resolution the contents of the ContainerLayer containing aFrame are
561 * being rendered at, as well as any currently-inactive transforms between
562 * aFrame and that container layer.
564 static gfxSize GetPaintedLayerScaleForFrame(nsIFrame* aFrame);
566 static void RemoveFrameFromLayerManager(nsIFrame* aFrame);
569 * Given a frame and a display item key that uniquely identifies a
570 * display item for the frame, find the layer that was last used to
571 * render that display item. Returns null if there is no such layer.
572 * This could be a dedicated layer for the display item, or a PaintedLayer
573 * that renders many display items.
575 DisplayItemData* GetOldLayerForFrame(
576 nsIFrame* aFrame, uint32_t aDisplayItemKey,
577 DisplayItemData* aOldData = nullptr,
578 LayerManager* aOldLayerManager = nullptr);
581 * Stores DisplayItemData associated with aFrame, stores the data in
582 * mNewDisplayItemData.
584 DisplayItemData* StoreDataForFrame(nsPaintedDisplayItem* aItem, Layer* aLayer,
585 LayerState aState, DisplayItemData* aData);
586 void StoreDataForFrame(nsIFrame* aFrame, uint32_t aDisplayItemKey,
587 Layer* aLayer, LayerState aState);
589 protected:
590 friend class LayerManagerData;
592 // Flash the area within the context clip if paint flashing is enabled.
593 static void FlashPaint(gfxContext* aContext);
596 * Get the DisplayItemData array associated with this frame, or null if one
597 * doesn't exist.
599 * Note that the pointer returned here is only valid so long as you don't
600 * poke the LayerManagerData's mFramesWithLayers hashtable.
602 DisplayItemData* GetDisplayItemData(nsIFrame* aFrame, uint32_t aKey);
605 * Get the DisplayItemData associated with this display item,
606 * using the LayerManager instead of FrameLayerBuilder.
608 static DisplayItemData* GetDisplayItemDataForManager(
609 nsPaintedDisplayItem* aItem, LayerManager* aManager);
612 * We store one of these for each display item associated with a
613 * PaintedLayer, in a hashtable that maps each PaintedLayer to an array
614 * of ClippedDisplayItems. (PaintedLayerItemsEntry is the hash entry
615 * for that hashtable.)
616 * These are only stored during the paint process, so that the
617 * DrawPaintedLayer callback can figure out which items to draw for the
618 * PaintedLayer.
621 static void RecomputeVisibilityForItems(
622 std::vector<AssignedDisplayItem>& aItems, nsDisplayListBuilder* aBuilder,
623 const nsIntRegion& aRegionToDraw, nsRect& aPreviousRectToDraw,
624 const nsIntPoint& aOffset, int32_t aAppUnitsPerDevPixel, float aXScale,
625 float aYScale);
627 void PaintItems(std::vector<AssignedDisplayItem>& aItems,
628 const nsIntRect& aRect, gfxContext* aContext,
629 nsDisplayListBuilder* aBuilder, nsPresContext* aPresContext,
630 const nsIntPoint& aOffset, float aXScale, float aYScale);
633 * We accumulate ClippedDisplayItem elements in a hashtable during
634 * the paint process. This is the hashentry for that hashtable.
636 public:
638 * Add the PaintedDisplayItemLayerUserData object as being used in this
639 * transaction so that we do some end-of-paint maintenance on it.
641 void AddPaintedLayerItemsEntry(PaintedDisplayItemLayerUserData* aData);
643 PaintedLayerData* GetContainingPaintedLayerData() {
644 return mContainingPaintedLayer;
647 const DisplayItemClip* GetInactiveLayerClip() const {
648 return mInactiveLayerClip;
652 * If we're building layers for an item with an inactive layer tree,
653 * this function saves the item's clip, which will later be applied
654 * to the event regions. The clip should be relative to
655 * mContainingPaintedLayer->mReferenceFrame.
657 void SetInactiveLayerClip(const DisplayItemClip* aClip) {
658 mInactiveLayerClip = aClip;
661 bool IsBuildingRetainedLayers() {
662 return !mIsInactiveLayerManager && mRetainingManager;
666 * Attempt to build the most compressed layer tree possible, even if it means
667 * throwing away existing retained buffers.
669 void SetLayerTreeCompressionMode() { mInLayerTreeCompressionMode = true; }
670 bool CheckInLayerTreeCompressionMode();
672 void ComputeGeometryChangeForItem(DisplayItemData* aData);
674 // Defined and used only in dom/base/nsDOMWindowUtils.cpp
675 template <class T>
676 static T* GetDebugSingleOldLayerForFrame(nsIFrame* aFrame);
678 protected:
680 * The layer manager belonging to the widget that is being retained
681 * across paints.
683 LayerManager* mRetainingManager;
685 * The root prescontext for the display list builder reference frame
687 RefPtr<nsRootPresContext> mRootPresContext;
690 * The display list builder being used.
692 nsDisplayListBuilder* mDisplayListBuilder;
694 * An array of PaintedLayer user data objects containing the
695 * list of display items (plus clipping data) to be rendered in the
696 * layer. We clean these up at the end of the transaction to
697 * remove references to display items.
699 AutoTArray<RefPtr<PaintedDisplayItemLayerUserData>, 5> mPaintedLayerItems;
702 * When building layers for an inactive layer, this is where the
703 * inactive layer will be placed.
705 PaintedLayerData* mContainingPaintedLayer;
708 * When building layers for an inactive layer, this stores the clip
709 * of the display item that built the inactive layer.
711 const DisplayItemClip* mInactiveLayerClip;
714 * Indicates that the entire layer tree should be rerendered
715 * during this paint.
717 bool mInvalidateAllLayers;
719 bool mInLayerTreeCompressionMode;
721 bool mIsInactiveLayerManager;
724 } // namespace mozilla
726 #endif /* FRAMELAYERBUILDER_H_ */