Bug 1444447 - Implement Compositor::BlitFromRenderTarget for BasicCompositor. r?jrmuizel draft
authorMarkus Stange <mstange@themasta.com>
Thu, 12 Apr 2018 15:37:16 -0400
changeset 781257 7d2c07d8a11ef4ee45298b12eb3a0651138e3772
parent 781256 03f704f1a407e1721fdea8cf76961a3318fdc618
push id106257
push userbmo:mstange@themasta.com
push dateThu, 12 Apr 2018 19:46:41 +0000
reviewersjrmuizel
bugs1444447
milestone61.0a1
Bug 1444447 - Implement Compositor::BlitFromRenderTarget for BasicCompositor. r?jrmuizel MozReview-Commit-ID: Hqw6DL1Nzwz
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -934,16 +934,31 @@ BasicCompositor::ReadbackRenderTarget(Co
 }
 
 already_AddRefed<AsyncReadbackBuffer>
 BasicCompositor::CreateAsyncReadbackBuffer(const gfx::IntSize& aSize)
 {
   return MakeAndAddRef<BasicAsyncReadbackBuffer>(aSize);
 }
 
+bool
+BasicCompositor::BlitRenderTarget(CompositingRenderTarget* aSource,
+                                  const gfx::IntSize& aSourceSize,
+                                  const gfx::IntSize& aDestSize)
+{
+  RefPtr<SourceSurface> surface =
+    static_cast<BasicCompositingRenderTarget*>(aSource)->mDrawTarget->Snapshot();
+  mRenderTarget->mDrawTarget->DrawSurface(surface,
+                                          Rect(Point(), Size(aDestSize)),
+                                          Rect(Point(), Size(aSourceSize)),
+                                          DrawSurfaceOptions(),
+                                          DrawOptions(1.0f, CompositionOp::OP_SOURCE));
+  return true;
+}
+
 void
 BasicCompositor::ClearRect(const gfx::Rect& aRect)
 {
   mRenderTarget->mDrawTarget->ClearRect(aRect);
 }
 
 void
 BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -88,16 +88,21 @@ public:
 
   virtual bool
   ReadbackRenderTarget(CompositingRenderTarget* aSource,
                        AsyncReadbackBuffer* aDest) override;
 
   virtual already_AddRefed<AsyncReadbackBuffer>
   CreateAsyncReadbackBuffer(const gfx::IntSize& aSize) override;
 
+  virtual bool
+  BlitRenderTarget(CompositingRenderTarget* aSource,
+                   const gfx::IntSize& aSourceSize,
+                   const gfx::IntSize& aDestSize) override;
+
   virtual void SetRenderTarget(CompositingRenderTarget *aSource) override
   {
     mRenderTarget = static_cast<BasicCompositingRenderTarget*>(aSource);
     mRenderTarget->BindRenderTarget();
   }
   virtual CompositingRenderTarget* GetCurrentRenderTarget() const override
   {
     return mRenderTarget;