Skip to content

Commit

Permalink
Cleanup Compositor creation code path
Browse files Browse the repository at this point in the history
Override both ConfigureAPZCTreeManager and ConfigureAPZControllerThread
to simplify compositor creation. The nsBaseWidget::CreateCompositor
calls virtual ConfigureAPZCTreeManager that shall not do anything as
APZTreeManager is configured elsewhere.
  • Loading branch information
rainemak committed Apr 5, 2019
1 parent c5072a3 commit c860945
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 72 deletions.
89 changes: 17 additions & 72 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.cpp
Expand Up @@ -796,81 +796,10 @@ void EmbedLitePuppetWidget::CreateCompositor()
CreateCompositor(size.width, size.height);
}

static void
CheckForBasicBackends(nsTArray<LayersBackend>& aHints)
{
for (size_t i = 0; i < aHints.Length(); ++i) {
if (aHints[i] == LayersBackend::LAYERS_BASIC &&
!Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false) &&
!Preferences::GetBool("browser.tabs.remote", false)) {
// basic compositor is not stable enough for regular use
aHints[i] = LayersBackend::LAYERS_NONE;
}
}
}

void EmbedLitePuppetWidget::CreateCompositor(int aWidth, int aHeight)
{
LOGT();

// This makes sure that gfxPlatforms gets initialized if it hasn't by now.
gfxPlatform::GetPlatform();

MOZ_ASSERT(gfxPlatform::UsesOffMainThreadCompositing(),
"This function assumes OMTC");

MOZ_ASSERT(!mCompositorParent,
"Should have properly cleaned up the previous CompositorParent beforehand");

CreateCompositorVsyncDispatcher();
mCompositorParent = NewCompositorParent(aWidth, aHeight);
// MessageChannel* parentChannel = mCompositorParent->GetIPCChannel();
RefPtr<ClientLayerManager> lm = new ClientLayerManager(this);
// MessageLoop* childMessageLoop = CompositorParent::CompositorLoop();
mCompositorChild = new CompositorChild(lm);
// mCompositorChild->Open(parentChannel, childMessageLoop, ipc::ChildSide);
mCompositorChild->OpenSameProcess(mCompositorParent);

// Make sure the parent knows it is same process.
mCompositorParent->SetOtherProcessId(base::GetCurrentProcId());

TextureFactoryIdentifier textureFactoryIdentifier;
PLayerTransactionChild* shadowManager = nullptr;

nsTArray<LayersBackend> backendHints;
gfxPlatform::GetPlatform()->GetCompositorBackends(ComputeShouldAccelerate(), backendHints);

CheckForBasicBackends(backendHints);

bool success = false;
if (!backendHints.IsEmpty()) {
shadowManager = mCompositorChild->SendPLayerTransactionConstructor(
backendHints, 0, &textureFactoryIdentifier, &success);
}

ShadowLayerForwarder* lf = lm->AsShadowForwarder();
if (!success || !lf) {
NS_WARNING("Failed to create an OMT compositor.");
DestroyCompositor();
mLayerManager = nullptr;
mCompositorChild = nullptr;
mCompositorParent = nullptr;
mCompositorVsyncDispatcher = nullptr;
return;
}

lf->SetShadowManager(shadowManager);
lf->IdentifyTextureHost(textureFactoryIdentifier);
ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier);
WindowUsesOMTC();

mLayerManager = lm.forget();

if (mWindowType == eWindowType_toplevel) {
// Only track compositors for top-level windows, since other window types
// may use the basic compositor.
gfxPlatform::GetPlatform()->NotifyCompositorCreated(mLayerManager->GetCompositorBackendType());
}
nsBaseWidget::CreateCompositor(aWidth, aHeight);
}

void
Expand Down Expand Up @@ -1009,5 +938,21 @@ EmbedLitePuppetWidget::GetEmbedLiteChildView() const
return nullptr;
}

void EmbedLitePuppetWidget::ConfigureAPZCTreeManager()
{
LOGT("Do nothing - APZEventState configured in EmbedLiteViewBaseChild");
}

void EmbedLitePuppetWidget::ConfigureAPZControllerThread()
{
LOGT("Do nothing - APZController thread configured in EmbedLiteViewBaseParent");
}

already_AddRefed<GeckoContentController>
EmbedLitePuppetWidget::CreateRootContentController()
{
return nullptr;
}

} // namespace widget
} // namespace mozilla
4 changes: 4 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.h
Expand Up @@ -211,6 +211,10 @@ class EmbedLitePuppetWidget : public nsBaseWidget
virtual ~EmbedLitePuppetWidget() override;
EmbedLiteViewChildIface* GetEmbedLiteChildView() const;

virtual void ConfigureAPZCTreeManager();
virtual void ConfigureAPZControllerThread();
virtual already_AddRefed<GeckoContentController> CreateRootContentController() override;

private:
EmbedLitePuppetWidget();
typedef nsTArray<EmbedLitePuppetWidget*> ChildrenArray;
Expand Down

0 comments on commit c860945

Please sign in to comment.