Bug 1358014 - Add a capability to allocate PipelineId with IPC MozPromise r=nical

This commit is contained in:
Sotaro Ikeda 2017-04-25 10:39:56 -07:00
Родитель cbe34ab9f7
Коммит 2a9e1b455e
7 изменённых файлов: 67 добавлений и 1 удалений

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

@ -28,7 +28,7 @@ include JavaScriptTypes;
include URIParams; include URIParams;
include PPrintingTypes; include PPrintingTypes;
include PTabContext; include PTabContext;
include "mozilla/layers/WebRenderMessageUtils.h";
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h"; using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h";
@ -83,6 +83,7 @@ using mozilla::widget::CandidateWindowPosition from "ipc/nsGUIEventIPC.h";
using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h"; using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h";
using mozilla::FontRange from "ipc/nsGUIEventIPC.h"; using mozilla::FontRange from "ipc/nsGUIEventIPC.h";
using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h"; using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h";
using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -555,6 +556,8 @@ parent:
async AccessKeyNotHandled(WidgetKeyboardEvent event); async AccessKeyNotHandled(WidgetKeyboardEvent event);
async AllocPipelineId() returns (PipelineId pipelineId);
child: child:
async NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse); async NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse);

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

@ -3310,6 +3310,18 @@ TabParent::RecvRequestCrossBrowserNavigation(const uint32_t& aGlobalIndex)
return IPC_OK(); return IPC_OK();
} }
mozilla::ipc::IPCResult
TabParent::RecvAllocPipelineId(RefPtr<AllocPipelineIdPromise>&& aPromise)
{
GPUProcessManager* pm = GPUProcessManager::Get();
if (!pm) {
aPromise->Reject(PromiseRejectReason::HandlerRejected, __func__);
return IPC_OK();
}
aPromise->Resolve(wr::AsPipelineId(pm->AllocateLayerTreeId()), __func__);
return IPC_OK();
}
void void
TabParent::LiveResizeStarted() TabParent::LiveResizeStarted()
{ {

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

@ -630,6 +630,8 @@ protected:
virtual mozilla::ipc::IPCResult RecvRequestCrossBrowserNavigation(const uint32_t& aGlobalIndex) override; virtual mozilla::ipc::IPCResult RecvRequestCrossBrowserNavigation(const uint32_t& aGlobalIndex) override;
virtual mozilla::ipc::IPCResult RecvAllocPipelineId(RefPtr<AllocPipelineIdPromise>&& aPromise) override;
ContentCacheInParent mContentCache; ContentCacheInParent mContentCache;
nsIntRect mRect; nsIntRect mRect;

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

@ -28,6 +28,7 @@ WebRenderImageLayer::WebRenderImageLayer(WebRenderLayerManager* aLayerManager)
WebRenderImageLayer::~WebRenderImageLayer() WebRenderImageLayer::~WebRenderImageLayer()
{ {
MOZ_COUNT_DTOR(WebRenderImageLayer); MOZ_COUNT_DTOR(WebRenderImageLayer);
mPipelineIdRequest.DisconnectIfExists();
if (mKey.isSome()) { if (mKey.isSome()) {
WrManager()->AddImageKeyForDiscard(mKey.value()); WrManager()->AddImageKeyForDiscard(mKey.value());
} }
@ -95,6 +96,21 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
MOZ_ASSERT(GetImageClientType() != CompositableType::UNKNOWN); MOZ_ASSERT(GetImageClientType() != CompositableType::UNKNOWN);
// Allocate PipelineId if necessary
if (GetImageClientType() == CompositableType::IMAGE_BRIDGE &&
mPipelineId.isNothing() && !mPipelineIdRequest.Exists()) {
RefPtr<WebRenderImageLayer> self = this;
Manager()->AllocPipelineId()
->Then(AbstractThread::GetCurrent(), __func__,
[self] (const wr::PipelineId& aPipelineId) {
self->mPipelineIdRequest.Complete();
self->mPipelineId = Some(aPipelineId);
},
[self] (const ipc::PromiseRejectReason &aReason) {
self->mPipelineIdRequest.Complete();
})->Track(mPipelineIdRequest);
}
if (GetImageClientType() == CompositableType::IMAGE && !mImageClient) { if (GetImageClientType() == CompositableType::IMAGE && !mImageClient) {
mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE, mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
WrBridge(), WrBridge(),

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

@ -22,6 +22,7 @@ public:
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override; virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
virtual void ClearCachedResources() override; virtual void ClearCachedResources() override;
protected: protected:
virtual ~WebRenderImageLayer(); virtual ~WebRenderImageLayer();
@ -30,6 +31,9 @@ protected:
return static_cast<WebRenderLayerManager*>(mManager); return static_cast<WebRenderLayerManager*>(mManager);
} }
void OnPipelineIdAllocated() {}
void OnPipelineIdFailed() {}
public: public:
Layer* GetLayer() override { return this; } Layer* GetLayer() override { return this; }
void RenderLayer(wr::DisplayListBuilder& aBuilder) override; void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
@ -42,6 +46,8 @@ protected:
Maybe<wr::ImageKey> mKey; Maybe<wr::ImageKey> mKey;
RefPtr<ImageClient> mImageClient; RefPtr<ImageClient> mImageClient;
CompositableType mImageClientTypeContainer; CompositableType mImageClientTypeContainer;
Maybe<wr::PipelineId> mPipelineId;
MozPromiseRequestHolder<PipelineIdPromise> mPipelineIdRequest;
}; };
} // namespace layers } // namespace layers

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

@ -9,6 +9,7 @@
#include "gfxPrefs.h" #include "gfxPrefs.h"
#include "LayersLogging.h" #include "LayersLogging.h"
#include "mozilla/dom/TabChild.h" #include "mozilla/dom/TabChild.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/AsyncCompositionManager.h" #include "mozilla/layers/AsyncCompositionManager.h"
#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/CompositorBridgeChild.h"
@ -678,6 +679,25 @@ WebRenderLayerManager::Composite()
WrBridge()->SendForceComposite(); WrBridge()->SendForceComposite();
} }
RefPtr<PipelineIdPromise>
WebRenderLayerManager::AllocPipelineId()
{
if (XRE_IsParentProcess()) {
GPUProcessManager* pm = GPUProcessManager::Get();
if (!pm) {
return PipelineIdPromise::CreateAndReject(ipc::PromiseRejectReason::HandlerRejected, __func__);
}
return PipelineIdPromise::CreateAndResolve(wr::AsPipelineId(pm->AllocateLayerTreeId()), __func__);;
}
MOZ_ASSERT(XRE_IsContentProcess());
TabChild* tabChild = mWidget ? mWidget->GetOwningTabChild() : nullptr;
if (!tabChild) {
return PipelineIdPromise::CreateAndReject(ipc::PromiseRejectReason::HandlerRejected, __func__);
}
return tabChild->SendAllocPipelineId();
}
void void
WebRenderLayerManager::SetRoot(Layer* aLayer) WebRenderLayerManager::SetRoot(Layer* aLayer)
{ {

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

@ -7,8 +7,10 @@
#define GFX_WEBRENDERLAYERMANAGER_H #define GFX_WEBRENDERLAYERMANAGER_H
#include "Layers.h" #include "Layers.h"
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/layers/CompositorController.h" #include "mozilla/layers/CompositorController.h"
#include "mozilla/layers/TransactionIdAllocator.h" #include "mozilla/layers/TransactionIdAllocator.h"
#include "mozilla/MozPromise.h"
#include "mozilla/webrender/webrender_ffi.h" #include "mozilla/webrender/webrender_ffi.h"
#include "mozilla/webrender/WebRenderTypes.h" #include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/webrender/WebRenderAPI.h" #include "mozilla/webrender/WebRenderAPI.h"
@ -26,6 +28,9 @@ class WebRenderBridgeChild;
class WebRenderLayerManager; class WebRenderLayerManager;
class APZCTreeManager; class APZCTreeManager;
typedef MozPromise<mozilla::wr::PipelineId, mozilla::ipc::PromiseRejectReason, false> PipelineIdPromise;
class WebRenderLayer class WebRenderLayer
{ {
public: public:
@ -171,6 +176,8 @@ public:
void SetTransactionIncomplete() { mTransactionIncomplete = true; } void SetTransactionIncomplete() { mTransactionIncomplete = true; }
bool IsMutatedLayer(Layer* aLayer); bool IsMutatedLayer(Layer* aLayer);
RefPtr<PipelineIdPromise> AllocPipelineId();
private: private:
/** /**
* Take a snapshot of the parent context, and copy * Take a snapshot of the parent context, and copy