Bug 1444447 - Implement Compositor::GetWindowRenderTarget() for unbuffered BasicCompositor. r?jrmuizel
MozReview-Commit-ID: Cmrm06itzSy
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -196,16 +196,17 @@ public:
BufferTextureHost* mTexture;
const gfx::IntSize mSize;
RefPtr<gfx::DataSourceSurface> mSurface;
bool mNeedsUpdate;
};
BasicCompositor::BasicCompositor(CompositorBridgeParent* aParent, widget::CompositorWidget* aWidget)
: Compositor(aWidget, aParent)
+ , mWindowRenderTarget(nullptr)
, mIsPendingEndRemoteDrawing(false)
{
MOZ_COUNT_CTOR(BasicCompositor);
mMaxTextureSize = Factory::GetMaxSurfaceSize(gfxVars::ContentBackend());
}
BasicCompositor::~BasicCompositor()
@@ -961,19 +962,25 @@ BasicCompositor::BeginFrame(const nsIntR
if (!target) {
if (!mTarget) {
mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
}
return;
}
SetRenderTarget(target);
- // We only allocate a surface sized to the invalidated region, so we need to
- // translate future coordinates.
- mRenderTarget->mDrawTarget->SetTransform(Matrix::Translation(-mRenderTarget->GetOrigin()));
+ if (bufferMode == BufferMode::BUFFER_NONE) {
+ // If there's no buffering, then the render target contains the entire
+ // window's content, so we can make it available via GetWindowRenderTarget().
+ mWindowRenderTarget = target;
+ } else {
+ // We only allocate a surface sized to the invalidated region, so we need to
+ // translate future coordinates.
+ mRenderTarget->mDrawTarget->SetTransform(Matrix::Translation(-mRenderTarget->GetOrigin()));
+ }
gfxUtils::ClipToRegion(mRenderTarget->mDrawTarget,
mInvalidRegion.ToUnknownRegion());
if (aRenderBoundsOut) {
*aRenderBoundsOut = rect;
}
@@ -1049,16 +1056,17 @@ BasicCompositor::TryToEndRemoteDrawing(b
}
}
if (aForceToEnd || !mTarget) {
mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
}
mDrawTarget = nullptr;
+ mWindowRenderTarget = nullptr;
mRenderTarget = nullptr;
mIsPendingEndRemoteDrawing = false;
}
bool
BasicCompositor::NeedsToDeferEndRemoteDrawing()
{
MOZ_ASSERT(mDrawTarget);
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -90,16 +90,20 @@ public:
{
mRenderTarget = static_cast<BasicCompositingRenderTarget*>(aSource);
mRenderTarget->BindRenderTarget();
}
virtual CompositingRenderTarget* GetCurrentRenderTarget() const override
{
return mRenderTarget;
}
+ virtual CompositingRenderTarget* GetWindowRenderTarget() const override
+ {
+ return mWindowRenderTarget;
+ }
virtual void DrawQuad(const gfx::Rect& aRect,
const gfx::IntRect& aClipRect,
const EffectChain &aEffectChain,
gfx::Float aOpacity,
const gfx::Matrix4x4& aTransform,
const gfx::Rect& aVisibleRect) override;
@@ -163,16 +167,18 @@ private:
void TryToEndRemoteDrawing(bool aForceToEnd = false);
bool NeedsToDeferEndRemoteDrawing();
// The final destination surface
RefPtr<gfx::DrawTarget> mDrawTarget;
// The current render target for drawing
RefPtr<BasicCompositingRenderTarget> mRenderTarget;
+ // The render target for the entire window, if available.
+ CompositingRenderTarget* mWindowRenderTarget;
LayoutDeviceIntRect mInvalidRect;
LayoutDeviceIntRegion mInvalidRegion;
uint32_t mMaxTextureSize;
bool mIsPendingEndRemoteDrawing;
};