diff --git a/gfx/layers/Compositor.cpp b/gfx/layers/Compositor.cpp index b3cc35078b43..2bf227f8cb4d 100644 --- a/gfx/layers/Compositor.cpp +++ b/gfx/layers/Compositor.cpp @@ -503,8 +503,10 @@ gfx::IntRect Compositor::ComputeBackdropCopyRect( const gfx::Matrix4x4& aTransform, gfx::Matrix4x4* aOutTransform, gfx::Rect* aOutLayerQuad) { // Compute the clip. - gfx::IntPoint rtOffset = GetCurrentRenderTarget()->GetOrigin(); - gfx::IntSize rtSize = GetCurrentRenderTarget()->GetSize(); + RefPtr currentRenderTarget = + GetCurrentRenderTarget(); + gfx::IntPoint rtOffset = currentRenderTarget->GetOrigin(); + gfx::IntSize rtSize = currentRenderTarget->GetSize(); return layers::ComputeBackdropCopyRect(aRect, aClipRect, aTransform, gfx::IntRect(rtOffset, rtSize), diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index b6a2eb3d4a5b..a44e167463fd 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -292,7 +292,8 @@ class Compositor : public TextureSourceProvider { * Returns the current target for rendering. Will return null if we are * rendering to the screen. */ - virtual CompositingRenderTarget* GetCurrentRenderTarget() const = 0; + virtual already_AddRefed GetCurrentRenderTarget() + const = 0; /** * Returns a render target which contains the entire window's drawing. @@ -300,7 +301,8 @@ class Compositor : public TextureSourceProvider { * with buffered BasicCompositor, where only the invalid area is drawn to a * render target), this will return null. */ - virtual CompositingRenderTarget* GetWindowRenderTarget() const { + virtual already_AddRefed GetWindowRenderTarget() + const { return nullptr; } diff --git a/gfx/layers/basic/BasicCompositor.h b/gfx/layers/basic/BasicCompositor.h index f103ac5038dd..f63657ad58c7 100644 --- a/gfx/layers/basic/BasicCompositor.h +++ b/gfx/layers/basic/BasicCompositor.h @@ -98,12 +98,14 @@ class BasicCompositor : public Compositor { mRenderTarget->BindRenderTarget(); } - virtual CompositingRenderTarget* GetWindowRenderTarget() const override { - return mFullWindowRenderTarget; + virtual already_AddRefed GetWindowRenderTarget() + const override { + return do_AddRef(mFullWindowRenderTarget); } - virtual CompositingRenderTarget* GetCurrentRenderTarget() const override { - return mRenderTarget; + virtual already_AddRefed GetCurrentRenderTarget() + const override { + return do_AddRef(mRenderTarget); } virtual void DrawQuad(const gfx::Rect& aRect, const gfx::IntRect& aClipRect, diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index a109037a473f..12248d189fc1 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -565,7 +565,7 @@ RefPtr CreateTemporaryTargetAndCopyFromBackground( !gfx::ThebesMatrix(transform2d).HasNonIntegerTranslation()); sourcePoint += gfx::IntPoint::Truncate(transform._41, transform._42); - sourcePoint -= compositor->GetCurrentRenderTarget()->GetOrigin(); + sourcePoint -= previousTarget->GetOrigin(); return compositor->CreateRenderTargetFromSource(surfaceRect, previousTarget, sourcePoint); diff --git a/gfx/layers/d3d11/CompositorD3D11.h b/gfx/layers/d3d11/CompositorD3D11.h index a4a499dd9d5b..5e78c0158e2c 100644 --- a/gfx/layers/d3d11/CompositorD3D11.h +++ b/gfx/layers/d3d11/CompositorD3D11.h @@ -54,8 +54,9 @@ class CompositorD3D11 : public Compositor { const gfx::IntPoint& aSourcePoint) override; virtual void SetRenderTarget(CompositingRenderTarget* aSurface) override; - virtual CompositingRenderTarget* GetCurrentRenderTarget() const override { - return mCurrentRT; + virtual already_AddRefed GetCurrentRenderTarget() + const override { + return do_AddRef(mCurrentRT); } virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) override {} diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 0d33a447c738..43873fa59820 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -656,12 +656,14 @@ void CompositorOGL::SetRenderTarget(CompositingRenderTarget* aSurface) { PrepareViewport(mCurrentRenderTarget); } -CompositingRenderTarget* CompositorOGL::GetCurrentRenderTarget() const { - return mCurrentRenderTarget; +already_AddRefed +CompositorOGL::GetCurrentRenderTarget() const { + return do_AddRef(mCurrentRenderTarget); } -CompositingRenderTarget* CompositorOGL::GetWindowRenderTarget() const { - return mWindowRenderTarget; +already_AddRefed CompositorOGL::GetWindowRenderTarget() + const { + return do_AddRef(mWindowRenderTarget); } already_AddRefed CompositorOGL::CreateAsyncReadbackBuffer( diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 8a2f2b7892a5..c8578a0f7f83 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -155,8 +155,10 @@ class CompositorOGL final : public Compositor { const gfx::IntPoint& aSourcePoint) override; virtual void SetRenderTarget(CompositingRenderTarget* aSurface) override; - virtual CompositingRenderTarget* GetCurrentRenderTarget() const override; - virtual CompositingRenderTarget* GetWindowRenderTarget() const override; + virtual already_AddRefed GetCurrentRenderTarget() + const override; + virtual already_AddRefed GetWindowRenderTarget() + const override; virtual bool ReadbackRenderTarget(CompositingRenderTarget* aSource, AsyncReadbackBuffer* aDest) override;