Bug 1332249 - Add WebRenderCompositableHolder for WebRenderAPI r=nical?

This commit is contained in:
sotaro 2017-01-20 11:00:17 +09:00
Родитель 19f2cbe03f
Коммит 9d4636027c
5 изменённых файлов: 40 добавлений и 25 удалений

Просмотреть файл

@ -52,6 +52,7 @@
#include "mozilla/layers/PLayerTransactionParent.h"
#include "mozilla/layers/RemoteContentController.h"
#include "mozilla/layers/WebRenderBridgeParent.h"
#include "mozilla/layers/WebRenderCompositableHolder.h"
#include "mozilla/layers/WebRenderCompositorOGL.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "mozilla/webrender/WebRenderAPI.h"
@ -1593,9 +1594,10 @@ CompositorBridgeParent::AllocPWebRenderBridgeParent(const wr::PipelineId& aPipel
if (MOZ_USE_RENDER_THREAD) {
RefPtr<widget::CompositorWidget> widget = mWidget;
RefPtr<wr::WebRenderAPI> api = wr::WebRenderAPI::Create(gfxPrefs::WebRenderProfilerEnabled(), this, Move(widget));
RefPtr<WebRenderCompositableHolder> holder = new WebRenderCompositableHolder();
MOZ_ASSERT(api); // TODO have a fallback
api->SetRootPipeline(aPipelineId);
mWrBridge = new WebRenderBridgeParent(this, aPipelineId, mWidget, Move(api));
mWrBridge = new WebRenderBridgeParent(this, aPipelineId, mWidget, Move(api), Move(holder));
} else {
RefPtr<gl::GLContext> glc(gl::GLContextProvider::CreateForCompositorWidget(mWidget, true));
mCompositor = new WebRenderCompositorOGL(this, glc.get());

Просмотреть файл

@ -220,7 +220,8 @@ CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const wr::Pipeli
WebRenderBridgeParent* parent = nullptr;
if (MOZ_USE_RENDER_THREAD) {
RefPtr<wr::WebRenderAPI> api = root->GetWebRenderAPI();
parent = new WebRenderBridgeParent(this, aPipelineId, nullptr, Move(api));
RefPtr<WebRenderCompositableHolder> holder = root->CompositableHolder();
parent = new WebRenderBridgeParent(this, aPipelineId, nullptr, Move(api), Move(holder));
} else {
parent = new WebRenderBridgeParent(this, aPipelineId, nullptr, root->GLContext(),
root->WindowState(), root->Compositor());

Просмотреть файл

@ -199,6 +199,7 @@ EXPORTS.mozilla.layers += [
'TransactionIdAllocator.h',
'wr/WebRenderBridgeChild.h',
'wr/WebRenderBridgeParent.h',
'wr/WebRenderCompositableHolder.h',
'wr/WebRenderCompositorOGL.h',
'wr/WebRenderLayerManager.h',
'wr/WebRenderMessageUtils.h',
@ -376,6 +377,7 @@ UNIFIED_SOURCES += [
'wr/WebRenderBridgeParent.cpp',
'wr/WebRenderCanvasLayer.cpp',
'wr/WebRenderColorLayer.cpp',
'wr/WebRenderCompositableHolder.cpp',
'wr/WebRenderCompositorOGL.cpp',
'wr/WebRenderContainerLayer.cpp',
'wr/WebRenderImageLayer.cpp',

Просмотреть файл

@ -17,6 +17,7 @@
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/ImageDataSerializer.h"
#include "mozilla/layers/TextureHost.h"
#include "mozilla/layers/WebRenderCompositableHolder.h"
#include "mozilla/layers/WebRenderCompositorOGL.h"
#include "mozilla/webrender/RenderThread.h"
#include "mozilla/widget/CompositorWidget.h"
@ -113,7 +114,8 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompositorBridge,
const wr::PipelineId& aPipelineId,
widget::CompositorWidget* aWidget,
RefPtr<wr::WebRenderAPI>&& aApi)
RefPtr<wr::WebRenderAPI>&& aApi,
RefPtr<WebRenderCompositableHolder>&& aHolder)
: mCompositorBridge(aCompositorBridge)
, mPipelineId(aPipelineId)
, mWidget(aWidget)
@ -121,12 +123,14 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
, mGLContext(nullptr)
, mWRWindowState(nullptr)
, mApi(aApi)
, mCompositableHolder(aHolder)
, mCompositor(nullptr)
, mChildLayerObserverEpoch(0)
, mParentLayerObserverEpoch(0)
, mPendingTransactionId(0)
, mDestroyed(false)
{
MOZ_ASSERT(mCompositableHolder);
if (mWidget) {
mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget);
}
@ -335,10 +339,6 @@ WebRenderBridgeParent::ProcessWebrenderCommands(InfallibleTArray<WebRenderComman
break;
}
case WebRenderCommand::TOpDPPushExternalImageId: {
if (MOZ_USE_RENDER_THREAD) {
// TODO(bug 1328602)
break;
}
const OpDPPushExternalImageId& op = cmd.get_OpDPPushExternalImageId();
MOZ_ASSERT(mExternalImageIds.Get(op.externalImageId()).get());
@ -515,10 +515,6 @@ WebRenderBridgeParent::RecvAddExternalImageId(const uint64_t& aImageId,
if (mDestroyed) {
return IPC_OK();
}
if (MOZ_USE_RENDER_THREAD) {
// TODO(bug 1328602)
return IPC_OK();
}
MOZ_ASSERT(!mExternalImageIds.Get(aImageId).get());
@ -538,8 +534,12 @@ WebRenderBridgeParent::RecvAddExternalImageId(const uint64_t& aImageId,
return IPC_OK();
}
host->SetCompositor(mCompositor);
mCompositor->AsWebRenderCompositorOGL()->AddExternalImageId(aImageId, host);
if (!MOZ_USE_RENDER_THREAD) {
host->SetCompositor(mCompositor);
mCompositor->AsWebRenderCompositorOGL()->AddExternalImageId(aImageId, host);
} else {
mCompositableHolder->AddExternalImageId(aImageId, host);
}
mExternalImageIds.Put(aImageId, host);
return IPC_OK();
}
@ -551,10 +551,6 @@ WebRenderBridgeParent::RecvAddExternalImageIdForCompositable(const uint64_t& aIm
if (mDestroyed) {
return IPC_OK();
}
if (MOZ_USE_RENDER_THREAD) {
// TODO(bug 1328602)
return IPC_OK();
}
MOZ_ASSERT(!mExternalImageIds.Get(aImageId).get());
RefPtr<CompositableHost> host = FindCompositable(aHandle);
@ -565,8 +561,12 @@ WebRenderBridgeParent::RecvAddExternalImageIdForCompositable(const uint64_t& aIm
return IPC_OK();
}
host->SetCompositor(mCompositor);
mCompositor->AsWebRenderCompositorOGL()->AddExternalImageId(aImageId, host);
if (!MOZ_USE_RENDER_THREAD) {
host->SetCompositor(mCompositor);
mCompositor->AsWebRenderCompositorOGL()->AddExternalImageId(aImageId, host);
} else {
mCompositableHolder->AddExternalImageId(aImageId, host);
}
mExternalImageIds.Put(aImageId, host);
return IPC_OK();
}
@ -577,13 +577,13 @@ WebRenderBridgeParent::RecvRemoveExternalImageId(const uint64_t& aImageId)
if (mDestroyed) {
return IPC_OK();
}
if (MOZ_USE_RENDER_THREAD) {
// TODO(bug 1328602)
return IPC_OK();
}
MOZ_ASSERT(mExternalImageIds.Get(aImageId).get());
mExternalImageIds.Remove(aImageId);
mCompositor->AsWebRenderCompositorOGL()->RemoveExternalImageId(aImageId);
if (!MOZ_USE_RENDER_THREAD) {
mCompositor->AsWebRenderCompositorOGL()->RemoveExternalImageId(aImageId);
} else {
mCompositableHolder->RemoveExternalImageId(aImageId);
}
return IPC_OK();
}
@ -704,6 +704,12 @@ WebRenderBridgeParent::ClearResources()
mCompositor->AsWebRenderCompositorOGL()->RemoveExternalImageId(externalImageId);
}
}
if (mCompositableHolder) {
for (auto iter = mExternalImageIds.Iter(); !iter.Done(); iter.Next()) {
uint64_t externalImageId = iter.Key();
mCompositableHolder->RemoveExternalImageId(externalImageId);
}
}
mExternalImageIds.Clear();
if (mBuilder.isSome()) {

Просмотреть файл

@ -36,6 +36,7 @@ class CompositableHost;
class Compositor;
class CompositorBridgeParentBase;
class CompositorVsyncScheduler;
class WebRenderCompositableHolder;
class WebRenderBridgeParent final : public PWebRenderBridgeParent
, public CompositorVsyncSchedulerOwner
@ -45,7 +46,8 @@ public:
WebRenderBridgeParent(CompositorBridgeParentBase* aCompositorBridge,
const wr::PipelineId& aPipelineId,
widget::CompositorWidget* aWidget,
RefPtr<wr::WebRenderAPI>&& aApi);
RefPtr<wr::WebRenderAPI>&& aApi,
RefPtr<WebRenderCompositableHolder>&& aHolder);
WebRenderBridgeParent(CompositorBridgeParentBase* aCompositorBridge,
const wr::PipelineId& aPipelineId,
@ -57,6 +59,7 @@ public:
gl::GLContext* GLContext() { return mGLContext.get(); }
WrWindowState* WindowState() { return mWRWindowState; }
wr::WebRenderAPI* GetWebRenderAPI() { return mApi; }
WebRenderCompositableHolder* CompositableHolder() { return mCompositableHolder; }
layers::Compositor* Compositor() { return mCompositor.get(); }
CompositorVsyncScheduler* CompositorScheduler() { return mCompositorScheduler.get(); }
@ -144,6 +147,7 @@ private:
RefPtr<gl::GLContext> mGLContext;
WrWindowState* mWRWindowState;
RefPtr<wr::WebRenderAPI> mApi;
RefPtr<WebRenderCompositableHolder> mCompositableHolder;
RefPtr<layers::Compositor> mCompositor;
RefPtr<CompositorVsyncScheduler> mCompositorScheduler;
std::vector<wr::ImageKey> mKeysToDelete;