Bug 1366915 part 1 - Remove pipeline id allocation with IPC MozPromise r=nical
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5211,28 +5211,16 @@ ContentParent::RecvClassifyLocal(const U
if (!uriClassifier) {
return IPC_FAIL_NO_REASON(this);
}
*aRv = uriClassifier->ClassifyLocalWithTables(uri, aTables, *aResults);
return IPC_OK();
}
mozilla::ipc::IPCResult
-ContentParent::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();
-}
-
-mozilla::ipc::IPCResult
ContentParent::RecvFileCreationRequest(const nsID& aID,
const nsString& aFullPath,
const nsString& aType,
const nsString& aName,
const bool& aLastModifiedPassed,
const int64_t& aLastModified,
const bool& aExistenceCheck,
const bool& aIsFromNsIFile)
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -638,19 +638,16 @@ public:
DeallocPURLClassifierParent(PURLClassifierParent* aActor) override;
virtual mozilla::ipc::IPCResult
RecvClassifyLocal(const URIParams& aURI,
const nsCString& aTables,
nsresult* aRv,
nsTArray<nsCString>* aResults) override;
- virtual mozilla::ipc::IPCResult
- RecvAllocPipelineId(RefPtr<AllocPipelineIdPromise>&& aPromise) override;
-
// Use the PHangMonitor channel to ask the child to repaint a tab.
void ForceTabPaint(TabParent* aTabParent, uint64_t aLayerObserverEpoch);
// This function is called when we are about to load a document from an
// HTTP(S), FTP or wyciwyg channel for a content process. It is a useful
// place to start to kick off work as early as possible in response to such
// document loads.
nsresult AboutToLoadHttpFtpWyciwygDocumentForChild(nsIChannel* aChannel);
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -58,17 +58,16 @@ include ServiceWorkerConfiguration;
include GraphicsMessages;
include ProfilerTypes;
include MemoryReportTypes;
// Workaround to prevent error if PContentChild.cpp & PContentBridgeParent.cpp
// are put into different UnifiedProtocolsXX.cpp files.
// XXX Remove this once bug 1069073 is fixed
include "mozilla/dom/PContentBridgeParent.h";
-include "mozilla/layers/WebRenderMessageUtils.h";
using GeoPosition from "nsGeoPositionIPCSerialiser.h";
using AlertNotificationType from "mozilla/AlertNotificationIPCSerializer.h";
using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h";
using struct SubstitutionMapping from "mozilla/chrome/RegistryMessageUtils.h";
using struct OverrideMapping from "mozilla/chrome/RegistryMessageUtils.h";
using base::ChildPrivileges from "base/process_util.h";
@@ -91,17 +90,16 @@ using mozilla::OriginAttributes from "mo
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
using struct mozilla::dom::FlyWebPublishOptions from "mozilla/dom/FlyWebPublishOptionsIPCSerializer.h";
using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";
-using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h";
union ChromeRegistryItem
{
ChromePackage;
OverrideMapping;
SubstitutionMapping;
};
@@ -1099,18 +1097,16 @@ parent:
sync GetA11yContentId() returns (uint32_t aContentId);
async A11yHandlerControl(uint32_t aPid,
IHandlerControlHolder aHandlerControl);
async AddMemoryReport(MemoryReport aReport);
async FinishMemoryReport(uint32_t aGeneration);
- async AllocPipelineId() returns (PipelineId pipelineId);
-
both:
async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
Principal aPrincipal, ClonedMessageData aData);
/**
* Notify `push-subscription-modified` observers in the parent and child.
*/
async NotifyPushSubscriptionModifiedObservers(nsCString scope,
--- a/gfx/layers/wr/WebRenderImageLayer.cpp
+++ b/gfx/layers/wr/WebRenderImageLayer.cpp
@@ -26,17 +26,16 @@ WebRenderImageLayer::WebRenderImageLayer
, mImageClientTypeContainer(CompositableType::UNKNOWN)
{
MOZ_COUNT_CTOR(WebRenderImageLayer);
}
WebRenderImageLayer::~WebRenderImageLayer()
{
MOZ_COUNT_DTOR(WebRenderImageLayer);
- mPipelineIdRequest.DisconnectIfExists();
for (auto key : mVideoKeys) {
WrManager()->AddImageKeyForDiscard(key);
}
if (mKey.isSome()) {
WrManager()->AddImageKeyForDiscard(mKey.value());
}
@@ -111,34 +110,16 @@ WebRenderImageLayer::RenderLayer(wr::Dis
CompositableType type = GetImageClientType();
if (type == CompositableType::UNKNOWN) {
return;
}
MOZ_ASSERT(GetImageClientType() != CompositableType::UNKNOWN);
- // Allocate PipelineId if necessary
- if (GetImageClientType() == CompositableType::IMAGE_BRIDGE &&
- mPipelineId.isNothing() && !mPipelineIdRequest.Exists()) {
- // Use Holder to pass this pointer to lambda.
- // Static anaysis tool does not permit to pass refcounted variable to lambda.
- // And we do not want to use RefPtr<WebRenderImageLayer> here.
- Holder holder(this);
- WrManager()->AllocPipelineId()
- ->Then(AbstractThread::MainThread(), __func__,
- [holder] (const wr::PipelineId& aPipelineId) {
- holder->mPipelineIdRequest.Complete();
- holder->mPipelineId = Some(aPipelineId);
- },
- [holder] (const ipc::PromiseRejectReason &aReason) {
- holder->mPipelineIdRequest.Complete();
- })->Track(mPipelineIdRequest);
- }
-
if (GetImageClientType() == CompositableType::IMAGE && !mImageClient) {
mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
WrBridge(),
TextureFlags::DEFAULT);
if (!mImageClient) {
return;
}
mImageClient->Connect();
--- a/gfx/layers/wr/WebRenderImageLayer.h
+++ b/gfx/layers/wr/WebRenderImageLayer.h
@@ -33,33 +33,22 @@ public:
const StackingContextHelper& aSc) override;
Maybe<WrImageMask> RenderMaskLayer(const gfx::Matrix4x4& aTransform) override;
protected:
CompositableType GetImageClientType();
void AddWRVideoImage(size_t aChannelNumber);
- class Holder {
- public:
- explicit Holder(WebRenderImageLayer* aLayer)
- : mLayer(aLayer)
- {}
- WebRenderImageLayer* operator ->() const { return mLayer; }
- private:
- WebRenderImageLayer* mLayer;
- };
-
wr::MaybeExternalImageId mExternalImageId;
// Some video image format contains multiple channel data.
nsTArray<wr::ImageKey> mVideoKeys;
// The regular single channel image.
Maybe<wr::ImageKey> mKey;
RefPtr<ImageClient> mImageClient;
CompositableType mImageClientTypeContainer;
Maybe<wr::PipelineId> mPipelineId;
- MozPromiseRequestHolder<PipelineIdPromise> mPipelineIdRequest;
};
} // namespace layers
} // namespace mozilla
#endif // GFX_WEBRENDERIMAGELAYER_H
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -2,18 +2,16 @@
* 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 "WebRenderLayerManager.h"
#include "gfxPrefs.h"
#include "LayersLogging.h"
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "WebRenderCanvasLayer.h"
#include "WebRenderColorLayer.h"
#include "WebRenderContainerLayer.h"
#include "WebRenderImageLayer.h"
@@ -488,35 +486,16 @@ WebRenderLayerManager::SendInvalidRegion
}
void
WebRenderLayerManager::Composite()
{
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());
- RefPtr<dom::ContentChild> contentChild = dom::ContentChild::GetSingleton();
- if (!contentChild) {
- return PipelineIdPromise::CreateAndReject(ipc::PromiseRejectReason::HandlerRejected, __func__);
- }
- return contentChild->SendAllocPipelineId();
-}
-
void
WebRenderLayerManager::SetRoot(Layer* aLayer)
{
mRoot = aLayer;
}
already_AddRefed<PaintedLayer>
WebRenderLayerManager::CreatePaintedLayer()
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -2,33 +2,30 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_WEBRENDERLAYERMANAGER_H
#define GFX_WEBRENDERLAYERMANAGER_H
#include "Layers.h"
-#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/MozPromise.h"
#include "mozilla/layers/TransactionIdAllocator.h"
#include "mozilla/webrender/WebRenderTypes.h"
class nsIWidget;
namespace mozilla {
namespace layers {
class CompositorBridgeChild;
class KnowsCompositor;
class PCompositorBridgeChild;
class WebRenderBridgeChild;
-typedef MozPromise<mozilla::wr::PipelineId, mozilla::ipc::PromiseRejectReason, false> PipelineIdPromise;
-
class WebRenderLayerManager final : public LayerManager
{
typedef nsTArray<RefPtr<Layer> > LayerRefArray;
public:
explicit WebRenderLayerManager(nsIWidget* aWidget);
void Initialize(PCompositorBridgeChild* aCBChild, wr::PipelineId aLayersId, TextureFactoryIdentifier* aTextureFactoryIdentifier);
@@ -124,18 +121,16 @@ public:
virtual void Mutated(Layer* aLayer) override;
virtual void MutatedSimple(Layer* aLayer) override;
void Hold(Layer* aLayer);
void SetTransactionIncomplete() { mTransactionIncomplete = true; }
bool IsMutatedLayer(Layer* aLayer);
- RefPtr<PipelineIdPromise> AllocPipelineId();
-
private:
/**
* Take a snapshot of the parent context, and copy
* it into mTarget.
*/
void MakeSnapshotIfRequired(LayoutDeviceIntSize aSize);
void ClearLayer(Layer* aLayer);