Bug 1216287 - Properly invalidate the debug overlay. r=mattwoodrow
authorBenoit Girard <b56girard@gmail.com>
Mon, 19 Oct 2015 18:03:48 -0400
changeset 303643 7dedd0f85f8b1be2230287e73b4906c5b1165996
parent 303642 d630beb006c9969707aa3216365f9fc064fa6205
child 303644 80d578836131322040a650a1a7672a4f84fa9a98
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1216287
milestone44.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 1216287 - Properly invalidate the debug overlay. r=mattwoodrow
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -293,16 +293,20 @@ LayerManagerComposite::EndTransaction(co
     mInvalidRegion.Or(mInvalidRegion, mRenderBounds);
   }
 
   if (mInvalidRegion.IsEmpty() && !mTarget) {
     // Composition requested, but nothing has changed. Don't do any work.
     return;
   }
 
+  // We don't want our debug overlay to cause more frames to happen
+  // so we will invalidate after we've decided if something changed.
+  InvalidateDebugOverlay(mRenderBounds);
+
  if (mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {
     MOZ_ASSERT(!aTimeStamp.IsNull());
     // The results of our drawing always go directly into a pixel buffer,
     // so we don't need to pass any global transform here.
     mRoot->ComputeEffectiveTransforms(gfx::Matrix4x4());
 
     nsIntRegion opaque;
     ApplyOcclusionCulling(mRoot, opaque);
@@ -388,16 +392,36 @@ LayerManagerComposite::RootLayer() const
 #ifdef MOZ_PROFILING
 // Only build the QR feature when profiling to avoid bloating
 // our data section.
 // This table was generated using qrencode and is a binary
 // encoding of the qrcodes 0-255.
 #include "qrcode_table.h"
 #endif
 
+void
+LayerManagerComposite::InvalidateDebugOverlay(const IntRect& aBounds)
+{
+  bool drawFps = gfxPrefs::LayersDrawFPS();
+  bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
+  bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
+
+  if (drawFps || drawFrameCounter) {
+    AddInvalidRegion(nsIntRect(0, 0, 256, 256));
+  }
+  if (drawFrameColorBars) {
+    AddInvalidRegion(nsIntRect(0, 0, 10, aBounds.height));
+  }
+
+  if (drawFrameColorBars) {
+    AddInvalidRegion(nsIntRect(0, 0, 10, aBounds.height));
+  }
+
+}
+
 static uint16_t sFrameCount = 0;
 void
 LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
 {
   bool drawFps = gfxPrefs::LayersDrawFPS();
   bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
   bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
 
@@ -456,34 +480,31 @@ LayerManagerComposite::RenderDebugOverla
       mCompositor->DrawQuad(gfx::Rect(aBounds.width - 20, 0, aBounds.width, 20),
                             aBounds, effects, alpha, gfx::Matrix4x4());
 
       mUnusedApzTransformWarning = false;
       SetDebugOverlayWantsNextFrame(true);
     }
 
     // Each frame is invalidate by the previous frame for simplicity
-    AddInvalidRegion(nsIntRect(0, 0, 256, 256));
   } else {
     mFPS = nullptr;
   }
 
   if (drawFrameColorBars) {
     gfx::Rect sideRect(0, 0, 10, aBounds.height);
 
     EffectChain effects;
     effects.mPrimaryEffect = new EffectSolidColor(gfxUtils::GetColorForFrameNumber(sFrameCount));
     mCompositor->DrawQuad(sideRect,
                           sideRect,
                           effects,
                           1.0,
                           gfx::Matrix4x4());
 
-    // Each frame is invalidate by the previous frame for simplicity
-    AddInvalidRegion(nsIntRect(0, 0, sideRect.width, sideRect.height));
   }
 
 #ifdef MOZ_PROFILING
   if (drawFrameCounter) {
     profiler_set_frame_number(sFrameCount);
     const char* qr = sQRCodeTable[sFrameCount%256];
 
     int size = 21;
@@ -517,18 +538,16 @@ LayerManagerComposite::RenderDebugOverla
                                 clip,
                                 effects,
                                 opacity,
                                 gfx::Matrix4x4());
         }
       }
     }
 
-    // Each frame is invalidate by the previous frame for simplicity
-    AddInvalidRegion(nsIntRect(0, 0, 256, 256));
   }
 #endif
 
   if (drawFrameColorBars || drawFrameCounter) {
     // We intentionally overflow at 2^16.
     sFrameCount++;
   }
 }
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -301,16 +301,21 @@ private:
    * Render the current layer tree to the active target.
    */
   void Render();
 #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
   void RenderToPresentationSurface();
 #endif
 
   /**
+   * We need to know our invalid region before we're ready to render.
+   */
+  void InvalidateDebugOverlay(const gfx::IntRect& aBounds);
+
+  /**
    * Render debug overlays such as the FPS/FrameCounter above the frame.
    */
   void RenderDebugOverlay(const gfx::Rect& aBounds);
 
 
   RefPtr<CompositingRenderTarget> PushGroupForLayerEffects();
   void PopGroupForLayerEffects(RefPtr<CompositingRenderTarget> aPreviousTarget,
                                gfx::IntRect aClipRect,