Bug 1444447 - Implement Compositor::BlitRenderTarget for BasicCompositor r=mstange
authorMarkus Stange <mstange@themasta.com>
Fri, 18 Jan 2019 03:51:08 +0000
changeset 514740 a70ed4f3086ae9e117c3e46f99fd40122bc07dc6
parent 514739 28e336f7b9da63ef319650a7bd698289574a4f11
child 514741 243733368484c9c41548d6acef5b6273be5f7948
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1444447
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1444447 - Implement Compositor::BlitRenderTarget for BasicCompositor r=mstange Depends on D14875 Differential Revision: https://phabricator.services.mozilla.com/D14876
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -862,16 +862,28 @@ bool BasicCompositor::ReadbackRenderTarg
   return true;
 }
 
 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::BeginFrame(
     const nsIntRegion& aInvalidRegion, const gfx::IntRect* aClipRectIn,
     const gfx::IntRect& aRenderBounds, const nsIntRegion& aOpaqueRegion,
     gfx::IntRect* aClipRectOut /* = nullptr */,
     gfx::IntRect* aRenderBoundsOut /* = nullptr */) {
   if (mIsPendingEndRemoteDrawing) {
     // Force to end previous remote drawing.
     TryToEndRemoteDrawing(/* aForceToEnd */ true);
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -84,16 +84,20 @@ class BasicCompositor : public Composito
   bool SupportsLayerGeometry() const override;
 
   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* GetWindowRenderTarget() const override {
     return mFullWindowRenderTarget;
   }