Bug 1296658: Attempt to create the correct BackendType buffers for a LayerManager. r=jrmuizel
MozReview-Commit-ID: 14Eg8FC6OpJ
--- a/gfx/layers/basic/BasicPaintedLayer.cpp
+++ b/gfx/layers/basic/BasicPaintedLayer.cpp
@@ -132,17 +132,17 @@ BasicPaintedLayer::PaintThebes(gfxContex
void
BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback)
{
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()) {
return;
}
nsTArray<ReadbackProcessor::Update> readbackUpdates;
if (aReadback && UsedForReadback()) {
@@ -223,14 +223,23 @@ BasicPaintedLayer::Validate(LayerManager
}
}
}
already_AddRefed<PaintedLayer>
BasicLayerManager::CreatePaintedLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
- RefPtr<PaintedLayer> 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<PaintedLayer> layer = new BasicPaintedLayer(this, backend);
return layer.forget();
}
} // namespace layers
} // namespace mozilla
--- a/gfx/layers/basic/BasicPaintedLayer.h
+++ b/gfx/layers/basic/BasicPaintedLayer.h
@@ -25,19 +25,20 @@ namespace layers {
class ReadbackProcessor;
class BasicPaintedLayer : public PaintedLayer, public BasicImplData {
public:
typedef RotatedContentBuffer::PaintState PaintState;
typedef RotatedContentBuffer::ContentType ContentType;
- explicit BasicPaintedLayer(BasicLayerManager* aLayerManager) :
+ explicit BasicPaintedLayer(BasicLayerManager* aLayerManager, gfx::BackendType aBackend) :
PaintedLayer(aLayerManager, static_cast<BasicImplData*>(this)),
mContentClient(nullptr)
+ , mBackend(aBackend)
{
MOZ_COUNT_CTOR(BasicPaintedLayer);
}
protected:
virtual ~BasicPaintedLayer()
{
MOZ_COUNT_DTOR(BasicPaintedLayer);
@@ -118,14 +119,15 @@ protected:
// here (OR doesn't automatically simplify to the simplest possible
// representation of a region.)
nsIntRegion tmp;
tmp.Or(mVisibleRegion.ToUnknownRegion(), aExtendedRegionToDraw);
mValidRegion.Or(mValidRegion, tmp);
}
RefPtr<ContentClientBasic> mContentClient;
+ gfx::BackendType mBackend;
};
} // namespace layers
} // namespace mozilla
#endif
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -109,34 +109,36 @@ ContentClient::PrintInfo(std::stringstre
pfx += " ";
Dump(aStream, pfx.get(), false);
}
}
// 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
ContentClientBasic::CreateBuffer(ContentType aType,
const IntRect& aRect,
uint32_t aFlags,
RefPtr<gfx::DrawTarget>* aBlackDT,
RefPtr<gfx::DrawTarget>* aWhiteDT)
{
MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
if (aFlags & BUFFER_COMPONENT_ALPHA) {
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));
}
void
ContentClientRemoteBuffer::DestroyBuffers()
{
if (!mTextureClient) {