Bug 1482956 - Standardize method names and add comments to PaintThread. r=nical
authorRyan Hunt <rhunt@eqrion.net>
Mon, 13 Aug 2018 12:58:25 -0500
changeset 486658 1185bd9092147fee2a8aa3668defd719061f3f2b
parent 486657 2698e4d327ef9a088c93fad43d65f88a97ae9614
child 486659 fea8a70ad61252016639588a0f6e1e8b75508912
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1482956
milestone63.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 1482956 - Standardize method names and add comments to PaintThread. r=nical These method names and ordering have gotten out of sync because of the recent churn. Differential Revision: https://phabricator.services.mozilla.com/D3288
gfx/layers/PaintThread.cpp
gfx/layers/PaintThread.h
gfx/layers/client/ClientLayerManager.cpp
--- a/gfx/layers/PaintThread.cpp
+++ b/gfx/layers/PaintThread.cpp
@@ -170,16 +170,26 @@ PaintThread::IsOnPaintThread()
 bool
 PaintThread::IsOnPaintWorkerThread()
 {
   return (mPaintWorkers && mPaintWorkers->IsOnCurrentThread()) ||
     (sThreadId == PlatformThread::CurrentId());
 }
 
 void
+PaintThread::Dispatch(RefPtr<Runnable>& aRunnable)
+{
+#ifndef OMTP_FORCE_SYNC
+  sThread->Dispatch(aRunnable.forget());
+#else
+  SyncRunnable::DispatchToThread(sThread, aRunnable);
+#endif
+}
+
+void
 PaintThread::UpdateRenderMode()
 {
   if (!!mPaintWorkers != gfxPlatform::GetPlatform()->UsesTiling()) {
     if (mPaintWorkers) {
       mPaintWorkers = nullptr;
     } else {
       InitPaintWorkers();
     }
@@ -242,29 +252,17 @@ PaintThread::AsyncPaintTask(CompositorBr
   }
 
   if (aBridge->NotifyFinishedAsyncWorkerPaint(aTask)) {
     AsyncEndLayerTransaction(aBridge);
   }
 }
 
 void
-
-void
-PaintThread::Dispatch(RefPtr<Runnable>& aRunnable)
-{
-#ifndef OMTP_FORCE_SYNC
-  sThread->Dispatch(aRunnable.forget());
-#else
-  SyncRunnable::DispatchToThread(sThread, aRunnable);
-#endif
-}
-
-void
-PaintThread::EndLayerTransaction(SyncObjectClient* aSyncObject)
+PaintThread::QueueEndLayerTransaction(SyncObjectClient* aSyncObject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<CompositorBridgeChild> cbc(CompositorBridgeChild::Get());
 
   if (cbc->NotifyBeginAsyncEndLayerTransaction(aSyncObject)) {
     RefPtr<PaintThread> self = this;
     RefPtr<Runnable> task = NS_NewRunnableFunction("PaintThread::AsyncEndLayerTransaction",
--- a/gfx/layers/PaintThread.h
+++ b/gfx/layers/PaintThread.h
@@ -20,18 +20,24 @@ class nsIThreadPool;
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 class DrawTargetCapture;
 };
 
 namespace layers {
 
-// Holds the key operations needed to update a tiled content client on the
-// paint thread.
+// A paint task contains a description of a rasterization work to be done
+// on the paint thread or paint worker pool.
+//
+// More specifically it contains:
+// 1. A capture command list of drawing commands
+// 2. A destination draw target to replay the draw commands upon
+// 3. A list of dependent texture clients that must be kept alive for the
+//    task's duration, and then destroyed on the main thread
 class PaintTask {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PaintTask)
 public:
   PaintTask() {}
 
   void DropTextureClients();
 
   RefPtr<gfx::DrawTarget> mTarget;
@@ -52,30 +58,35 @@ public:
   static void Start();
   static void Shutdown();
   static PaintThread* Get();
 
   // Helper for asserts.
   static bool IsOnPaintThread();
   bool IsOnPaintWorkerThread();
 
+  // This allows external users to run code on the paint thread.
+  void Dispatch(RefPtr<Runnable>& aRunnable);
+
+  // This allows the paint thread to dynamically toggle between a paint worker
+  // thread pool used with tiling, and a single paint thread used with rotated
+  // buffer.
   void UpdateRenderMode();
 
+  // Must be called on the main thread. Queues an async paint
+  // task to be completed on the paint thread.
   void QueuePaintTask(PaintTask* aTask);
 
-  // This allows external users to run code on the paint thread.
-  void Dispatch(RefPtr<Runnable>& aRunnable);
-
   // Must be called on the main thread. Signifies that the current
   // layer tree transaction has been finished and any async paints
   // for it have been queued on the paint thread. This MUST be called
   // at the end of a layer transaction as it will be used to do an optional
   // texture sync and then unblock the main thread if it is waiting to paint
   // a new frame.
-  void EndLayerTransaction(SyncObjectClient* aSyncObject);
+  void QueueEndLayerTransaction(SyncObjectClient* aSyncObject);
 
   // Sync Runnables need threads to be ref counted,
   // But this thread lives through the whole process.
   // We're only temporarily using sync runnables so
   // Override release/addref but don't do anything.
   void Release();
   void AddRef();
 
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -428,17 +428,17 @@ ClientLayerManager::EndEmptyTransaction(
     return false;
   }
 
   if (!EndTransactionInternal(nullptr, nullptr, aFlags)) {
     // Return without calling ForwardTransaction. This leaves the
     // ShadowLayerForwarder transaction open; the following
     // EndTransaction will complete it.
     if (PaintThread::Get() && mQueuedAsyncPaints) {
-      PaintThread::Get()->EndLayerTransaction(nullptr);
+      PaintThread::Get()->QueueEndLayerTransaction(nullptr);
     }
     return false;
   }
   if (mWidget) {
     mWidget->PrepareWindowEffects();
   }
   ForwardTransaction(!(aFlags & END_NO_REMOTE_COMPOSITE));
   MakeSnapshotIfRequired();
@@ -717,17 +717,17 @@ ClientLayerManager::ForwardTransaction(b
   }
 
   // If there were async paints queued, then we need to notify the paint thread
   // that we finished queuing async paints so it can schedule a runnable after
   // all async painting is finished to do a texture sync and unblock the main
   // thread if it is waiting before doing a new layer transaction.
   if (mQueuedAsyncPaints) {
     MOZ_ASSERT(PaintThread::Get());
-    PaintThread::Get()->EndLayerTransaction(syncObject);
+    PaintThread::Get()->QueueEndLayerTransaction(syncObject);
   } else if (syncObject) {
     syncObject->Synchronize();
   }
 
   mPhase = PHASE_FORWARD;
 
   mLatestTransactionId = mTransactionIdAllocator->GetTransactionId(!mIsRepeatTransaction);
   TimeStamp refreshStart = mTransactionIdAllocator->GetTransactionStart();