Bug 1238753 - Use StartRemoteDrawingInRegion on Mac. r=mattwoodrow, a=sylvestre
authorMarkus Stange <mstange@themasta.com>
Mon, 11 Jan 2016 20:12:25 +0100
changeset 311041 b5419e75a3fe6f2a049cefa64ea41582ff97b226
parent 311040 577224869ce76cecfad16cd69fb31e2072a274c1
child 311042 aaa48192f8c5553a914e7bcb4eb89527a9eec5fe
push id5535
push usercbook@mozilla.com
push dateMon, 01 Feb 2016 13:42:17 +0000
treeherdermozilla-beta@aaa48192f8c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, sylvestre
bugs1238753
milestone45.0
Bug 1238753 - Use StartRemoteDrawingInRegion on Mac. r=mattwoodrow, a=sylvestre This improves upload performance and lets us override the invalid region if we need more than what BasicCompositor thinks we need.
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -535,17 +535,17 @@ public:
   // to DevPixelsToCocoaPoints().
   NSRect            UntypedDevPixelsToCocoaPoints(const nsIntRect& aRect) const {
     return nsCocoaUtils::UntypedDevPixelsToCocoaPoints(aRect, BackingScaleFactor());
   }
   NSRect            DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect) const {
     return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor());
   }
 
-  already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawing() override;
+  already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) override;
   void EndRemoteDrawing() override;
   void CleanupRemoteDrawing() override;
   bool InitCompositor(mozilla::layers::Compositor* aCompositor) override;
 
   APZCTreeManager* APZCTM() { return mAPZC ; }
 
   NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
                             int32_t aPanelX, int32_t aPanelY,
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2631,45 +2631,47 @@ nsChildView::TrackScrollEventAsSwipe(con
 
 void
 nsChildView::SwipeFinished()
 {
   mSwipeTracker = nullptr;
 }
 
 already_AddRefed<gfx::DrawTarget>
-nsChildView::StartRemoteDrawing()
+nsChildView::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
 {
   // should have created the GLPresenter in InitCompositor.
   MOZ_ASSERT(mGLPresenter);
   if (!mGLPresenter) {
     mGLPresenter = GLPresenter::CreateForWindow(this);
 
     if (!mGLPresenter) {
       return nullptr;
     }
   }
 
-  LayoutDeviceIntRegion dirtyRegion(LayoutDeviceIntRect::FromUnknownRect(mBounds));
+  LayoutDeviceIntRegion dirtyRegion(LayoutDeviceIntRegion::FromUnknownRegion(aInvalidRegion));
   LayoutDeviceIntSize renderSize =
     LayoutDeviceIntSize::FromUnknownSize(mBounds.Size());
 
   if (!mBasicCompositorImage) {
     mBasicCompositorImage = new RectTextureImage(mGLPresenter->gl());
   }
 
   RefPtr<gfx::DrawTarget> drawTarget =
     mBasicCompositorImage->BeginUpdate(renderSize, dirtyRegion);
 
   if (!drawTarget) {
     // Composite unchanged textures.
     DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));
     return nullptr;
   }
 
+  aInvalidRegion = mBasicCompositorImage->GetUpdateRegion().ToUnknownRegion();
+
   return drawTarget.forget();
 }
 
 void
 nsChildView::EndRemoteDrawing()
 {
   mBasicCompositorImage->EndUpdate(true);
   DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));