From c764b148d3fe99b12b2c70a74d1cc676b359ce39 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 18 Jun 2013 19:58:43 +1200 Subject: [PATCH] Bug 873944 - Add FlushRendering API to the compositor interface. r=nrc --- gfx/layers/Layers.h | 9 +++++++++ gfx/layers/client/ClientLayerManager.cpp | 10 ++++++++++ gfx/layers/client/ClientLayerManager.h | 2 ++ gfx/layers/ipc/CompositorParent.cpp | 13 +++++++++++++ gfx/layers/ipc/CompositorParent.h | 1 + gfx/layers/ipc/PCompositor.ipdl | 4 ++++ 6 files changed, 39 insertions(+) diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 29aef1df13c..95c8bd864b1 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -466,6 +466,15 @@ public: */ virtual void SetIsFirstPaint() {} + /** + * Make sure that the previous transaction has been entirely + * completed. + * + * Note: This may sychronously wait on a remote compositor + * to complete rendering. + */ + virtual void FlushRendering() { } + // We always declare the following logging symbols, because it's // extremely tricky to conditionally declare them. However, for // ifndef MOZ_LAYERS_HAVE_LOG builds, they only have trivial diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 0ceb44f9d14..bd041160fa4 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -260,6 +260,16 @@ ClientLayerManager::MakeSnapshotIfRequired() mShadowTarget = nullptr; } +void +ClientLayerManager::FlushRendering() +{ + if (mWidget) { + if (CompositorChild* remoteRenderer = mWidget->GetRemoteRenderer()) { + remoteRenderer->SendFlushRendering(); + } + } +} + void ClientLayerManager::ForwardTransaction() { diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 08c64b20d0e..774a57c807f 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -53,6 +53,8 @@ public: virtual already_AddRefed CreateColorLayer(); virtual already_AddRefed CreateRefLayer(); + virtual void FlushRendering() MOZ_OVERRIDE; + ShadowableLayer* Hold(Layer* aLayer); bool HasShadowManager() const { return ShadowLayerForwarder::HasShadowManager(); } diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index d807d567bf9..be6dbf779c3 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -249,6 +249,18 @@ CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, return true; } +bool +CompositorParent::RecvFlushRendering() +{ + // If we're waiting to do a composite, then cancel it + // and do it immediately instead. + if (mCurrentCompositeTask) { + mCurrentCompositeTask->Cancel(); + ComposeToTarget(nullptr); + } + return true; +} + void CompositorParent::ActorDestroy(ActorDestroyReason why) { @@ -743,6 +755,7 @@ public: virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, SurfaceDescriptor* aOutSnapshot) { return true; } + virtual bool RecvFlushRendering() MOZ_OVERRIDE { return true; } virtual PLayerTransactionParent* AllocPLayerTransaction(const LayersBackend& aBackendType, diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index fba4cbff667..4f25a4201af 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -55,6 +55,7 @@ public: virtual bool RecvResume() MOZ_OVERRIDE; virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, SurfaceDescriptor* aOutSnapshot); + virtual bool RecvFlushRendering() MOZ_OVERRIDE; virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index cc78eba14cc..72e1ea00f01 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -53,6 +53,10 @@ parent: sync MakeSnapshot(SurfaceDescriptor inSnapshot) returns (SurfaceDescriptor outSnapshot); + // Make sure any pending composites are started immediately and + // block until they are completed. + sync FlushRendering(); + sync PLayerTransaction(LayersBackend layersBackendHint, uint64_t id) returns (TextureFactoryIdentifier textureFactoryIdentifier); };