diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index a9d8dfec9862..c6f3a248a82a 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -8,7 +8,6 @@ #include "MobileViewportManager.h" #include "mozilla/layers/CompositorBridgeChild.h" -#include "mozilla/layers/LayerTransactionChild.h" #include "nsPresContext.h" #include "nsCaret.h" #include "nsContentList.h" diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp index af5d09df135b..86a5cc876c1c 100644 --- a/dom/canvas/ClientWebGLContext.cpp +++ b/dom/canvas/ClientWebGLContext.cpp @@ -20,7 +20,6 @@ #include "mozilla/ipc/Shmem.h" #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/ImageBridgeChild.h" -#include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/OOPCanvasRenderer.h" #include "mozilla/layers/TextureClientSharedSurface.h" #include "mozilla/layers/WebRenderUserData.h" diff --git a/dom/canvas/HostWebGLContext.cpp b/dom/canvas/HostWebGLContext.cpp index e009f1942600..9d0b47d9a03e 100644 --- a/dom/canvas/HostWebGLContext.cpp +++ b/dom/canvas/HostWebGLContext.cpp @@ -6,7 +6,6 @@ #include "HostWebGLContext.h" #include "CompositableHost.h" -#include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/LayersSurfaces.h" #include "MozFramebuffer.h" diff --git a/dom/canvas/PWebGL.ipdl b/dom/canvas/PWebGL.ipdl index 44086b174611..5403b8c82d41 100644 --- a/dom/canvas/PWebGL.ipdl +++ b/dom/canvas/PWebGL.ipdl @@ -6,7 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PCompositorBridge; -include protocol PLayerTransaction; using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h"; using mozilla::layers::SurfaceDescriptor from "mozilla/layers/LayersTypes.h"; diff --git a/dom/canvas/WebGLParent.cpp b/dom/canvas/WebGLParent.cpp index 7042027d9078..d72422b79f02 100644 --- a/dom/canvas/WebGLParent.cpp +++ b/dom/canvas/WebGLParent.cpp @@ -6,7 +6,6 @@ #include "WebGLParent.h" #include "WebGLChild.h" -#include "mozilla/layers/LayerTransactionParent.h" #include "mozilla/layers/TextureClientSharedSurface.h" #include "ImageContainer.h" #include "HostWebGLContext.h" diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 5ef18e7479c1..44e24f393770 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -92,7 +92,6 @@ #include "mozilla/layers/IAPZCTreeManager.h" #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/InputAPZContext.h" -#include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "nsBrowserStatusFilter.h" #include "nsColorPickerProxy.h" diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index f5e7b160b3cd..08f92df085dd 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -69,7 +69,6 @@ #include "mozilla/layers/APZUtils.h" // for AsyncTransform #include "mozilla/layers/CompositorController.h" // for CompositorController #include "mozilla/layers/DirectionUtils.h" // for GetAxis{Start,End,Length,Scale} -#include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent #include "mozilla/layers/MetricsSharingController.h" // for MetricsSharingController #include "mozilla/mozalloc.h" // for operator new, etc #include "mozilla/Unused.h" // for unused @@ -3660,7 +3659,6 @@ Maybe AsyncPanZoomController::GetCurrentAnimationDestination( ParentLayerPoint AsyncPanZoomController::AdjustHandoffVelocityForOverscrollBehavior( ParentLayerPoint& aHandoffVelocity) const { - ParentLayerPoint residualVelocity; ScrollDirections handoffDirections = GetAllowedHandoffDirections(); if (!handoffDirections.contains(ScrollDirection::eHorizontal)) { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 1230840e3e51..89b4df6da41c 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -14,7 +14,6 @@ #include "mozilla/dom/MouseEventBinding.h" #include "mozilla/dom/BrowserParent.h" #include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/RepaintRequest.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/layers/WebRenderBridgeChild.h" diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index e239859e0869..9f4216b4a2d2 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -23,7 +23,8 @@ #include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc #include "mozilla/layers/ISurfaceAllocator.h" -#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc +#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc +#include "mozilla/layers/TextureForwarder.h" #include "mozilla/layers/TextureClient.h" // for TextureClient, etc #include "mozilla/layers/TextureClientOGL.h" // for SurfaceTextureClient #include "mozilla/mozalloc.h" // for operator delete, etc diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index ed2d28a1c311..a809069f1c5e 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -17,8 +17,6 @@ #include "mozilla/layers/APZCTreeManagerChild.h" #include "mozilla/layers/CanvasChild.h" #include "mozilla/layers/LayerManager.h" -#include "mozilla/layers/LayerTransactionChild.h" -#include "mozilla/layers/PLayerTransactionChild.h" #include "mozilla/layers/PTextureChild.h" #include "mozilla/layers/TextureClient.h" // for TextureClient #include "mozilla/layers/TextureClientPool.h" // for TextureClientPool @@ -57,7 +55,6 @@ using mozilla::Unused; using mozilla::gfx::GPUProcessManager; -using mozilla::layers::LayerTransactionChild; namespace mozilla { namespace layers { @@ -173,14 +170,6 @@ void CompositorBridgeChild::Destroy() { return; } - AutoTArray transactions; - ManagedPLayerTransactionChild(transactions); - for (int i = transactions.Length() - 1; i >= 0; --i) { - RefPtr layers = - static_cast(transactions[i]); - layers->Destroy(); - } - AutoTArray wrBridges; ManagedPWebRenderBridgeChild(wrBridges); for (int i = wrBridges.Length() - 1; i >= 0; --i) { @@ -314,22 +303,6 @@ bool CompositorBridgeChild::CompositorIsInGPUProcess() { return bridge->OtherPid() != dom::ContentChild::GetSingleton()->OtherPid(); } -PLayerTransactionChild* CompositorBridgeChild::AllocPLayerTransactionChild( - const nsTArray& aBackendHints, const LayersId& aId) { - LayerTransactionChild* c = new LayerTransactionChild(aId); - c->AddIPDLReference(); - - return c; -} - -bool CompositorBridgeChild::DeallocPLayerTransactionChild( - PLayerTransactionChild* actor) { - LayersId childId = static_cast(actor)->GetId(); - ClearSharedFrameMetricsData(childId); - static_cast(actor)->ReleaseIPDLReference(); - return true; -} - mozilla::ipc::IPCResult CompositorBridgeChild::RecvInvalidateLayers( const LayersId& aLayersId) { if (mLayerManager) { diff --git a/gfx/layers/ipc/CompositorBridgeChild.h b/gfx/layers/ipc/CompositorBridgeChild.h index 45c6b9beb808..abf0476c0dd6 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.h +++ b/gfx/layers/ipc/CompositorBridgeChild.h @@ -241,11 +241,6 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, void PrepareFinalDestroy(); void AfterDestroy(); - PLayerTransactionChild* AllocPLayerTransactionChild( - const nsTArray& aBackendHints, const LayersId& aId); - - bool DeallocPLayerTransactionChild(PLayerTransactionChild* aChild); - void ActorDestroy(ActorDestroyReason aWhy) override; mozilla::ipc::IPCResult RecvSharedCompositorFrameMetrics( diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 14889396fa7d..e901099c7636 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -12,7 +12,6 @@ #include // for pair #include "apz/src/APZCTreeManager.h" // for APZCTreeManager -#include "LayerTransactionParent.h" // for LayerTransactionParent #include "RenderTrace.h" // for RenderTraceLayers #include "base/process.h" // for ProcessId #include "gfxContext.h" // for gfxContext @@ -57,7 +56,6 @@ #include "mozilla/layers/LayerTreeOwnerTracker.h" #include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/OMTASampler.h" -#include "mozilla/layers/PLayerTransactionParent.h" #include "mozilla/layers/RemoteContentController.h" #include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/layers/WebRenderBridgeParent.h" @@ -224,8 +222,7 @@ CompositorBridgeParent::LayerTreeState::LayerTreeState() : mApzcTreeManagerParent(nullptr), mParent(nullptr), mLayerManager(nullptr), - mContentCompositorBridgeParent(nullptr), - mLayerTree(nullptr) {} + mContentCompositorBridgeParent(nullptr) {} CompositorBridgeParent::LayerTreeState::~LayerTreeState() { if (mController) { @@ -776,27 +773,6 @@ void CompositorBridgeParent::ResumeCompositionAndResize(int x, int y, int width, ResumeComposition(); } -void CompositorBridgeParent::UpdatePaintTime(LayerTransactionParent* aLayerTree, - const TimeDuration& aPaintTime) { - // We get a lot of paint timings for things with empty transactions. - if (!mLayerManager || aPaintTime.ToMilliseconds() < 1.0) { - return; - } - - mLayerManager->SetPaintTime(aPaintTime); -} - -void CompositorBridgeParent::RegisterPayloads( - LayerTransactionParent* aLayerTree, - const nsTArray& aPayload) { - // We get a lot of paint timings for things with empty transactions. - if (!mLayerManager) { - return; - } - - mLayerManager->RegisterPayloads(aPayload); -} - void CompositorBridgeParent::NotifyShadowTreeTransaction( LayersId aId, bool aIsFirstPaint, const FocusTarget& aFocusTarget, bool aScheduleComposite, uint32_t aPaintSequenceNumber, @@ -863,107 +839,6 @@ void CompositorBridgeParent::SetShadowProperties(Layer* aLayer) { }); } -void CompositorBridgeParent::CompositeToTarget(VsyncId aId, DrawTarget* aTarget, - const gfx::IntRect* aRect) { - AUTO_PROFILER_TRACING_MARKER("Paint", "Composite", GRAPHICS); - AUTO_PROFILER_LABEL("CompositorBridgeParent::CompositeToTarget", GRAPHICS); - PerfStats::AutoMetricRecording autoRecording; - - MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread(), - "Composite can only be called on the compositor thread"); - TimeStamp start = TimeStamp::Now(); - - if (!CanComposite()) { - TimeStamp end = TimeStamp::Now(); - DidComposite(aId, start, end); - return; - } - - AutoResolveRefLayers resolve(mCompositionManager, this); - - nsCString none; - if (aTarget) { - mLayerManager->BeginTransactionWithDrawTarget(aTarget, *aRect); - } else { - mLayerManager->BeginTransaction(none); - } - - SetShadowProperties(mLayerManager->GetRoot()); - - if (mForceCompositionTask && !mOverrideComposeReadiness) { - if (mCompositionManager->ReadyForCompose()) { - mForceCompositionTask->Cancel(); - mForceCompositionTask = nullptr; - } else { - return; - } - } - - mCompositionManager->ComputeRotation(); - - SampleTime time = mTestTime ? SampleTime::FromTest(*mTestTime) - : mCompositorScheduler->GetLastComposeTime(); - bool requestNextFrame = - mCompositionManager->TransformShadowTree(time, mVsyncRate); - - if (requestNextFrame) { - ScheduleComposition(); - } - - RenderTraceLayers(mLayerManager->GetRoot(), "0000"); - - if (StaticPrefs::layers_dump_host_layers() || StaticPrefs::layers_dump()) { - printf_stderr("Painting --- compositing layer tree:\n"); - mLayerManager->Dump(/* aSorted = */ true); - } - mLayerManager->SetDebugOverlayWantsNextFrame(false); - mLayerManager->EndTransaction(time.Time()); - - if (!aTarget) { - TimeStamp end = TimeStamp::Now(); - DidComposite(aId, start, end); - } - - // We're not really taking advantage of the stored composite-again-time here. - // We might be able to skip the next few composites altogether. However, - // that's a bit complex to implement and we'll get most of the advantage - // by skipping compositing when we detect there's nothing invalid. This is why - // we do "composite until" rather than "composite again at". - // - // TODO(bug 1328602) Figure out what we should do here with the render thread. - if (!mLayerManager->GetCompositeUntilTime().IsNull() || - mLayerManager->DebugOverlayWantsNextFrame()) { - ScheduleComposition(); - } - -#ifdef COMPOSITOR_PERFORMANCE_WARNING - TimeDuration executionTime = - TimeStamp::Now() - mCompositorScheduler->GetLastComposeTime().Time(); - TimeDuration frameBudget = TimeDuration::FromMilliseconds(15); - int32_t frameRate = CalculateCompositionFrameRate(); - if (frameRate > 0) { - frameBudget = TimeDuration::FromSeconds(1.0 / frameRate); - } - if (executionTime > frameBudget) { - printf_stderr("Compositor: Composite execution took %4.1f ms\n", - executionTime.ToMilliseconds()); - } -#endif - - // 0 -> Full-tilt composite - if (StaticPrefs::layers_offmainthreadcomposition_frame_rate() == 0 || - mLayerManager->AlwaysScheduleComposite()) { - // Special full-tilt composite mode for performance testing - ScheduleComposition(); - } - - // TODO(bug 1328602) Need an equivalent that works with the rende thread. - mLayerManager->SetCompositionTime(TimeStamp()); - - mozilla::Telemetry::AccumulateTimeDelta(mozilla::Telemetry::COMPOSITE_TIME, - start); -} - void CompositorBridgeParent::ForceComposeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect) { AUTO_PROFILER_LABEL("CompositorBridgeParent::ForceComposeToTarget", GRAPHICS); @@ -1116,68 +991,6 @@ void CompositorBridgeParent::ScheduleRotationOnCompositorThread( } } -void CompositorBridgeParent::ShadowLayersUpdated( - LayerTransactionParent* aLayerTree, const TransactionInfo& aInfo, - bool aHitTestUpdate) { - const TargetConfig& targetConfig = aInfo.targetConfig(); - - ScheduleRotationOnCompositorThread(targetConfig, aInfo.isFirstPaint()); - - // Instruct the LayerManager to update its render bounds now. Since all the - // orientation change, dimension change would be done at the stage, update the - // size here is free of race condition. - mLayerManager->UpdateRenderBounds(targetConfig.naturalBounds()); - mLayerManager->SetRegionToClear(targetConfig.clearRegion()); - if (mLayerManager->GetCompositor()) { - mLayerManager->GetCompositor()->SetScreenRotation(targetConfig.rotation()); - } - - mCompositionManager->Updated(aInfo.isFirstPaint(), targetConfig); - Layer* root = aLayerTree->GetRoot(); - mLayerManager->SetRoot(root); - - if (mApzUpdater && !aInfo.isRepeatTransaction()) { - mApzUpdater->UpdateFocusState(mRootLayerTreeID, mRootLayerTreeID, - aInfo.focusTarget()); - - if (aHitTestUpdate) { - AutoResolveRefLayers resolve(mCompositionManager); - - mApzUpdater->UpdateHitTestingTree(root, aInfo.isFirstPaint(), - mRootLayerTreeID, - aInfo.paintSequenceNumber()); - } - } - - // The transaction ID might get reset to 1 if the page gets reloaded, see - // https://bugzilla.mozilla.org/show_bug.cgi?id=1145295#c41 - // Otherwise, it should be continually increasing. - MOZ_ASSERT(aInfo.id() == TransactionId{1} || mPendingTransactions.IsEmpty() || - aInfo.id() > mPendingTransactions.LastElement()); - mPendingTransactions.AppendElement(aInfo.id()); - mRefreshStartTime = aInfo.refreshStart(); - mTxnStartTime = aInfo.transactionStart(); - mFwdTime = aInfo.fwdTime(); - RegisterPayloads(aLayerTree, aInfo.payload()); - - if (root) { - SetShadowProperties(root); - } - if (aInfo.scheduleComposite()) { - ScheduleComposition(); - if (mPaused) { - TimeStamp now = TimeStamp::Now(); - DidComposite(VsyncId(), now, now); - } - } - mLayerManager->NotifyShadowTreeTransaction(); -} - -void CompositorBridgeParent::ScheduleComposite( - LayerTransactionParent* aLayerTree) { - ScheduleComposition(); -} - bool CompositorBridgeParent::SetTestSampleTime(const LayersId& aId, const TimeStamp& aTime) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); @@ -1222,34 +1035,6 @@ void CompositorBridgeParent::LeaveTestMode(const LayersId& aId) { } } -void CompositorBridgeParent::ApplyAsyncProperties( - LayerTransactionParent* aLayerTree, TransformsToSkip aSkip) { - // NOTE: This should only be used for testing. For example, when mTestTime is - // non-empty, or when called from test-only methods like - // LayerTransactionParent::RecvGetAnimationTransform. - - // Synchronously update the layer tree - if (aLayerTree->GetRoot()) { - AutoResolveRefLayers resolve(mCompositionManager); - SetShadowProperties(mLayerManager->GetRoot()); - - SampleTime time; - if (mTestTime) { - time = SampleTime::FromTest(*mTestTime); - } else { - time = mCompositorScheduler->GetLastComposeTime(); - } - bool requestNextFrame = - mCompositionManager->TransformShadowTree(time, mVsyncRate, aSkip); - if (!requestNextFrame) { - CancelCurrentCompositeTask(); - // Pretend we composited in case someone is waiting for this event. - TimeStamp now = TimeStamp::Now(); - DidComposite(VsyncId(), now, now); - } - } -} - CompositorAnimationStorage* CompositorBridgeParent::GetAnimationStorage() { if (!mAnimationStorage) { mAnimationStorage = new CompositorAnimationStorage(this); @@ -1347,8 +1132,8 @@ void CompositorBridgeParent::SetConfirmedTargetAPZC( void CompositorBridgeParent::SetFixedLayerMargins(ScreenIntCoord aTop, ScreenIntCoord aBottom) { - if (AsyncCompositionManager* manager = GetCompositionManager(nullptr)) { - manager->SetFixedLayerMargins(aTop, aBottom); + if (mCompositionManager) { + mCompositionManager->SetFixedLayerMargins(aTop, aBottom); } if (mApzcTreeManager) { @@ -1454,44 +1239,6 @@ RefPtr CompositorBridgeParent::NewCompositor( return nullptr; } -PLayerTransactionParent* CompositorBridgeParent::AllocPLayerTransactionParent( - const nsTArray& aBackendHints, const LayersId& aId) { - MOZ_ASSERT(!aId.IsValid()); - -#ifdef XP_WIN - // This is needed to avoid freezing the window on a device crash on double - // buffering, see bug 1549674. - if (gfxVars::UseDoubleBufferingWithCompositor() && XRE_IsGPUProcess() && - aBackendHints.Contains(LayersBackend::LAYERS_D3D11)) { - mWidget->AsWindows()->EnsureCompositorWindow(); - } -#endif - - InitializeLayerManager(aBackendHints); - - if (!mLayerManager) { - NS_WARNING("Failed to initialise Compositor"); - LayerTransactionParent* p = new LayerTransactionParent( - /* aManager */ nullptr, this, /* aAnimStorage */ nullptr, - mRootLayerTreeID, mVsyncRate); - p->AddIPDLReference(); - return p; - } - - mCompositionManager = new AsyncCompositionManager(this, mLayerManager); - - LayerTransactionParent* p = new LayerTransactionParent( - mLayerManager, this, GetAnimationStorage(), mRootLayerTreeID, mVsyncRate); - p->AddIPDLReference(); - return p; -} - -bool CompositorBridgeParent::DeallocPLayerTransactionParent( - PLayerTransactionParent* actor) { - static_cast(actor)->ReleaseIPDLReference(); - return true; -} - CompositorBridgeParent* CompositorBridgeParent::GetCompositorBridgeParent( uint64_t id) { AssertIsInCompositorThread(); @@ -1676,14 +1423,6 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( oldApzUpdater = sIndirectLayerTrees[child].mParent->mApzUpdater; } NotifyChildCreated(child); - if (sIndirectLayerTrees[child].mLayerTree) { - sIndirectLayerTrees[child].mLayerTree->SetLayerManager( - mLayerManager, GetAnimationStorage()); - // Trigger composition to handle a case that mLayerTree was not composited - // yet by previous CompositorBridgeParent, since nsRefreshDriver might - // wait composition complete. - scheduleComposition = true; - } if (mWrBridge) { childWrBridge = sIndirectLayerTrees[child].mWrBridge; } @@ -2145,22 +1884,6 @@ bool CompositorBridgeParent::DeallocPCompositorWidgetParent( #endif } -bool CompositorBridgeParent::IsPendingComposite() { - MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); - if (!mCompositor) { - return false; - } - return mCompositor->IsPendingComposite(); -} - -void CompositorBridgeParent::FinishPendingComposite() { - MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); - if (!mCompositor) { - return; - } - return mCompositor->FinishPendingComposite(); -} - CompositorController* CompositorBridgeParent::LayerTreeState::GetCompositorController() const { return mParent; diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index dd9fdbf6ccd4..7c73cdd9354a 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -90,7 +90,6 @@ class GeckoContentController; class HostLayerManager; class IAPZCTreeManager; class Layer; -class LayerTransactionParent; class OMTASampler; class ContentCompositorBridgeParent; class CompositorThreadHolder; @@ -122,25 +121,11 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, public: explicit CompositorBridgeParentBase(CompositorManagerParent* aManager); - virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree, - const TransactionInfo& aInfo, - bool aHitTestUpdate) = 0; - - virtual AsyncCompositionManager* GetCompositionManager( - LayerTransactionParent* aLayerTree) { - return nullptr; - } - - virtual void NotifyClearCachedResources(LayerTransactionParent* aLayerTree) {} - - virtual void ScheduleComposite(LayerTransactionParent* aLayerTree) {} virtual bool SetTestSampleTime(const LayersId& aId, const TimeStamp& aTime) { return true; } virtual void LeaveTestMode(const LayersId& aId) {} enum class TransformsToSkip : uint8_t { NoneOfThem = 0, APZ = 1 }; - virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree, - TransformsToSkip aSkip) = 0; virtual void SetTestAsyncScrollOffset( const LayersId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) = 0; @@ -155,10 +140,6 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, virtual void SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, nsTArray&& aTargets) = 0; - virtual void UpdatePaintTime(LayerTransactionParent* aLayerTree, - const TimeDuration& aPaintTime) {} - virtual void RegisterPayloads(LayerTransactionParent* aLayerTree, - const nsTArray& aPayload) {} IShmemAllocator* AsShmemAllocator() override { return this; } @@ -230,12 +211,6 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, virtual bool DeallocPAPZCTreeManagerParent( PAPZCTreeManagerParent* aActor) = 0; - virtual PLayerTransactionParent* AllocPLayerTransactionParent( - const nsTArray& layersBackendHints, - const LayersId& id) = 0; - virtual bool DeallocPLayerTransactionParent( - PLayerTransactionParent* aActor) = 0; - virtual PTextureParent* AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aBackend, const TextureFlags& aTextureFlags, @@ -308,8 +283,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS( CompositorBridgeParentBase::TransformsToSkip) class CompositorBridgeParent final : public CompositorBridgeParentBase, - public CompositorController, - public CompositorVsyncSchedulerOwner { + public CompositorController { friend class CompositorThreadHolder; friend class InProcessCompositorSession; friend class gfx::GPUProcessManager; @@ -384,14 +358,8 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void ActorDestroy(ActorDestroyReason why) override; - void ShadowLayersUpdated(LayerTransactionParent* aLayerTree, - const TransactionInfo& aInfo, - bool aHitTestUpdate) override; - void ScheduleComposite(LayerTransactionParent* aLayerTree) override; bool SetTestSampleTime(const LayersId& aId, const TimeStamp& aTime) override; void LeaveTestMode(const LayersId& aId) override; - void ApplyAsyncProperties(LayerTransactionParent* aLayerTree, - TransformsToSkip aSkip) override; CompositorAnimationStorage* GetAnimationStorage(); using JankedAnimations = std::unordered_map, LayersId::HashFn>; @@ -410,10 +378,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, nsTArray&& aTargets) override; - AsyncCompositionManager* GetCompositionManager( - LayerTransactionParent* aLayerTree) override { - return mCompositionManager; - } void SetFixedLayerMargins(ScreenIntCoord aTop, ScreenIntCoord aBottom); PTextureParent* AllocPTextureParent( @@ -479,11 +443,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, bool aIsRepeatTransaction, bool aHitTestUpdate); - void UpdatePaintTime(LayerTransactionParent* aLayerTree, - const TimeDuration& aPaintTime) override; - void RegisterPayloads(LayerTransactionParent* aLayerTree, - const nsTArray& aPayload) override; - /** * Check rotation info and schedule a rendering task if needed. * Only can be called from compositor thread. @@ -547,7 +506,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, // the PCompositorBridgeChild ContentCompositorBridgeParent* mContentCompositorBridgeParent; TargetConfig mTargetConfig; - LayerTransactionParent* mLayerTree; CompositorController* GetCompositorController() const; MetricsSharingController* CrossProcessSharingController() const; @@ -616,7 +574,7 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, CompositorOptions GetOptions() const { return mOptions; } - TimeDuration GetVsyncInterval() const override { + TimeDuration GetVsyncInterval() const { // the variable is called "rate" but really it's an interval return mVsyncRate; } @@ -707,12 +665,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void DeferredDestroy(); - PLayerTransactionParent* AllocPLayerTransactionParent( - const nsTArray& aBackendHints, - const LayersId& aId) override; - bool DeallocPLayerTransactionParent( - PLayerTransactionParent* aLayers) override; - void SetEGLSurfaceRect(int x, int y, int width, int height); void InitializeLayerManager(const nsTArray& aBackendHints); @@ -728,12 +680,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void ForceComposition(); void CancelCurrentCompositeTask(); - // CompositorVsyncSchedulerOwner - bool IsPendingComposite() override; - void FinishPendingComposite() override; - void CompositeToTarget(VsyncId aId, gfx::DrawTarget* aTarget, - const gfx::IntRect* aRect = nullptr) override; - RefPtr NewCompositor( const nsTArray& aBackendHints); diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp index 454b8487f3ed..daa7bbad16d9 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp @@ -8,7 +8,6 @@ #include // for uint64_t -#include "LayerTransactionParent.h" // for LayerTransactionParent #include "apz/src/APZCTreeManager.h" // for APZCTreeManager #include "gfxUtils.h" #ifdef XP_WIN @@ -25,7 +24,6 @@ #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/LayerTreeOwnerTracker.h" -#include "mozilla/layers/PLayerTransactionParent.h" #include "mozilla/layers/RemoteContentController.h" #include "mozilla/layers/WebRenderBridgeParent.h" #include "mozilla/layers/AsyncImagePipelineManager.h" @@ -63,57 +61,6 @@ void ContentCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { &ContentCompositorBridgeParent::DeferredDestroy)); } -PLayerTransactionParent* -ContentCompositorBridgeParent::AllocPLayerTransactionParent( - const nsTArray&, const LayersId& aId) { - MOZ_ASSERT(aId.IsValid()); - - // Check to see if this child process has access to this layer tree. - if (!LayerTreeOwnerTracker::Get()->IsMapped(aId, OtherPid())) { - NS_ERROR( - "Unexpected layers id in AllocPLayerTransactionParent; dropping " - "message..."); - return nullptr; - } - - MonitorAutoLock lock(*sIndirectLayerTreesLock); - - CompositorBridgeParent::LayerTreeState* state = nullptr; - LayerTreeMap::iterator itr = sIndirectLayerTrees.find(aId); - if (sIndirectLayerTrees.end() != itr) { - state = &itr->second; - } - - if (state && state->mLayerManager) { - state->mContentCompositorBridgeParent = this; - HostLayerManager* lm = state->mLayerManager; - CompositorAnimationStorage* animStorage = - state->mParent ? state->mParent->GetAnimationStorage() : nullptr; - TimeDuration vsyncRate = - state->mParent ? state->mParent->GetVsyncInterval() : TimeDuration(); - LayerTransactionParent* p = - new LayerTransactionParent(lm, this, animStorage, aId, vsyncRate); - p->AddIPDLReference(); - sIndirectLayerTrees[aId].mLayerTree = p; - return p; - } - - NS_WARNING("Created child without a matching parent?"); - LayerTransactionParent* p = new LayerTransactionParent( - /* aManager */ nullptr, this, /* aAnimStorage */ nullptr, aId, - TimeDuration()); - p->AddIPDLReference(); - return p; -} - -bool ContentCompositorBridgeParent::DeallocPLayerTransactionParent( - PLayerTransactionParent* aLayers) { - LayerTransactionParent* slp = static_cast(aLayers); - EraseLayerState(slp->GetId()); - static_cast(aLayers)->ReleaseIPDLReference(); - return true; -} - PAPZCTreeManagerParent* ContentCompositorBridgeParent::AllocPAPZCTreeManagerParent( const LayersId& aLayersId) { @@ -320,104 +267,15 @@ mozilla::ipc::IPCResult ContentCompositorBridgeParent::RecvCheckContentOnlyTDR( return IPC_OK(); }; -void ContentCompositorBridgeParent::ShadowLayersUpdated( - LayerTransactionParent* aLayerTree, const TransactionInfo& aInfo, - bool aHitTestUpdate) { - LayersId id = aLayerTree->GetId(); - - MOZ_ASSERT(id.IsValid()); - - CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(id); - if (!state) { - return; - } - MOZ_ASSERT(state->mParent); - state->mParent->ScheduleRotationOnCompositorThread(aInfo.targetConfig(), - aInfo.isFirstPaint()); - - Layer* shadowRoot = aLayerTree->GetRoot(); - if (shadowRoot) { - CompositorBridgeParent::SetShadowProperties(shadowRoot); - } - UpdateIndirectTree(id, shadowRoot, aInfo.targetConfig()); - - state->mParent->NotifyShadowTreeTransaction( - id, aInfo.isFirstPaint(), aInfo.focusTarget(), aInfo.scheduleComposite(), - aInfo.paintSequenceNumber(), aInfo.isRepeatTransaction(), aHitTestUpdate); - - if (aLayerTree->ShouldParentObserveEpoch()) { - // Note that we send this through the window compositor, since this needs - // to reach the widget owning the tab. - Unused << state->mParent->SendObserveLayersUpdate( - id, aLayerTree->GetChildEpoch(), true); - } - - auto endTime = TimeStamp::Now(); - if (profiler_can_accept_markers()) { - profiler_add_marker( - "CONTENT_FULL_PAINT_TIME", geckoprofiler::category::GRAPHICS, - MarkerTiming::Interval(aInfo.transactionStart(), endTime), - baseprofiler::markers::ContentBuildMarker{}); - } - Telemetry::Accumulate( - Telemetry::CONTENT_FULL_PAINT_TIME, - static_cast( - (endTime - aInfo.transactionStart()).ToMilliseconds())); - - RegisterPayloads(aLayerTree, aInfo.payload()); - - aLayerTree->SetPendingTransactionId( - aInfo.id(), aInfo.vsyncId(), aInfo.vsyncStart(), aInfo.refreshStart(), - aInfo.transactionStart(), endTime, aInfo.containsSVG(), aInfo.url(), - aInfo.fwdTime()); -} - void ContentCompositorBridgeParent::DidCompositeLocked( LayersId aId, const VsyncId& aVsyncId, TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) { sIndirectLayerTreesLock->AssertCurrentThreadOwns(); - if (LayerTransactionParent* layerTree = sIndirectLayerTrees[aId].mLayerTree) { - nsTArray transactions; - layerTree->FlushPendingTransactions(aVsyncId, aCompositeEnd, transactions); - if (!transactions.IsEmpty()) { - Unused << SendDidComposite(aId, transactions, aCompositeStart, - aCompositeEnd); - } - } else if (sIndirectLayerTrees[aId].mWrBridge) { + if (sIndirectLayerTrees[aId].mWrBridge) { MOZ_ASSERT(false); // this should never get called for a WR compositor } } -void ContentCompositorBridgeParent::ScheduleComposite( - LayerTransactionParent* aLayerTree) { - LayersId id = aLayerTree->GetId(); - MOZ_ASSERT(id.IsValid()); - CompositorBridgeParent* parent; - { // scope lock - MonitorAutoLock lock(*sIndirectLayerTreesLock); - parent = sIndirectLayerTrees[id].mParent; - } - if (parent) { - parent->ScheduleComposite(aLayerTree); - } -} - -void ContentCompositorBridgeParent::NotifyClearCachedResources( - LayerTransactionParent* aLayerTree) { - LayersId id = aLayerTree->GetId(); - MOZ_ASSERT(id.IsValid()); - - const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(id); - if (state && state->mParent) { - // Note that we send this through the window compositor, since this needs - // to reach the widget owning the tab. - Unused << state->mParent->SendObserveLayersUpdate( - id, aLayerTree->GetChildEpoch(), false); - } -} - bool ContentCompositorBridgeParent::SetTestSampleTime(const LayersId& aId, const TimeStamp& aTime) { MOZ_ASSERT(aId.IsValid()); @@ -443,20 +301,6 @@ void ContentCompositorBridgeParent::LeaveTestMode(const LayersId& aId) { state->mParent->LeaveTestMode(aId); } -void ContentCompositorBridgeParent::ApplyAsyncProperties( - LayerTransactionParent* aLayerTree, TransformsToSkip aSkip) { - LayersId id = aLayerTree->GetId(); - MOZ_ASSERT(id.IsValid()); - const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(id); - if (!state) { - return; - } - - MOZ_ASSERT(state->mParent); - state->mParent->ApplyAsyncProperties(aLayerTree, aSkip); -} - void ContentCompositorBridgeParent::SetTestAsyncScrollOffset( const LayersId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) { @@ -535,19 +379,6 @@ void ContentCompositorBridgeParent::SetConfirmedTargetAPZC( std::move(aTargets)); } -AsyncCompositionManager* ContentCompositorBridgeParent::GetCompositionManager( - LayerTransactionParent* aLayerTree) { - LayersId id = aLayerTree->GetId(); - const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(id); - if (!state) { - return nullptr; - } - - MOZ_ASSERT(state->mParent); - return state->mParent->GetCompositionManager(aLayerTree); -} - void ContentCompositorBridgeParent::DeferredDestroy() { mSelfRef = nullptr; } ContentCompositorBridgeParent::~ContentCompositorBridgeParent() { @@ -624,35 +455,6 @@ bool ContentCompositorBridgeParent::IsSameProcess() const { return OtherPid() == base::GetCurrentProcId(); } -void ContentCompositorBridgeParent::UpdatePaintTime( - LayerTransactionParent* aLayerTree, const TimeDuration& aPaintTime) { - LayersId id = aLayerTree->GetId(); - MOZ_ASSERT(id.IsValid()); - - CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(id); - if (!state || !state->mParent) { - return; - } - - state->mParent->UpdatePaintTime(aLayerTree, aPaintTime); -} - -void ContentCompositorBridgeParent::RegisterPayloads( - LayerTransactionParent* aLayerTree, - const nsTArray& aPayload) { - LayersId id = aLayerTree->GetId(); - MOZ_ASSERT(id.IsValid()); - - CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(id); - if (!state || !state->mParent) { - return; - } - - state->mParent->RegisterPayloads(aLayerTree, aPayload); -} - void ContentCompositorBridgeParent::ObserveLayersUpdate( LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive) { MOZ_ASSERT(aLayersId.IsValid()); diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.h b/gfx/layers/ipc/ContentCompositorBridgeParent.h index bfdfd22237e3..579e69be50c8 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.h +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.h @@ -108,22 +108,8 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { return IPC_OK(); } - PLayerTransactionParent* AllocPLayerTransactionParent( - const nsTArray& aBackendHints, - const LayersId& aId) override; - - bool DeallocPLayerTransactionParent( - PLayerTransactionParent* aLayers) override; - - void ShadowLayersUpdated(LayerTransactionParent* aLayerTree, - const TransactionInfo& aInfo, - bool aHitTestUpdate) override; - void ScheduleComposite(LayerTransactionParent* aLayerTree) override; - void NotifyClearCachedResources(LayerTransactionParent* aLayerTree) override; bool SetTestSampleTime(const LayersId& aId, const TimeStamp& aTime) override; void LeaveTestMode(const LayersId& aId) override; - void ApplyAsyncProperties(LayerTransactionParent* aLayerTree, - TransformsToSkip aSkip) override; void SetTestAsyncScrollOffset(const LayersId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) override; @@ -139,9 +125,6 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { const LayersId& aLayersId, const uint64_t& aInputBlockId, nsTArray&& aTargets) override; - AsyncCompositionManager* GetCompositionManager( - LayerTransactionParent* aParent) override; - already_AddRefed AllocPWebGLParent() override; // Use DidCompositeLocked if you already hold a lock on @@ -183,11 +166,6 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { PAPZParent* AllocPAPZParent(const LayersId& aLayersId) override; bool DeallocPAPZParent(PAPZParent* aActor) override; - void UpdatePaintTime(LayerTransactionParent* aLayerTree, - const TimeDuration& aPaintTime) override; - void RegisterPayloads(LayerTransactionParent* aLayerTree, - const nsTArray& aPayload) override; - PWebRenderBridgeParent* AllocPWebRenderBridgeParent( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize& aSize, const WindowKind& aWindowKind) override; diff --git a/gfx/layers/ipc/KnowsCompositor.cpp b/gfx/layers/ipc/KnowsCompositor.cpp index bcb8aa45f48d..69c24d85f390 100644 --- a/gfx/layers/ipc/KnowsCompositor.cpp +++ b/gfx/layers/ipc/KnowsCompositor.cpp @@ -7,6 +7,7 @@ #include "KnowsCompositor.h" #include "mozilla/layers/ImageDataSerializer.h" #include "mozilla/layers/ImageBridgeChild.h" +#include "mozilla/ipc/ProtocolUtils.h" namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/LayerTransactionChild.cpp b/gfx/layers/ipc/LayerTransactionChild.cpp deleted file mode 100644 index 4e937e702dbe..000000000000 --- a/gfx/layers/ipc/LayerTransactionChild.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- 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 "LayerTransactionChild.h" -#include "mozilla/gfx/Logging.h" -#include "mozilla/mozalloc.h" // for operator delete, etc -#include "nsTArray.h" // for nsTArray -#include "mozilla/layers/TextureClient.h" - -namespace mozilla { -namespace layers { - -void LayerTransactionChild::Destroy() { - if (!IPCOpen()) { - return; - } - // mDestroyed is used to prevent calling Send__delete__() twice. - // When this function is called from CompositorBridgeChild::Destroy(), - // under Send__delete__() call, this function is called from - // ShadowLayerForwarder's destructor. - // When it happens, IPCOpen() is still true. - // See bug 1004191. - mDestroyed = true; - - SendShutdown(); -} - -void LayerTransactionChild::ActorDestroy(ActorDestroyReason why) { - mDestroyed = true; -} - -} // namespace layers -} // namespace mozilla diff --git a/gfx/layers/ipc/LayerTransactionChild.h b/gfx/layers/ipc/LayerTransactionChild.h deleted file mode 100644 index 83ce36b02245..000000000000 --- a/gfx/layers/ipc/LayerTransactionChild.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- 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 MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H -#define MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H - -#include // for uint32_t -#include "mozilla/Attributes.h" // for override -#include "mozilla/ipc/ProtocolUtils.h" -#include "mozilla/layers/PLayerTransactionChild.h" -#include "mozilla/RefPtr.h" - -namespace mozilla { - -namespace layers { - -class ShadowLayerForwarder; - -class LayerTransactionChild : public PLayerTransactionChild { - public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(LayerTransactionChild) - /** - * Clean this up, finishing with SendShutDown() which will cause __delete__ - * to be sent from the parent side. - * - * It is expected (checked with an assert) that all shadow layers - * created by this have already been destroyed and - * Send__delete__()d by the time this method is called. - */ - void Destroy(); - - bool IPCOpen() const { return mIPCOpen && !mDestroyed; } - bool IsDestroyed() const { return mDestroyed; } - - void SetForwarder(ShadowLayerForwarder* aForwarder) { - mForwarder = aForwarder; - } - - LayersId GetId() const { return mId; } - - void MarkDestroyed() { mDestroyed = true; } - - protected: - explicit LayerTransactionChild(const LayersId& aId) - : mForwarder(nullptr), mIPCOpen(false), mDestroyed(false), mId(aId) {} - virtual ~LayerTransactionChild() = default; - - void ActorDestroy(ActorDestroyReason why) override; - - void AddIPDLReference() { - MOZ_ASSERT(mIPCOpen == false); - mIPCOpen = true; - AddRef(); - } - void ReleaseIPDLReference() { - MOZ_ASSERT(mIPCOpen == true); - mIPCOpen = false; - Release(); - } - friend class CompositorBridgeChild; - - ShadowLayerForwarder* mForwarder; - bool mIPCOpen; - bool mDestroyed; - LayersId mId; -}; - -} // namespace layers -} // namespace mozilla - -#endif // MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp deleted file mode 100644 index 510cf0a431e3..000000000000 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ /dev/null @@ -1,1019 +0,0 @@ -/* -*- 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 "LayerTransactionParent.h" -#include // for vector -#include "CompositableHost.h" // for CompositableParent, Get, etc -#include "ImageLayers.h" // for ImageLayer -#include "Layers.h" // for Layer, ContainerLayer, etc -#include "CompositableTransactionParent.h" // for EditReplyVector -#include "CompositorBridgeParent.h" -#include "mozilla/gfx/BasePoint3D.h" // for BasePoint3D -#include "mozilla/layers/AnimationHelper.h" // for GetAnimatedPropValue -#include "mozilla/layers/CanvasLayerComposite.h" -#include "mozilla/layers/ColorLayerComposite.h" -#include "mozilla/layers/Compositor.h" // for Compositor -#include "mozilla/layers/CompositorAnimationStorage.h" // for CompositorAnimationStorage -#include "mozilla/layers/ContainerLayerComposite.h" -#include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent -#include "mozilla/layers/ImageLayerComposite.h" -#include "mozilla/layers/LayerManagerComposite.h" -#include "mozilla/layers/LayersMessages.h" // for EditReply, etc -#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG -#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL -#include "mozilla/layers/PaintedLayerComposite.h" -#include "mozilla/mozalloc.h" // for operator delete, etc -#include "mozilla/PerfStats.h" -#include "mozilla/StaticPrefs_layers.h" -#include "mozilla/StaticPrefs_layout.h" -#include "mozilla/Telemetry.h" -#include "mozilla/Unused.h" -#include "nsCoord.h" // for NSAppUnitsToFloatPixels -#include "nsISupportsImpl.h" // for Layer::Release, etc -#include "nsLayoutUtils.h" // for nsLayoutUtils -#include "nsMathUtils.h" // for NS_round -#include "nsPoint.h" // for nsPoint -#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc -#include "TreeTraversal.h" // for ForEachNode -#include "mozilla/ProfilerLabels.h" -#include "mozilla/ProfilerMarkers.h" -#include "mozilla/layers/TextureHost.h" -#include "mozilla/layers/AsyncCompositionManager.h" - -using mozilla::Telemetry::LABELS_CONTENT_FRAME_TIME_REASON; - -namespace mozilla { -namespace layers { - -//-------------------------------------------------- -// LayerTransactionParent -LayerTransactionParent::LayerTransactionParent( - HostLayerManager* aManager, CompositorBridgeParentBase* aBridge, - CompositorAnimationStorage* aAnimStorage, LayersId aId, - TimeDuration aVsyncRate) - : mLayerManager(aManager), - mCompositorBridge(aBridge), - mAnimStorage(aAnimStorage), - mId(aId), - mChildEpoch{0}, - mParentEpoch{0}, - mVsyncRate(aVsyncRate), - mDestroyed(false), - mIPCOpen(false), - mUpdateHitTestingTree(false) { - MOZ_ASSERT(mId.IsValid()); -} - -LayerTransactionParent::~LayerTransactionParent() = default; - -void LayerTransactionParent::SetLayerManager( - HostLayerManager* aLayerManager, CompositorAnimationStorage* aAnimStorage) { - if (mDestroyed) { - return; - } - mLayerManager = aLayerManager; - for (const auto& layer : mLayerMap.Values()) { - if (mAnimStorage && layer->GetCompositorAnimationsId()) { - mAnimStorage->ClearById(layer->GetCompositorAnimationsId()); - } - layer->AsHostLayer()->SetLayerManager(aLayerManager); - } - mAnimStorage = aAnimStorage; -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvShutdown() { - Destroy(); - IProtocol* mgr = Manager(); - if (!Send__delete__(this)) { - return IPC_FAIL_NO_REASON(mgr); - } - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvShutdownSync() { - return RecvShutdown(); -} - -void LayerTransactionParent::Destroy() { - if (mDestroyed) { - return; - } - mDestroyed = true; - if (mAnimStorage) { - for (const auto& layer : mLayerMap.Values()) { - if (layer->GetCompositorAnimationsId()) { - mAnimStorage->ClearById(layer->GetCompositorAnimationsId()); - } - layer->Disconnect(); - } - } - mCompositables.clear(); - mAnimStorage = nullptr; -} - -class MOZ_STACK_CLASS AutoLayerTransactionParentAsyncMessageSender final { - public: - explicit AutoLayerTransactionParentAsyncMessageSender( - LayerTransactionParent* aLayerTransaction, - const nsTArray* aDestroyActors = nullptr) - : mLayerTransaction(aLayerTransaction), mActorsToDestroy(aDestroyActors) { - mLayerTransaction->SetAboutToSendAsyncMessages(); - } - - ~AutoLayerTransactionParentAsyncMessageSender() { - mLayerTransaction->SendPendingAsyncMessages(); - if (mActorsToDestroy) { - // Destroy the actors after sending the async messages because the latter - // may contain references to some actors. - for (const auto& op : *mActorsToDestroy) { - mLayerTransaction->DestroyActor(op); - } - } - } - - private: - LayerTransactionParent* mLayerTransaction; - const nsTArray* mActorsToDestroy; -}; - -mozilla::ipc::IPCResult LayerTransactionParent::RecvPaintTime( - const TransactionId& aTransactionId, const TimeDuration& aPaintTime) { - mCompositorBridge->UpdatePaintTime(this, aPaintTime); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvUpdate( - const TransactionInfo& aInfo) { - AUTO_PROFILER_TRACING_MARKER("Paint", "LayerTransaction", GRAPHICS); - AUTO_PROFILER_LABEL("LayerTransactionParent::RecvUpdate", GRAPHICS); - PerfStats::AutoMetricRecording - autoRecording; - - TimeStamp updateStart = TimeStamp::Now(); - - MOZ_LAYERS_LOG( - ("[ParentSide] received txn with %zu edits", aInfo.cset().Length())); - - UpdateFwdTransactionId(aInfo.fwdTransactionId()); - - if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) { - for (const auto& op : aInfo.toDestroy()) { - DestroyActor(op); - } - return IPC_OK(); - } - - // This ensures that destroy operations are always processed. It is not safe - // to early-return from RecvUpdate without doing so. - AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender( - this, &aInfo.toDestroy()); - - { - AutoResolveRefLayers resolve( - mCompositorBridge->GetCompositionManager(this)); - nsCString none; - mLayerManager->BeginTransaction(none); - } - - // Not all edits require an update to the hit testing tree. - mUpdateHitTestingTree = false; - - for (EditArray::index_type i = 0; i < aInfo.cset().Length(); ++i) { - const Edit& edit = const_cast(aInfo.cset()[i]); - - switch (edit.type()) { - // Create* ops - case Edit::TOpCreatePaintedLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreatePaintedLayer")); - - RefPtr layer = mLayerManager->CreatePaintedLayer(); - if (!BindLayer(layer, edit.get_OpCreatePaintedLayer())) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "CreatePaintedLayer"); - break; - } - case Edit::TOpCreateContainerLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreateContainerLayer")); - - RefPtr layer = mLayerManager->CreateContainerLayer(); - if (!BindLayer(layer, edit.get_OpCreateContainerLayer())) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "CreateContainerLayer"); - break; - } - case Edit::TOpCreateImageLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreateImageLayer")); - - RefPtr layer = mLayerManager->CreateImageLayer(); - if (!BindLayer(layer, edit.get_OpCreateImageLayer())) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "CreateImageLayer"); - break; - } - case Edit::TOpCreateColorLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreateColorLayer")); - - RefPtr layer = mLayerManager->CreateColorLayer(); - if (!BindLayer(layer, edit.get_OpCreateColorLayer())) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "CreateColorLayer"); - break; - } - case Edit::TOpCreateCanvasLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreateCanvasLayer")); - - RefPtr layer = mLayerManager->CreateCanvasLayer(); - if (!BindLayer(layer, edit.get_OpCreateCanvasLayer())) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "CreateCanvasLayer"); - break; - } - case Edit::TOpCreateRefLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreateRefLayer")); - - RefPtr layer = mLayerManager->CreateRefLayer(); - if (!BindLayer(layer, edit.get_OpCreateRefLayer())) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "CreateRefLayer"); - break; - } - case Edit::TOpSetDiagnosticTypes: { - mLayerManager->SetDiagnosticTypes( - edit.get_OpSetDiagnosticTypes().diagnostics()); - break; - } - // Tree ops - case Edit::TOpSetRoot: { - MOZ_LAYERS_LOG(("[ParentSide] SetRoot")); - - Layer* newRoot = AsLayer(edit.get_OpSetRoot().root()); - if (!newRoot) { - return IPC_FAIL_NO_REASON(this); - } - if (newRoot->GetParent()) { - // newRoot is not a root! - return IPC_FAIL_NO_REASON(this); - } - mRoot = newRoot; - - UpdateHitTestingTree(mRoot, "SetRoot"); - break; - } - case Edit::TOpInsertAfter: { - MOZ_LAYERS_LOG(("[ParentSide] InsertAfter")); - - const OpInsertAfter& oia = edit.get_OpInsertAfter(); - Layer* child = AsLayer(oia.childLayer()); - Layer* layer = AsLayer(oia.container()); - Layer* after = AsLayer(oia.after()); - if (!child || !layer || !after) { - return IPC_FAIL_NO_REASON(this); - } - ContainerLayer* container = layer->AsContainerLayer(); - if (!container || !container->InsertAfter(child, after)) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "InsertAfter"); - break; - } - case Edit::TOpPrependChild: { - MOZ_LAYERS_LOG(("[ParentSide] PrependChild")); - - const OpPrependChild& oac = edit.get_OpPrependChild(); - Layer* child = AsLayer(oac.childLayer()); - Layer* layer = AsLayer(oac.container()); - if (!child || !layer) { - return IPC_FAIL_NO_REASON(this); - } - ContainerLayer* container = layer->AsContainerLayer(); - if (!container || !container->InsertAfter(child, nullptr)) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "PrependChild"); - break; - } - case Edit::TOpRemoveChild: { - MOZ_LAYERS_LOG(("[ParentSide] RemoveChild")); - - const OpRemoveChild& orc = edit.get_OpRemoveChild(); - Layer* childLayer = AsLayer(orc.childLayer()); - Layer* layer = AsLayer(orc.container()); - if (!childLayer || !layer) { - return IPC_FAIL_NO_REASON(this); - } - ContainerLayer* container = layer->AsContainerLayer(); - if (!container || !container->RemoveChild(childLayer)) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "RemoveChild"); - break; - } - case Edit::TOpRepositionChild: { - MOZ_LAYERS_LOG(("[ParentSide] RepositionChild")); - - const OpRepositionChild& orc = edit.get_OpRepositionChild(); - Layer* child = AsLayer(orc.childLayer()); - Layer* after = AsLayer(orc.after()); - Layer* layer = AsLayer(orc.container()); - if (!child || !layer || !after) { - return IPC_FAIL_NO_REASON(this); - } - ContainerLayer* container = layer->AsContainerLayer(); - if (!container || !container->RepositionChild(child, after)) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "RepositionChild"); - break; - } - case Edit::TOpRaiseToTopChild: { - MOZ_LAYERS_LOG(("[ParentSide] RaiseToTopChild")); - - const OpRaiseToTopChild& rtc = edit.get_OpRaiseToTopChild(); - Layer* child = AsLayer(rtc.childLayer()); - if (!child) { - return IPC_FAIL_NO_REASON(this); - } - Layer* layer = AsLayer(rtc.container()); - if (!layer) { - return IPC_FAIL_NO_REASON(this); - } - ContainerLayer* container = layer->AsContainerLayer(); - if (!container || !container->RepositionChild(child, nullptr)) { - return IPC_FAIL_NO_REASON(this); - } - - UpdateHitTestingTree(layer, "RaiseToTopChild"); - break; - } - case Edit::TCompositableOperation: { - if (!ReceiveCompositableUpdate(edit.get_CompositableOperation())) { - return IPC_FAIL_NO_REASON(this); - } - break; - } - case Edit::TOpAttachCompositable: { - const OpAttachCompositable& op = edit.get_OpAttachCompositable(); - RefPtr host = FindCompositable(op.compositable()); - if (!Attach(AsLayer(op.layer()), host, false)) { - return IPC_FAIL_NO_REASON(this); - } - host->SetCompositorBridgeID(mLayerManager->GetCompositorBridgeID()); - break; - } - case Edit::TOpAttachAsyncCompositable: { - const OpAttachAsyncCompositable& op = - edit.get_OpAttachAsyncCompositable(); - RefPtr imageBridge = - ImageBridgeParent::GetInstance(OtherPid()); - if (!imageBridge) { - return IPC_FAIL_NO_REASON(this); - } - RefPtr host = imageBridge->FindCompositable( - op.compositable(), /* aAllowDisablingWebRender */ true); - if (!host) { - // This normally should not happen, but can after a GPU process crash. - // Media may not have had time to update the ImageContainer associated - // with a video frame, and we may try to attach a stale - // CompositableHandle. Rather than break the whole transaction, we - // just continue. - gfxCriticalNote << "CompositableHost " << op.compositable().Value() - << " not found"; - continue; - } - if (!Attach(AsLayer(op.layer()), host, true)) { - return IPC_FAIL_NO_REASON(this); - } - host->SetCompositorBridgeID(mLayerManager->GetCompositorBridgeID()); - break; - } - default: - MOZ_CRASH("not reached"); - } - } - - // Process simple attribute updates. - for (const auto& op : aInfo.setSimpleAttrs()) { - MOZ_LAYERS_LOG(("[ParentSide] SetSimpleLayerAttributes")); - Layer* layer = AsLayer(op.layer()); - if (!layer) { - return IPC_FAIL_NO_REASON(this); - } - const SimpleLayerAttributes& attrs = op.attrs(); - const SimpleLayerAttributes& orig = layer->GetSimpleAttributes(); - if (!attrs.HitTestingInfoIsEqual(orig)) { - UpdateHitTestingTree(layer, "scrolling info changed"); - } - layer->SetSimpleAttributes(op.attrs()); - } - - // Process attribute updates. - for (const auto& op : aInfo.setAttrs()) { - MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes")); - if (!SetLayerAttributes(op)) { - return IPC_FAIL_NO_REASON(this); - } - } - - // Process paints separately, after all normal edits. - for (const auto& op : aInfo.paints()) { - if (!ReceiveCompositableUpdate(op)) { - return IPC_FAIL_NO_REASON(this); - } - } - - mCompositorBridge->ShadowLayersUpdated(this, aInfo, mUpdateHitTestingTree); - - { - AutoResolveRefLayers resolve( - mCompositorBridge->GetCompositionManager(this)); - mLayerManager->EndTransaction(TimeStamp(), - LayerManager::END_NO_IMMEDIATE_REDRAW); - } - - if (!IsSameProcess()) { - // Ensure that any pending operations involving back and front - // buffers have completed, so that neither process stomps on the - // other's buffer contents. - LayerManagerComposite::PlatformSyncBeforeReplyUpdate(); - } - -#ifdef COMPOSITOR_PERFORMANCE_WARNING - int compositeTime = - (int)(mozilla::TimeStamp::Now() - updateStart).ToMilliseconds(); - if (compositeTime > 15) { - printf_stderr("Compositor: Layers update took %i ms (blocking gecko).\n", - compositeTime); - } -#endif - - // Enable visual warning for long transaction when draw FPS option is enabled - bool drawFps = StaticPrefs::layers_acceleration_draw_fps(); - if (drawFps) { - uint32_t visualWarningTrigger = - StaticPrefs::layers_transaction_warning_ms(); - // The default theshold is 200ms to trigger, hit red when it take 4 times - // longer - TimeDuration latency = TimeStamp::Now() - aInfo.transactionStart(); - if (latency > TimeDuration::FromMilliseconds(visualWarningTrigger)) { - float severity = - (latency - TimeDuration::FromMilliseconds(visualWarningTrigger)) - .ToMilliseconds() / - (4 * visualWarningTrigger); - if (severity > 1.f) { - severity = 1.f; - } - mLayerManager->VisualFrameWarning(severity); - printf_stderr( - "LayerTransactionParent::RecvUpdate transaction from process %d took " - "%f ms", - OtherPid(), latency.ToMilliseconds()); - } - - mLayerManager->RecordUpdateTime( - (TimeStamp::Now() - updateStart).ToMilliseconds()); - } - - return IPC_OK(); -} - -bool LayerTransactionParent::SetLayerAttributes( - const OpSetLayerAttributes& aOp) { - Layer* layer = AsLayer(aOp.layer()); - if (!layer) { - return false; - } - - const LayerAttributes& attrs = aOp.attrs(); - const CommonLayerAttributes& common = attrs.common(); - if (common.visibleRegion() != layer->GetVisibleRegion()) { - UpdateHitTestingTree(layer, "visible region changed"); - layer->SetVisibleRegion(common.visibleRegion()); - } - if (common.eventRegions() != layer->GetEventRegions()) { - UpdateHitTestingTree(layer, "event regions changed"); - layer->SetEventRegions(common.eventRegions()); - } - Maybe clipRect = - common.useClipRect() ? Some(common.clipRect()) : Nothing(); - if (clipRect != layer->GetClipRect()) { - UpdateHitTestingTree(layer, "clip rect changed"); - layer->SetClipRect(clipRect); - } - if (LayerHandle maskLayer = common.maskLayer()) { - layer->SetMaskLayer(AsLayer(maskLayer)); - } else { - layer->SetMaskLayer(nullptr); - } - layer->SetCompositorAnimations(mId, common.compositorAnimations()); - // Clean up the Animations by id in the CompositorAnimationStorage - // if there are no active animations on the layer - if (mAnimStorage && layer->GetCompositorAnimationsId() && - layer->GetPropertyAnimationGroups().IsEmpty()) { - mAnimStorage->ClearById(layer->GetCompositorAnimationsId()); - } - if (common.scrollMetadata() != layer->GetAllScrollMetadata()) { - UpdateHitTestingTree(layer, "scroll metadata changed"); - layer->SetScrollMetadata(common.scrollMetadata()); - } - layer->SetDisplayListLog(common.displayListLog().get()); - - // The updated invalid region is added to the existing one, since we can - // update multiple times before the next composite. - layer->AddInvalidRegion(common.invalidRegion()); - - nsTArray> maskLayers; - for (size_t i = 0; i < common.ancestorMaskLayers().Length(); i++) { - Layer* maskLayer = AsLayer(common.ancestorMaskLayers().ElementAt(i)); - if (!maskLayer) { - return false; - } - maskLayers.AppendElement(maskLayer); - } - layer->SetAncestorMaskLayers(maskLayers); - - typedef SpecificLayerAttributes Specific; - const SpecificLayerAttributes& specific = attrs.specific(); - switch (specific.type()) { - case Specific::Tnull_t: - break; - - case Specific::TPaintedLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] painted layer")); - - PaintedLayer* paintedLayer = layer->AsPaintedLayer(); - if (!paintedLayer) { - return false; - } - const PaintedLayerAttributes& attrs = - specific.get_PaintedLayerAttributes(); - - paintedLayer->SetValidRegion(attrs.validRegion()); - break; - } - case Specific::TContainerLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] container layer")); - - ContainerLayer* containerLayer = layer->AsContainerLayer(); - if (!containerLayer) { - return false; - } - const ContainerLayerAttributes& attrs = - specific.get_ContainerLayerAttributes(); - containerLayer->SetPreScale(attrs.preXScale(), attrs.preYScale()); - containerLayer->SetInheritedScale(attrs.inheritedXScale(), - attrs.inheritedYScale()); - containerLayer->SetScaleToResolution(attrs.presShellResolution()); - break; - } - case Specific::TColorLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] color layer")); - - ColorLayer* colorLayer = layer->AsColorLayer(); - if (!colorLayer) { - return false; - } - colorLayer->SetColor(specific.get_ColorLayerAttributes().color().value()); - colorLayer->SetBounds(specific.get_ColorLayerAttributes().bounds()); - break; - } - case Specific::TCanvasLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] canvas layer")); - - CanvasLayer* canvasLayer = layer->AsCanvasLayer(); - if (!canvasLayer) { - return false; - } - canvasLayer->SetSamplingFilter( - specific.get_CanvasLayerAttributes().samplingFilter()); - canvasLayer->SetBounds(specific.get_CanvasLayerAttributes().bounds()); - break; - } - case Specific::TRefLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] ref layer")); - - RefLayer* refLayer = layer->AsRefLayer(); - if (!refLayer) { - return false; - } - refLayer->SetReferentId(specific.get_RefLayerAttributes().id()); - refLayer->SetEventRegionsOverride( - specific.get_RefLayerAttributes().eventRegionsOverride()); - refLayer->SetRemoteDocumentSize( - specific.get_RefLayerAttributes().remoteDocumentSize()); - UpdateHitTestingTree(layer, "ref layer attributes changed"); - break; - } - case Specific::TImageLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] image layer")); - - ImageLayer* imageLayer = layer->AsImageLayer(); - if (!imageLayer) { - return false; - } - const ImageLayerAttributes& attrs = specific.get_ImageLayerAttributes(); - imageLayer->SetSamplingFilter(attrs.samplingFilter()); - imageLayer->SetScaleToSize(attrs.scaleToSize(), attrs.scaleMode()); - break; - } - default: - MOZ_CRASH("not reached"); - } - - return true; -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvSetLayersObserverEpoch( - const LayersObserverEpoch& aChildEpoch) { - mChildEpoch = aChildEpoch; - return IPC_OK(); -} - -bool LayerTransactionParent::ShouldParentObserveEpoch() { - if (mParentEpoch == mChildEpoch) { - return false; - } - - mParentEpoch = mChildEpoch; - return true; -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvSetTestSampleTime( - const TimeStamp& aTime) { - if (!mCompositorBridge->SetTestSampleTime(GetId(), aTime)) { - return IPC_FAIL_NO_REASON(this); - } - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvLeaveTestMode() { - if (mDestroyed) { - return IPC_FAIL_NO_REASON(this); - } - - mCompositorBridge->LeaveTestMode(GetId()); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvGetAnimationValue( - const uint64_t& aCompositorAnimationsId, OMTAValue* aValue) { - if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) { - return IPC_FAIL_NO_REASON(this); - } - - // Make sure we apply the latest animation style or else we can end up with - // a race between when we temporarily clear the animation transform (in - // CompositorBridgeParent::SetShadowProperties) and when animation - // recalculates the value. - mCompositorBridge->ApplyAsyncProperties( - this, CompositorBridgeParentBase::TransformsToSkip::APZ); - - if (!mAnimStorage) { - return IPC_FAIL_NO_REASON(this); - } - - *aValue = mAnimStorage->GetOMTAValue(aCompositorAnimationsId); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvGetTransform( - const LayerHandle& aLayerHandle, Maybe* aTransform) { - if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) { - return IPC_FAIL_NO_REASON(this); - } - - Layer* layer = AsLayer(aLayerHandle); - if (!layer) { - return IPC_FAIL_NO_REASON(this); - } - - mCompositorBridge->ApplyAsyncProperties( - this, CompositorBridgeParentBase::TransformsToSkip::NoneOfThem); - - Matrix4x4 transform = layer->AsHostLayer()->GetShadowBaseTransform(); - // Undo the scale transform applied by FrameTransformToTransformInDevice in - // AsyncCompositionManager.cpp. - if (ContainerLayer* c = layer->AsContainerLayer()) { - transform.PostScale(1.0f / c->GetInheritedXScale(), - 1.0f / c->GetInheritedYScale(), 1.0f); - } - float scale = 1; - Point3D scaledOrigin; - if (layer->GetTransformData()) { - const TransformData& data = *layer->GetTransformData(); - scale = data.appUnitsPerDevPixel(); - scaledOrigin = Point3D( - NS_round(NSAppUnitsToFloatPixels(data.origin().x, scale)), - NS_round(NSAppUnitsToFloatPixels(data.origin().y, scale)), 0.0f); - } - - // If our parent isn't a perspective layer, then the offset into reference - // frame coordinates will have been applied to us. Add an inverse translation - // to cancel it out. - if (!layer->GetParent() || !layer->GetParent()->GetTransformIsPerspective()) { - transform.PostTranslate(-scaledOrigin.x, -scaledOrigin.y, -scaledOrigin.z); - } - - *aTransform = Some(transform); - - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvSetAsyncScrollOffset( - const ScrollableLayerGuid::ViewID& aScrollID, const float& aX, - const float& aY) { - if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) { - return IPC_FAIL_NO_REASON(this); - } - - mCompositorBridge->SetTestAsyncScrollOffset(GetId(), aScrollID, - CSSPoint(aX, aY)); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvSetAsyncZoom( - const ScrollableLayerGuid::ViewID& aScrollID, const float& aValue) { - if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) { - return IPC_FAIL_NO_REASON(this); - } - - mCompositorBridge->SetTestAsyncZoom(GetId(), aScrollID, - LayerToParentLayerScale(aValue)); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvFlushApzRepaints() { - mCompositorBridge->FlushApzRepaints(GetId()); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvGetAPZTestData( - APZTestData* aOutData) { - mCompositorBridge->GetAPZTestData(GetId(), aOutData); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvGetFrameUniformity( - FrameUniformityData* aOutData) { - mCompositorBridge->GetFrameUniformity(GetId(), aOutData); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvRequestProperty( - const nsString& aProperty, float* aValue) { - *aValue = -1; - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvSetConfirmedTargetAPZC( - const uint64_t& aBlockId, nsTArray&& aTargets) { - for (size_t i = 0; i < aTargets.Length(); i++) { - // Guard against bad data from hijacked child processes - if (aTargets[i].mLayersId != GetId()) { - NS_ERROR( - "Unexpected layers id in RecvSetConfirmedTargetAPZC; dropping " - "message..."); - return IPC_FAIL(this, "Bad layers id"); - } - } - mCompositorBridge->SetConfirmedTargetAPZC(GetId(), aBlockId, - std::move(aTargets)); - return IPC_OK(); -} - -bool LayerTransactionParent::Attach(Layer* aLayer, - CompositableHost* aCompositable, - bool aIsAsync) { - if (!aCompositable || !aLayer) { - return false; - } - - HostLayer* layer = aLayer->AsHostLayer(); - if (!layer) { - return false; - } - - TextureSourceProvider* provider = - static_cast(aLayer->Manager()) - ->GetTextureSourceProvider(); - - MOZ_ASSERT(!aCompositable->AsWebRenderImageHost()); - if (aCompositable->AsWebRenderImageHost()) { - gfxCriticalNote << "Use WebRenderImageHost at LayerTransactionParent."; - } - if (!layer->SetCompositableHost(aCompositable)) { - // not all layer types accept a compositable, see bug 967824 - return false; - } - aCompositable->Attach(aLayer, provider, - aIsAsync ? CompositableHost::ALLOW_REATTACH | - CompositableHost::KEEP_ATTACHED - : CompositableHost::NO_FLAGS); - return true; -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvClearCachedResources() { - if (mRoot) { - // NB: |mRoot| here is the *child* context's root. In this parent - // context, it's just a subtree root. We need to scope the clear - // of resources to exactly that subtree, so we specify it here. - mLayerManager->ClearCachedResources(mRoot); - } - mCompositorBridge->NotifyClearCachedResources(this); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvScheduleComposite() { - mCompositorBridge->ScheduleComposite(this); - return IPC_OK(); -} - -void LayerTransactionParent::ActorDestroy(ActorDestroyReason why) { Destroy(); } - -bool LayerTransactionParent::AllocShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { - if (!mIPCOpen || mDestroyed) { - return false; - } - return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem); -} - -bool LayerTransactionParent::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { - if (!mIPCOpen || mDestroyed) { - return false; - } - - return PLayerTransactionParent::AllocUnsafeShmem(aSize, aType, aShmem); -} - -bool LayerTransactionParent::DeallocShmem(ipc::Shmem& aShmem) { - if (!mIPCOpen || mDestroyed) { - return false; - } - return PLayerTransactionParent::DeallocShmem(aShmem); -} - -bool LayerTransactionParent::IsSameProcess() const { - return OtherPid() == base::GetCurrentProcId(); -} - -void LayerTransactionParent::SetPendingTransactionId( - TransactionId aId, const VsyncId& aVsyncId, - const TimeStamp& aVsyncStartTime, const TimeStamp& aRefreshStartTime, - const TimeStamp& aTxnStartTime, const TimeStamp& aTxnEndTime, - bool aContainsSVG, const nsCString& aURL, const TimeStamp& aFwdTime) { - mPendingTransactions.AppendElement(PendingTransaction{ - aId, aVsyncId, aVsyncStartTime, aRefreshStartTime, aTxnStartTime, - aTxnEndTime, aFwdTime, aURL, aContainsSVG}); -} - -void LayerTransactionParent::FlushPendingTransactions( - const VsyncId& aCompositeId, TimeStamp& aCompositeEnd, - nsTArray& aOutTransactions) { - for (auto& transaction : mPendingTransactions) { - aOutTransactions.AppendElement(transaction.mId); - if (mId.IsValid() && transaction.mId.IsValid() && !mVsyncRate.IsZero()) { - RecordContentFrameTime( - transaction.mTxnVsyncId, transaction.mVsyncStartTime, - transaction.mTxnStartTime, aCompositeId, aCompositeEnd, - transaction.mTxnEndTime - transaction.mTxnStartTime, mVsyncRate, - transaction.mContainsSVG, false); - } - -#if defined(ENABLE_FRAME_LATENCY_LOG) - if (transaction.mId.IsValid()) { - if (transaction.mRefreshStartTime) { - int32_t latencyMs = lround( - (aCompositeEnd - transaction.mRefreshStartTime).ToMilliseconds()); - printf_stderr( - "From transaction start to end of generate frame latencyMs %d this " - "%p\n", - latencyMs, this); - } - if (transaction.mFwdTime) { - int32_t latencyMs = - lround((aCompositeEnd - transaction.mFwdTime).ToMilliseconds()); - printf_stderr( - "From forwarding transaction to end of generate frame latencyMs %d " - "this %p\n", - latencyMs, this); - } - } -#endif - } - - mPendingTransactions.Clear(); -} - -void LayerTransactionParent::SendAsyncMessage( - const nsTArray& aMessage) { - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); -} - -void LayerTransactionParent::SendPendingAsyncMessages() { - mCompositorBridge->SendPendingAsyncMessages(); -} - -void LayerTransactionParent::SetAboutToSendAsyncMessages() { - mCompositorBridge->SetAboutToSendAsyncMessages(); -} - -void LayerTransactionParent::NotifyNotUsed(PTextureParent* aTexture, - uint64_t aTransactionId) { - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); -} - -bool LayerTransactionParent::BindLayerToHandle(RefPtr aLayer, - const LayerHandle& aHandle) { - if (!aHandle || !aLayer) { - return false; - } - return mLayerMap.WithEntryHandle(aHandle.Value(), [&](auto&& entry) { - if (entry) { - return false; - } - entry.Insert(std::move(aLayer)); - return true; - }); -} - -Layer* LayerTransactionParent::AsLayer(const LayerHandle& aHandle) { - if (!aHandle) { - return nullptr; - } - return mLayerMap.GetWeak(aHandle.Value()); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvNewCompositable( - const CompositableHandle& aHandle, const TextureInfo& aInfo) { - if (!AddCompositable(aHandle, aInfo, /* aUseWebRender */ false)) { - return IPC_FAIL_NO_REASON(this); - } - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvReleaseLayer( - const LayerHandle& aHandle) { - RefPtr layer; - if (!aHandle || !mLayerMap.Remove(aHandle.Value(), getter_AddRefs(layer))) { - return IPC_FAIL_NO_REASON(this); - } - if (mAnimStorage && layer->GetCompositorAnimationsId()) { - mAnimStorage->ClearById(layer->GetCompositorAnimationsId()); - layer->ClearCompositorAnimations(); - } - layer->Disconnect(); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvReleaseCompositable( - const CompositableHandle& aHandle) { - ReleaseCompositable(aHandle); - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvRecordPaintTimes( - const PaintTiming& aTiming) { - // Currently we only add paint timings for remote layers. In the future - // we could be smarter and use paint timings from the UI process, either - // as a separate overlay or if no remote layers are attached. - if (mLayerManager && mCompositorBridge->IsRemote()) { - mLayerManager->RecordPaintTimes(aTiming); - } - return IPC_OK(); -} - -mozilla::ipc::IPCResult LayerTransactionParent::RecvGetTextureFactoryIdentifier( - TextureFactoryIdentifier* aIdentifier) { - if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) { - // Default constructor sets mParentBackend to LAYERS_NONE. - return IPC_OK(); - } - - *aIdentifier = mLayerManager->GetTextureFactoryIdentifier(); - return IPC_OK(); -} - -} // namespace layers -} // namespace mozilla diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h deleted file mode 100644 index 417236729ae3..000000000000 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- 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 MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H -#define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H - -#include // for size_t -#include // for uint64_t, uint32_t -#include "CompositableTransactionParent.h" -#include "mozilla/Attributes.h" // for override -#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc -#include "mozilla/layers/PLayerTransactionParent.h" -#include "nsRefPtrHashtable.h" -#include "nsTArrayForwardDeclare.h" // for nsTArray - -namespace mozilla { - -namespace ipc { -class Shmem; -} // namespace ipc - -namespace layers { - -class Layer; -class HostLayerManager; -class ShadowLayerParent; -class CompositableParent; -class CompositorAnimationStorage; -class CompositorBridgeParentBase; - -class LayerTransactionParent final : public PLayerTransactionParent, - public CompositableParentManager, - public mozilla::ipc::IShmemAllocator { - typedef nsTArray EditArray; - typedef nsTArray OpDestroyArray; - - friend class PLayerTransactionParent; - - public: - LayerTransactionParent(HostLayerManager* aManager, - CompositorBridgeParentBase* aBridge, - CompositorAnimationStorage* aAnimStorage, LayersId aId, - TimeDuration aVsyncRate); - - protected: - virtual ~LayerTransactionParent(); - - public: - void Destroy(); - - void SetLayerManager(HostLayerManager* aLayerManager, - CompositorAnimationStorage* aAnimStorage); - - LayersId GetId() const { return mId; } - Layer* GetRoot() const { return mRoot; } - - LayersObserverEpoch GetChildEpoch() const { return mChildEpoch; } - bool ShouldParentObserveEpoch(); - - IShmemAllocator* AsShmemAllocator() override { return this; } - - bool AllocShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; - - bool AllocUnsafeShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; - - bool DeallocShmem(ipc::Shmem& aShmem) override; - - bool IsSameProcess() const override; - - void SetPendingTransactionId(TransactionId aId, const VsyncId& aVsyncId, - const TimeStamp& aVsyncStartTime, - const TimeStamp& aRefreshStartTime, - const TimeStamp& aTxnStartTime, - const TimeStamp& aTxnEndTime, bool aContainsSVG, - const nsCString& aURL, - const TimeStamp& aFwdTime); - void FlushPendingTransactions(const VsyncId& aId, TimeStamp& aCompositeEnd, - nsTArray& aOutTransactions); - - // CompositableParentManager - void SendAsyncMessage( - const nsTArray& aMessage) override; - - void SendPendingAsyncMessages() override; - - void SetAboutToSendAsyncMessages() override; - - void NotifyNotUsed(PTextureParent* aTexture, - uint64_t aTransactionId) override; - - base::ProcessId GetChildProcessId() override { return OtherPid(); } - - protected: - mozilla::ipc::IPCResult RecvShutdown(); - mozilla::ipc::IPCResult RecvShutdownSync(); - - mozilla::ipc::IPCResult RecvPaintTime(const TransactionId& aTransactionId, - const TimeDuration& aPaintTime); - - mozilla::ipc::IPCResult RecvUpdate(const TransactionInfo& aInfo); - - mozilla::ipc::IPCResult RecvSetLayersObserverEpoch( - const LayersObserverEpoch& aChildEpoch); - mozilla::ipc::IPCResult RecvNewCompositable(const CompositableHandle& aHandle, - const TextureInfo& aInfo); - mozilla::ipc::IPCResult RecvReleaseLayer(const LayerHandle& aHandle); - mozilla::ipc::IPCResult RecvReleaseCompositable( - const CompositableHandle& aHandle); - - mozilla::ipc::IPCResult RecvClearCachedResources(); - mozilla::ipc::IPCResult RecvScheduleComposite(); - mozilla::ipc::IPCResult RecvSetTestSampleTime(const TimeStamp& aTime); - mozilla::ipc::IPCResult RecvLeaveTestMode(); - mozilla::ipc::IPCResult RecvGetAnimationValue( - const uint64_t& aCompositorAnimationsId, OMTAValue* aValue); - mozilla::ipc::IPCResult RecvGetTransform(const LayerHandle& aHandle, - Maybe* aTransform); - mozilla::ipc::IPCResult RecvSetAsyncScrollOffset( - const ScrollableLayerGuid::ViewID& aId, const float& aX, const float& aY); - mozilla::ipc::IPCResult RecvSetAsyncZoom( - const ScrollableLayerGuid::ViewID& aId, const float& aValue); - mozilla::ipc::IPCResult RecvFlushApzRepaints(); - mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* aOutData); - mozilla::ipc::IPCResult RecvGetFrameUniformity(FrameUniformityData* aOutData); - mozilla::ipc::IPCResult RecvRequestProperty(const nsString& aProperty, - float* aValue); - mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC( - const uint64_t& aBlockId, nsTArray&& aTargets); - mozilla::ipc::IPCResult RecvRecordPaintTimes(const PaintTiming& aTiming); - mozilla::ipc::IPCResult RecvGetTextureFactoryIdentifier( - TextureFactoryIdentifier* aIdentifier); - - bool SetLayerAttributes(const OpSetLayerAttributes& aOp); - - void ActorDestroy(ActorDestroyReason why) override; - - template - bool BindLayer(const RefPtr& aLayer, const T& aCreateOp) { - return BindLayerToHandle(aLayer, aCreateOp.layer()); - } - - bool BindLayerToHandle(RefPtr aLayer, const LayerHandle& aHandle); - - Layer* AsLayer(const LayerHandle& aLayer); - - bool Attach(Layer* aLayer, CompositableHost* aCompositable, - bool aIsAsyncVideo); - - void AddIPDLReference() { - MOZ_ASSERT(mIPCOpen == false); - mIPCOpen = true; - AddRef(); - } - void ReleaseIPDLReference() { - MOZ_ASSERT(mIPCOpen == true); - mIPCOpen = false; - Release(); - } - friend class CompositorBridgeParent; - friend class ContentCompositorBridgeParent; - - private: - // This is a function so we can log or breakpoint on why hit - // testing tree changes are made. - void UpdateHitTestingTree(Layer* aLayer, const char* aWhy) { - mUpdateHitTestingTree = true; - } - - private: - RefPtr mLayerManager; - CompositorBridgeParentBase* mCompositorBridge; - RefPtr mAnimStorage; - - // Hold the root because it might be grafted under various - // containers in the "real" layer tree - RefPtr mRoot; - - // Mapping from LayerHandles to Layers. - nsRefPtrHashtable mLayerMap; - - LayersId mId; - - // These fields keep track of the latest epoch values in the child and the - // parent. mChildEpoch is the latest epoch value received from the child. - // mParentEpoch is the latest epoch value that we have told BrowserParent - // about (via ObserveLayerUpdate). - LayersObserverEpoch mChildEpoch; - LayersObserverEpoch mParentEpoch; - - TimeDuration mVsyncRate; - - struct PendingTransaction { - TransactionId mId; - VsyncId mTxnVsyncId; - TimeStamp mVsyncStartTime; - TimeStamp mRefreshStartTime; - TimeStamp mTxnStartTime; - TimeStamp mTxnEndTime; - TimeStamp mFwdTime; - nsCString mTxnURL; - bool mContainsSVG; - }; - AutoTArray mPendingTransactions; - - // When the widget/frame/browser stuff in this process begins its - // destruction process, we need to Disconnect() all the currently - // live shadow layers, because some of them might be orphaned from - // the layer tree. This happens in Destroy() above. After we - // Destroy() ourself, there's a window in which that information - // hasn't yet propagated back to the child side and it might still - // send us layer transactions. We want to ignore those transactions - // because they refer to "zombie layers" on this side. So, we track - // that state with |mDestroyed|. This is similar to, but separate - // from, |mLayerManager->IsDestroyed()|; we might have had Destroy() - // called on us but the mLayerManager might not be destroyed, or - // vice versa. In both cases though, we want to ignore shadow-layer - // transactions posted by the child. - - bool mDestroyed; - bool mIPCOpen; - - // This is set during RecvUpdate to track whether we'll need to update - // APZ's hit test regions. - bool mUpdateHitTestingTree; -}; - -} // namespace layers -} // namespace mozilla - -#endif // MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H diff --git a/gfx/layers/ipc/PCompositorBridge.ipdl b/gfx/layers/ipc/PCompositorBridge.ipdl index 01a8c3a3f348..d58a05658671 100644 --- a/gfx/layers/ipc/PCompositorBridge.ipdl +++ b/gfx/layers/ipc/PCompositorBridge.ipdl @@ -15,7 +15,6 @@ include protocol PBrowser; include protocol PCanvas; include protocol PCompositorManager; include protocol PCompositorWidget; -include protocol PLayerTransaction; include protocol PTexture; include protocol PWebGL; include protocol PWebRenderBridge; @@ -99,7 +98,6 @@ struct FrameStats { manages PAPZ; manages PAPZCTreeManager; // A Compositor manages a single Layer Manager (PLayerTransaction) - manages PLayerTransaction; manages PTexture; manages PCompositorWidget; manages PWebRenderBridge; @@ -209,11 +207,6 @@ parent: sync StopFrameTimeRecording(uint32_t startIndex) returns (float[] intervals); - // layersBackendHints is an ordered list of preffered backends where - // layersBackendHints[0] is the best backend. If any hints are LayersBackend::LAYERS_NONE - // that hint is ignored. - async PLayerTransaction(LayersBackend[] layersBackendHints, LayersId id); - // Notify the compositor that a region of the screen has been invalidated. async NotifyRegionInvalidated(nsIntRegion region); diff --git a/gfx/layers/ipc/PLayerTransaction.ipdl b/gfx/layers/ipc/PLayerTransaction.ipdl deleted file mode 100644 index ddc50216e5c3..000000000000 --- a/gfx/layers/ipc/PLayerTransaction.ipdl +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=8 et : - */ -/* 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 LayersSurfaces; -include LayersMessages; -include protocol PCompositorBridge; -include protocol PTexture; - -include "mozilla/GfxMessageUtils.h"; -include "mozilla/layers/LayersMessageUtils.h"; - -using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; -using struct mozilla::void_t from "mozilla/ipc/IPCCore.h"; -using struct mozilla::null_t from "mozilla/ipc/IPCCore.h"; -using class mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h"; -using mozilla::layers::FrameUniformityData from "mozilla/layers/FrameUniformityData.h"; -using mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; -using mozilla::layers::ScrollableLayerGuid::ViewID from "mozilla/layers/ScrollableLayerGuid.h"; -using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; -using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; -using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h"; -using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h"; -using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h"; -using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h"; - -/** - * The layers protocol is spoken between thread contexts that manage - * layer (sub)trees. The protocol comprises atomically publishing - * layer subtrees to a "shadow" thread context (which grafts the - * subtree into its own tree), and atomically updating a published - * subtree. ("Atomic" in this sense is wrt painting.) - */ - -namespace mozilla { -namespace layers { - -/** - * The PLayerTransaction protocol manages the layer tree for a single "browser". - * The "browser" can be a top-level browser window, in which case the PLayer- - * TransactionChild exists in the UI process. The "browser" can also be a content - * tab, in which case the PLayerTransactionChild exists in the content process. - * In either case, the PLayerTransactionParent exists in the GPU process (if - * there is one) or the UI process otherwise. - */ -sync protocol PLayerTransaction { - manager PCompositorBridge; - -parent: - // The isFirstPaint flag can be used to indicate that this is the first update - // for a particular document. - async Update(TransactionInfo txn); - - async PaintTime(TransactionId id, TimeDuration paintTime); - - async SetLayersObserverEpoch(LayersObserverEpoch aChildEpoch); - - // Create a new Compositable. - async NewCompositable(CompositableHandle handle, TextureInfo info); - - // Release an object that is no longer in use. - async ReleaseLayer(LayerHandle layer); - async ReleaseCompositable(CompositableHandle compositable); - - // Tell the compositor to notify APZ that a layer has been confirmed for an - // input event. - async SetConfirmedTargetAPZC(uint64_t aInputBlockId, ScrollableLayerGuid[] aTargets); - - // Testing APIs - - // Enter test mode, set the sample time to sampleTime, and resample - // animations. sampleTime must not be null. - sync SetTestSampleTime(TimeStamp sampleTime); - // Leave test mode and resume normal compositing - sync LeaveTestMode(); - - // Returns |OMTAValue| applied to the layer. - sync GetAnimationValue(uint64_t aCompositorAnimationId) returns (OMTAValue value); - - // Returns the value of the transform applied to the layer by animation and - // APZC. - sync GetTransform(LayerHandle layer) returns (Matrix4x4? transform); - - // The next time the layer tree is composited, add this async scroll offset in - // CSS pixels for the given ViewID. - // Useful for testing rendering of async scrolling. - sync SetAsyncScrollOffset(ViewID id, float x, float y); - - // The next time the layer tree is composited, include this async zoom in - // for the given ViewID. - // Useful for testing rendering of async zooming. - sync SetAsyncZoom(ViewID id, float zoom); - - // Flush any pending APZ repaints to the main thread. - async FlushApzRepaints(); - - // Drop any front buffers that might be retained on the compositor - // side. - async ClearCachedResources(); - - // Schedule a composite if one isn't already scheduled. - async ScheduleComposite(); - - // Get a copy of the compositor-side APZ test data instance for this - // layers id. - sync GetAPZTestData() returns (APZTestData data); - - // Child requests frame uniformity measurements - sync GetFrameUniformity() returns (FrameUniformityData data); - - // Query a named property from the last frame - sync RequestProperty(nsString property) returns (float value); - - // Return the TextureFactoryIdentifier for this compositor. - sync GetTextureFactoryIdentifier() returns (TextureFactoryIdentifier aIdentifier); - - async RecordPaintTimes(PaintTiming timing); - - async Shutdown(); - sync ShutdownSync(); - -child: - async __delete__(); -}; - -} // namespace layers -} // namespace mozilla diff --git a/gfx/layers/ipc/PTexture.ipdl b/gfx/layers/ipc/PTexture.ipdl index b82a757bbcea..18eeb84c897e 100644 --- a/gfx/layers/ipc/PTexture.ipdl +++ b/gfx/layers/ipc/PTexture.ipdl @@ -6,7 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include LayersSurfaces; -include protocol PLayerTransaction; include protocol PCompositorBridge; include protocol PImageBridge; include protocol PVideoBridge; diff --git a/gfx/layers/ipc/ShadowLayerUtilsMac.cpp b/gfx/layers/ipc/ShadowLayerUtilsMac.cpp index c95e15483897..b095e5c2e900 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsMac.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsMac.cpp @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/gfx/Point.h" -#include "mozilla/layers/PLayerTransaction.h" #include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/CompositorTypes.h" diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 98a5bb3f55e1..5656597ae801 100755 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -186,8 +186,6 @@ EXPORTS.mozilla.layers += [ "ipc/KnowsCompositor.h", "ipc/LayerAnimationUtils.h", "ipc/LayersMessageUtils.h", - "ipc/LayerTransactionChild.h", - "ipc/LayerTransactionParent.h", "ipc/LayerTreeOwnerTracker.h", "ipc/RefCountedShmem.h", "ipc/RemoteContentController.h", @@ -443,8 +441,6 @@ UNIFIED_SOURCES += [ "ipc/ISurfaceAllocator.cpp", "ipc/KnowsCompositor.cpp", "ipc/LayerAnimationUtils.cpp", - "ipc/LayerTransactionChild.cpp", - "ipc/LayerTransactionParent.cpp", "ipc/LayerTreeOwnerTracker.cpp", "ipc/RefCountedShmem.cpp", "ipc/RemoteContentController.cpp", @@ -537,7 +533,6 @@ IPDL_SOURCES += [ "ipc/PCompositorBridgeTypes.ipdlh", "ipc/PCompositorManager.ipdl", "ipc/PImageBridge.ipdl", - "ipc/PLayerTransaction.ipdl", "ipc/PTexture.ipdl", "ipc/PUiCompositorController.ipdl", "ipc/PVideoBridge.ipdl", diff --git a/ipc/ipdl/message-metadata.ini b/ipc/ipdl/message-metadata.ini index 88c471502626..50ad64253796 100644 --- a/ipc/ipdl/message-metadata.ini +++ b/ipc/ipdl/message-metadata.ini @@ -8,8 +8,6 @@ segment_capacity = 16384 [PContent::AccumulateChildHistograms] segment_capacity = 16384 -[PLayerTransaction::Update] -segment_capacity = 8192 [PContent::StoreAndBroadcastBlobURLRegistration] segment_capacity = 8192 [PHttpChannel::Redirect1Begin] diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index c55d6131f8c5..662a33d09b90 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -85,7 +85,6 @@ #include "mozilla/layers/APZPublicUtils.h" #include "mozilla/layers/AxisPhysicsModel.h" #include "mozilla/layers/AxisPhysicsMSDModel.h" -#include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/ScrollLinkedEffectDetector.h" #include "mozilla/Unused.h" #include "MobileViewportManager.h" diff --git a/layout/ipc/RemoteLayerTreeOwner.cpp b/layout/ipc/RemoteLayerTreeOwner.cpp index feb442cb1cbb..f860921f50ce 100644 --- a/layout/ipc/RemoteLayerTreeOwner.cpp +++ b/layout/ipc/RemoteLayerTreeOwner.cpp @@ -11,7 +11,6 @@ #include "mozilla/dom/BrowserParent.h" #include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/CompositorTypes.h" -#include "mozilla/layers/LayerTransactionParent.h" #include "nsFrameLoader.h" #include "nsStyleStructInlines.h" #include "nsSubDocumentFrame.h" diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 0c1216dc1938..cfe04b1ff972 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -27,7 +27,6 @@ #include "mozilla/dom/SVGElement.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/gfx/2D.h" -#include "mozilla/layers/PLayerTransaction.h" #include "mozilla/PresShell.h" #include "mozilla/ShapeUtils.h" #include "mozilla/StaticPrefs_apz.h" diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 05227999749d..4be2be01055c 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -14,7 +14,6 @@ #include "mozilla/Hal.h" #include "mozilla/IMEStateManager.h" #include "mozilla/layers/APZChild.h" -#include "mozilla/layers/PLayerTransactionChild.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index a8032e851ea5..430e8e890f18 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -123,7 +123,6 @@ using mozilla::java::GeckoSession; #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/CompositorSession.h" -#include "mozilla/layers/LayerTransactionParent.h" #include "mozilla/layers/UiCompositorControllerChild.h" #include "nsThreadUtils.h" diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 8598fe46e9a3..1c1d468a60d0 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -52,7 +52,6 @@ #include "mozilla/layers/IAPZCTreeManager.h" #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/InputAPZContext.h" -#include "mozilla/layers/PLayerTransactionChild.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/webrender/WebRenderTypes.h" #include "nsAppDirectoryServiceDefs.h" diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index fbe9c390277e..51bb03731662 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -81,7 +81,6 @@ class CompositorBridgeChild; struct FrameMetrics; class LayerManager; class LayerManagerComposite; -class PLayerTransactionChild; class WebRenderBridgeChild; } // namespace layers namespace gfx { @@ -381,7 +380,6 @@ class nsIWidget : public nsISupports { typedef mozilla::layers::LayerManagerComposite LayerManagerComposite; typedef mozilla::layers::LayersBackend LayersBackend; typedef mozilla::layers::LayersId LayersId; - typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild; typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; typedef mozilla::layers::ZoomConstraints ZoomConstraints; typedef mozilla::widget::IMEEnabled IMEEnabled;