Skip to content

Commit

Permalink
Bug 1727682 - Make WebRenderLayerManager not inherit LayerManager. r=…
Browse files Browse the repository at this point in the history
…jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D124433
  • Loading branch information
mattwoodrow committed Sep 5, 2021
1 parent b9c6122 commit 189cbcd
Show file tree
Hide file tree
Showing 28 changed files with 197 additions and 267 deletions.
9 changes: 4 additions & 5 deletions dom/ipc/BrowserChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2878,12 +2878,11 @@ bool BrowserChild::CreateRemoteLayerManager(
MOZ_ASSERT(aCompositorChild);

return mPuppetWidget->CreateRemoteLayerManager(
[&](LayerManager* aLayerManager) -> bool {
MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager());
[&](WebRenderLayerManager* aLayerManager) -> bool {
nsCString error;
return aLayerManager->AsWebRenderLayerManager()->Initialize(
aCompositorChild, wr::AsPipelineId(mLayersId),
&mTextureFactoryIdentifier, error);
return aLayerManager->Initialize(aCompositorChild,
wr::AsPipelineId(mLayersId),
&mTextureFactoryIdentifier, error);
});
}

Expand Down
4 changes: 2 additions & 2 deletions gfx/ipc/GPUProcessManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ void GPUProcessManager::DestroyProcess() {
}

