diff --git a/gfx/layers/basic/BasicPaintedLayer.cpp b/gfx/layers/basic/BasicPaintedLayer.cpp index b5fa31a54d9a..6cfa403e4bc9 100644 --- a/gfx/layers/basic/BasicPaintedLayer.cpp +++ b/gfx/layers/basic/BasicPaintedLayer.cpp @@ -137,7 +137,7 @@ BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback, if (!mContentClient) { // This client will have a null Forwarder, which means it will not have // a ContentHost on the other side. - mContentClient = new ContentClientBasic(); + mContentClient = new ContentClientBasic(mBackend); } if (!BasicManager()->IsRetained()) { @@ -229,7 +229,16 @@ already_AddRefed BasicLayerManager::CreatePaintedLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - RefPtr layer = new BasicPaintedLayer(this); + + BackendType backend = gfxPlatform::GetPlatform()->GetDefaultContentBackend(); + + if (mDefaultTarget) { + backend = mDefaultTarget->GetDrawTarget()->GetBackendType(); + } else if (mType == BLM_WIDGET) { + backend = gfxPlatform::GetPlatform()->GetContentBackendFor(LayersBackend::LAYERS_BASIC); + } + + RefPtr layer = new BasicPaintedLayer(this, backend); return layer.forget(); } diff --git a/gfx/layers/basic/BasicPaintedLayer.h b/gfx/layers/basic/BasicPaintedLayer.h index 59f71b20ce07..e616948e1cf5 100644 --- a/gfx/layers/basic/BasicPaintedLayer.h +++ b/gfx/layers/basic/BasicPaintedLayer.h @@ -30,9 +30,10 @@ public: typedef RotatedContentBuffer::PaintState PaintState; typedef RotatedContentBuffer::ContentType ContentType; - explicit BasicPaintedLayer(BasicLayerManager* aLayerManager) : + explicit BasicPaintedLayer(BasicLayerManager* aLayerManager, gfx::BackendType aBackend) : PaintedLayer(aLayerManager, static_cast(this)), mContentClient(nullptr) + , mBackend(aBackend) { MOZ_COUNT_CTOR(BasicPaintedLayer); } @@ -123,6 +124,7 @@ protected: } RefPtr mContentClient; + gfx::BackendType mBackend; }; } // namespace layers diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 645c47f1bb5e..5096f6209fff 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -114,9 +114,10 @@ ContentClient::PrintInfo(std::stringstream& aStream, const char* aPrefix) // We pass a null pointer for the ContentClient Forwarder argument, which means // this client will not have a ContentHost on the other side. -ContentClientBasic::ContentClientBasic() +ContentClientBasic::ContentClientBasic(gfx::BackendType aBackend) : ContentClient(nullptr) , RotatedContentBuffer(ContainsVisibleBounds) + , mBackend(aBackend) {} void @@ -131,7 +132,8 @@ ContentClientBasic::CreateBuffer(ContentType aType, gfxDevCrash(LogReason::AlphaWithBasicClient) << "Asking basic content client for component alpha"; } - *aBlackDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget( + *aBlackDT = gfxPlatform::GetPlatform()->CreateDrawTargetForBackend( + mBackend, IntSize(aRect.width, aRect.height), gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType)); } diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index c4cef16461ac..34a7e3348aef 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -126,7 +126,7 @@ class ContentClientBasic final : public ContentClient , protected RotatedContentBuffer { public: - ContentClientBasic(); + ContentClientBasic(gfx::BackendType aBackend); typedef RotatedContentBuffer::PaintState PaintState; typedef RotatedContentBuffer::ContentType ContentType; @@ -165,6 +165,9 @@ public: { MOZ_CRASH("GFX: Should not be called on non-remote ContentClient"); } + +private: + gfx::BackendType mBackend; }; /**