mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1676357 - Avoid including Layers.h in header files. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D96538 Depends on D96537
This commit is contained in:
parent
02262049f0
commit
73d4d57082
@ -178,6 +178,37 @@ class OldWindowSize : public LinkedListElement<OldWindowSize> {
|
||||
nsSize mSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
template <class T>
|
||||
T* mozilla::FrameLayerBuilder::GetDebugSingleOldLayerForFrame(
|
||||
nsIFrame* aFrame) {
|
||||
SmallPointerArray<DisplayItemData>& array = aFrame->DisplayItemData();
|
||||
|
||||
Layer* layer = nullptr;
|
||||
for (DisplayItemData* data : array) {
|
||||
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);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class NativeInputRunnable final : public PrioritizableRunnable {
|
||||
|
@ -75,6 +75,8 @@
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/CanvasGradient.h"
|
||||
#include "mozilla/dom/CanvasPattern.h"
|
||||
#include "mozilla/dom/DOMMatrix.h"
|
||||
#include "mozilla/dom/ImageBitmap.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
@ -912,6 +914,25 @@ CanvasRenderingContext2D::ContextState::ContextState(const ContextState& aOther)
|
||||
|
||||
CanvasRenderingContext2D::ContextState::~ContextState() = default;
|
||||
|
||||
void CanvasRenderingContext2D::ContextState::SetColorStyle(Style aWhichStyle,
|
||||
nscolor aColor) {
|
||||
colorStyles[aWhichStyle] = aColor;
|
||||
gradientStyles[aWhichStyle] = nullptr;
|
||||
patternStyles[aWhichStyle] = nullptr;
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::ContextState::SetPatternStyle(
|
||||
Style aWhichStyle, CanvasPattern* aPat) {
|
||||
gradientStyles[aWhichStyle] = nullptr;
|
||||
patternStyles[aWhichStyle] = aPat;
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::ContextState::SetGradientStyle(
|
||||
Style aWhichStyle, CanvasGradient* aGrad) {
|
||||
gradientStyles[aWhichStyle] = aGrad;
|
||||
patternStyles[aWhichStyle] = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
** CanvasRenderingContext2D impl
|
||||
**/
|
||||
|
@ -7,11 +7,8 @@
|
||||
|
||||
#include <vector>
|
||||
#include "mozilla/dom/BasicRenderingContext2D.h"
|
||||
#include "mozilla/dom/CanvasGradient.h"
|
||||
#include "mozilla/dom/CanvasPattern.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
@ -19,11 +16,9 @@
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/SurfaceFromElementResult.h"
|
||||
#include "mozilla/SVGObserverUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "FilterDescription.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "Layers.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
#include "nsBidi.h"
|
||||
#include "nsColor.h"
|
||||
@ -39,6 +34,11 @@ namespace gl {
|
||||
class SourceSurface;
|
||||
} // namespace gl
|
||||
|
||||
namespace layers {
|
||||
class PersistentBufferProvider;
|
||||
enum class LayersBackend : int8_t;
|
||||
} // namespace layers
|
||||
|
||||
namespace dom {
|
||||
class
|
||||
HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap;
|
||||
@ -49,7 +49,9 @@ class ImageData;
|
||||
class StringOrCanvasGradientOrCanvasPattern;
|
||||
class OwningStringOrCanvasGradientOrCanvasPattern;
|
||||
class TextMetrics;
|
||||
class CanvasGradient;
|
||||
class CanvasPath;
|
||||
class CanvasPattern;
|
||||
|
||||
extern const mozilla::gfx::Float SIGMA_MAX;
|
||||
|
||||
@ -898,21 +900,9 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
|
||||
ContextState(const ContextState& aOther);
|
||||
~ContextState();
|
||||
|
||||
void SetColorStyle(Style aWhichStyle, nscolor aColor) {
|
||||
colorStyles[aWhichStyle] = aColor;
|
||||
gradientStyles[aWhichStyle] = nullptr;
|
||||
patternStyles[aWhichStyle] = nullptr;
|
||||
}
|
||||
|
||||
void SetPatternStyle(Style aWhichStyle, CanvasPattern* aPat) {
|
||||
gradientStyles[aWhichStyle] = nullptr;
|
||||
patternStyles[aWhichStyle] = aPat;
|
||||
}
|
||||
|
||||
void SetGradientStyle(Style aWhichStyle, CanvasGradient* aGrad) {
|
||||
gradientStyles[aWhichStyle] = aGrad;
|
||||
patternStyles[aWhichStyle] = nullptr;
|
||||
}
|
||||
void SetColorStyle(Style aWhichStyle, nscolor aColor);
|
||||
void SetPatternStyle(Style aWhichStyle, CanvasPattern* aPat);
|
||||
void SetGradientStyle(Style aWhichStyle, CanvasGradient* aGrad);
|
||||
|
||||
/**
|
||||
* returns true iff the given style is a solid color.
|
||||
|
216
gfx/layers/LayerManager.cpp
Normal file
216
gfx/layers/LayerManager.cpp
Normal file
@ -0,0 +1,216 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/layers/LayerManager.h"
|
||||
|
||||
#include <stdint.h> // for uint64_t, uint8_t
|
||||
#include <stdlib.h> // for abort
|
||||
#include <algorithm> // for copy, copy_backward
|
||||
#include <utility> // for move, forward
|
||||
#include "FrameMetrics.h" // for FrameMetrics
|
||||
#include "ImageContainer.h" // for ImageContainer, ImageContainer::Mode
|
||||
#include "LayerUserData.h" // for LayerUserData
|
||||
#include "Layers.h" // for RecordCompositionPayloadsPresented, Layer
|
||||
#include "TreeTraversal.h" // for ForwardIterator, BreadthFirstSearch
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/ArrayIterator.h" // for ArrayIterator
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_ASSERT_HELPER1
|
||||
#include "mozilla/EffectSet.h" // for EffectSet
|
||||
#include "mozilla/Logging.h" // for LazyLogModule, LogModule (ptr only)
|
||||
#include "mozilla/RefPtr.h" // for RefPtr, getter_AddRefs, RefPtrGetterAddRefs
|
||||
#include "mozilla/StaticPrefs_layers.h" // for layers_componentalpha_enabled_AtStartup_DoNotUseDirectly
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr
|
||||
#include "mozilla/dom/Animation.h" // for Animation
|
||||
#include "mozilla/dom/AnimationEffect.h" // for AnimationEffect
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat, gfx
|
||||
#include "mozilla/gfx/UserData.h" // for UserData, UserDataKey (ptr only)
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "mozilla/layers/LayersTypes.h" // for CompositionPayload
|
||||
#include "mozilla/layers/PersistentBufferProvider.h" // for PersistentBufferProviderBasic, PersistentBufferProvider (ptr only)
|
||||
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid::NULL_SCROLL_ID, ScrollableLayerGu...
|
||||
#include "nsHashKeys.h" // for nsUint64HashKey
|
||||
#include "nsRefPtrHashtable.h" // for nsRefPtrHashtable
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
|
||||
uint8_t gLayerManagerLayerBuilder;
|
||||
|
||||
// Undo the damage done by mozzconf.h
|
||||
#undef compress
|
||||
#include "mozilla/Compression.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::Compression;
|
||||
|
||||
//--------------------------------------------------
|
||||
// LayerManager
|
||||
|
||||
LayerManager::LayerManager()
|
||||
: mDestroyed(false),
|
||||
mSnapEffectiveTransforms(true),
|
||||
mId(0),
|
||||
mInTransaction(false),
|
||||
mContainsSVG(false),
|
||||
mPaintedPixelCount(0) {}
|
||||
|
||||
LayerManager::~LayerManager() = default;
|
||||
|
||||
void LayerManager::Destroy() {
|
||||
mDestroyed = true;
|
||||
mUserData.Destroy();
|
||||
mRoot = nullptr;
|
||||
mPartialPrerenderedAnimations.Clear();
|
||||
}
|
||||
|
||||
/* static */ mozilla::LogModule* LayerManager::GetLog() {
|
||||
static LazyLogModule sLog("Layers");
|
||||
return sLog;
|
||||
}
|
||||
|
||||
ScrollableLayerGuid::ViewID LayerManager::GetRootScrollableLayerId() {
|
||||
if (!mRoot) {
|
||||
return ScrollableLayerGuid::NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
LayerMetricsWrapper layerMetricsRoot = LayerMetricsWrapper(mRoot);
|
||||
|
||||
LayerMetricsWrapper rootScrollableLayerMetrics =
|
||||
BreadthFirstSearch<ForwardIterator>(
|
||||
layerMetricsRoot, [](LayerMetricsWrapper aLayerMetrics) {
|
||||
return aLayerMetrics.Metrics().IsScrollable();
|
||||
});
|
||||
|
||||
return rootScrollableLayerMetrics.IsValid()
|
||||
? rootScrollableLayerMetrics.Metrics().GetScrollId()
|
||||
: ScrollableLayerGuid::NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
LayerMetricsWrapper LayerManager::GetRootContentLayer() {
|
||||
if (!mRoot) {
|
||||
return LayerMetricsWrapper();
|
||||
}
|
||||
|
||||
LayerMetricsWrapper root(mRoot);
|
||||
|
||||
return BreadthFirstSearch<ForwardIterator>(
|
||||
root, [](LayerMetricsWrapper aLayerMetrics) {
|
||||
return aLayerMetrics.Metrics().IsRootContent();
|
||||
});
|
||||
}
|
||||
|
||||
already_AddRefed<DrawTarget> LayerManager::CreateOptimalDrawTarget(
|
||||
const gfx::IntSize& aSize, SurfaceFormat aFormat) {
|
||||
return gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aSize,
|
||||
aFormat);
|
||||
}
|
||||
|
||||
already_AddRefed<DrawTarget> LayerManager::CreateOptimalMaskDrawTarget(
|
||||
const gfx::IntSize& aSize) {
|
||||
return CreateOptimalDrawTarget(aSize, SurfaceFormat::A8);
|
||||
}
|
||||
|
||||
already_AddRefed<DrawTarget> LayerManager::CreateDrawTarget(
|
||||
const IntSize& aSize, SurfaceFormat aFormat) {
|
||||
return gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(aSize,
|
||||
aFormat);
|
||||
}
|
||||
|
||||
already_AddRefed<PersistentBufferProvider>
|
||||
LayerManager::CreatePersistentBufferProvider(
|
||||
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat) {
|
||||
RefPtr<PersistentBufferProviderBasic> bufferProvider =
|
||||
PersistentBufferProviderBasic::Create(
|
||||
aSize, aFormat,
|
||||
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
|
||||
|
||||
if (!bufferProvider) {
|
||||
bufferProvider = PersistentBufferProviderBasic::Create(
|
||||
aSize, aFormat, gfxPlatform::GetPlatform()->GetFallbackCanvasBackend());
|
||||
}
|
||||
|
||||
return bufferProvider.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ImageContainer> LayerManager::CreateImageContainer(
|
||||
ImageContainer::Mode flag) {
|
||||
RefPtr<ImageContainer> container = new ImageContainer(flag);
|
||||
return container.forget();
|
||||
}
|
||||
|
||||
bool LayerManager::LayersComponentAlphaEnabled() {
|
||||
// If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off
|
||||
// and ignore the preference.
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
return false;
|
||||
#else
|
||||
return StaticPrefs::
|
||||
layers_componentalpha_enabled_AtStartup_DoNotUseDirectly();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool LayerManager::AreComponentAlphaLayersEnabled() {
|
||||
return LayerManager::LayersComponentAlphaEnabled();
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void LayerManager::LayerUserDataDestroy(void* data) {
|
||||
delete static_cast<LayerUserData*>(data);
|
||||
}
|
||||
|
||||
UniquePtr<LayerUserData> LayerManager::RemoveUserData(void* aKey) {
|
||||
UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(
|
||||
mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
||||
return d;
|
||||
}
|
||||
|
||||
void LayerManager::PayloadPresented() {
|
||||
RecordCompositionPayloadsPresented(mPayload);
|
||||
}
|
||||
|
||||
void LayerManager::AddPartialPrerenderedAnimation(
|
||||
uint64_t aCompositorAnimationId, dom::Animation* aAnimation) {
|
||||
mPartialPrerenderedAnimations.Put(aCompositorAnimationId, RefPtr{aAnimation});
|
||||
aAnimation->SetPartialPrerendered(aCompositorAnimationId);
|
||||
}
|
||||
|
||||
void LayerManager::RemovePartialPrerenderedAnimation(
|
||||
uint64_t aCompositorAnimationId, dom::Animation* aAnimation) {
|
||||
MOZ_ASSERT(aAnimation);
|
||||
#ifdef DEBUG
|
||||
RefPtr<dom::Animation> animation;
|
||||
if (mPartialPrerenderedAnimations.Remove(aCompositorAnimationId,
|
||||
getter_AddRefs(animation)) &&
|
||||
// It may be possible that either animation's effect has already been
|
||||
// nulled out via Animation::SetEffect() so ignore such cases.
|
||||
aAnimation->GetEffect() && aAnimation->GetEffect()->AsKeyframeEffect() &&
|
||||
animation->GetEffect() && animation->GetEffect()->AsKeyframeEffect()) {
|
||||
MOZ_ASSERT(EffectSet::GetEffectSetForEffect(
|
||||
aAnimation->GetEffect()->AsKeyframeEffect()) ==
|
||||
EffectSet::GetEffectSetForEffect(
|
||||
animation->GetEffect()->AsKeyframeEffect()));
|
||||
}
|
||||
#else
|
||||
mPartialPrerenderedAnimations.Remove(aCompositorAnimationId);
|
||||
#endif
|
||||
aAnimation->ResetPartialPrerendered();
|
||||
}
|
||||
|
||||
void LayerManager::UpdatePartialPrerenderedAnimations(
|
||||
const nsTArray<uint64_t>& aJankedAnimations) {
|
||||
for (uint64_t id : aJankedAnimations) {
|
||||
RefPtr<dom::Animation> animation;
|
||||
if (mPartialPrerenderedAnimations.Remove(id, getter_AddRefs(animation))) {
|
||||
animation->UpdatePartialPrerendered();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
788
gfx/layers/LayerManager.h
Normal file
788
gfx/layers/LayerManager.h
Normal file
@ -0,0 +1,788 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef GFX_LAYERMANAGER_H
|
||||
#define GFX_LAYERMANAGER_H
|
||||
|
||||
#include <cstdint> // for uint32_t, uint64_t, int32_t, uint8_t
|
||||
#include <iosfwd> // for stringstream
|
||||
#include <new> // for operator new
|
||||
#include <unordered_set> // for unordered_set
|
||||
#include <utility> // for forward
|
||||
#include "FrameMetrics.h" // for ScrollUpdatesMap
|
||||
#include "ImageContainer.h" // for ImageContainer, ImageContainer::Mode, ImageContainer::SYNCHRONOUS
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Maybe.h" // for Maybe
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr
|
||||
#include "mozilla/dom/Animation.h" // for Animation
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "mozilla/gfx/UserData.h" // for UserData, UserDataKey (ptr only)
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureFactoryIdentifier
|
||||
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid::ViewID
|
||||
#include "nsHashKeys.h" // for nsUint64HashKey
|
||||
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING
|
||||
#include "nsIWidget.h" // for nsIWidget
|
||||
#include "nsRefPtrHashtable.h" // for nsRefPtrHashtable
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsStringFwd.h" // for nsCString, nsAString
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
|
||||
// XXX These includes could be avoided by moving function implementations to the
|
||||
// cpp file
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_A...
|
||||
#include "mozilla/layers/LayersTypes.h" // for CompositionPayload, LayersBackend, TransactionId, DrawRegionClip, LayersBackend:...
|
||||
|
||||
class gfxContext;
|
||||
|
||||
extern uint8_t gLayerManagerLayerBuilder;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class FrameLayerBuilder;
|
||||
class LogModule;
|
||||
class ScrollPositionUpdate;
|
||||
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
} // namespace gfx
|
||||
|
||||
namespace layers {
|
||||
|
||||
class AsyncPanZoomController;
|
||||
class BasicLayerManager;
|
||||
class ClientLayerManager;
|
||||
class HostLayerManager;
|
||||
class Layer;
|
||||
class LayerMetricsWrapper;
|
||||
class PaintedLayer;
|
||||
class ContainerLayer;
|
||||
class ImageLayer;
|
||||
class ColorLayer;
|
||||
class CompositorBridgeChild;
|
||||
class CanvasLayer;
|
||||
class ReadbackLayer;
|
||||
class ReadbackProcessor;
|
||||
class RefLayer;
|
||||
class HostLayer;
|
||||
class FocusTarget;
|
||||
class KnowsCompositor;
|
||||
class ShadowableLayer;
|
||||
class ShadowLayerForwarder;
|
||||
class LayerManagerComposite;
|
||||
class TransactionIdAllocator;
|
||||
class FrameUniformityData;
|
||||
class PersistentBufferProvider;
|
||||
class GlyphArray;
|
||||
class WebRenderLayerManager;
|
||||
struct LayerPolygon;
|
||||
struct AnimData;
|
||||
|
||||
namespace layerscope {
|
||||
class LayersPacket;
|
||||
} // namespace layerscope
|
||||
|
||||
// Defined in LayerUserData.h; please include that file instead.
|
||||
class LayerUserData;
|
||||
|
||||
class DidCompositeObserver {
|
||||
public:
|
||||
virtual void DidComposite() = 0;
|
||||
};
|
||||
|
||||
class FrameRecorder {
|
||||
public:
|
||||
/**
|
||||
* Record (and return) frame-intervals and paint-times for frames which were
|
||||
* presented between calling StartFrameTimeRecording and
|
||||
* StopFrameTimeRecording.
|
||||
*
|
||||
* - Uses a cyclic buffer and serves concurrent consumers, so if Stop is
|
||||
* called too late
|
||||
* (elements were overwritten since Start), result is considered invalid
|
||||
* and hence empty.)
|
||||
* - Buffer is capable of holding 10 seconds @ 60fps (or more if frames were
|
||||
* less frequent).
|
||||
* Can be changed (up to 1 hour) via pref:
|
||||
* toolkit.framesRecording.bufferSize.
|
||||
* - Note: the first frame-interval may be longer than expected because last
|
||||
* frame
|
||||
* might have been presented some time before calling
|
||||
* StartFrameTimeRecording.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a handle which represents current recording start position.
|
||||
*/
|
||||
virtual uint32_t StartFrameTimeRecording(int32_t aBufferSize);
|
||||
|
||||
/**
|
||||
* Clears, then populates aFrameIntervals with the recorded frame timing
|
||||
* data. The array will be empty if data was overwritten since
|
||||
* aStartIndex was obtained.
|
||||
*/
|
||||
virtual void StopFrameTimeRecording(uint32_t aStartIndex,
|
||||
nsTArray<float>& aFrameIntervals);
|
||||
|
||||
void RecordFrame();
|
||||
|
||||
private:
|
||||
struct FramesTimingRecording {
|
||||
// Stores state and data for frame intervals and paint times recording.
|
||||
// see LayerManager::StartFrameTimeRecording() at Layers.cpp for more
|
||||
// details.
|
||||
FramesTimingRecording()
|
||||
: mNextIndex(0),
|
||||
mLatestStartIndex(0),
|
||||
mCurrentRunStartIndex(0),
|
||||
mIsPaused(true) {}
|
||||
nsTArray<float> mIntervals;
|
||||
TimeStamp mLastFrameTime;
|
||||
uint32_t mNextIndex;
|
||||
uint32_t mLatestStartIndex;
|
||||
uint32_t mCurrentRunStartIndex;
|
||||
bool mIsPaused;
|
||||
};
|
||||
FramesTimingRecording mRecording;
|
||||
};
|
||||
|
||||
/*
|
||||
* Motivation: For truly smooth animation and video playback, we need to
|
||||
* be able to compose frames and render them on a dedicated thread (i.e.
|
||||
* off the main thread where DOM manipulation, script execution and layout
|
||||
* induce difficult-to-bound latency). This requires Gecko to construct
|
||||
* some kind of persistent scene structure (graph or tree) that can be
|
||||
* safely transmitted across threads. We have other scenarios (e.g. mobile
|
||||
* browsing) where retaining some rendered data between paints is desired
|
||||
* for performance, so again we need a retained scene structure.
|
||||
*
|
||||
* Our retained scene structure is a layer tree. Each layer represents
|
||||
* content which can be composited onto a destination surface; the root
|
||||
* layer is usually composited into a window, and non-root layers are
|
||||
* composited into their parent layers. Layers have attributes (e.g.
|
||||
* opacity and clipping) that influence their compositing.
|
||||
*
|
||||
* We want to support a variety of layer implementations, including
|
||||
* a simple "immediate mode" implementation that doesn't retain any
|
||||
* rendered data between paints (i.e. uses cairo in just the way that
|
||||
* Gecko used it before layers were introduced). But we also don't want
|
||||
* to have bifurcated "layers"/"non-layers" rendering paths in Gecko.
|
||||
* Therefore the layers API is carefully designed to permit maximally
|
||||
* efficient implementation in an "immediate mode" style. See the
|
||||
* BasicLayerManager for such an implementation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A LayerManager controls a tree of layers. All layers in the tree
|
||||
* must use the same LayerManager.
|
||||
*
|
||||
* All modifications to a layer tree must happen inside a transaction.
|
||||
* Only the state of the layer tree at the end of a transaction is
|
||||
* rendered. Transactions cannot be nested
|
||||
*
|
||||
* Each transaction has two phases:
|
||||
* 1) Construction: layers are created, inserted, removed and have
|
||||
* properties set on them in this phase.
|
||||
* BeginTransaction and BeginTransactionWithTarget start a transaction in
|
||||
* the Construction phase.
|
||||
* 2) Drawing: PaintedLayers are rendered into in this phase, in tree
|
||||
* order. When the client has finished drawing into the PaintedLayers, it should
|
||||
* call EndTransaction to complete the transaction.
|
||||
*
|
||||
* All layer API calls happen on the main thread.
|
||||
*
|
||||
* Layers are refcounted. The layer manager holds a reference to the
|
||||
* root layer, and each container layer holds a reference to its children.
|
||||
*/
|
||||
class LayerManager : public FrameRecorder {
|
||||
NS_INLINE_DECL_REFCOUNTING(LayerManager)
|
||||
|
||||
protected:
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::gfx::IntSize IntSize;
|
||||
typedef mozilla::gfx::SurfaceFormat SurfaceFormat;
|
||||
|
||||
public:
|
||||
LayerManager();
|
||||
|
||||
/**
|
||||
* Release layers and resources held by this layer manager, and mark
|
||||
* it as destroyed. Should do any cleanup necessary in preparation
|
||||
* for its widget going away. After this call, only user data calls
|
||||
* are valid on the layer manager.
|
||||
*/
|
||||
virtual void Destroy();
|
||||
bool IsDestroyed() { return mDestroyed; }
|
||||
|
||||
virtual ShadowLayerForwarder* AsShadowForwarder() { return nullptr; }
|
||||
|
||||
virtual KnowsCompositor* AsKnowsCompositor() { return nullptr; }
|
||||
|
||||
virtual LayerManagerComposite* AsLayerManagerComposite() { return nullptr; }
|
||||
|
||||
virtual ClientLayerManager* AsClientLayerManager() { return nullptr; }
|
||||
|
||||
virtual BasicLayerManager* AsBasicLayerManager() { return nullptr; }
|
||||
virtual HostLayerManager* AsHostLayerManager() { return nullptr; }
|
||||
|
||||
virtual WebRenderLayerManager* AsWebRenderLayerManager() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Returns true if this LayerManager is owned by an nsIWidget,
|
||||
* and is used for drawing into the widget.
|
||||
*/
|
||||
virtual bool IsWidgetLayerManager() { return true; }
|
||||
virtual bool IsInactiveLayerManager() { return false; }
|
||||
|
||||
/**
|
||||
* Start a new transaction. Nested transactions are not allowed so
|
||||
* there must be no transaction currently in progress.
|
||||
* This transaction will update the state of the window from which
|
||||
* this LayerManager was obtained.
|
||||
*/
|
||||
virtual bool BeginTransaction(const nsCString& aURL = nsCString()) = 0;
|
||||
/**
|
||||
* Start a new transaction. Nested transactions are not allowed so
|
||||
* there must be no transaction currently in progress.
|
||||
* This transaction will render the contents of the layer tree to
|
||||
* the given target context. The rendering will be complete when
|
||||
* EndTransaction returns.
|
||||
*/
|
||||
virtual bool BeginTransactionWithTarget(
|
||||
gfxContext* aTarget, const nsCString& aURL = nsCString()) = 0;
|
||||
|
||||
enum EndTransactionFlags {
|
||||
END_DEFAULT = 0,
|
||||
END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase
|
||||
END_NO_COMPOSITE =
|
||||
1 << 1, // Do not composite after drawing painted layer contents.
|
||||
END_NO_REMOTE_COMPOSITE = 1 << 2 // Do not schedule a composition with a
|
||||
// remote Compositor, if one exists.
|
||||
};
|
||||
|
||||
FrameLayerBuilder* GetLayerBuilder() {
|
||||
return reinterpret_cast<FrameLayerBuilder*>(
|
||||
GetUserData(&gLayerManagerLayerBuilder));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to end an "empty transaction". There must have been no
|
||||
* changes to the layer tree since the BeginTransaction().
|
||||
* It's possible for this to fail; PaintedLayers may need to be updated
|
||||
* due to VRAM data being lost, for example. In such cases this method
|
||||
* returns false, and the caller must proceed with a normal layer tree
|
||||
* update and EndTransaction.
|
||||
*/
|
||||
virtual bool EndEmptyTransaction(
|
||||
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
||||
|
||||
/**
|
||||
* Function called to draw the contents of each PaintedLayer.
|
||||
* aRegionToDraw contains the region that needs to be drawn.
|
||||
* This would normally be a subregion of the visible region.
|
||||
* The callee must draw all of aRegionToDraw. Drawing outside
|
||||
* aRegionToDraw will be clipped out or ignored.
|
||||
* The callee must draw all of aRegionToDraw.
|
||||
* This region is relative to 0,0 in the PaintedLayer.
|
||||
*
|
||||
* aDirtyRegion should contain the total region that is be due to be painted
|
||||
* during the transaction, even though only aRegionToDraw should be drawn
|
||||
* during this call. aRegionToDraw must be entirely contained within
|
||||
* aDirtyRegion. If the total dirty region is unknown it is okay to pass a
|
||||
* subregion of the total dirty region, e.g. just aRegionToDraw, though it
|
||||
* may not be as efficient.
|
||||
*
|
||||
* aRegionToInvalidate contains a region whose contents have been
|
||||
* changed by the layer manager and which must therefore be invalidated.
|
||||
* For example, this could be non-empty if a retained layer internally
|
||||
* switches from RGBA to RGB or back ... we might want to repaint it to
|
||||
* consistently use subpixel-AA or not.
|
||||
* This region is relative to 0,0 in the PaintedLayer.
|
||||
* aRegionToInvalidate may contain areas that are outside
|
||||
* aRegionToDraw; the callee must ensure that these areas are repainted
|
||||
* in the current layer manager transaction or in a later layer
|
||||
* manager transaction.
|
||||
*
|
||||
* aContext must not be used after the call has returned.
|
||||
* We guarantee that buffered contents in the visible
|
||||
* region are valid once drawing is complete.
|
||||
*
|
||||
* The origin of aContext is 0,0 in the PaintedLayer.
|
||||
*/
|
||||
typedef void (*DrawPaintedLayerCallback)(
|
||||
PaintedLayer* aLayer, gfxContext* aContext,
|
||||
const nsIntRegion& aRegionToDraw, const nsIntRegion& aDirtyRegion,
|
||||
DrawRegionClip aClip, const nsIntRegion& aRegionToInvalidate,
|
||||
void* aCallbackData);
|
||||
|
||||
/**
|
||||
* Finish the construction phase of the transaction, perform the
|
||||
* drawing phase, and end the transaction.
|
||||
* During the drawing phase, all PaintedLayers in the tree are
|
||||
* drawn in tree order, exactly once each, except for those layers
|
||||
* where it is known that the visible region is empty.
|
||||
*/
|
||||
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
||||
void* aCallbackData,
|
||||
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
||||
|
||||
/**
|
||||
* Schedule a composition with the remote Compositor, if one exists
|
||||
* for this LayerManager. Useful in conjunction with the
|
||||
* END_NO_REMOTE_COMPOSITE flag to EndTransaction.
|
||||
*/
|
||||
virtual void ScheduleComposite() {}
|
||||
|
||||
virtual void SetNeedsComposite(bool aNeedsComposite) {}
|
||||
virtual bool NeedsComposite() const { return false; }
|
||||
|
||||
virtual bool HasShadowManagerInternal() const { return false; }
|
||||
bool HasShadowManager() const { return HasShadowManagerInternal(); }
|
||||
virtual void StorePluginWidgetConfigurations(
|
||||
const nsTArray<nsIWidget::Configuration>& aConfigurations) {}
|
||||
bool IsSnappingEffectiveTransforms() { return mSnapEffectiveTransforms; }
|
||||
|
||||
/**
|
||||
* Returns true if the underlying platform can properly support layers with
|
||||
* SurfaceMode::SURFACE_COMPONENT_ALPHA.
|
||||
*/
|
||||
static bool LayersComponentAlphaEnabled();
|
||||
|
||||
/**
|
||||
* Returns true if this LayerManager can properly support layers with
|
||||
* SurfaceMode::SURFACE_COMPONENT_ALPHA. LayerManagers that can't will use
|
||||
* transparent surfaces (and lose subpixel-AA for text).
|
||||
*/
|
||||
virtual bool AreComponentAlphaLayersEnabled();
|
||||
|
||||
/**
|
||||
* Returns true if this LayerManager always requires an intermediate surface
|
||||
* to render blend operations.
|
||||
*/
|
||||
virtual bool BlendingRequiresIntermediateSurface() { return false; }
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Set the root layer. The root layer is initially null. If there is
|
||||
* no root layer, EndTransaction won't draw anything.
|
||||
*/
|
||||
virtual void SetRoot(Layer* aLayer) = 0;
|
||||
/**
|
||||
* Can be called anytime
|
||||
*/
|
||||
Layer* GetRoot() { return mRoot; }
|
||||
|
||||
/**
|
||||
* Does a breadth-first search from the root layer to find the first
|
||||
* scrollable layer, and returns its ViewID. Note that there may be
|
||||
* other layers in the tree which share the same ViewID.
|
||||
* Can be called any time.
|
||||
*/
|
||||
ScrollableLayerGuid::ViewID GetRootScrollableLayerId();
|
||||
|
||||
/**
|
||||
* Returns a LayerMetricsWrapper containing the Root
|
||||
* Content Documents layer.
|
||||
*/
|
||||
LayerMetricsWrapper GetRootContentLayer();
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Called when a managee has mutated.
|
||||
* Subclasses overriding this method must first call their
|
||||
* superclass's impl
|
||||
*/
|
||||
virtual void Mutated(Layer* aLayer) {}
|
||||
virtual void MutatedSimple(Layer* aLayer) {}
|
||||
|
||||
/**
|
||||
* Hints that can be used during PaintedLayer creation to influence the type
|
||||
* or properties of the layer created.
|
||||
*
|
||||
* NONE: No hint.
|
||||
* SCROLLABLE: This layer may represent scrollable content.
|
||||
*/
|
||||
enum PaintedLayerCreationHint { NONE, SCROLLABLE };
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a PaintedLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a PaintedLayer for this manager's layer tree, with a creation hint
|
||||
* parameter to help optimise the type of layer created.
|
||||
*/
|
||||
virtual already_AddRefed<PaintedLayer> CreatePaintedLayerWithHint(
|
||||
PaintedLayerCreationHint) {
|
||||
return CreatePaintedLayer();
|
||||
}
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a ContainerLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create an ImageLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ImageLayer> CreateImageLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a ColorLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a CanvasLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a ReadbackLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() {
|
||||
return nullptr;
|
||||
}
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a RefLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<RefLayer> CreateRefLayer() { return nullptr; }
|
||||
/**
|
||||
* Can be called anytime, from any thread.
|
||||
*
|
||||
* Creates an Image container which forwards its images to the compositor
|
||||
* within layer transactions on the main thread or asynchronously using the
|
||||
* ImageBridge IPDL protocol. In the case of asynchronous, If the protocol is
|
||||
* not available, the returned ImageContainer will forward images within layer
|
||||
* transactions.
|
||||
*/
|
||||
static already_AddRefed<ImageContainer> CreateImageContainer(
|
||||
ImageContainer::Mode flag = ImageContainer::SYNCHRONOUS);
|
||||
|
||||
/**
|
||||
* Type of layer manager his is. This is to be used sparsely in order to
|
||||
* avoid a lot of Layers backend specific code. It should be used only when
|
||||
* Layers backend specific functionality is necessary.
|
||||
*/
|
||||
virtual LayersBackend GetBackendType() = 0;
|
||||
|
||||
/**
|
||||
* Type of layers backend that will be used to composite this layer tree.
|
||||
* When compositing is done remotely, then this returns the layers type
|
||||
* of the compositor.
|
||||
*/
|
||||
virtual LayersBackend GetCompositorBackendType() { return GetBackendType(); }
|
||||
|
||||
/**
|
||||
* Creates a DrawTarget which is optimized for inter-operating with this
|
||||
* layer manager.
|
||||
*/
|
||||
virtual already_AddRefed<DrawTarget> CreateOptimalDrawTarget(
|
||||
const IntSize& aSize, SurfaceFormat imageFormat);
|
||||
|
||||
/**
|
||||
* Creates a DrawTarget for alpha masks which is optimized for inter-
|
||||
* operating with this layer manager. In contrast to CreateOptimalDrawTarget,
|
||||
* this surface is optimised for drawing alpha only and we assume that
|
||||
* drawing the mask is fairly simple.
|
||||
*/
|
||||
virtual already_AddRefed<DrawTarget> CreateOptimalMaskDrawTarget(
|
||||
const IntSize& aSize);
|
||||
|
||||
/**
|
||||
* Creates a DrawTarget for use with canvas which is optimized for
|
||||
* inter-operating with this layermanager.
|
||||
*/
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget(
|
||||
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
|
||||
|
||||
/**
|
||||
* Creates a PersistentBufferProvider for use with canvas which is optimized
|
||||
* for inter-operating with this layermanager.
|
||||
*/
|
||||
virtual already_AddRefed<PersistentBufferProvider>
|
||||
CreatePersistentBufferProvider(const mozilla::gfx::IntSize& aSize,
|
||||
mozilla::gfx::SurfaceFormat aFormat);
|
||||
|
||||
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the maximum texture size on this layer backend, or INT32_MAX
|
||||
* if there is no maximum
|
||||
*/
|
||||
virtual int32_t GetMaxTextureSize() const = 0;
|
||||
|
||||
/**
|
||||
* Return the name of the layer manager's backend.
|
||||
*/
|
||||
virtual void GetBackendName(nsAString& aName) = 0;
|
||||
|
||||
/**
|
||||
* This setter can be used anytime. The user data for all keys is
|
||||
* initially null. Ownership pases to the layer manager.
|
||||
*/
|
||||
void SetUserData(void* aKey, LayerUserData* aData) {
|
||||
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData,
|
||||
LayerUserDataDestroy);
|
||||
}
|
||||
/**
|
||||
* This can be used anytime. Ownership passes to the caller!
|
||||
*/
|
||||
UniquePtr<LayerUserData> RemoveUserData(void* aKey);
|
||||
|
||||
/**
|
||||
* This getter can be used anytime.
|
||||
*/
|
||||
bool HasUserData(void* aKey) {
|
||||
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
||||
}
|
||||
/**
|
||||
* This getter can be used anytime. Ownership is retained by the layer
|
||||
* manager.
|
||||
*/
|
||||
LayerUserData* GetUserData(void* aKey) const {
|
||||
return static_cast<LayerUserData*>(
|
||||
mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called outside of a layers transaction.
|
||||
*
|
||||
* For the subtree rooted at |aSubtree|, this attempts to free up
|
||||
* any free-able resources like retained buffers, but may do nothing
|
||||
* at all. After this call, the layer tree is left in an undefined
|
||||
* state; the layers in |aSubtree|'s subtree may no longer have
|
||||
* buffers with valid content and may no longer be able to draw
|
||||
* their visible and valid regions.
|
||||
*
|
||||
* In general, a painting or forwarding transaction on |this| must
|
||||
* complete on the tree before it returns to a valid state.
|
||||
*
|
||||
* Resource freeing begins from |aSubtree| or |mRoot| if |aSubtree|
|
||||
* is null. |aSubtree|'s manager must be this.
|
||||
*/
|
||||
virtual void ClearCachedResources(Layer* aSubtree = nullptr) {}
|
||||
|
||||
/**
|
||||
* Flag the next paint as the first for a document.
|
||||
*/
|
||||
virtual void SetIsFirstPaint() {}
|
||||
virtual bool GetIsFirstPaint() const { return false; }
|
||||
|
||||
/**
|
||||
* Set the current focus target to be sent with the next paint.
|
||||
*/
|
||||
virtual void SetFocusTarget(const FocusTarget& aFocusTarget) {}
|
||||
|
||||
/**
|
||||
* Make sure that the previous transaction has been entirely
|
||||
* completed.
|
||||
*
|
||||
* Note: This may sychronously wait on a remote compositor
|
||||
* to complete rendering.
|
||||
*/
|
||||
virtual void FlushRendering() {}
|
||||
|
||||
/**
|
||||
* Make sure that the previous transaction has been
|
||||
* received. This will synchronsly wait on a remote compositor. */
|
||||
virtual void WaitOnTransactionProcessed() {}
|
||||
|
||||
virtual void SendInvalidRegion(const nsIntRegion& aRegion) {}
|
||||
|
||||
/**
|
||||
* Checks if we need to invalidate the OS widget to trigger
|
||||
* painting when updating this layer manager.
|
||||
*/
|
||||
virtual bool NeedsWidgetInvalidation() { return true; }
|
||||
|
||||
virtual const char* Name() const { return "???"; }
|
||||
|
||||
/**
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
* aStream.
|
||||
*/
|
||||
void Dump(std::stringstream& aStream, const char* aPrefix = "",
|
||||
bool aDumpHtml = false, bool aSorted = false);
|
||||
/**
|
||||
* Dump information about just this layer manager itself to aStream
|
||||
*/
|
||||
void DumpSelf(std::stringstream& aStream, const char* aPrefix = "",
|
||||
bool aSorted = false);
|
||||
void Dump(bool aSorted = false);
|
||||
|
||||
/**
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
* layerscope packet.
|
||||
*/
|
||||
void Dump(layerscope::LayersPacket* aPacket);
|
||||
|
||||
/**
|
||||
* Log information about this layer manager and its managed tree to
|
||||
* the NSPR log (if enabled for "Layers").
|
||||
*/
|
||||
void Log(const char* aPrefix = "");
|
||||
/**
|
||||
* Log information about just this layer manager itself to the NSPR
|
||||
* log (if enabled for "Layers").
|
||||
*/
|
||||
void LogSelf(const char* aPrefix = "");
|
||||
|
||||
static bool IsLogEnabled();
|
||||
static mozilla::LogModule* GetLog();
|
||||
|
||||
bool IsCompositingCheap(LayersBackend aBackend) {
|
||||
// LayersBackend::LAYERS_NONE is an error state, but in that case we should
|
||||
// try to avoid loading the compositor!
|
||||
return LayersBackend::LAYERS_BASIC != aBackend &&
|
||||
LayersBackend::LAYERS_NONE != aBackend;
|
||||
}
|
||||
|
||||
virtual bool IsCompositingCheap() { return true; }
|
||||
|
||||
bool IsInTransaction() const { return mInTransaction; }
|
||||
virtual void GetFrameUniformity(FrameUniformityData* aOutData) {}
|
||||
|
||||
virtual void SetRegionToClear(const nsIntRegion& aRegion) {
|
||||
mRegionToClear = aRegion;
|
||||
}
|
||||
|
||||
virtual float RequestProperty(const nsAString& property) { return -1; }
|
||||
|
||||
const TimeStamp& GetAnimationReadyTime() const { return mAnimationReadyTime; }
|
||||
|
||||
virtual bool AsyncPanZoomEnabled() const { return false; }
|
||||
|
||||
static void LayerUserDataDestroy(void* data);
|
||||
|
||||
void AddPaintedPixelCount(int32_t aCount) { mPaintedPixelCount += aCount; }
|
||||
|
||||
uint32_t GetAndClearPaintedPixelCount() {
|
||||
uint32_t count = mPaintedPixelCount;
|
||||
mPaintedPixelCount = 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
virtual void SetLayersObserverEpoch(LayersObserverEpoch aEpoch) {}
|
||||
|
||||
virtual void DidComposite(TransactionId aTransactionId,
|
||||
const mozilla::TimeStamp& aCompositeStart,
|
||||
const mozilla::TimeStamp& aCompositeEnd) {}
|
||||
|
||||
virtual void AddDidCompositeObserver(DidCompositeObserver* aObserver) {
|
||||
MOZ_CRASH("GFX: LayerManager");
|
||||
}
|
||||
virtual void RemoveDidCompositeObserver(DidCompositeObserver* aObserver) {
|
||||
MOZ_CRASH("GFX: LayerManager");
|
||||
}
|
||||
|
||||
virtual void UpdateTextureFactoryIdentifier(
|
||||
const TextureFactoryIdentifier& aNewIdentifier) {}
|
||||
|
||||
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() {
|
||||
return TextureFactoryIdentifier();
|
||||
}
|
||||
|
||||
virtual void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) {}
|
||||
|
||||
virtual TransactionId GetLastTransactionId() { return TransactionId{0}; }
|
||||
|
||||
virtual CompositorBridgeChild* GetCompositorBridgeChild() { return nullptr; }
|
||||
|
||||
void RegisterPayload(const CompositionPayload& aPayload) {
|
||||
mPayload.AppendElement(aPayload);
|
||||
MOZ_ASSERT(mPayload.Length() < 10000);
|
||||
}
|
||||
|
||||
void RegisterPayloads(const nsTArray<CompositionPayload>& aPayload) {
|
||||
mPayload.AppendElements(aPayload);
|
||||
MOZ_ASSERT(mPayload.Length() < 10000);
|
||||
}
|
||||
|
||||
virtual void PayloadPresented();
|
||||
|
||||
void SetContainsSVG(bool aContainsSVG) { mContainsSVG = aContainsSVG; }
|
||||
|
||||
void AddPartialPrerenderedAnimation(uint64_t aCompositorAnimationId,
|
||||
dom::Animation* aAnimation);
|
||||
void RemovePartialPrerenderedAnimation(uint64_t aCompositorAnimationId,
|
||||
dom::Animation* aAnimation);
|
||||
void UpdatePartialPrerenderedAnimations(
|
||||
const nsTArray<uint64_t>& aJankedAnimations);
|
||||
|
||||
protected:
|
||||
RefPtr<Layer> mRoot;
|
||||
gfx::UserData mUserData;
|
||||
bool mDestroyed;
|
||||
bool mSnapEffectiveTransforms;
|
||||
|
||||
nsIntRegion mRegionToClear;
|
||||
|
||||
// Protected destructor, to discourage deletion outside of Release():
|
||||
virtual ~LayerManager();
|
||||
|
||||
// Print interesting information about this into aStreamo. Internally
|
||||
// used to implement Dump*() and Log*().
|
||||
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
||||
|
||||
// Print interesting information about this into layerscope packet.
|
||||
// Internally used to implement Dump().
|
||||
virtual void DumpPacket(layerscope::LayersPacket* aPacket);
|
||||
|
||||
uint64_t mId;
|
||||
bool mInTransaction;
|
||||
|
||||
// Used for tracking CONTENT_FRAME_TIME_WITH_SVG
|
||||
bool mContainsSVG;
|
||||
// The time when painting most recently finished. This is recorded so that
|
||||
// we can time any play-pending animations from this point.
|
||||
TimeStamp mAnimationReadyTime;
|
||||
// The count of pixels that were painted in the current transaction.
|
||||
uint32_t mPaintedPixelCount;
|
||||
// The payload associated with currently pending painting work, for
|
||||
// client layer managers that typically means payload that is part of the
|
||||
// 'upcoming transaction', for HostLayerManagers this typically means
|
||||
// what has been included in received transactions to be presented on the
|
||||
// next composite.
|
||||
// IMPORTANT: Clients should take care to clear this or risk it slowly
|
||||
// growing out of control.
|
||||
nsTArray<CompositionPayload> mPayload;
|
||||
// Transform animations which are not fully pre-rendered because it's on a
|
||||
// large frame. We need to update the pre-rendered area once after we tried
|
||||
// to composite area which is outside of the pre-rendered area on the
|
||||
// compositor.
|
||||
nsRefPtrHashtable<nsUint64HashKey, dom::Animation>
|
||||
mPartialPrerenderedAnimations;
|
||||
|
||||
public:
|
||||
/*
|
||||
* Methods to store/get/clear a "pending scroll info update" object on a
|
||||
* per-scrollid basis. This is used for empty transactions that push over
|
||||
* scroll position updates to the APZ code.
|
||||
*/
|
||||
virtual bool AddPendingScrollUpdateForNextTransaction(
|
||||
ScrollableLayerGuid::ViewID aScrollId,
|
||||
const ScrollPositionUpdate& aUpdateInfo);
|
||||
Maybe<nsTArray<ScrollPositionUpdate>> GetPendingScrollInfoUpdate(
|
||||
ScrollableLayerGuid::ViewID aScrollId);
|
||||
std::unordered_set<ScrollableLayerGuid::ViewID>
|
||||
ClearPendingScrollInfoUpdate();
|
||||
|
||||
protected:
|
||||
ScrollUpdatesMap mPendingScrollUpdates;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* GFX_LAYERS_H */
|
@ -5,53 +5,54 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Layers.h"
|
||||
#include <algorithm> // for max, min
|
||||
#include "apz/src/AsyncPanZoomController.h"
|
||||
|
||||
#include <inttypes.h> // for PRIu64
|
||||
#include <stdio.h> // for stderr
|
||||
#include <algorithm> // for max, min
|
||||
#include <list> // for list
|
||||
#include <set> // for set
|
||||
#include <string> // for char_traits, string, basic_string
|
||||
#include <type_traits> // for remove_reference<>::type
|
||||
#include "CompositableHost.h" // for CompositableHost
|
||||
#include "ImageContainer.h" // for ImageContainer, etc
|
||||
#include "ImageLayers.h" // for ImageLayer
|
||||
#include "LayerSorter.h" // for SortLayersBy3DZOrder
|
||||
#include "LayerUserData.h"
|
||||
#include "ReadbackLayer.h" // for ReadbackLayer
|
||||
#include "UnitTransforms.h" // for ViewAs
|
||||
#include "gfxEnv.h"
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
#include "gfxUtils.h" // for gfxUtils, etc
|
||||
#include "gfx2DGlue.h"
|
||||
#include "mozilla/DebugOnly.h" // for DebugOnly
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/StaticPrefs_layers.h"
|
||||
#include "mozilla/Telemetry.h" // for Accumulate
|
||||
#include "mozilla/ToString.h"
|
||||
#include "mozilla/dom/Animation.h" // for dom::Animation
|
||||
#include "mozilla/dom/KeyframeEffect.h" // for dom::Animation
|
||||
#include "mozilla/EffectSet.h" // for dom::Animation
|
||||
#include "mozilla/gfx/2D.h" // for DrawTarget
|
||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Polygon.h" // for Polygon
|
||||
#include "mozilla/layers/BSPTree.h" // for BSPTree
|
||||
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "mozilla/layers/LayersMessages.h" // for TransformFunction, etc
|
||||
#include "mozilla/layers/LayersTypes.h" // for TextureDumpMode
|
||||
#include "mozilla/layers/PersistentBufferProvider.h"
|
||||
#include "GeckoProfiler.h" // for profiler_can_accept_markers, PROFILER_MARKER_TEXT
|
||||
#include "ImageLayers.h" // for ImageLayer
|
||||
#include "LayerUserData.h" // for LayerUserData
|
||||
#include "ReadbackLayer.h" // for ReadbackLayer
|
||||
#include "TreeTraversal.h" // for ForwardIterator, ForEachNode, DepthFirstSearch, TraversalFlag, TraversalFl...
|
||||
#include "UnitTransforms.h" // for ViewAs, PixelCastJustification, PixelCastJustification::RenderTargetIsPare...
|
||||
#include "apz/src/AsyncPanZoomController.h" // for AsyncPanZoomController
|
||||
#include "gfx2DGlue.h" // for ThebesMatrix, ToPoint, ThebesRect
|
||||
#include "gfxEnv.h" // for gfxEnv
|
||||
#include "gfxMatrix.h" // for gfxMatrix
|
||||
#include "gfxUtils.h" // for gfxUtils, gfxUtils::sDumpPaintFile
|
||||
#include "mozilla/ArrayIterator.h" // for ArrayIterator
|
||||
#include "mozilla/BaseProfilerMarkersPrerequisites.h" // for MarkerTiming
|
||||
#include "mozilla/DebugOnly.h" // for DebugOnly
|
||||
#include "mozilla/Logging.h" // for LogLevel, LogLevel::Debug, MOZ_LOG_TEST
|
||||
#include "mozilla/ScrollPositionUpdate.h" // for ScrollPositionUpdate
|
||||
#include "mozilla/Telemetry.h" // for AccumulateTimeDelta
|
||||
#include "mozilla/TelemetryHistogramEnums.h" // for KEYPRESS_PRESENT_LATENCY, SCROLL_PRESENT_LATENCY
|
||||
#include "mozilla/ToString.h" // for ToString
|
||||
#include "mozilla/gfx/2D.h" // for SourceSurface, DrawTarget, DataSourceSurface
|
||||
#include "mozilla/gfx/BasePoint3D.h" // for BasePoint3D<>::(anonymous union)::(anonymous), BasePoint3D<>::(anonymous)
|
||||
#include "mozilla/gfx/BaseRect.h" // for operator<<, BaseRect (ptr only)
|
||||
#include "mozilla/gfx/BaseSize.h" // for operator<<, BaseSize<>::(anonymous union)::(anonymous), BaseSize<>::(anony...
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix, Matrix4x4Typed<>::(anonymous union)::(anonymous), Matri...
|
||||
#include "mozilla/gfx/MatrixFwd.h" // for Float
|
||||
#include "mozilla/gfx/Polygon.h" // for Polygon, PolygonTyped
|
||||
#include "mozilla/layers/BSPTree.h" // for LayerPolygon, BSPTree
|
||||
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/LayerManagerComposite.h" // for HostLayer
|
||||
#include "mozilla/layers/LayersMessages.h" // for SpecificLayerAttributes, CompositorAnimations (ptr only), ContainerLayerAt...
|
||||
#include "mozilla/layers/LayersTypes.h" // for EventRegions, operator<<, CompositionPayload, CSSTransformMatrix, MOZ_LAYE...
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer
|
||||
#include "nsAString.h"
|
||||
#include "nsCSSValue.h" // for nsCSSValue::Array, etc
|
||||
#include "nsDisplayList.h" // for nsDisplayItem
|
||||
#include "nsPrintfCString.h" // for nsPrintfCString
|
||||
#include "protobuf/LayerScopePacket.pb.h"
|
||||
#include "mozilla/Compression.h"
|
||||
#include "TreeTraversal.h" // for ForEachNode
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
uint8_t gLayerManagerLayerBuilder;
|
||||
#include "nsBaseHashtable.h" // for nsBaseHashtable<>::Iterator, nsBaseHashtable<>::LookupResult
|
||||
#include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE
|
||||
#include "nsPrintfCString.h" // for nsPrintfCString
|
||||
#include "nsRegionFwd.h" // for IntRegion
|
||||
#include "nsString.h" // for nsTSubstring
|
||||
#include "protobuf/LayerScopePacket.pb.h" // for LayersPacket::Layer, LayersPacket, LayersPacket_Layer::Matrix, LayersPacke...
|
||||
|
||||
// Undo the damage done by mozzconf.h
|
||||
#undef compress
|
||||
@ -65,152 +66,6 @@ typedef ScrollableLayerGuid::ViewID ViewID;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::Compression;
|
||||
|
||||
//--------------------------------------------------
|
||||
// LayerManager
|
||||
|
||||
/* static */ mozilla::LogModule* LayerManager::GetLog() {
|
||||
static LazyLogModule sLog("Layers");
|
||||
return sLog;
|
||||
}
|
||||
|
||||
ScrollableLayerGuid::ViewID LayerManager::GetRootScrollableLayerId() {
|
||||
if (!mRoot) {
|
||||
return ScrollableLayerGuid::NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
LayerMetricsWrapper layerMetricsRoot = LayerMetricsWrapper(mRoot);
|
||||
|
||||
LayerMetricsWrapper rootScrollableLayerMetrics =
|
||||
BreadthFirstSearch<ForwardIterator>(
|
||||
layerMetricsRoot, [](LayerMetricsWrapper aLayerMetrics) {
|
||||
return aLayerMetrics.Metrics().IsScrollable();
|
||||
});
|
||||
|
||||
return rootScrollableLayerMetrics.IsValid()
|
||||
? rootScrollableLayerMetrics.Metrics().GetScrollId()
|
||||
: ScrollableLayerGuid::NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
LayerMetricsWrapper LayerManager::GetRootContentLayer() {
|
||||
if (!mRoot) {
|
||||
return LayerMetricsWrapper();
|
||||
}
|
||||
|
||||
LayerMetricsWrapper root(mRoot);
|
||||
|
||||
return BreadthFirstSearch<ForwardIterator>(
|
||||
root, [](LayerMetricsWrapper aLayerMetrics) {
|
||||
return aLayerMetrics.Metrics().IsRootContent();
|
||||
});
|
||||
}
|
||||
|
||||
already_AddRefed<DrawTarget> LayerManager::CreateOptimalDrawTarget(
|
||||
const gfx::IntSize& aSize, SurfaceFormat aFormat) {
|
||||
return gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aSize,
|
||||
aFormat);
|
||||
}
|
||||
|
||||
already_AddRefed<DrawTarget> LayerManager::CreateOptimalMaskDrawTarget(
|
||||
const gfx::IntSize& aSize) {
|
||||
return CreateOptimalDrawTarget(aSize, SurfaceFormat::A8);
|
||||
}
|
||||
|
||||
already_AddRefed<DrawTarget> LayerManager::CreateDrawTarget(
|
||||
const IntSize& aSize, SurfaceFormat aFormat) {
|
||||
return gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(aSize,
|
||||
aFormat);
|
||||
}
|
||||
|
||||
already_AddRefed<PersistentBufferProvider>
|
||||
LayerManager::CreatePersistentBufferProvider(
|
||||
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat) {
|
||||
RefPtr<PersistentBufferProviderBasic> bufferProvider =
|
||||
PersistentBufferProviderBasic::Create(
|
||||
aSize, aFormat,
|
||||
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
|
||||
|
||||
if (!bufferProvider) {
|
||||
bufferProvider = PersistentBufferProviderBasic::Create(
|
||||
aSize, aFormat, gfxPlatform::GetPlatform()->GetFallbackCanvasBackend());
|
||||
}
|
||||
|
||||
return bufferProvider.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ImageContainer> LayerManager::CreateImageContainer(
|
||||
ImageContainer::Mode flag) {
|
||||
RefPtr<ImageContainer> container = new ImageContainer(flag);
|
||||
return container.forget();
|
||||
}
|
||||
|
||||
bool LayerManager::LayersComponentAlphaEnabled() {
|
||||
// If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off
|
||||
// and ignore the preference.
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
return false;
|
||||
#else
|
||||
return StaticPrefs::
|
||||
layers_componentalpha_enabled_AtStartup_DoNotUseDirectly();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool LayerManager::AreComponentAlphaLayersEnabled() {
|
||||
return LayerManager::LayersComponentAlphaEnabled();
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void LayerManager::LayerUserDataDestroy(void* data) {
|
||||
delete static_cast<LayerUserData*>(data);
|
||||
}
|
||||
|
||||
UniquePtr<LayerUserData> LayerManager::RemoveUserData(void* aKey) {
|
||||
UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(
|
||||
mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
||||
return d;
|
||||
}
|
||||
|
||||
void LayerManager::PayloadPresented() {
|
||||
RecordCompositionPayloadsPresented(mPayload);
|
||||
}
|
||||
|
||||
void LayerManager::AddPartialPrerenderedAnimation(
|
||||
uint64_t aCompositorAnimationId, dom::Animation* aAnimation) {
|
||||
mPartialPrerenderedAnimations.Put(aCompositorAnimationId, RefPtr{aAnimation});
|
||||
aAnimation->SetPartialPrerendered(aCompositorAnimationId);
|
||||
}
|
||||
|
||||
void LayerManager::RemovePartialPrerenderedAnimation(
|
||||
uint64_t aCompositorAnimationId, dom::Animation* aAnimation) {
|
||||
MOZ_ASSERT(aAnimation);
|
||||
#ifdef DEBUG
|
||||
RefPtr<dom::Animation> animation;
|
||||
if (mPartialPrerenderedAnimations.Remove(aCompositorAnimationId,
|
||||
getter_AddRefs(animation)) &&
|
||||
// It may be possible that either animation's effect has already been
|
||||
// nulled out via Animation::SetEffect() so ignore such cases.
|
||||
aAnimation->GetEffect() && aAnimation->GetEffect()->AsKeyframeEffect() &&
|
||||
animation->GetEffect() && animation->GetEffect()->AsKeyframeEffect()) {
|
||||
MOZ_ASSERT(EffectSet::GetEffectSetForEffect(
|
||||
aAnimation->GetEffect()->AsKeyframeEffect()) ==
|
||||
EffectSet::GetEffectSetForEffect(
|
||||
animation->GetEffect()->AsKeyframeEffect()));
|
||||
}
|
||||
#else
|
||||
mPartialPrerenderedAnimations.Remove(aCompositorAnimationId);
|
||||
#endif
|
||||
aAnimation->ResetPartialPrerendered();
|
||||
}
|
||||
|
||||
void LayerManager::UpdatePartialPrerenderedAnimations(
|
||||
const nsTArray<uint64_t>& aJankedAnimations) {
|
||||
for (uint64_t id : aJankedAnimations) {
|
||||
RefPtr<dom::Animation> animation;
|
||||
if (mPartialPrerenderedAnimations.Remove(id, getter_AddRefs(animation))) {
|
||||
animation->UpdatePartialPrerendered();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// Layer
|
||||
|
||||
|
@ -7,47 +7,41 @@
|
||||
#ifndef GFX_LAYERS_H
|
||||
#define GFX_LAYERS_H
|
||||
|
||||
#include <cstdint> // for uint32_t, uint64_t, int32_t, uint8_t
|
||||
#include <cstring> // for memcpy
|
||||
#include <iosfwd> // for stringstream
|
||||
#include <new> // for operator new
|
||||
#include <unordered_set> // for unordered_set
|
||||
#include <utility> // for forward, move
|
||||
#include "FrameMetrics.h" // for ScrollMetadata, FrameMetrics::ViewID, Fra...
|
||||
#include "ImageContainer.h" // for ImageContainer, ImageContainer::Mode, Ima...
|
||||
#include "Units.h" // for LayerIntRegion, ParentLayerIntRect, Layer...
|
||||
#include "gfxPoint.h" // for gfxPoint
|
||||
#include "gfxRect.h" // for gfxRect
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Maybe.h" // for Maybe, Nothing (ptr only)
|
||||
#include "mozilla/Poison.h" // for CorruptionCanary
|
||||
#include "mozilla/RefPtr.h" // for RefPtr, operator!=
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr, MakeUnique
|
||||
#include "mozilla/dom/Animation.h" // for Animation
|
||||
#include "mozilla/gfx/BasePoint.h" // for BasePoint<>::(anonymous union)::(anonymous)
|
||||
#include <cstdint> // for uint32_t, uint64_t, int32_t, uint8_t
|
||||
#include <cstring> // for memcpy, size_t
|
||||
#include <iosfwd> // for stringstream
|
||||
#include <new> // for operator new
|
||||
#include <unordered_set> // for unordered_set
|
||||
#include <utility> // for forward, move
|
||||
#include "FrameMetrics.h" // for ScrollMetadata, FrameMetrics::ViewID, FrameMetrics
|
||||
#include "Units.h" // for LayerIntRegion, ParentLayerIntRect, LayerIntSize, Lay...
|
||||
#include "gfxPoint.h" // for gfxPoint
|
||||
#include "gfxRect.h" // for gfxRect
|
||||
#include "mozilla/Maybe.h" // for Maybe, Nothing (ptr only)
|
||||
#include "mozilla/Poison.h" // for CorruptionCanary
|
||||
#include "mozilla/RefPtr.h" // for RefPtr, operator!=
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr, MakeUnique
|
||||
#include "mozilla/gfx/BasePoint.h" // for BasePoint<>::(anonymous union)::(anonymous), BasePoin...
|
||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix, Matrix4x4Typed
|
||||
#include "mozilla/gfx/Point.h" // for Point, PointTyped, IntSize
|
||||
#include "mozilla/gfx/Point.h" // for Point, PointTyped
|
||||
#include "mozilla/gfx/Polygon.h" // for Polygon
|
||||
#include "mozilla/gfx/Rect.h" // for IntRectTyped, IntRect
|
||||
#include "mozilla/gfx/TiledRegion.h" // for TiledIntRegion
|
||||
#include "mozilla/gfx/Types.h" // for CompositionOp, DeviceColor, SamplingFilter
|
||||
#include "mozilla/gfx/Types.h" // for CompositionOp, DeviceColor, SamplingFilter, SideBits
|
||||
#include "mozilla/gfx/UserData.h" // for UserData, UserDataKey (ptr only)
|
||||
#include "mozilla/layers/AnimationInfo.h" // for AnimationInfo
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureFactoryIdentifier
|
||||
#include "mozilla/layers/LayerAttributes.h" // for SimpleLayerAttributes, ScrollbarData (ptr...
|
||||
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid:...
|
||||
#include "nsHashKeys.h" // for nsUint64HashKey
|
||||
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING
|
||||
#include "nsIWidget.h" // for nsIWidget
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsRect.h" // for nsIntRect
|
||||
#include "nsRefPtrHashtable.h" // for nsRefPtrHashtable
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsStringFlags.h" // for operator&
|
||||
#include "nsStringFwd.h" // for nsCString, nsAString, nsACString
|
||||
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, nsTArray_Impl<>:...
|
||||
#include "mozilla/layers/AnimationInfo.h" // for AnimationInfo
|
||||
#include "mozilla/layers/LayerAttributes.h" // for SimpleLayerAttributes, ScrollbarData (ptr only)
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager, LayerManager::PaintedLayerCreationHint
|
||||
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid::ViewID
|
||||
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsRect.h" // for nsIntRect
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsStringFlags.h" // for operator&
|
||||
#include "nsStringFwd.h" // for nsCString, nsACString
|
||||
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, nsTArray_Impl<>::elem_type
|
||||
|
||||
// XXX These includes could be avoided by moving function implementations to the
|
||||
// cpp file
|
||||
@ -55,55 +49,36 @@
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_A...
|
||||
#include "mozilla/DebugOnly.h" // for DebugOnly
|
||||
#include "mozilla/layers/CanvasRenderer.h" // for CanvasRenderer
|
||||
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG_IF_SHADOWABLE, Composition...
|
||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING
|
||||
|
||||
class gfxContext;
|
||||
|
||||
extern uint8_t gLayerManagerLayerBuilder;
|
||||
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG_IF_SHADOWABLE, LayersId, EventRegionsO...
|
||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class FrameLayerBuilder;
|
||||
|
||||
namespace gfx {
|
||||
class DataSourceSurface;
|
||||
class DrawTarget;
|
||||
class Path;
|
||||
} // namespace gfx
|
||||
|
||||
namespace layers {
|
||||
|
||||
class Animation;
|
||||
class AsyncPanZoomController;
|
||||
class BasicLayerManager;
|
||||
class ClientLayerManager;
|
||||
class HostLayerManager;
|
||||
class Layer;
|
||||
class LayerMetricsWrapper;
|
||||
class PaintedLayer;
|
||||
class ContainerLayer;
|
||||
class ImageLayer;
|
||||
class ColorLayer;
|
||||
class CompositorAnimations;
|
||||
class CompositorBridgeChild;
|
||||
class CanvasLayer;
|
||||
class ReadbackLayer;
|
||||
class ReadbackProcessor;
|
||||
class RefLayer;
|
||||
class HostLayer;
|
||||
class FocusTarget;
|
||||
class KnowsCompositor;
|
||||
class ShadowableLayer;
|
||||
class ShadowLayerForwarder;
|
||||
class LayerManagerComposite;
|
||||
class SpecificLayerAttributes;
|
||||
class TransactionIdAllocator;
|
||||
class Compositor;
|
||||
class FrameUniformityData;
|
||||
class PersistentBufferProvider;
|
||||
class GlyphArray;
|
||||
class WebRenderLayerManager;
|
||||
class TransformData;
|
||||
struct LayerPolygon;
|
||||
struct AnimData;
|
||||
struct PropertyAnimationGroup;
|
||||
|
||||
namespace layerscope {
|
||||
class LayersPacket;
|
||||
@ -114,70 +89,6 @@ class LayersPacket;
|
||||
LayerType GetType() const override { return e; } \
|
||||
static LayerType Type() { return e; }
|
||||
|
||||
// Defined in LayerUserData.h; please include that file instead.
|
||||
class LayerUserData;
|
||||
|
||||
class DidCompositeObserver {
|
||||
public:
|
||||
virtual void DidComposite() = 0;
|
||||
};
|
||||
|
||||
class FrameRecorder {
|
||||
public:
|
||||
/**
|
||||
* Record (and return) frame-intervals and paint-times for frames which were
|
||||
* presented between calling StartFrameTimeRecording and
|
||||
* StopFrameTimeRecording.
|
||||
*
|
||||
* - Uses a cyclic buffer and serves concurrent consumers, so if Stop is
|
||||
* called too late
|
||||
* (elements were overwritten since Start), result is considered invalid
|
||||
* and hence empty.)
|
||||
* - Buffer is capable of holding 10 seconds @ 60fps (or more if frames were
|
||||
* less frequent).
|
||||
* Can be changed (up to 1 hour) via pref:
|
||||
* toolkit.framesRecording.bufferSize.
|
||||
* - Note: the first frame-interval may be longer than expected because last
|
||||
* frame
|
||||
* might have been presented some time before calling
|
||||
* StartFrameTimeRecording.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a handle which represents current recording start position.
|
||||
*/
|
||||
virtual uint32_t StartFrameTimeRecording(int32_t aBufferSize);
|
||||
|
||||
/**
|
||||
* Clears, then populates aFrameIntervals with the recorded frame timing
|
||||
* data. The array will be empty if data was overwritten since
|
||||
* aStartIndex was obtained.
|
||||
*/
|
||||
virtual void StopFrameTimeRecording(uint32_t aStartIndex,
|
||||
nsTArray<float>& aFrameIntervals);
|
||||
|
||||
void RecordFrame();
|
||||
|
||||
private:
|
||||
struct FramesTimingRecording {
|
||||
// Stores state and data for frame intervals and paint times recording.
|
||||
// see LayerManager::StartFrameTimeRecording() at Layers.cpp for more
|
||||
// details.
|
||||
FramesTimingRecording()
|
||||
: mNextIndex(0),
|
||||
mLatestStartIndex(0),
|
||||
mCurrentRunStartIndex(0),
|
||||
mIsPaused(true) {}
|
||||
nsTArray<float> mIntervals;
|
||||
TimeStamp mLastFrameTime;
|
||||
uint32_t mNextIndex;
|
||||
uint32_t mLatestStartIndex;
|
||||
uint32_t mCurrentRunStartIndex;
|
||||
bool mIsPaused;
|
||||
};
|
||||
FramesTimingRecording mRecording;
|
||||
};
|
||||
|
||||
/*
|
||||
* Motivation: For truly smooth animation and video playback, we need to
|
||||
* be able to compose frames and render them on a dedicated thread (i.e.
|
||||
@ -204,622 +115,6 @@ class FrameRecorder {
|
||||
* BasicLayerManager for such an implementation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A LayerManager controls a tree of layers. All layers in the tree
|
||||
* must use the same LayerManager.
|
||||
*
|
||||
* All modifications to a layer tree must happen inside a transaction.
|
||||
* Only the state of the layer tree at the end of a transaction is
|
||||
* rendered. Transactions cannot be nested
|
||||
*
|
||||
* Each transaction has two phases:
|
||||
* 1) Construction: layers are created, inserted, removed and have
|
||||
* properties set on them in this phase.
|
||||
* BeginTransaction and BeginTransactionWithTarget start a transaction in
|
||||
* the Construction phase.
|
||||
* 2) Drawing: PaintedLayers are rendered into in this phase, in tree
|
||||
* order. When the client has finished drawing into the PaintedLayers, it should
|
||||
* call EndTransaction to complete the transaction.
|
||||
*
|
||||
* All layer API calls happen on the main thread.
|
||||
*
|
||||
* Layers are refcounted. The layer manager holds a reference to the
|
||||
* root layer, and each container layer holds a reference to its children.
|
||||
*/
|
||||
class LayerManager : public FrameRecorder {
|
||||
NS_INLINE_DECL_REFCOUNTING(LayerManager)
|
||||
|
||||
protected:
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::gfx::IntSize IntSize;
|
||||
typedef mozilla::gfx::SurfaceFormat SurfaceFormat;
|
||||
|
||||
public:
|
||||
LayerManager()
|
||||
: mDestroyed(false),
|
||||
mSnapEffectiveTransforms(true),
|
||||
mId(0),
|
||||
mInTransaction(false),
|
||||
mContainsSVG(false),
|
||||
mPaintedPixelCount(0) {}
|
||||
|
||||
/**
|
||||
* Release layers and resources held by this layer manager, and mark
|
||||
* it as destroyed. Should do any cleanup necessary in preparation
|
||||
* for its widget going away. After this call, only user data calls
|
||||
* are valid on the layer manager.
|
||||
*/
|
||||
virtual void Destroy() {
|
||||
mDestroyed = true;
|
||||
mUserData.Destroy();
|
||||
mRoot = nullptr;
|
||||
mPartialPrerenderedAnimations.Clear();
|
||||
}
|
||||
bool IsDestroyed() { return mDestroyed; }
|
||||
|
||||
virtual ShadowLayerForwarder* AsShadowForwarder() { return nullptr; }
|
||||
|
||||
virtual KnowsCompositor* AsKnowsCompositor() { return nullptr; }
|
||||
|
||||
virtual LayerManagerComposite* AsLayerManagerComposite() { return nullptr; }
|
||||
|
||||
virtual ClientLayerManager* AsClientLayerManager() { return nullptr; }
|
||||
|
||||
virtual BasicLayerManager* AsBasicLayerManager() { return nullptr; }
|
||||
virtual HostLayerManager* AsHostLayerManager() { return nullptr; }
|
||||
|
||||
virtual WebRenderLayerManager* AsWebRenderLayerManager() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Returns true if this LayerManager is owned by an nsIWidget,
|
||||
* and is used for drawing into the widget.
|
||||
*/
|
||||
virtual bool IsWidgetLayerManager() { return true; }
|
||||
virtual bool IsInactiveLayerManager() { return false; }
|
||||
|
||||
/**
|
||||
* Start a new transaction. Nested transactions are not allowed so
|
||||
* there must be no transaction currently in progress.
|
||||
* This transaction will update the state of the window from which
|
||||
* this LayerManager was obtained.
|
||||
*/
|
||||
virtual bool BeginTransaction(const nsCString& aURL = nsCString()) = 0;
|
||||
/**
|
||||
* Start a new transaction. Nested transactions are not allowed so
|
||||
* there must be no transaction currently in progress.
|
||||
* This transaction will render the contents of the layer tree to
|
||||
* the given target context. The rendering will be complete when
|
||||
* EndTransaction returns.
|
||||
*/
|
||||
virtual bool BeginTransactionWithTarget(
|
||||
gfxContext* aTarget, const nsCString& aURL = nsCString()) = 0;
|
||||
|
||||
enum EndTransactionFlags {
|
||||
END_DEFAULT = 0,
|
||||
END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase
|
||||
END_NO_COMPOSITE =
|
||||
1 << 1, // Do not composite after drawing painted layer contents.
|
||||
END_NO_REMOTE_COMPOSITE = 1 << 2 // Do not schedule a composition with a
|
||||
// remote Compositor, if one exists.
|
||||
};
|
||||
|
||||
FrameLayerBuilder* GetLayerBuilder() {
|
||||
return reinterpret_cast<FrameLayerBuilder*>(
|
||||
GetUserData(&gLayerManagerLayerBuilder));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to end an "empty transaction". There must have been no
|
||||
* changes to the layer tree since the BeginTransaction().
|
||||
* It's possible for this to fail; PaintedLayers may need to be updated
|
||||
* due to VRAM data being lost, for example. In such cases this method
|
||||
* returns false, and the caller must proceed with a normal layer tree
|
||||
* update and EndTransaction.
|
||||
*/
|
||||
virtual bool EndEmptyTransaction(
|
||||
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
||||
|
||||
/**
|
||||
* Function called to draw the contents of each PaintedLayer.
|
||||
* aRegionToDraw contains the region that needs to be drawn.
|
||||
* This would normally be a subregion of the visible region.
|
||||
* The callee must draw all of aRegionToDraw. Drawing outside
|
||||
* aRegionToDraw will be clipped out or ignored.
|
||||
* The callee must draw all of aRegionToDraw.
|
||||
* This region is relative to 0,0 in the PaintedLayer.
|
||||
*
|
||||
* aDirtyRegion should contain the total region that is be due to be painted
|
||||
* during the transaction, even though only aRegionToDraw should be drawn
|
||||
* during this call. aRegionToDraw must be entirely contained within
|
||||
* aDirtyRegion. If the total dirty region is unknown it is okay to pass a
|
||||
* subregion of the total dirty region, e.g. just aRegionToDraw, though it
|
||||
* may not be as efficient.
|
||||
*
|
||||
* aRegionToInvalidate contains a region whose contents have been
|
||||
* changed by the layer manager and which must therefore be invalidated.
|
||||
* For example, this could be non-empty if a retained layer internally
|
||||
* switches from RGBA to RGB or back ... we might want to repaint it to
|
||||
* consistently use subpixel-AA or not.
|
||||
* This region is relative to 0,0 in the PaintedLayer.
|
||||
* aRegionToInvalidate may contain areas that are outside
|
||||
* aRegionToDraw; the callee must ensure that these areas are repainted
|
||||
* in the current layer manager transaction or in a later layer
|
||||
* manager transaction.
|
||||
*
|
||||
* aContext must not be used after the call has returned.
|
||||
* We guarantee that buffered contents in the visible
|
||||
* region are valid once drawing is complete.
|
||||
*
|
||||
* The origin of aContext is 0,0 in the PaintedLayer.
|
||||
*/
|
||||
typedef void (*DrawPaintedLayerCallback)(
|
||||
PaintedLayer* aLayer, gfxContext* aContext,
|
||||
const nsIntRegion& aRegionToDraw, const nsIntRegion& aDirtyRegion,
|
||||
DrawRegionClip aClip, const nsIntRegion& aRegionToInvalidate,
|
||||
void* aCallbackData);
|
||||
|
||||
/**
|
||||
* Finish the construction phase of the transaction, perform the
|
||||
* drawing phase, and end the transaction.
|
||||
* During the drawing phase, all PaintedLayers in the tree are
|
||||
* drawn in tree order, exactly once each, except for those layers
|
||||
* where it is known that the visible region is empty.
|
||||
*/
|
||||
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
||||
void* aCallbackData,
|
||||
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
||||
|
||||
/**
|
||||
* Schedule a composition with the remote Compositor, if one exists
|
||||
* for this LayerManager. Useful in conjunction with the
|
||||
* END_NO_REMOTE_COMPOSITE flag to EndTransaction.
|
||||
*/
|
||||
virtual void ScheduleComposite() {}
|
||||
|
||||
virtual void SetNeedsComposite(bool aNeedsComposite) {}
|
||||
virtual bool NeedsComposite() const { return false; }
|
||||
|
||||
virtual bool HasShadowManagerInternal() const { return false; }
|
||||
bool HasShadowManager() const { return HasShadowManagerInternal(); }
|
||||
virtual void StorePluginWidgetConfigurations(
|
||||
const nsTArray<nsIWidget::Configuration>& aConfigurations) {}
|
||||
bool IsSnappingEffectiveTransforms() { return mSnapEffectiveTransforms; }
|
||||
|
||||
/**
|
||||
* Returns true if the underlying platform can properly support layers with
|
||||
* SurfaceMode::SURFACE_COMPONENT_ALPHA.
|
||||
*/
|
||||
static bool LayersComponentAlphaEnabled();
|
||||
|
||||
/**
|
||||
* Returns true if this LayerManager can properly support layers with
|
||||
* SurfaceMode::SURFACE_COMPONENT_ALPHA. LayerManagers that can't will use
|
||||
* transparent surfaces (and lose subpixel-AA for text).
|
||||
*/
|
||||
virtual bool AreComponentAlphaLayersEnabled();
|
||||
|
||||
/**
|
||||
* Returns true if this LayerManager always requires an intermediate surface
|
||||
* to render blend operations.
|
||||
*/
|
||||
virtual bool BlendingRequiresIntermediateSurface() { return false; }
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Set the root layer. The root layer is initially null. If there is
|
||||
* no root layer, EndTransaction won't draw anything.
|
||||
*/
|
||||
virtual void SetRoot(Layer* aLayer) = 0;
|
||||
/**
|
||||
* Can be called anytime
|
||||
*/
|
||||
Layer* GetRoot() { return mRoot; }
|
||||
|
||||
/**
|
||||
* Does a breadth-first search from the root layer to find the first
|
||||
* scrollable layer, and returns its ViewID. Note that there may be
|
||||
* other layers in the tree which share the same ViewID.
|
||||
* Can be called any time.
|
||||
*/
|
||||
ScrollableLayerGuid::ViewID GetRootScrollableLayerId();
|
||||
|
||||
/**
|
||||
* Returns a LayerMetricsWrapper containing the Root
|
||||
* Content Documents layer.
|
||||
*/
|
||||
LayerMetricsWrapper GetRootContentLayer();
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Called when a managee has mutated.
|
||||
* Subclasses overriding this method must first call their
|
||||
* superclass's impl
|
||||
*/
|
||||
virtual void Mutated(Layer* aLayer) {}
|
||||
virtual void MutatedSimple(Layer* aLayer) {}
|
||||
|
||||
/**
|
||||
* Hints that can be used during PaintedLayer creation to influence the type
|
||||
* or properties of the layer created.
|
||||
*
|
||||
* NONE: No hint.
|
||||
* SCROLLABLE: This layer may represent scrollable content.
|
||||
*/
|
||||
enum PaintedLayerCreationHint { NONE, SCROLLABLE };
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a PaintedLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a PaintedLayer for this manager's layer tree, with a creation hint
|
||||
* parameter to help optimise the type of layer created.
|
||||
*/
|
||||
virtual already_AddRefed<PaintedLayer> CreatePaintedLayerWithHint(
|
||||
PaintedLayerCreationHint) {
|
||||
return CreatePaintedLayer();
|
||||
}
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a ContainerLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create an ImageLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ImageLayer> CreateImageLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a ColorLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a CanvasLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a ReadbackLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() {
|
||||
return nullptr;
|
||||
}
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Create a RefLayer for this manager's layer tree.
|
||||
*/
|
||||
virtual already_AddRefed<RefLayer> CreateRefLayer() { return nullptr; }
|
||||
/**
|
||||
* Can be called anytime, from any thread.
|
||||
*
|
||||
* Creates an Image container which forwards its images to the compositor
|
||||
* within layer transactions on the main thread or asynchronously using the
|
||||
* ImageBridge IPDL protocol. In the case of asynchronous, If the protocol is
|
||||
* not available, the returned ImageContainer will forward images within layer
|
||||
* transactions.
|
||||
*/
|
||||
static already_AddRefed<ImageContainer> CreateImageContainer(
|
||||
ImageContainer::Mode flag = ImageContainer::SYNCHRONOUS);
|
||||
|
||||
/**
|
||||
* Type of layer manager his is. This is to be used sparsely in order to
|
||||
* avoid a lot of Layers backend specific code. It should be used only when
|
||||
* Layers backend specific functionality is necessary.
|
||||
*/
|
||||
virtual LayersBackend GetBackendType() = 0;
|
||||
|
||||
/**
|
||||
* Type of layers backend that will be used to composite this layer tree.
|
||||
* When compositing is done remotely, then this returns the layers type
|
||||
* of the compositor.
|
||||
*/
|
||||
virtual LayersBackend GetCompositorBackendType() { return GetBackendType(); }
|
||||
|
||||
/**
|
||||
* Creates a DrawTarget which is optimized for inter-operating with this
|
||||
* layer manager.
|
||||
*/
|
||||
virtual already_AddRefed<DrawTarget> CreateOptimalDrawTarget(
|
||||
const IntSize& aSize, SurfaceFormat imageFormat);
|
||||
|
||||
/**
|
||||
* Creates a DrawTarget for alpha masks which is optimized for inter-
|
||||
* operating with this layer manager. In contrast to CreateOptimalDrawTarget,
|
||||
* this surface is optimised for drawing alpha only and we assume that
|
||||
* drawing the mask is fairly simple.
|
||||
*/
|
||||
virtual already_AddRefed<DrawTarget> CreateOptimalMaskDrawTarget(
|
||||
const IntSize& aSize);
|
||||
|
||||
/**
|
||||
* Creates a DrawTarget for use with canvas which is optimized for
|
||||
* inter-operating with this layermanager.
|
||||
*/
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget(
|
||||
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
|
||||
|
||||
/**
|
||||
* Creates a PersistentBufferProvider for use with canvas which is optimized
|
||||
* for inter-operating with this layermanager.
|
||||
*/
|
||||
virtual already_AddRefed<PersistentBufferProvider>
|
||||
CreatePersistentBufferProvider(const mozilla::gfx::IntSize& aSize,
|
||||
mozilla::gfx::SurfaceFormat aFormat);
|
||||
|
||||
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the maximum texture size on this layer backend, or INT32_MAX
|
||||
* if there is no maximum
|
||||
*/
|
||||
virtual int32_t GetMaxTextureSize() const = 0;
|
||||
|
||||
/**
|
||||
* Return the name of the layer manager's backend.
|
||||
*/
|
||||
virtual void GetBackendName(nsAString& aName) = 0;
|
||||
|
||||
/**
|
||||
* This setter can be used anytime. The user data for all keys is
|
||||
* initially null. Ownership pases to the layer manager.
|
||||
*/
|
||||
void SetUserData(void* aKey, LayerUserData* aData) {
|
||||
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData,
|
||||
LayerUserDataDestroy);
|
||||
}
|
||||
/**
|
||||
* This can be used anytime. Ownership passes to the caller!
|
||||
*/
|
||||
UniquePtr<LayerUserData> RemoveUserData(void* aKey);
|
||||
|
||||
/**
|
||||
* This getter can be used anytime.
|
||||
*/
|
||||
bool HasUserData(void* aKey) {
|
||||
return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
|
||||
}
|
||||
/**
|
||||
* This getter can be used anytime. Ownership is retained by the layer
|
||||
* manager.
|
||||
*/
|
||||
LayerUserData* GetUserData(void* aKey) const {
|
||||
return static_cast<LayerUserData*>(
|
||||
mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called outside of a layers transaction.
|
||||
*
|
||||
* For the subtree rooted at |aSubtree|, this attempts to free up
|
||||
* any free-able resources like retained buffers, but may do nothing
|
||||
* at all. After this call, the layer tree is left in an undefined
|
||||
* state; the layers in |aSubtree|'s subtree may no longer have
|
||||
* buffers with valid content and may no longer be able to draw
|
||||
* their visible and valid regions.
|
||||
*
|
||||
* In general, a painting or forwarding transaction on |this| must
|
||||
* complete on the tree before it returns to a valid state.
|
||||
*
|
||||
* Resource freeing begins from |aSubtree| or |mRoot| if |aSubtree|
|
||||
* is null. |aSubtree|'s manager must be this.
|
||||
*/
|
||||
virtual void ClearCachedResources(Layer* aSubtree = nullptr) {}
|
||||
|
||||
/**
|
||||
* Flag the next paint as the first for a document.
|
||||
*/
|
||||
virtual void SetIsFirstPaint() {}
|
||||
virtual bool GetIsFirstPaint() const { return false; }
|
||||
|
||||
/**
|
||||
* Set the current focus target to be sent with the next paint.
|
||||
*/
|
||||
virtual void SetFocusTarget(const FocusTarget& aFocusTarget) {}
|
||||
|
||||
/**
|
||||
* Make sure that the previous transaction has been entirely
|
||||
* completed.
|
||||
*
|
||||
* Note: This may sychronously wait on a remote compositor
|
||||
* to complete rendering.
|
||||
*/
|
||||
virtual void FlushRendering() {}
|
||||
|
||||
/**
|
||||
* Make sure that the previous transaction has been
|
||||
* received. This will synchronsly wait on a remote compositor. */
|
||||
virtual void WaitOnTransactionProcessed() {}
|
||||
|
||||
virtual void SendInvalidRegion(const nsIntRegion& aRegion) {}
|
||||
|
||||
/**
|
||||
* Checks if we need to invalidate the OS widget to trigger
|
||||
* painting when updating this layer manager.
|
||||
*/
|
||||
virtual bool NeedsWidgetInvalidation() { return true; }
|
||||
|
||||
virtual const char* Name() const { return "???"; }
|
||||
|
||||
/**
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
* aStream.
|
||||
*/
|
||||
void Dump(std::stringstream& aStream, const char* aPrefix = "",
|
||||
bool aDumpHtml = false, bool aSorted = false);
|
||||
/**
|
||||
* Dump information about just this layer manager itself to aStream
|
||||
*/
|
||||
void DumpSelf(std::stringstream& aStream, const char* aPrefix = "",
|
||||
bool aSorted = false);
|
||||
void Dump(bool aSorted = false);
|
||||
|
||||
/**
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
* layerscope packet.
|
||||
*/
|
||||
void Dump(layerscope::LayersPacket* aPacket);
|
||||
|
||||
/**
|
||||
* Log information about this layer manager and its managed tree to
|
||||
* the NSPR log (if enabled for "Layers").
|
||||
*/
|
||||
void Log(const char* aPrefix = "");
|
||||
/**
|
||||
* Log information about just this layer manager itself to the NSPR
|
||||
* log (if enabled for "Layers").
|
||||
*/
|
||||
void LogSelf(const char* aPrefix = "");
|
||||
|
||||
static bool IsLogEnabled();
|
||||
static mozilla::LogModule* GetLog();
|
||||
|
||||
bool IsCompositingCheap(LayersBackend aBackend) {
|
||||
// LayersBackend::LAYERS_NONE is an error state, but in that case we should
|
||||
// try to avoid loading the compositor!
|
||||
return LayersBackend::LAYERS_BASIC != aBackend &&
|
||||
LayersBackend::LAYERS_NONE != aBackend;
|
||||
}
|
||||
|
||||
virtual bool IsCompositingCheap() { return true; }
|
||||
|
||||
bool IsInTransaction() const { return mInTransaction; }
|
||||
virtual void GetFrameUniformity(FrameUniformityData* aOutData) {}
|
||||
|
||||
virtual void SetRegionToClear(const nsIntRegion& aRegion) {
|
||||
mRegionToClear = aRegion;
|
||||
}
|
||||
|
||||
virtual float RequestProperty(const nsAString& property) { return -1; }
|
||||
|
||||
const TimeStamp& GetAnimationReadyTime() const { return mAnimationReadyTime; }
|
||||
|
||||
virtual bool AsyncPanZoomEnabled() const { return false; }
|
||||
|
||||
static void LayerUserDataDestroy(void* data);
|
||||
|
||||
void AddPaintedPixelCount(int32_t aCount) { mPaintedPixelCount += aCount; }
|
||||
|
||||
uint32_t GetAndClearPaintedPixelCount() {
|
||||
uint32_t count = mPaintedPixelCount;
|
||||
mPaintedPixelCount = 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
virtual void SetLayersObserverEpoch(LayersObserverEpoch aEpoch) {}
|
||||
|
||||
virtual void DidComposite(TransactionId aTransactionId,
|
||||
const mozilla::TimeStamp& aCompositeStart,
|
||||
const mozilla::TimeStamp& aCompositeEnd) {}
|
||||
|
||||
virtual void AddDidCompositeObserver(DidCompositeObserver* aObserver) {
|
||||
MOZ_CRASH("GFX: LayerManager");
|
||||
}
|
||||
virtual void RemoveDidCompositeObserver(DidCompositeObserver* aObserver) {
|
||||
MOZ_CRASH("GFX: LayerManager");
|
||||
}
|
||||
|
||||
virtual void UpdateTextureFactoryIdentifier(
|
||||
const TextureFactoryIdentifier& aNewIdentifier) {}
|
||||
|
||||
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() {
|
||||
return TextureFactoryIdentifier();
|
||||
}
|
||||
|
||||
virtual void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) {}
|
||||
|
||||
virtual TransactionId GetLastTransactionId() { return TransactionId{0}; }
|
||||
|
||||
virtual CompositorBridgeChild* GetCompositorBridgeChild() { return nullptr; }
|
||||
|
||||
void RegisterPayload(const CompositionPayload& aPayload) {
|
||||
mPayload.AppendElement(aPayload);
|
||||
MOZ_ASSERT(mPayload.Length() < 10000);
|
||||
}
|
||||
|
||||
void RegisterPayloads(const nsTArray<CompositionPayload>& aPayload) {
|
||||
mPayload.AppendElements(aPayload);
|
||||
MOZ_ASSERT(mPayload.Length() < 10000);
|
||||
}
|
||||
|
||||
virtual void PayloadPresented();
|
||||
|
||||
void SetContainsSVG(bool aContainsSVG) { mContainsSVG = aContainsSVG; }
|
||||
|
||||
void AddPartialPrerenderedAnimation(uint64_t aCompositorAnimationId,
|
||||
dom::Animation* aAnimation);
|
||||
void RemovePartialPrerenderedAnimation(uint64_t aCompositorAnimationId,
|
||||
dom::Animation* aAnimation);
|
||||
void UpdatePartialPrerenderedAnimations(
|
||||
const nsTArray<uint64_t>& aJankedAnimations);
|
||||
|
||||
protected:
|
||||
RefPtr<Layer> mRoot;
|
||||
gfx::UserData mUserData;
|
||||
bool mDestroyed;
|
||||
bool mSnapEffectiveTransforms;
|
||||
|
||||
nsIntRegion mRegionToClear;
|
||||
|
||||
// Protected destructor, to discourage deletion outside of Release():
|
||||
virtual ~LayerManager() = default;
|
||||
|
||||
// Print interesting information about this into aStreamo. Internally
|
||||
// used to implement Dump*() and Log*().
|
||||
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
||||
|
||||
// Print interesting information about this into layerscope packet.
|
||||
// Internally used to implement Dump().
|
||||
virtual void DumpPacket(layerscope::LayersPacket* aPacket);
|
||||
|
||||
uint64_t mId;
|
||||
bool mInTransaction;
|
||||
|
||||
// Used for tracking CONTENT_FRAME_TIME_WITH_SVG
|
||||
bool mContainsSVG;
|
||||
// The time when painting most recently finished. This is recorded so that
|
||||
// we can time any play-pending animations from this point.
|
||||
TimeStamp mAnimationReadyTime;
|
||||
// The count of pixels that were painted in the current transaction.
|
||||
uint32_t mPaintedPixelCount;
|
||||
// The payload associated with currently pending painting work, for
|
||||
// client layer managers that typically means payload that is part of the
|
||||
// 'upcoming transaction', for HostLayerManagers this typically means
|
||||
// what has been included in received transactions to be presented on the
|
||||
// next composite.
|
||||
// IMPORTANT: Clients should take care to clear this or risk it slowly
|
||||
// growing out of control.
|
||||
nsTArray<CompositionPayload> mPayload;
|
||||
// Transform animations which are not fully pre-rendered because it's on a
|
||||
// large frame. We need to update the pre-rendered area once after we tried
|
||||
// to composite area which is outside of the pre-rendered area on the
|
||||
// compositor.
|
||||
nsRefPtrHashtable<nsUint64HashKey, dom::Animation>
|
||||
mPartialPrerenderedAnimations;
|
||||
|
||||
public:
|
||||
/*
|
||||
* Methods to store/get/clear a "pending scroll info update" object on a
|
||||
* per-scrollid basis. This is used for empty transactions that push over
|
||||
* scroll position updates to the APZ code.
|
||||
*/
|
||||
virtual bool AddPendingScrollUpdateForNextTransaction(
|
||||
ScrollableLayerGuid::ViewID aScrollId,
|
||||
const ScrollPositionUpdate& aUpdateInfo);
|
||||
Maybe<nsTArray<ScrollPositionUpdate>> GetPendingScrollInfoUpdate(
|
||||
ScrollableLayerGuid::ViewID aScrollId);
|
||||
std::unordered_set<ScrollableLayerGuid::ViewID>
|
||||
ClearPendingScrollInfoUpdate();
|
||||
|
||||
protected:
|
||||
ScrollUpdatesMap mPendingScrollUpdates;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Layer represents anything that can be rendered onto a destination
|
||||
* surface.
|
||||
|
@ -7,7 +7,7 @@
|
||||
#ifndef GFX_UPDATEIMAGEHELPER_H
|
||||
#define GFX_UPDATEIMAGEHELPER_H
|
||||
|
||||
#include "Layers.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/ImageClient.h"
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
||||
|
@ -7,15 +7,24 @@
|
||||
#ifndef GFX_BASICIMPLDATA_H
|
||||
#define GFX_BASICIMPLDATA_H
|
||||
|
||||
#include "Layers.h" // for Layer (ptr only), etc
|
||||
#include "gfxContext.h" // for gfxContext, etc
|
||||
#include "nsDebug.h" // for NS_ASSERTION
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/gfx/Point.h" // for Point
|
||||
#include "mozilla/gfx/Types.h" // for CompositionOp, CompositionOp::OP_OVER, CompositionOp::OP_SOURCE
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager, LayerManager::DrawPaintedLayerCallback
|
||||
#include "nsDebug.h" // for NS_ASSERTION
|
||||
#include "nsISupports.h" // for MOZ_COUNTED_DTOR_VIRTUAL, MOZ_COUNT_CTOR
|
||||
|
||||
class gfxContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
class SourceSurface;
|
||||
} // namespace gfx
|
||||
|
||||
namespace layers {
|
||||
|
||||
class Layer;
|
||||
class ReadbackProcessor;
|
||||
|
||||
/**
|
||||
|
@ -8,12 +8,12 @@
|
||||
#define GFX_BASICLAYERS_H
|
||||
|
||||
#include <stdint.h> // for INT32_MAX, int32_t
|
||||
#include "Layers.h" // for Layer (ptr only), etc
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxContext.h" // for gfxContext
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/WidgetUtils.h" // for ScreenRotation
|
||||
#include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc
|
||||
#include "gfxContext.h" // for gfxContext
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/WidgetUtils.h" // for ScreenRotation
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager::DrawPaintedLayerCallback, LayerManager::END_DEFAULT, LayerManager::EndTra...
|
||||
#include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
@ -26,9 +26,14 @@ class nsIWidget;
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class CanvasLayer;
|
||||
class ColorLayer;
|
||||
class ContainerLayer;
|
||||
class ImageFactory;
|
||||
class ImageLayer;
|
||||
class Layer;
|
||||
class PaintLayerContext;
|
||||
class PaintedLayer;
|
||||
class ReadbackLayer;
|
||||
|
||||
/**
|
||||
|
@ -895,5 +895,9 @@ ClientLayerManager::CreatePersistentBufferProvider(const gfx::IntSize& aSize,
|
||||
|
||||
ClientLayer::~ClientLayer() { MOZ_COUNT_DTOR(ClientLayer); }
|
||||
|
||||
ClientLayer* ClientLayer::ToClientLayer(Layer* aLayer) {
|
||||
return static_cast<ClientLayer*>(aLayer->ImplData());
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -7,38 +7,57 @@
|
||||
#ifndef GFX_CLIENTLAYERMANAGER_H
|
||||
#define GFX_CLIENTLAYERMANAGER_H
|
||||
|
||||
#include <stdint.h> // for int32_t
|
||||
#include "Layers.h"
|
||||
#include "gfxContext.h" // for gfxContext
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/LinkedList.h" // for LinkedList
|
||||
#include "mozilla/StaticPrefs_apz.h"
|
||||
#include "mozilla/WidgetUtils.h" // for ScreenRotation
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/FocusTarget.h" // for FocusTarget
|
||||
#include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc
|
||||
#include "mozilla/layers/PaintThread.h" // For PaintThread
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder, etc
|
||||
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
||||
#include "mozilla/layers/MemoryPressureObserver.h"
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsISupportsImpl.h" // for Layer::Release, etc
|
||||
#include "nsRect.h" // for mozilla::gfx::IntRect
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "nscore.h" // for nsAString
|
||||
#include "mozilla/layers/TransactionIdAllocator.h"
|
||||
#include "nsIWidget.h" // For plugin window configuration information structs
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdint> // for uint32_t, int32_t
|
||||
#include <new> // for operator new
|
||||
#include <string> // for string
|
||||
#include <utility> // for forward
|
||||
#include "gfxContext.h" // for gfxContext
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp, BaseTimeDuration
|
||||
#include "mozilla/WidgetUtils.h" // for ScreenRotation
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "mozilla/layers/APZTestData.h" // for APZTestData, SequenceNumber
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureFactoryIdentifier
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager::DrawPaintedLayerCallback, DidCompositeObserver (ptr only), Laye...
|
||||
#include "mozilla/layers/LayersTypes.h" // for LayerHandle, LayersBackend, TransactionId, BufferMode, LayersBackend::LAYERS_...
|
||||
#include "mozilla/layers/MemoryPressureObserver.h" // for MemoryPressureListener, MemoryPressureObserver (ptr only), MemoryPressureReason
|
||||
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid::ViewID
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder, ShadowableLayer
|
||||
#include "nsISupports.h" // for MOZ_COUNTED_DEFAULT_CTOR
|
||||
#include "nsIThread.h" // for TimeDuration
|
||||
#include "nsIWidget.h" // for nsIWidget
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsStringFwd.h" // for nsCString, nsAString
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
|
||||
class nsDisplayListBuilder;
|
||||
// XXX Includes that could be avoided by moving function implementation to the
|
||||
// cpp file.
|
||||
#include "mozilla/StaticPrefs_apz.h" // for apz_test_logging_enabled
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class CanvasLayer;
|
||||
class ColorLayer;
|
||||
class ContainerLayer;
|
||||
class ClientPaintedLayer;
|
||||
class CompositorBridgeChild;
|
||||
class ImageLayer;
|
||||
class FocusTarget;
|
||||
class FrameUniformityData;
|
||||
class ImageLayer;
|
||||
class Layer;
|
||||
class PCompositorBridgeChild;
|
||||
class PaintTiming;
|
||||
class PaintedLayer;
|
||||
class PersistentBufferProvider;
|
||||
class ReadbackLayer;
|
||||
class ReadbackProcessor;
|
||||
class RefLayer;
|
||||
class TransactionIdAllocator;
|
||||
|
||||
class ClientLayerManager final : public LayerManager,
|
||||
public MemoryPressureListener {
|
||||
@ -356,9 +375,7 @@ class ClientLayer : public ShadowableLayer {
|
||||
|
||||
virtual ClientPaintedLayer* AsThebes() { return nullptr; }
|
||||
|
||||
static inline ClientLayer* ToClientLayer(Layer* aLayer) {
|
||||
return static_cast<ClientLayer*>(aLayer->ImplData());
|
||||
}
|
||||
static ClientLayer* ToClientLayer(Layer* aLayer);
|
||||
|
||||
template <typename LayerType>
|
||||
static inline void RenderMaskLayers(LayerType* aLayer) {
|
||||
|
@ -7,42 +7,36 @@
|
||||
#ifndef MOZILLA_GFX_TILEDCONTENTCLIENT_H
|
||||
#define MOZILLA_GFX_TILEDCONTENTCLIENT_H
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdint.h> // for uint16_t
|
||||
#include <algorithm> // for swap
|
||||
#include <limits>
|
||||
#include "Layers.h" // for LayerManager, etc
|
||||
#include "TiledLayerBuffer.h" // for TiledLayerBuffer
|
||||
#include "Units.h" // for CSSPoint
|
||||
#include "gfxTypes.h"
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/gfx/2D.h" // for gfx::Tile
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/ipc/Shmem.h" // for Shmem
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory
|
||||
#include "mozilla/layers/APZUtils.h" // for AsyncTransform
|
||||
#include <cstdint> // for uint64_t, uint16_t, uint8_t
|
||||
#include <iosfwd> // for stringstream
|
||||
#include <utility> // for move
|
||||
#include "ClientLayerManager.h" // for ClientLayerManager
|
||||
#include "Units.h" // for CSSToParentLayerScale2D, ParentLayerPoint, LayerIntRect, LayerRect, LayerToParent...
|
||||
#include "gfxTypes.h" // for gfxContentType, gfxContentType::COLOR
|
||||
#include "mozilla/Maybe.h" // for Maybe
|
||||
#include "mozilla/RefPtr.h" // for RefPtr, operator==, operator!=
|
||||
#include "mozilla/TypedEnumBits.h" // for CastableTypedEnumResult, UnsignedIntegerTypeForEnum, MOZ_MAKE_ENUM_CLASS_BITWISE_...
|
||||
#include "mozilla/gfx/2D.h" // for DrawTarget, DrawTargetCapture
|
||||
#include "mozilla/gfx/Rect.h" // for IntRect
|
||||
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
|
||||
#include "mozilla/layers/LayersMessages.h" // for TileDescriptor
|
||||
#include "mozilla/layers/LayersTypes.h" // for TextureDumpMode
|
||||
#include "mozilla/layers/PaintThread.h" // for CapturedTiledPaintState
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
#include "mozilla/layers/TextureClientPool.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_DTOR
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsRect.h" // for mozilla::gfx::IntRect
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
|
||||
#include "nsExpirationTracker.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, CompositableType, CompositableType::CONTENT_TILED
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager, LayerManager::DrawPaintedLayerCallback
|
||||
#include "mozilla/layers/LayersMessages.h" // for TileDescriptor
|
||||
#include "mozilla/layers/LayersTypes.h" // for SurfaceMode, TextureDumpMode, Compress, SurfaceMode::SURFACE_OPAQUE
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
||||
#include "mozilla/layers/TextureClientPool.h" // for TextureClientAllocator
|
||||
#include "nsExpirationTracker.h" // for nsExpirationState
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsTArray.h" // for AutoTArray, nsTArray (ptr only)
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class ClientTiledPaintedLayer;
|
||||
class ClientLayerManager;
|
||||
class LayerMetricsWrapper;
|
||||
struct AsyncTransform;
|
||||
struct FrameMetrics;
|
||||
|
||||
enum class TilePaintFlags : uint8_t {
|
||||
None = 0x0,
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "mozilla/layers/LayerManagerCompositeUtils.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsAString.h"
|
||||
#include "mozilla/RefPtr.h" // for nsRefPtr
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
|
@ -13,8 +13,9 @@
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticFlags::COLOR
|
||||
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "UnitTransforms.h" // for ViewAs
|
||||
#include "mozilla/layers/LayerManagerCompositeUtils.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "UnitTransforms.h" // for ViewAs
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
|
||||
#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget
|
||||
#include "mozilla/layers/APZUtils.h" // for AsyncTransform
|
||||
#include "mozilla/layers/LayerManagerCompositeUtils.h"
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "mozilla/layers/LayersHelpers.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
|
@ -5,18 +5,19 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ImageLayerComposite.h"
|
||||
#include "CompositableHost.h" // for CompositableHost
|
||||
#include "Layers.h" // for WriteSnapshotToDumpFile, etc
|
||||
#include "gfx2DGlue.h" // for ToFilter
|
||||
#include "gfxEnv.h" // for gfxEnv
|
||||
#include "gfxRect.h" // for gfxRect
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Point.h" // for IntSize, Point
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/layers/ImageHost.h" // for ImageHost
|
||||
#include "CompositableHost.h" // for CompositableHost
|
||||
#include "Layers.h" // for WriteSnapshotToDumpFile, etc
|
||||
#include "gfx2DGlue.h" // for ToFilter
|
||||
#include "gfxEnv.h" // for gfxEnv
|
||||
#include "gfxRect.h" // for gfxRect
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Point.h" // for IntSize, Point
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/layers/ImageHost.h" // for ImageHost
|
||||
#include "mozilla/layers/LayerManagerCompositeUtils.h"
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsAString.h"
|
||||
|
@ -591,6 +591,8 @@ void LayerManagerComposite::EndTransaction(const TimeStamp& aTimeStamp,
|
||||
#endif
|
||||
}
|
||||
|
||||
void LayerManagerComposite::SetRoot(Layer* aLayer) { mRoot = aLayer; }
|
||||
|
||||
void LayerManagerComposite::UpdateAndRender() {
|
||||
mCompositionOpportunityId = mCompositionOpportunityId.Next();
|
||||
|
||||
|
@ -7,36 +7,37 @@
|
||||
#ifndef GFX_LayerManagerComposite_H
|
||||
#define GFX_LayerManagerComposite_H
|
||||
|
||||
#include <stdint.h> // for int32_t, uint32_t
|
||||
#include "CompositableHost.h" // for CompositableHost, ImageCompositeNotificationInfo
|
||||
#include "GLDefs.h" // for GLenum
|
||||
#include "Layers.h"
|
||||
#include "Units.h" // for ParentLayerIntRect
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "mozilla/layers/CompositionRecorder.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/layers/LayersMessages.h"
|
||||
#include "mozilla/layers/LayersTypes.h" // for LayersBackend, etc
|
||||
#include "mozilla/Maybe.h" // for Maybe
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsAString.h"
|
||||
#include "mozilla/RefPtr.h" // for nsRefPtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsDebug.h" // for NS_ASSERTION
|
||||
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
|
||||
#include "nsRect.h" // for mozilla::gfx::IntRect
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nscore.h" // for nsAString, etc
|
||||
#include "LayerTreeInvalidation.h"
|
||||
#include "mozilla/layers/ScreenshotGrabber.h"
|
||||
#include <cstdint> // for uint64_t, int32_t
|
||||
#include <deque> // for deque
|
||||
#include <new> // for operator new
|
||||
#include <type_traits> // for remove_reference<>::type
|
||||
#include <utility> // for move, forward
|
||||
#include "CompositableHost.h" // for ImageCompositeNotificationInfo
|
||||
#include "Units.h" // for LayerIntRegion, ParentLayerIntRect, RenderTargetIntRect
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Assertions.h" // for MOZ_CRASH, AssertionConditionType, MOZ_ASSERT, MOZ_AS...
|
||||
#include "mozilla/Maybe.h" // for Maybe
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp, BaseTimeDuration
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr
|
||||
#include "mozilla/gfx/2D.h" // for DrawTarget
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Polygon.h" // for Polygon
|
||||
#include "mozilla/gfx/Rect.h" // for IntRect
|
||||
#include "mozilla/gfx/Types.h" // for DeviceColor (ptr only), SurfaceFormat
|
||||
#include "mozilla/layers/CompositionRecorder.h" // for CompositionRecorder, CollectedFrames (ptr only)
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticTypes, TextureFactoryIdentifier
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager::END_DEFAULT, LayerManager::EndTransacti...
|
||||
#include "mozilla/layers/LayersTypes.h" // for CompositionOpportunityId, LayersBackend, LayersBacken...
|
||||
#include "mozilla/layers/ScreenshotGrabber.h" // for ScreenshotGrabber
|
||||
#include "nsDebug.h" // for NS_WARNING
|
||||
#include "nsIThread.h" // for TimeDuration
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsRegionFwd.h" // for IntRegion
|
||||
#include "nsStringFwd.h" // for nsCString, nsAString
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
|
||||
class gfxContext;
|
||||
|
||||
@ -45,30 +46,37 @@ class gfxContext;
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
} // namespace gfx
|
||||
|
||||
namespace layers {
|
||||
|
||||
class CanvasLayer;
|
||||
class CanvasLayerComposite;
|
||||
class ColorLayer;
|
||||
class ColorLayerComposite;
|
||||
class Compositor;
|
||||
class ContainerLayer;
|
||||
class ContainerLayerComposite;
|
||||
class Diagnostics;
|
||||
struct EffectChain;
|
||||
class ImageLayer;
|
||||
class ImageLayerComposite;
|
||||
class LayerComposite;
|
||||
class NativeLayer;
|
||||
class NativeLayerRoot;
|
||||
class RefLayerComposite;
|
||||
class PaintTiming;
|
||||
class PaintedLayer;
|
||||
class PaintedLayerComposite;
|
||||
class RefLayer;
|
||||
class SurfacePoolHandle;
|
||||
class TextRenderer;
|
||||
class TextureSourceProvider;
|
||||
class CompositingRenderTarget;
|
||||
struct FPSState;
|
||||
class PaintCounter;
|
||||
class LayerMLGPU;
|
||||
class LayerManagerMLGPU;
|
||||
class UiCompositorControllerParent;
|
||||
class Layer;
|
||||
struct LayerProperties;
|
||||
|
||||
static const int kVisualWarningDuration = 150; // ms
|
||||
|
||||
@ -289,7 +297,7 @@ class LayerManagerComposite final : public HostLayerManager {
|
||||
MOZ_CRASH("GFX: Use EndTransaction(aTimeStamp)");
|
||||
}
|
||||
|
||||
void SetRoot(Layer* aLayer) override { mRoot = aLayer; }
|
||||
void SetRoot(Layer* aLayer) override;
|
||||
|
||||
// XXX[nrc]: never called, we should move this logic to ClientLayerManager
|
||||
// (bug 946926).
|
||||
@ -700,138 +708,6 @@ class LayerComposite : public HostLayer {
|
||||
gfx::IntRect mClearRect;
|
||||
};
|
||||
|
||||
// Render aLayer using aCompositor and apply all mask layers of aLayer: The
|
||||
// layer's own mask layer (aLayer->GetMaskLayer()), and any ancestor mask
|
||||
// layers.
|
||||
// If more than one mask layer needs to be applied, we use intermediate surfaces
|
||||
// (CompositingRenderTargets) for rendering, applying one mask layer at a time.
|
||||
// Callers need to provide a callback function aRenderCallback that does the
|
||||
// actual rendering of the source. It needs to have the following form:
|
||||
// void (EffectChain& effectChain, const Rect& clipRect)
|
||||
// aRenderCallback is called exactly once, inside this function, unless aLayer's
|
||||
// visible region is completely clipped out (in that case, aRenderCallback won't
|
||||
// be called at all).
|
||||
// This function calls aLayer->AsHostLayer()->AddBlendModeEffect for the
|
||||
// final rendering pass.
|
||||
//
|
||||
// (This function should really live in LayerManagerComposite.cpp, but we
|
||||
// need to use templates for passing lambdas until bug 1164522 is resolved.)
|
||||
template <typename RenderCallbackType>
|
||||
void RenderWithAllMasks(Layer* aLayer, Compositor* aCompositor,
|
||||
const gfx::IntRect& aClipRect,
|
||||
RenderCallbackType aRenderCallback) {
|
||||
Layer* firstMask = nullptr;
|
||||
size_t maskLayerCount = 0;
|
||||
size_t nextAncestorMaskLayer = 0;
|
||||
|
||||
size_t ancestorMaskLayerCount = aLayer->GetAncestorMaskLayerCount();
|
||||
if (Layer* ownMask = aLayer->GetMaskLayer()) {
|
||||
firstMask = ownMask;
|
||||
maskLayerCount = ancestorMaskLayerCount + 1;
|
||||
nextAncestorMaskLayer = 0;
|
||||
} else if (ancestorMaskLayerCount > 0) {
|
||||
firstMask = aLayer->GetAncestorMaskLayerAt(0);
|
||||
maskLayerCount = ancestorMaskLayerCount;
|
||||
nextAncestorMaskLayer = 1;
|
||||
} else {
|
||||
// no mask layers at all
|
||||
}
|
||||
|
||||
if (maskLayerCount <= 1) {
|
||||
// This is the common case. Render in one pass and return.
|
||||
EffectChain effectChain(aLayer);
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(firstMask,
|
||||
effectChain);
|
||||
static_cast<LayerComposite*>(aLayer->AsHostLayer())
|
||||
->AddBlendModeEffect(effectChain);
|
||||
aRenderCallback(effectChain, aClipRect);
|
||||
return;
|
||||
}
|
||||
|
||||
// We have multiple mask layers.
|
||||
// We split our list of mask layers into three parts:
|
||||
// (1) The first mask
|
||||
// (2) The list of intermediate masks (every mask except first and last)
|
||||
// (3) The final mask.
|
||||
// Part (2) can be empty.
|
||||
// For parts (1) and (2) we need to allocate intermediate surfaces to render
|
||||
// into. The final mask gets rendered into the original render target.
|
||||
|
||||
// Calculate the size of the intermediate surfaces.
|
||||
gfx::Rect visibleRect(
|
||||
aLayer->GetLocalVisibleRegion().GetBounds().ToUnknownRect());
|
||||
gfx::Matrix4x4 transform = aLayer->GetEffectiveTransform();
|
||||
// TODO: Use RenderTargetIntRect and TransformBy here
|
||||
gfx::IntRect surfaceRect = RoundedOut(
|
||||
transform.TransformAndClipBounds(visibleRect, gfx::Rect(aClipRect)));
|
||||
if (surfaceRect.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<CompositingRenderTarget> originalTarget =
|
||||
aCompositor->GetCurrentRenderTarget();
|
||||
|
||||
RefPtr<CompositingRenderTarget> firstTarget =
|
||||
aCompositor->CreateRenderTarget(surfaceRect, INIT_MODE_CLEAR);
|
||||
if (!firstTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Render the source while applying the first mask.
|
||||
aCompositor->SetRenderTarget(firstTarget);
|
||||
{
|
||||
EffectChain firstEffectChain(aLayer);
|
||||
LayerManagerComposite::AutoAddMaskEffect firstMaskEffect(firstMask,
|
||||
firstEffectChain);
|
||||
aRenderCallback(firstEffectChain, aClipRect - surfaceRect.TopLeft());
|
||||
// firstTarget now contains the transformed source with the first mask and
|
||||
// opacity already applied.
|
||||
}
|
||||
|
||||
// Apply the intermediate masks.
|
||||
gfx::IntRect intermediateClip(surfaceRect - surfaceRect.TopLeft());
|
||||
RefPtr<CompositingRenderTarget> previousTarget = firstTarget;
|
||||
for (size_t i = nextAncestorMaskLayer; i < ancestorMaskLayerCount - 1; i++) {
|
||||
Layer* intermediateMask = aLayer->GetAncestorMaskLayerAt(i);
|
||||
RefPtr<CompositingRenderTarget> intermediateTarget =
|
||||
aCompositor->CreateRenderTarget(surfaceRect, INIT_MODE_CLEAR);
|
||||
if (!intermediateTarget) {
|
||||
break;
|
||||
}
|
||||
aCompositor->SetRenderTarget(intermediateTarget);
|
||||
EffectChain intermediateEffectChain(aLayer);
|
||||
LayerManagerComposite::AutoAddMaskEffect intermediateMaskEffect(
|
||||
intermediateMask, intermediateEffectChain);
|
||||
if (intermediateMaskEffect.Failed()) {
|
||||
continue;
|
||||
}
|
||||
intermediateEffectChain.mPrimaryEffect =
|
||||
new EffectRenderTarget(previousTarget);
|
||||
aCompositor->DrawQuad(gfx::Rect(surfaceRect), intermediateClip,
|
||||
intermediateEffectChain, 1.0, gfx::Matrix4x4());
|
||||
previousTarget = intermediateTarget;
|
||||
}
|
||||
|
||||
aCompositor->SetRenderTarget(originalTarget);
|
||||
|
||||
// Apply the final mask, rendering into originalTarget.
|
||||
EffectChain finalEffectChain(aLayer);
|
||||
finalEffectChain.mPrimaryEffect = new EffectRenderTarget(previousTarget);
|
||||
Layer* finalMask = aLayer->GetAncestorMaskLayerAt(ancestorMaskLayerCount - 1);
|
||||
|
||||
// The blend mode needs to be applied in this final step, because this is
|
||||
// where we're blending with the actual background (which is in
|
||||
// originalTarget).
|
||||
static_cast<LayerComposite*>(aLayer->AsHostLayer())
|
||||
->AddBlendModeEffect(finalEffectChain);
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(finalMask,
|
||||
finalEffectChain);
|
||||
if (!autoMaskEffect.Failed()) {
|
||||
aCompositor->DrawQuad(gfx::Rect(surfaceRect), aClipRect, finalEffectChain,
|
||||
1.0, gfx::Matrix4x4());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
160
gfx/layers/composite/LayerManagerCompositeUtils.h
Normal file
160
gfx/layers/composite/LayerManagerCompositeUtils.h
Normal file
@ -0,0 +1,160 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef GFX_LayerManagerCompositeUtils_H
|
||||
#define GFX_LayerManagerCompositeUtils_H
|
||||
|
||||
#include <cstddef> // for size_t
|
||||
#include "Layers.h" // for Layer
|
||||
#include "Units.h" // for LayerIntRegion
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/gfx/BaseRect.h" // for operator-
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/gfx/Rect.h" // for IntRect, Rect, RoundedOut, IntRectTyped
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor, INIT_MODE_CLEAR
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain, EffectRenderTarget
|
||||
#include "mozilla/layers/LayerManagerComposite.h" // for LayerManagerComposite::AutoAddMaskEffect, LayerComposite, LayerManagerComposite
|
||||
#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
// Render aLayer using aCompositor and apply all mask layers of aLayer: The
|
||||
// layer's own mask layer (aLayer->GetMaskLayer()), and any ancestor mask
|
||||
// layers.
|
||||
// If more than one mask layer needs to be applied, we use intermediate surfaces
|
||||
// (CompositingRenderTargets) for rendering, applying one mask layer at a time.
|
||||
// Callers need to provide a callback function aRenderCallback that does the
|
||||
// actual rendering of the source. It needs to have the following form:
|
||||
// void (EffectChain& effectChain, const Rect& clipRect)
|
||||
// aRenderCallback is called exactly once, inside this function, unless aLayer's
|
||||
// visible region is completely clipped out (in that case, aRenderCallback won't
|
||||
// be called at all).
|
||||
// This function calls aLayer->AsHostLayer()->AddBlendModeEffect for the
|
||||
// final rendering pass.
|
||||
//
|
||||
// (This function should really live in LayerManagerComposite.cpp, but we
|
||||
// need to use templates for passing lambdas until bug 1164522 is resolved.)
|
||||
template <typename RenderCallbackType>
|
||||
void RenderWithAllMasks(Layer* aLayer, Compositor* aCompositor,
|
||||
const gfx::IntRect& aClipRect,
|
||||
RenderCallbackType aRenderCallback) {
|
||||
Layer* firstMask = nullptr;
|
||||
size_t maskLayerCount = 0;
|
||||
size_t nextAncestorMaskLayer = 0;
|
||||
|
||||
size_t ancestorMaskLayerCount = aLayer->GetAncestorMaskLayerCount();
|
||||
if (Layer* ownMask = aLayer->GetMaskLayer()) {
|
||||
firstMask = ownMask;
|
||||
maskLayerCount = ancestorMaskLayerCount + 1;
|
||||
nextAncestorMaskLayer = 0;
|
||||
} else if (ancestorMaskLayerCount > 0) {
|
||||
firstMask = aLayer->GetAncestorMaskLayerAt(0);
|
||||
maskLayerCount = ancestorMaskLayerCount;
|
||||
nextAncestorMaskLayer = 1;
|
||||
} else {
|
||||
// no mask layers at all
|
||||
}
|
||||
|
||||
if (maskLayerCount <= 1) {
|
||||
// This is the common case. Render in one pass and return.
|
||||
EffectChain effectChain(aLayer);
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(firstMask,
|
||||
effectChain);
|
||||
static_cast<LayerComposite*>(aLayer->AsHostLayer())
|
||||
->AddBlendModeEffect(effectChain);
|
||||
aRenderCallback(effectChain, aClipRect);
|
||||
return;
|
||||
}
|
||||
|
||||
// We have multiple mask layers.
|
||||
// We split our list of mask layers into three parts:
|
||||
// (1) The first mask
|
||||
// (2) The list of intermediate masks (every mask except first and last)
|
||||
// (3) The final mask.
|
||||
// Part (2) can be empty.
|
||||
// For parts (1) and (2) we need to allocate intermediate surfaces to render
|
||||
// into. The final mask gets rendered into the original render target.
|
||||
|
||||
// Calculate the size of the intermediate surfaces.
|
||||
gfx::Rect visibleRect(
|
||||
aLayer->GetLocalVisibleRegion().GetBounds().ToUnknownRect());
|
||||
gfx::Matrix4x4 transform = aLayer->GetEffectiveTransform();
|
||||
// TODO: Use RenderTargetIntRect and TransformBy here
|
||||
gfx::IntRect surfaceRect = RoundedOut(
|
||||
transform.TransformAndClipBounds(visibleRect, gfx::Rect(aClipRect)));
|
||||
if (surfaceRect.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<CompositingRenderTarget> originalTarget =
|
||||
aCompositor->GetCurrentRenderTarget();
|
||||
|
||||
RefPtr<CompositingRenderTarget> firstTarget =
|
||||
aCompositor->CreateRenderTarget(surfaceRect, INIT_MODE_CLEAR);
|
||||
if (!firstTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Render the source while applying the first mask.
|
||||
aCompositor->SetRenderTarget(firstTarget);
|
||||
{
|
||||
EffectChain firstEffectChain(aLayer);
|
||||
LayerManagerComposite::AutoAddMaskEffect firstMaskEffect(firstMask,
|
||||
firstEffectChain);
|
||||
aRenderCallback(firstEffectChain, aClipRect - surfaceRect.TopLeft());
|
||||
// firstTarget now contains the transformed source with the first mask and
|
||||
// opacity already applied.
|
||||
}
|
||||
|
||||
// Apply the intermediate masks.
|
||||
gfx::IntRect intermediateClip(surfaceRect - surfaceRect.TopLeft());
|
||||
RefPtr<CompositingRenderTarget> previousTarget = firstTarget;
|
||||
for (size_t i = nextAncestorMaskLayer; i < ancestorMaskLayerCount - 1; i++) {
|
||||
Layer* intermediateMask = aLayer->GetAncestorMaskLayerAt(i);
|
||||
RefPtr<CompositingRenderTarget> intermediateTarget =
|
||||
aCompositor->CreateRenderTarget(surfaceRect, INIT_MODE_CLEAR);
|
||||
if (!intermediateTarget) {
|
||||
break;
|
||||
}
|
||||
aCompositor->SetRenderTarget(intermediateTarget);
|
||||
EffectChain intermediateEffectChain(aLayer);
|
||||
LayerManagerComposite::AutoAddMaskEffect intermediateMaskEffect(
|
||||
intermediateMask, intermediateEffectChain);
|
||||
if (intermediateMaskEffect.Failed()) {
|
||||
continue;
|
||||
}
|
||||
intermediateEffectChain.mPrimaryEffect =
|
||||
new EffectRenderTarget(previousTarget);
|
||||
aCompositor->DrawQuad(gfx::Rect(surfaceRect), intermediateClip,
|
||||
intermediateEffectChain, 1.0, gfx::Matrix4x4());
|
||||
previousTarget = intermediateTarget;
|
||||
}
|
||||
|
||||
aCompositor->SetRenderTarget(originalTarget);
|
||||
|
||||
// Apply the final mask, rendering into originalTarget.
|
||||
EffectChain finalEffectChain(aLayer);
|
||||
finalEffectChain.mPrimaryEffect = new EffectRenderTarget(previousTarget);
|
||||
Layer* finalMask = aLayer->GetAncestorMaskLayerAt(ancestorMaskLayerCount - 1);
|
||||
|
||||
// The blend mode needs to be applied in this final step, because this is
|
||||
// where we're blending with the actual background (which is in
|
||||
// originalTarget).
|
||||
static_cast<LayerComposite*>(aLayer->AsHostLayer())
|
||||
->AddBlendModeEffect(finalEffectChain);
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(finalMask,
|
||||
finalEffectChain);
|
||||
if (!autoMaskEffect.Failed()) {
|
||||
aCompositor->DrawQuad(gfx::Rect(surfaceRect), aClipRect, finalEffectChain,
|
||||
1.0, gfx::Matrix4x4());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* GFX_LayerManagerCompositeUtils_H */
|
@ -18,7 +18,8 @@
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/ContentHost.h" // for ContentHost
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "mozilla/layers/LayerManagerCompositeUtils.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsAString.h"
|
||||
#include "mozilla/RefPtr.h" // for nsRefPtr
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
|
@ -15,38 +15,25 @@
|
||||
// which the deadline will be 15ms + throttle threshold
|
||||
//#define COMPOSITOR_PERFORMANCE_WARNING
|
||||
|
||||
#include <stdint.h> // for uint64_t
|
||||
#include "Layers.h" // for Layer
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/GfxMessageUtils.h" // for WebGLVersion
|
||||
#include <stdint.h> // for uint64_t
|
||||
#include <unordered_map>
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Monitor.h" // for Monitor
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/dom/ipc/IdType.h"
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/ipc/SharedMemory.h"
|
||||
#include "mozilla/layers/CompositionRecorder.h"
|
||||
#include "mozilla/layers/CompositorController.h"
|
||||
#include "mozilla/layers/CompositorOptions.h"
|
||||
#include "mozilla/layers/CompositorVsyncSchedulerOwner.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for IShmemAllocator
|
||||
#include "mozilla/layers/LayersMessages.h" // for TargetConfig
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
#include "mozilla/layers/MetricsSharingController.h"
|
||||
#include "mozilla/layers/PCompositorBridgeTypes.h"
|
||||
#include "mozilla/layers/PCompositorBridgeParent.h"
|
||||
#include "mozilla/layers/APZTestData.h"
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
|
||||
#include "mozilla/layers/UiCompositorControllerParent.h"
|
||||
#include "mozilla/VsyncDispatcher.h"
|
||||
|
||||
class nsIWidget;
|
||||
struct DxgiAdapterDesc;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -74,11 +61,24 @@ class PWebGPUParent;
|
||||
class WebGPUParent;
|
||||
} // namespace webgpu
|
||||
|
||||
namespace widget {
|
||||
class CompositorWidget;
|
||||
}
|
||||
|
||||
namespace wr {
|
||||
class WebRenderPipelineInfo;
|
||||
struct Epoch;
|
||||
struct MemoryReport;
|
||||
struct PipelineId;
|
||||
struct RendererStats;
|
||||
} // namespace wr
|
||||
|
||||
namespace layers {
|
||||
|
||||
class APZCTreeManager;
|
||||
class APZCTreeManagerParent;
|
||||
class APZSampler;
|
||||
class APZTestData;
|
||||
class APZUpdater;
|
||||
class AsyncCompositionManager;
|
||||
class AsyncImagePipelineManager;
|
||||
@ -87,17 +87,19 @@ class CompositorAnimationStorage;
|
||||
class CompositorBridgeParent;
|
||||
class CompositorManagerParent;
|
||||
class CompositorVsyncScheduler;
|
||||
class FrameUniformityData;
|
||||
class GeckoContentController;
|
||||
class HostLayerManager;
|
||||
class IAPZCTreeManager;
|
||||
class Layer;
|
||||
class LayerTransactionParent;
|
||||
class OMTASampler;
|
||||
class PAPZParent;
|
||||
class ContentCompositorBridgeParent;
|
||||
class CompositorThreadHolder;
|
||||
class InProcessCompositorSession;
|
||||
class TextureData;
|
||||
class UiCompositorControllerParent;
|
||||
class WebRenderBridgeParent;
|
||||
struct CollectedFrames;
|
||||
|
||||
struct ScopedLayerTreeRegistration {
|
||||
ScopedLayerTreeRegistration(APZCTreeManager* aApzctm, LayersId aLayersId,
|
||||
|
@ -7,19 +7,28 @@
|
||||
#ifndef MOZILLA_GFX_LAYERMANAGERMLGPU_H
|
||||
#define MOZILLA_GFX_LAYERMANAGERMLGPU_H
|
||||
|
||||
#include "Layers.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "LayerMLGPU.h"
|
||||
#include "mozilla/layers/MLGPUScreenshotGrabber.h"
|
||||
#include <cstdint> // for uint32_t
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_ASSERT_HELPER1
|
||||
#include "mozilla/Maybe.h" // for Maybe
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr
|
||||
#include "mozilla/gfx/Rect.h" // for IntRect
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureFactoryIdentifier
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager::EndTransactionFlags, LayerManager::DrawPaintedLayerCallback
|
||||
#include "mozilla/layers/LayerManagerComposite.h" // for HostLayerManager
|
||||
#include "mozilla/layers/LayersTypes.h" // for LayersBackend
|
||||
#include "mozilla/layers/MLGPUScreenshotGrabber.h" // for MLGPUScreenshotGrabber
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsStringFwd.h" // for nsCString
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class FrameBuilder;
|
||||
class LayerManagerMLGPU;
|
||||
class RenderPassMLGPU;
|
||||
class SharedBufferMLGPU;
|
||||
class RenderViewMLGPU;
|
||||
class TextRenderer;
|
||||
class TextureSourceProviderMLGPU;
|
||||
class MLGBuffer;
|
||||
|
@ -164,6 +164,7 @@ EXPORTS.mozilla.layers += [
|
||||
"composite/ImageHost.h",
|
||||
"composite/ImageLayerComposite.h",
|
||||
"composite/LayerManagerComposite.h",
|
||||
"composite/LayerManagerCompositeUtils.h",
|
||||
"composite/PaintedLayerComposite.h",
|
||||
"composite/TextRenderer.h",
|
||||
"composite/TextureHost.h",
|
||||
@ -222,6 +223,7 @@ EXPORTS.mozilla.layers += [
|
||||
"ipc/VideoBridgeParent.h",
|
||||
"ipc/VideoBridgeUtils.h",
|
||||
"LayerAttributes.h",
|
||||
"LayerManager.h",
|
||||
"LayerMetricsWrapper.h",
|
||||
"LayersHelpers.h",
|
||||
"LayersTypes.h",
|
||||
@ -492,6 +494,7 @@ UNIFIED_SOURCES += [
|
||||
"ipc/UiCompositorControllerParent.cpp",
|
||||
"ipc/VideoBridgeChild.cpp",
|
||||
"ipc/VideoBridgeParent.cpp",
|
||||
"LayerManager.cpp",
|
||||
"Layers.cpp",
|
||||
"LayerScope.cpp",
|
||||
"LayersHelpers.cpp",
|
||||
|
@ -731,5 +731,13 @@ wr::Epoch AsyncImagePipelineManager::GetNextImageEpoch() {
|
||||
return mAsyncImageEpoch;
|
||||
}
|
||||
|
||||
AsyncImagePipelineManager::WebRenderPipelineInfoHolder::
|
||||
WebRenderPipelineInfoHolder(RefPtr<const wr::WebRenderPipelineInfo>&& aInfo,
|
||||
ipc::FileDescriptor&& aFenceFd)
|
||||
: mInfo(aInfo), mFenceFd(aFenceFd) {}
|
||||
|
||||
AsyncImagePipelineManager::WebRenderPipelineInfoHolder::
|
||||
~WebRenderPipelineInfoHolder() = default;
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -253,9 +253,8 @@ class AsyncImagePipelineManager final {
|
||||
|
||||
struct WebRenderPipelineInfoHolder {
|
||||
WebRenderPipelineInfoHolder(RefPtr<const wr::WebRenderPipelineInfo>&& aInfo,
|
||||
ipc::FileDescriptor&& aFenceFd)
|
||||
: mInfo(aInfo), mFenceFd(aFenceFd) {}
|
||||
~WebRenderPipelineInfoHolder() {}
|
||||
ipc::FileDescriptor&& aFenceFd);
|
||||
~WebRenderPipelineInfoHolder();
|
||||
RefPtr<const wr::WebRenderPipelineInfo> mInfo;
|
||||
ipc::FileDescriptor mFenceFd;
|
||||
};
|
||||
|
@ -12,20 +12,17 @@
|
||||
|
||||
#include "CompositableHost.h" // for CompositableHost, ImageCompositeNotificationInfo
|
||||
#include "GLContextProvider.h"
|
||||
#include "Layers.h"
|
||||
#include "mozilla/DataMutex.h"
|
||||
#include "mozilla/layers/CompositableTransactionParent.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/CompositorVsyncSchedulerOwner.h"
|
||||
#include "mozilla/layers/LayerManager.h"
|
||||
#include "mozilla/layers/PWebRenderBridgeParent.h"
|
||||
#include "mozilla/layers/UiCompositorControllerParent.h"
|
||||
#include "mozilla/HashTable.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -40,7 +37,8 @@ class CompositorWidget;
|
||||
|
||||
namespace wr {
|
||||
class WebRenderAPI;
|
||||
}
|
||||
class WebRenderPipelineInfo;
|
||||
} // namespace wr
|
||||
|
||||
namespace layers {
|
||||
|
||||
@ -49,6 +47,7 @@ class Compositor;
|
||||
class CompositorBridgeParentBase;
|
||||
class CompositorVsyncScheduler;
|
||||
class OMTASampler;
|
||||
class UiCompositorControllerParent;
|
||||
class WebRenderImageHost;
|
||||
struct WrAnimations;
|
||||
|
||||
|
@ -7,29 +7,37 @@
|
||||
#ifndef GFX_WEBRENDERLAYERMANAGER_H
|
||||
#define GFX_WEBRENDERLAYERMANAGER_H
|
||||
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "Layers.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/StaticPrefs_apz.h"
|
||||
#include "mozilla/SVGIntegrationUtils.h" // for WrFiltersHolder
|
||||
#include "mozilla/layers/APZTestData.h"
|
||||
#include "mozilla/layers/FocusTarget.h"
|
||||
#include "mozilla/layers/IpcResourceUpdateQueue.h"
|
||||
#include "mozilla/layers/RenderRootStateManager.h"
|
||||
#include "mozilla/layers/SharedSurfacesChild.h"
|
||||
#include "mozilla/layers/StackingContextHelper.h"
|
||||
#include "mozilla/layers/TransactionIdAllocator.h"
|
||||
#include "mozilla/layers/WebRenderCommandBuilder.h"
|
||||
#include "mozilla/layers/WebRenderScrollData.h"
|
||||
#include "mozilla/layers/WebRenderUserData.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdint> // for uint32_t, int32_t, INT32_MAX
|
||||
#include <string> // for string
|
||||
#include "Units.h" // for LayoutDeviceIntSize
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/Attributes.h" // for MOZ_NON_OWNING_REF
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/StaticPrefs_apz.h" // for apz_test_logging_enabled
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureFactoryIdentifier
|
||||
#include "mozilla/layers/DisplayItemCache.h" // for DisplayItemCache
|
||||
#include "mozilla/layers/FocusTarget.h" // for FocusTarget
|
||||
#include "mozilla/layers/LayerManager.h" // for DidCompositeObserver (ptr only), LayerManager::END_DEFAULT, LayerManager::En...
|
||||
#include "mozilla/layers/LayersTypes.h" // for TransactionId, LayersBackend, CompositionPayload (ptr only), LayersBackend::...
|
||||
#include "mozilla/layers/RenderRootStateManager.h" // for RenderRootStateManager
|
||||
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid::ViewID
|
||||
#include "mozilla/layers/WebRenderCommandBuilder.h" // for WebRenderCommandBuilder
|
||||
#include "mozilla/layers/WebRenderScrollData.h" // for WebRenderScrollData
|
||||
#include "nsHashKeys.h" // for nsRefPtrHashKey
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsStringFwd.h" // for nsCString, nsAString
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "nsTHashtable.h" // for nsTHashtable<>::Iterator, nsTHashtable
|
||||
|
||||
class gfxContext;
|
||||
class nsDisplayList;
|
||||
class nsDisplayListBuilder;
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
@ -40,6 +48,7 @@ namespace layers {
|
||||
|
||||
class CompositorBridgeChild;
|
||||
class KnowsCompositor;
|
||||
class Layer;
|
||||
class PCompositorBridgeChild;
|
||||
class WebRenderBridgeChild;
|
||||
class WebRenderParentCommand;
|
||||
|
@ -8,13 +8,12 @@
|
||||
#define GFX_WEBRENDERUSERDATA_H
|
||||
|
||||
#include <vector>
|
||||
#include "BasicLayers.h" // for BasicLayerManager
|
||||
#include "mozilla/layers/StackingContextHelper.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "mozilla/layers/AnimationInfo.h"
|
||||
#include "mozilla/dom/RemoteBrowser.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "ImageTypes.h"
|
||||
|
||||
class nsDisplayItemGeometry;
|
||||
@ -33,12 +32,14 @@ class SourceSurface;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
class BasicLayerManager;
|
||||
class CanvasLayer;
|
||||
class ImageClient;
|
||||
class ImageContainer;
|
||||
class WebRenderBridgeChild;
|
||||
class WebRenderCanvasData;
|
||||
class WebRenderCanvasRenderer;
|
||||
class WebRenderCanvasRendererAsync;
|
||||
class WebRenderImageData;
|
||||
class WebRenderFallbackData;
|
||||
class WebRenderLocalCanvasData;
|
||||
|
@ -7,10 +7,8 @@
|
||||
#ifndef NSSUBDOCUMENTFRAME_H_
|
||||
#define NSSUBDOCUMENTFRAME_H_
|
||||
|
||||
#include "Layers.h"
|
||||
#include "LayerState.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/layers/WebRenderScrollData.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsAtomicContainerFrame.h"
|
||||
#include "nsIReflowCallback.h"
|
||||
@ -21,6 +19,14 @@ namespace mozilla {
|
||||
class PresShell;
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla::layers {
|
||||
class Layer;
|
||||
class RefLayer;
|
||||
class RenderRootStateManager;
|
||||
class WebRenderLayerScrollData;
|
||||
class WebRenderScrollData;
|
||||
} // namespace mozilla::layers
|
||||
|
||||
/******************************************************************************
|
||||
* nsSubDocumentFrame
|
||||
*****************************************************************************/
|
||||
|
@ -130,6 +130,47 @@ static inline MaskLayerImageCache* GetMaskLayerImageCache() {
|
||||
return gMaskLayerImageCache;
|
||||
}
|
||||
|
||||
struct InactiveLayerData {
|
||||
RefPtr<layers::BasicLayerManager> mLayerManager;
|
||||
RefPtr<layers::Layer> mLayer;
|
||||
UniquePtr<layers::LayerProperties> mProps;
|
||||
|
||||
~InactiveLayerData();
|
||||
};
|
||||
|
||||
struct AssignedDisplayItem {
|
||||
AssignedDisplayItem(nsPaintedDisplayItem* aItem, LayerState aLayerState,
|
||||
DisplayItemData* aData, const nsRect& aContentRect,
|
||||
DisplayItemEntryType aType, const bool aHasOpacity,
|
||||
const RefPtr<TransformClipNode>& aTransform,
|
||||
const bool aIsMerged);
|
||||
AssignedDisplayItem(AssignedDisplayItem&& aRhs) = default;
|
||||
|
||||
bool HasOpacity() const { return mHasOpacity; }
|
||||
|
||||
bool HasTransform() const { return mTransform; }
|
||||
|
||||
nsPaintedDisplayItem* mItem;
|
||||
DisplayItemData* mDisplayItemData;
|
||||
|
||||
/**
|
||||
* If the display item is being rendered as an inactive
|
||||
* layer, then this stores the layer manager being
|
||||
* used for the inactive transaction.
|
||||
*/
|
||||
UniquePtr<InactiveLayerData> mInactiveLayerData;
|
||||
RefPtr<TransformClipNode> mTransform;
|
||||
|
||||
nsRect mContentRect;
|
||||
LayerState mLayerState;
|
||||
DisplayItemEntryType mType;
|
||||
|
||||
bool mReused;
|
||||
bool mMerged;
|
||||
bool mHasOpacity;
|
||||
bool mHasPaintRect;
|
||||
};
|
||||
|
||||
struct DisplayItemEntry {
|
||||
DisplayItemEntry(nsDisplayItem* aItem, DisplayItemEntryType aType)
|
||||
: mItem(aItem), mType(aType) {}
|
||||
|
@ -7,36 +7,57 @@
|
||||
#ifndef FRAMELAYERBUILDER_H_
|
||||
#define FRAMELAYERBUILDER_H_
|
||||
|
||||
#include "nsCSSPropertyIDSet.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "DisplayItemClip.h"
|
||||
#include "mozilla/gfx/MatrixFwd.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "LayerState.h"
|
||||
#include "Layers.h"
|
||||
#include "LayerUserData.h"
|
||||
#include "nsDisplayItemTypes.h"
|
||||
#include "TransformClipNode.h"
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdint> // for uint32_t, UINT32_MAX, int32_t, uint64_t, uint8_t
|
||||
#include <iosfwd> // for stringstream
|
||||
#include <vector> // for vector
|
||||
#include "DisplayItemClip.h" // for DisplayItemClip
|
||||
#include "LayerState.h" // for LayerState
|
||||
#include "LayerUserData.h" // for LayerUserData
|
||||
#include "Units.h" // for LayerIntPoint, LayoutDeviceToLayerScale2D
|
||||
#include "gfxPoint.h" // for gfxSize
|
||||
#include "mozilla/AlreadyAddRefed.h" // for already_AddRefed
|
||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/FunctionRef.h" // for FunctionRef
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix, Matrix4x4
|
||||
#include "mozilla/gfx/Point.h" // for Size
|
||||
#include "mozilla/layers/LayerManager.h" // for LayerManager, LayerManager::NONE, LayerManager::PaintedLayerCreationHint, LayerMetricsW...
|
||||
#include "mozilla/layers/LayersTypes.h" // for DrawRegionClip, EventRegions
|
||||
#include "nsColor.h" // for NS_RGBA, nscolor
|
||||
#include "nsDebug.h" // for NS_WARNING
|
||||
#include "nsDisplayItemTypes.h" // for DisplayItemType
|
||||
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING, NS_LOG_ADDREF, NS_LOG_RELEASE
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsRect.h" // for nsRect (ptr only), nsIntRect
|
||||
#include "nsRegion.h" // for nsIntRegion, nsRegion
|
||||
#include "nsTArray.h" // for AutoTArray, nsTArray_Impl
|
||||
#include "nscore.h" // for nsrefcnt
|
||||
|
||||
class nsDisplayListBuilder;
|
||||
class nsDisplayList;
|
||||
class nsDisplayItem;
|
||||
class nsPaintedDisplayItem;
|
||||
class gfxContext;
|
||||
class nsDisplayItem;
|
||||
class nsDisplayItemGeometry;
|
||||
class nsDisplayList;
|
||||
class nsDisplayListBuilder;
|
||||
class nsDisplayMasksAndClipPaths;
|
||||
class nsIFrame;
|
||||
class nsPaintedDisplayItem;
|
||||
class nsPresContext;
|
||||
class nsRootPresContext;
|
||||
|
||||
namespace mozilla {
|
||||
struct ActiveScrolledRoot;
|
||||
struct DisplayItemClipChain;
|
||||
class TransformClipNode;
|
||||
template <class T>
|
||||
class Maybe;
|
||||
template <typename T>
|
||||
class SmallPointerArray;
|
||||
|
||||
namespace layers {
|
||||
class ContainerLayer;
|
||||
class LayerManager;
|
||||
class Layer;
|
||||
class BasicLayerManager;
|
||||
class PaintedLayer;
|
||||
class ImageLayer;
|
||||
@ -212,46 +233,7 @@ class RefCountedRegion {
|
||||
bool mIsInfinite;
|
||||
};
|
||||
|
||||
struct InactiveLayerData {
|
||||
RefPtr<layers::BasicLayerManager> mLayerManager;
|
||||
RefPtr<layers::Layer> mLayer;
|
||||
UniquePtr<layers::LayerProperties> mProps;
|
||||
|
||||
~InactiveLayerData();
|
||||
};
|
||||
|
||||
struct AssignedDisplayItem {
|
||||
AssignedDisplayItem(nsPaintedDisplayItem* aItem, LayerState aLayerState,
|
||||
DisplayItemData* aData, const nsRect& aContentRect,
|
||||
DisplayItemEntryType aType, const bool aHasOpacity,
|
||||
const RefPtr<TransformClipNode>& aTransform,
|
||||
const bool aIsMerged);
|
||||
AssignedDisplayItem(AssignedDisplayItem&& aRhs) = default;
|
||||
|
||||
bool HasOpacity() const { return mHasOpacity; }
|
||||
|
||||
bool HasTransform() const { return mTransform; }
|
||||
|
||||
nsPaintedDisplayItem* mItem;
|
||||
DisplayItemData* mDisplayItemData;
|
||||
|
||||
/**
|
||||
* If the display item is being rendered as an inactive
|
||||
* layer, then this stores the layer manager being
|
||||
* used for the inactive transaction.
|
||||
*/
|
||||
UniquePtr<InactiveLayerData> mInactiveLayerData;
|
||||
RefPtr<TransformClipNode> mTransform;
|
||||
|
||||
nsRect mContentRect;
|
||||
LayerState mLayerState;
|
||||
DisplayItemEntryType mType;
|
||||
|
||||
bool mReused;
|
||||
bool mMerged;
|
||||
bool mHasOpacity;
|
||||
bool mHasPaintRect;
|
||||
};
|
||||
struct AssignedDisplayItem;
|
||||
|
||||
struct ContainerLayerParameters {
|
||||
ContainerLayerParameters()
|
||||
@ -560,36 +542,6 @@ class FrameLayerBuilder : public layers::LayerUserData {
|
||||
|
||||
static DisplayItemData* GetOldDataFor(nsDisplayItem* aItem);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
template <class T>
|
||||
static T* GetDebugSingleOldLayerForFrame(nsIFrame* aFrame) {
|
||||
SmallPointerArray<DisplayItemData>& array = aFrame->DisplayItemData();
|
||||
|
||||
Layer* layer = nullptr;
|
||||
for (DisplayItemData* data : array) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy any stored LayerManagerDataProperty and the associated data for
|
||||
* aFrame.
|
||||
@ -725,6 +677,10 @@ class FrameLayerBuilder : public layers::LayerUserData {
|
||||
|
||||
void ComputeGeometryChangeForItem(DisplayItemData* aData);
|
||||
|
||||
// Defined and used only in dom/base/nsDOMWindowUtils.cpp
|
||||
template <class T>
|
||||
static T* GetDebugSingleOldLayerForFrame(nsIFrame* aFrame);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The layer manager belonging to the widget that is being retained
|
||||
|
@ -60,6 +60,10 @@
|
||||
#include <algorithm>
|
||||
#include <unordered_set>
|
||||
|
||||
// XXX Includes that could be avoided by moving function implementations to the
|
||||
// cpp file.
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
class gfxContext;
|
||||
class nsIContent;
|
||||
class nsDisplayList;
|
||||
|
@ -565,6 +565,17 @@ inline already_AddRefed<T> do_AddRef(const RefPtr<T>& aObj) {
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
template <typename T>
|
||||
class AlignmentFinder;
|
||||
|
||||
// Provide a specialization of AlignmentFinder to allow MOZ_ALIGNOF(RefPtr<T>)
|
||||
// with an incomplete T.
|
||||
template <typename T>
|
||||
class AlignmentFinder<RefPtr<T>> {
|
||||
public:
|
||||
static const size_t alignment = alignof(T*);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to be able to conveniently write things like:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user