Bug 1282957 - Add a visual indicator for pages affected by scroll-linked effects. r?mstange draft
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 28 Jun 2016 18:31:15 -0400
changeset 382117 8713cc8e25795aea9a3bac6917aaed94e50a893c
parent 381597 2ab57664bf7cafdd64e136e341527c275fc8c3aa
child 524098 27e3faf002499d1d404f9e06aac7abd71bd05da3
push id21622
push userkgupta@mozilla.com
push dateTue, 28 Jun 2016 22:32:05 +0000
reviewersmstange
bugs1282957
milestone50.0a1
Bug 1282957 - Add a visual indicator for pages affected by scroll-linked effects. r?mstange MozReview-Commit-ID: KuAL2CUDCnj
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -620,16 +620,25 @@ RenderLayers(ContainerT* aContainer,
     LayerComposite* layerToRender = preparedData.mLayer;
     const RenderTargetIntRect& clipRect = preparedData.mClipRect;
     Layer* layer = layerToRender->GetLayer();
 
     if (layerToRender->HasStaleCompositor()) {
       continue;
     }
 
+    if (gfxPrefs::LayersDrawFPS()) {
+      for (auto metadata : layer->GetAllScrollMetadata()) {
+        if (metadata.IsApzForceDisabled()) {
+          aManager->DisabledApzWarning();
+          break;
+        }
+      }
+    }
+
     Color color;
     if (NeedToDrawCheckerboardingForLayer(layer, &color)) {
       if (gfxPrefs::APZHighlightCheckerboardedAreas()) {
         color = Color(255 / 255.f, 188 / 255.f, 217 / 255.f, 1.f); // "Cotton Candy"
       }
       // Ideally we would want to intersect the checkerboard region from the APZ with the layer bounds
       // and only fill in that area. However the layer bounds takes into account the base translation
       // for the painted layer whereas the checkerboard region does not. One does not simply
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -113,16 +113,17 @@ LayerManagerComposite::ClearCachedResour
 }
 
 /**
  * LayerManagerComposite
  */
 LayerManagerComposite::LayerManagerComposite(Compositor* aCompositor)
 : mWarningLevel(0.0f)
 , mUnusedApzTransformWarning(false)
+, mDisabledApzWarning(false)
 , mCompositor(aCompositor)
 , mInTransaction(false)
 , mIsCompositorReady(false)
 , mDebugOverlayWantsNextFrame(false)
 , mGeometryChanged(true)
 , mLastFrameMissedHWC(false)
 , mWindowOverlayChanged(false)
 {
@@ -621,22 +622,35 @@ LayerManagerComposite::RenderDebugOverla
     float fillRatio = mCompositor->GetFillRatio();
     mFPS->DrawFPS(now, drawFrameColorBars ? 10 : 1, 2, unsigned(fillRatio), mCompositor);
 
     if (mUnusedApzTransformWarning) {
       // If we have an unused APZ transform on this composite, draw a 20x20 red box
       // in the top-right corner
       EffectChain effects;
       effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(1, 0, 0, 1));
-      mCompositor->DrawQuad(gfx::Rect(aBounds.width - 20, 0, aBounds.width, 20),
+      mCompositor->DrawQuad(gfx::Rect(aBounds.width - 20, 0, 20, 20),
                             aBounds, effects, alpha, gfx::Matrix4x4());
 
       mUnusedApzTransformWarning = false;
       SetDebugOverlayWantsNextFrame(true);
     }
+    if (mDisabledApzWarning) {
+      // If we have a disabled APZ on this composite, draw a 20x20 yellow box
+      // in the top-right corner, to the left of the unused-apz-transform
+      // warning box
+      EffectChain effects;
+      effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(1, 1, 0, 1));
+      mCompositor->DrawQuad(gfx::Rect(aBounds.width - 40, 0, 20, 20),
+                            aBounds, effects, alpha, gfx::Matrix4x4());
+
+      mDisabledApzWarning = false;
+      SetDebugOverlayWantsNextFrame(true);
+    }
+
 
     // Each frame is invalidate by the previous frame for simplicity
   } else {
     mFPS = nullptr;
   }
 
   if (drawFrameColorBars) {
     gfx::IntRect sideRect(0, 0, 10, aBounds.height);
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -304,16 +304,19 @@ public:
       mWarnTime = now;
       mWarningLevel = severity;
     }
   }
 
   void UnusedApzTransformWarning() {
     mUnusedApzTransformWarning = true;
   }
+  void DisabledApzWarning() {
+    mDisabledApzWarning = true;
+  }
 
   bool LastFrameMissedHWC() { return mLastFrameMissedHWC; }
 
   bool AsyncPanZoomEnabled() const override;
 
   void AppendImageCompositeNotification(const ImageCompositeNotification& aNotification)
   {
     // Only send composite notifications when we're drawing to the screen,
@@ -387,16 +390,17 @@ private:
                                bool aInvertEffect,
                                float aContrastEffect);
 
   void ChangeCompositorInternal(Compositor* aNewCompositor);
 
   float mWarningLevel;
   mozilla::TimeStamp mWarnTime;
   bool mUnusedApzTransformWarning;
+  bool mDisabledApzWarning;
   RefPtr<Compositor> mCompositor;
   UniquePtr<LayerProperties> mClonedLayerTreeProperties;
 
   nsTArray<ImageCompositeNotification> mImageCompositeNotifications;
 
   /**
    * Context target, nullptr when drawing directly to our swap chain.
    */