Bug 1330696 - Add profiler labels for canvas captureStream. r?jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 12 Jan 2017 13:57:15 +0100
changeset 459725 c579431dcfd12caf60e372d808ec1042ecf79d9a
parent 459724 4c93686bbaedfb67eb0d1179278346779e7f37be
child 459727 49689cd6397a3e792800faab995bdc714f505024
push id41322
push userbmo:pehrson@telenordigital.com
push dateThu, 12 Jan 2017 16:49:53 +0000
reviewersjesup
bugs1330696
milestone53.0a1
Bug 1330696 - Add profiler labels for canvas captureStream. r?jesup MozReview-Commit-ID: IDY1Elfd2Kn
dom/html/HTMLCanvasElement.cpp
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -103,16 +103,18 @@ public:
 
     return copy.forget();
   }
 
   void WillRefresh(TimeStamp aTime) override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
+    PROFILER_LABEL("HTMLCanvasElement", "FrameCapture", js::ProfileEntry::Category::OTHER);
+
     if (!mOwningElement) {
       return;
     }
 
     if (mOwningElement->IsWriteOnly()) {
       return;
     }
 
@@ -121,28 +123,39 @@ public:
     }
 
     mOwningElement->ProcessDestroyedFrameListeners();
 
     if (!mOwningElement->IsFrameCaptureRequested()) {
       return;
     }
 
-    RefPtr<SourceSurface> snapshot = mOwningElement->GetSurfaceSnapshot(nullptr);
-    if (!snapshot) {
-      return;
+    RefPtr<SourceSurface> snapshot;
+    {
+      PROFILER_LABEL("HTMLCanvasElement", "GetSnapshot", js::ProfileEntry::Category::OTHER);
+      snapshot = mOwningElement->GetSurfaceSnapshot(nullptr);
+      if (!snapshot) {
+        return;
+      }
     }
 
-    RefPtr<DataSourceSurface> copy = CopySurface(snapshot);
-    if (!copy) {
-      return;
+    RefPtr<DataSourceSurface> copy;
+    {
+      PROFILER_LABEL("HTMLCanvasElement", "CopySnapshot", js::ProfileEntry::Category::OTHER);
+      copy = CopySurface(snapshot);
+      if (!copy) {
+        return;
+      }
     }
 
-    mOwningElement->SetFrameCapture(copy.forget());
-    mOwningElement->MarkContextCleanForFrameCapture();
+    {
+      PROFILER_LABEL("HTMLCanvasElement", "SetFrame", js::ProfileEntry::Category::OTHER);
+      mOwningElement->SetFrameCapture(copy.forget());
+      mOwningElement->MarkContextCleanForFrameCapture();
+    }
   }
 
   void DetachFromRefreshDriver()
   {
     MOZ_ASSERT(mOwningElement);
     MOZ_ASSERT(mRefreshDriver);
 
     Unregister();