already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor(
nsBaseWidget* aWidget, LayerManager* aLayerManager,
nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize,
bool* aRetryOut) {
Expand Down Expand Up @@ -882,7 +882,7 @@ already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor(
}

RefPtr<CompositorSession> GPUProcessManager::CreateRemoteSession(
nsBaseWidget* aWidget, LayerManager* aLayerManager,
nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize) {
Expand Down
8 changes: 4 additions & 4 deletions gfx/ipc/GPUProcessManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PVideoBridgeParent;
class RemoteCompositorSession;
class InProcessCompositorSession;
class UiCompositorControllerChild;
class LayerManager;
class WebRenderLayerManager;
} // namespace layers
namespace widget {
class CompositorWidget;
Expand Down Expand Up @@ -69,7 +69,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
typedef layers::CompositorSession CompositorSession;
typedef layers::CompositorUpdateObserver CompositorUpdateObserver;
typedef layers::IAPZCTreeManager IAPZCTreeManager;
typedef layers::LayerManager LayerManager;
typedef layers::WebRenderLayerManager WebRenderLayerManager;
typedef layers::LayersId LayersId;
typedef layers::PCompositorBridgeChild PCompositorBridgeChild;
typedef layers::PCompositorManagerChild PCompositorManagerChild;
Expand All @@ -96,7 +96,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
bool EnsureGPUReady();

already_AddRefed<CompositorSession> CreateTopLevelCompositor(
nsBaseWidget* aWidget, LayerManager* aLayerManager,
nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize,
bool* aRetry);
Expand Down Expand Up @@ -265,7 +265,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
#endif // defined(MOZ_WIDGET_ANDROID)

RefPtr<CompositorSession> CreateRemoteSession(
nsBaseWidget* aWidget, LayerManager* aLayerManager,
nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize);
Expand Down
2 changes: 1 addition & 1 deletion gfx/ipc/InProcessCompositorSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ InProcessCompositorSession::InProcessCompositorSession(

/* static */
RefPtr<InProcessCompositorSession> InProcessCompositorSession::Create(
nsBaseWidget* aWidget, LayerManager* aLayerManager,
nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize, uint32_t aNamespace) {
Expand Down
4 changes: 2 additions & 2 deletions gfx/ipc/InProcessCompositorSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ namespace mozilla {
namespace layers {

class CompositorOptions;
class LayerManager;
class WebRenderLayerManager;

// A CompositorSession where both the child and parent CompositorBridge reside
// in the same process.
class InProcessCompositorSession final : public CompositorSession {
public:
static RefPtr<InProcessCompositorSession> Create(
nsBaseWidget* baseWidget, LayerManager* aLayerManager,
nsBaseWidget* baseWidget, WebRenderLayerManager* aLayerManager,
const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize, uint32_t aNamespace);
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/AnimationInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ bool AnimationInfo::AddAnimationsForProperty(
nsIFrame* aFrame, const EffectSet* aEffects,
const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations,
const Maybe<TransformData>& aTransformData, nsCSSPropertyID aProperty,
Send aSendFlag, LayerManager* aLayerManager) {
Send aSendFlag, WebRenderLayerManager* aLayerManager) {
bool addedAny = false;
// Add from first to last (since last overrides)
for (dom::Animation* anim : aCompositorAnimations) {
Expand Down Expand Up @@ -908,7 +908,7 @@ void AnimationInfo::AddNonAnimatingTransformLikePropertiesStyles(

void AnimationInfo::AddAnimationsForDisplayItem(
nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
DisplayItemType aType, LayerManager* aLayerManager,
DisplayItemType aType, WebRenderLayerManager* aLayerManager,
const Maybe<LayoutDevicePoint>& aPosition) {
Send sendFlag = !aBuilder ? Send::NextTransaction : Send::Immediate;
if (sendFlag == Send::NextTransaction) {
Expand Down
6 changes: 3 additions & 3 deletions gfx/layers/AnimationInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace layers {
class Animation;
class CompositorAnimations;
class Layer;
class LayerManager;
class WebRenderLayerManager;
struct CompositorAnimationData;
struct PropertyAnimationGroup;

Expand Down Expand Up @@ -118,7 +118,7 @@ class AnimationInfo final {

void AddAnimationsForDisplayItem(
nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
DisplayItemType aType, LayerManager* aLayerManager,
DisplayItemType aType, WebRenderLayerManager* aLayerManager,
const Maybe<LayoutDevicePoint>& aPosition = Nothing());

private:
Expand All @@ -136,7 +136,7 @@ class AnimationInfo final {
nsIFrame* aFrame, const EffectSet* aEffects,
const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations,
const Maybe<TransformData>& aTransformData, nsCSSPropertyID aProperty,
Send aSendFlag, LayerManager* aLayerManager);
Send aSendFlag, WebRenderLayerManager* aLayerManager);

void AddNonAnimatingTransformLikePropertiesStyles(
const nsCSSPropertyIDSet& aNonAnimatingProperties, nsIFrame* aFrame,
Expand Down
6 changes: 3 additions & 3 deletions gfx/layers/ipc/CompositorBridgeChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "mozilla/layers/IAPZCTreeManager.h"
#include "mozilla/layers/APZCTreeManagerChild.h"
#include "mozilla/layers/CanvasChild.h"
#include "mozilla/layers/LayerManager.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/PTextureChild.h"
#include "mozilla/layers/TextureClient.h" // for TextureClient
#include "mozilla/layers/TextureClientPool.h" // for TextureClientPool
Expand Down Expand Up @@ -249,7 +249,7 @@ void CompositorBridgeChild::InitForContent(uint32_t aNamespace) {
}

void CompositorBridgeChild::InitForWidget(uint64_t aProcessToken,
LayerManager* aLayerManager,
WebRenderLayerManager* aLayerManager,
uint32_t aNamespace) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aProcessToken);
Expand Down Expand Up @@ -318,7 +318,7 @@ mozilla::ipc::IPCResult CompositorBridgeChild::RecvDidComposite(
LayersBackend::LAYERS_CLIENT ||
mLayerManager->GetBackendType() == LayersBackend::LAYERS_WR);
// Hold a reference to keep LayerManager alive. See Bug 1242668.
RefPtr<LayerManager> m = mLayerManager;
RefPtr<WebRenderLayerManager> m = mLayerManager;
m->DidComposite(id, aCompositeStart, aCompositeEnd);
} else if (aId.IsValid()) {
RefPtr<dom::BrowserChild> child = dom::BrowserChild::GetFrom(aId);
Expand Down
9 changes: 4 additions & 5 deletions gfx/layers/ipc/CompositorBridgeChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ using mozilla::dom::BrowserChild;
class IAPZCTreeManager;
class APZCTreeManagerChild;
class CanvasChild;
class ClientLayerManager;
class CompositorBridgeParent;
class CompositorManagerChild;
class CompositorOptions;
class LayerManager;
class WebRenderLayerManager;
class TextureClient;
class TextureClientPool;
struct FrameMetrics;
Expand All @@ -70,8 +69,8 @@ class CompositorBridgeChild final : public PCompositorBridgeChild,
*/
void InitForContent(uint32_t aNamespace);

void InitForWidget(uint64_t aProcessToken, LayerManager* aLayerManager,
uint32_t aNamespace);
void InitForWidget(uint64_t aProcessToken,
WebRenderLayerManager* aLayerManager, uint32_t aNamespace);

void Destroy();

Expand Down Expand Up @@ -246,7 +245,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild,

RefPtr<CompositorManagerChild> mCompositorManager;

RefPtr<LayerManager> mLayerManager;
RefPtr<WebRenderLayerManager> mLayerManager;

uint32_t mIdNamespace;
uint32_t mResourceId;
Expand Down
9 changes: 5 additions & 4 deletions gfx/layers/ipc/CompositorManagerChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ bool CompositorManagerChild::CreateContentCompositorBridge(
/* static */
already_AddRefed<CompositorBridgeChild>
CompositorManagerChild::CreateWidgetCompositorBridge(
uint64_t aProcessToken, LayerManager* aLayerManager, uint32_t aNamespace,
CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize) {
uint64_t aProcessToken, WebRenderLayerManager* aLayerManager,
uint32_t aNamespace, CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
if (NS_WARN_IF(!sInstance || !sInstance->CanSend())) {
Expand Down Expand Up @@ -145,7 +146,7 @@ CompositorManagerChild::CreateWidgetCompositorBridge(
/* static */
already_AddRefed<CompositorBridgeChild>
CompositorManagerChild::CreateSameProcessWidgetCompositorBridge(
LayerManager* aLayerManager, uint32_t aNamespace) {
WebRenderLayerManager* aLayerManager, uint32_t aNamespace) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
if (NS_WARN_IF(!sInstance || !sInstance->CanSend())) {
Expand Down
11 changes: 6 additions & 5 deletions gfx/layers/ipc/CompositorManagerChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace layers {

class CompositorBridgeChild;
class CompositorManagerParent;
class LayerManager;
class WebRenderLayerManager;

class CompositorManagerChild : public PCompositorManagerChild {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerChild)
Expand All @@ -35,12 +35,13 @@ class CompositorManagerChild : public PCompositorManagerChild {
static bool CreateContentCompositorBridge(uint32_t aNamespace);

static already_AddRefed<CompositorBridgeChild> CreateWidgetCompositorBridge(
uint64_t aProcessToken, LayerManager* aLayerManager, uint32_t aNamespace,
CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize);
uint64_t aProcessToken, WebRenderLayerManager* aLayerManager,
uint32_t aNamespace, CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize);

static already_AddRefed<CompositorBridgeChild>
CreateSameProcessWidgetCompositorBridge(LayerManager* aLayerManager,
CreateSameProcessWidgetCompositorBridge(WebRenderLayerManager* aLayerManager,
uint32_t aNamespace);

static CompositorManagerChild* GetInstance() {
Expand Down
42 changes: 26 additions & 16 deletions gfx/layers/wr/WebRenderLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "nsDisplayList.h"
#include "nsLayoutUtils.h"
#include "WebRenderCanvasRenderer.h"
#include "LayerUserData.h"

#ifdef XP_WIN
# include "gfxDWriteFonts.h"
Expand All @@ -39,6 +40,7 @@ WebRenderLayerManager::WebRenderLayerManager(nsIWidget* aWidget)
mLatestTransactionId{0},
mNeedsComposite(false),
mIsFirstPaint(false),
mDestroyed(false),
mTarget(nullptr),
mPaintSequenceNumber(0),
mWebRenderCommandBuilder(this) {
Expand Down Expand Up @@ -137,8 +139,8 @@ void WebRenderLayerManager::DoDestroy(bool aIsSync) {
}

mDLBuilder = nullptr;

LayerManager::Destroy();
mUserData.Destroy();
mPartialPrerenderedAnimations.Clear();

mStateManager.Destroy();

Expand Down Expand Up @@ -166,6 +168,7 @@ void WebRenderLayerManager::DoDestroy(bool aIsSync) {

// Forget the widget pointer in case we outlive our owning widget.
mWidget = nullptr;
mDestroyed = true;
}

WebRenderLayerManager::~WebRenderLayerManager() {
Expand Down Expand Up @@ -320,14 +323,6 @@ bool WebRenderLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags) {
return true;
}

void WebRenderLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags) {
// This should never get called, all callers should use
// EndTransactionWithoutLayer instead.
MOZ_ASSERT(false);
}

void WebRenderLayerManager::EndTransactionWithoutLayer(
nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder,
WrFiltersHolder&& aFilters, WebRenderBackgroundData* aBackground,
Expand Down Expand Up @@ -739,11 +734,6 @@ void WebRenderLayerManager::ScheduleComposite() {
WrBridge()->SendScheduleComposite();
}

void WebRenderLayerManager::SetRoot(Layer* aLayer) {
// This should never get called
MOZ_ASSERT(false);
}

already_AddRefed<PersistentBufferProvider>
WebRenderLayerManager::CreatePersistentBufferProvider(
const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) {
Expand All @@ -760,7 +750,7 @@ WebRenderLayerManager::CreatePersistentBufferProvider(
return provider.forget();
}

return LayerManager::CreatePersistentBufferProvider(aSize, aFormat);
return WindowRenderer::CreatePersistentBufferProvider(aSize, aFormat);
}

void WebRenderLayerManager::ClearAsyncAnimations() {
Expand All @@ -776,5 +766,25 @@ void WebRenderLayerManager::GetFrameUniformity(FrameUniformityData* aOutData) {
WrBridge()->SendGetFrameUniformity(aOutData);
}

/*static*/
void WebRenderLayerManager::LayerUserDataDestroy(void* data) {
delete static_cast<LayerUserData*>(data);
}

UniquePtr<LayerUserData> WebRenderLayerManager::RemoveUserData(void* aKey) {
UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(
mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
return d;
}

std::unordered_set<ScrollableLayerGuid::ViewID>
WebRenderLayerManager::ClearPendingScrollInfoUpdate() {
std::unordered_set<ScrollableLayerGuid::ViewID> scrollIds(
mPendingScrollUpdates.Keys().cbegin(),
mPendingScrollUpdates.Keys().cend());
mPendingScrollUpdates.Clear();
return scrollIds;
}

} // namespace layers
} // namespace mozilla
Loading

0 comments on commit 189cbcd

Please sign in to comment.