Don't do PaintThebes after PaintOffMainThread. (bug 1399692 part 10, r=dvander) draft
authorRyan Hunt <rhunt@eqrion.net>
Thu, 09 Nov 2017 15:44:21 -0500
changeset 695951 cf0b0687a3c1ec690fffe1e81bd84447db38fe4f
parent 695950 e46827626f63ba84547fc191cde05d40a23e5249
child 739748 f0ad3bf62639e87c783aab493d66c50f38d6455a
push id88593
push userbmo:rhunt@eqrion.net
push dateFri, 10 Nov 2017 01:41:10 +0000
reviewersdvander
bugs1399692
milestone58.0a1
Don't do PaintThebes after PaintOffMainThread. (bug 1399692 part 10, r=dvander) MozReview-Commit-ID: J0IOzqIGRtz
gfx/layers/client/ClientPaintedLayer.cpp
gfx/layers/client/ClientPaintedLayer.h
--- a/gfx/layers/client/ClientPaintedLayer.cpp
+++ b/gfx/layers/client/ClientPaintedLayer.cpp
@@ -199,31 +199,34 @@ ClientPaintedLayer::PaintThebes(nsTArray
  *    ClientLayerManager will force a flushed paint and block the main thread
  *    if we have another transaction. Thus we have a gap between when the main
  *    thread records, the paint thread paints, and we block the main thread
  *    from trying to paint again. The underlying API however is NOT thread safe.
  *  4) We have both "sync" and "async" OMTP. Sync OMTP means we paint on the main thread
  *     but block the main thread while the paint thread paints. Async OMTP doesn't block
  *     the main thread. Sync OMTP is only meant to be used as a debugging tool.
  */
-bool
+void
 ClientPaintedLayer::PaintOffMainThread()
 {
   uint32_t flags = GetPaintFlags();
 
   PaintState state = mContentClient->BeginPaint(this, flags | ContentClient::PAINT_ASYNC);
   bool didUpdate = false;
 
   if (state.mBufferState) {
     PaintThread::Get()->PrepareBuffer(state.mBufferState);
     didUpdate = true;
   }
 
   if (!UpdatePaintRegion(state)) {
-    return false;
+    if (didUpdate) {
+      ClientManager()->SetQueuedAsyncPaints();
+    }
+    return;
   }
 
   RotatedBuffer::DrawIterator iter;
 
   // Debug Protip: Change to BorrowDrawTargetForPainting if using sync OMTP.
   while (RefPtr<CapturedPaintState> captureState =
           mContentClient->BorrowDrawTargetForRecording(state, &iter))
   {
@@ -267,32 +270,31 @@ ClientPaintedLayer::PaintOffMainThread()
 
   PaintThread::Get()->EndLayer();
   mContentClient->EndPaint(nullptr);
 
   if (didUpdate) {
     UpdateContentClient(state);
     ClientManager()->SetQueuedAsyncPaints();
   }
-  return true;
+  return;
 }
 
 void
 ClientPaintedLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback)
 {
   RenderMaskLayers(this);
 
   if (!EnsureContentClient()) {
     return;
   }
 
   if (CanRecordLayer(aReadback)) {
-    if (PaintOffMainThread()) {
-      return;
-    }
+    PaintOffMainThread();
+    return;
   }
 
   nsTArray<ReadbackProcessor::Update> readbackUpdates;
   nsIntRegion readbackRegion;
   if (aReadback && UsedForReadback()) {
     aReadback->GetPaintedLayerUpdates(this, &readbackUpdates);
   }
 
--- a/gfx/layers/client/ClientPaintedLayer.h
+++ b/gfx/layers/client/ClientPaintedLayer.h
@@ -116,17 +116,17 @@ protected:
   void PaintThebes(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates);
   void RecordThebes();
   bool CanRecordLayer(ReadbackProcessor* aReadback);
   bool HasMaskLayers();
   bool EnsureContentClient();
   uint32_t GetPaintFlags();
   void UpdateContentClient(PaintState& aState);
   bool UpdatePaintRegion(PaintState& aState);
-  bool PaintOffMainThread();
+  void PaintOffMainThread();
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
 
   void DestroyBackBuffer()
   {
     mContentClient = nullptr;
   }