Bug 1321412 - Change the return type of ShouldPrerenderTransformedContent() to an enum. r=mattwoodrow
☠☠ backed out by daf9dcc44cae ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Wed, 23 Nov 2016 12:58:59 -0500
changeset 325545 964ff414c5607ed43a884fddba06694fac2a04a6
parent 325544 dbd699a368449b9b55c1eacbcfd31aa8c7309c01
child 325546 94302209286e4102d8e1bea82102970d36fbbbad
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmattwoodrow
bugs1321412
milestone53.0a1
Bug 1321412 - Change the return type of ShouldPrerenderTransformedContent() to an enum. r=mattwoodrow MozReview-Commit-ID: EMTdW46D8cM
layout/generic/nsFrame.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2203,21 +2203,24 @@ nsIFrame::BuildDisplayListForStackingCon
   // so we keep track if the parent stacking context needs a container too.
   AutoSaveRestoreContainsBlendMode autoRestoreBlendMode(*aBuilder);
   aBuilder->SetContainsBlendMode(false);
  
   nsRect dirtyRectOutsideTransform = dirtyRect;
   bool allowAsyncAnimation = false;
   if (isTransformed) {
     const nsRect overflow = GetVisualOverflowRectRelativeToSelf();
-    if (nsDisplayTransform::ShouldPrerenderTransformedContent(aBuilder,
-                                                              this)) {
+    nsDisplayTransform::PrerenderDecision decision =
+        nsDisplayTransform::ShouldPrerenderTransformedContent(aBuilder, this);
+    switch (decision) {
+    case nsDisplayTransform::FullPrerender:
       dirtyRect = overflow;
       allowAsyncAnimation = true;
-    } else {
+      break;
+    case nsDisplayTransform::NoPrerender:
       if (overflow.IsEmpty() && !extend3DContext) {
         return;
       }
 
       // If we're in preserve-3d then grab the dirty rect that was given to the root
       // and transform using the combined transform.
       if (Combines3DTransformWithAncestors()) {
         dirtyRect = aBuilder->GetPreserves3DDirtyRect(this);
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6221,49 +6221,49 @@ nsDisplayOpacity::CanUseAsyncAnimations(
 }
 
 bool
 nsDisplayTransform::CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder)
 {
   return mAllowAsyncAnimation;
 }
 
-/* static */ bool
+/* static */ auto
 nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder,
-                                                      nsIFrame* aFrame)
+                                                      nsIFrame* aFrame) -> PrerenderDecision
 {
   // Elements whose transform has been modified recently, or which
   // have a compositor-animated transform, can be prerendered. An element
   // might have only just had its transform animated in which case
   // the ActiveLayerManager may not have been notified yet.
   if (!ActiveLayerTracker::IsStyleMaybeAnimated(aFrame, eCSSProperty_transform) &&
       !EffectCompositor::HasAnimationsForCompositor(aFrame,
                                                     eCSSProperty_transform)) {
     EffectCompositor::SetPerformanceWarning(
       aFrame, eCSSProperty_transform,
       AnimationPerformanceWarning(
         AnimationPerformanceWarning::Type::TransformFrameInactive));
 
-    return false;
+    return NoPrerender;
   }
 
   nsSize refSize = aBuilder->RootReferenceFrame()->GetSize();
   // Only prerender if the transformed frame's size is <= the
   // reference frame size (~viewport), allowing a 1/8th fuzz factor
   // for shadows, borders, etc.
   refSize += nsSize(refSize.width / 8, refSize.height / 8);
   gfxSize scale = nsLayoutUtils::GetTransformToAncestorScale(aFrame);
   nsSize frameSize = nsSize(
     aFrame->GetVisualOverflowRectRelativeToSelf().Size().width * scale.width,
     aFrame->GetVisualOverflowRectRelativeToSelf().Size().height * scale.height);
   nscoord maxInAppUnits = nscoord_MAX;
   if (frameSize <= refSize) {
     maxInAppUnits = aFrame->PresContext()->DevPixelsToAppUnits(4096);
     if (frameSize <= nsSize(maxInAppUnits, maxInAppUnits)) {
-      return true;
+      return FullPrerender;
     }
   }
 
   nsRect visual = aFrame->GetVisualOverflowRect();
 
 
   EffectCompositor::SetPerformanceWarning(
     aFrame, eCSSProperty_transform,
@@ -6273,17 +6273,17 @@ nsDisplayTransform::ShouldPrerenderTrans
         nsPresContext::AppUnitsToIntCSSPixels(frameSize.width),
         nsPresContext::AppUnitsToIntCSSPixels(frameSize.height),
         nsPresContext::AppUnitsToIntCSSPixels(refSize.width),
         nsPresContext::AppUnitsToIntCSSPixels(refSize.height),
         nsPresContext::AppUnitsToIntCSSPixels(visual.width),
         nsPresContext::AppUnitsToIntCSSPixels(visual.height),
         nsPresContext::AppUnitsToIntCSSPixels(maxInAppUnits)
       }));
-  return false;
+  return NoPrerender;
 }
 
 /* If the matrix is singular, or a hidden backface is shown, the frame won't be visible or hit. */
 static bool IsFrameVisible(nsIFrame* aFrame, const Matrix4x4& aMatrix)
 {
   if (aMatrix.IsSingular()) {
     return false;
   }
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -4058,16 +4058,21 @@ class nsDisplayTransform: public nsDispl
       for (nsDisplayItem *i = mList.GetBottom(); i; i = i->GetAbove()) {
         i->DoUpdateBoundsPreserves3D(aBuilder);
       }
       nsDisplayWrapList::UpdateBounds(aBuilder);
     }
   };
 
 public:
+  enum PrerenderDecision {
+    NoPrerender,
+    FullPrerender
+  };
+
   /**
    * Returns a matrix (in pixels) for the current frame. The matrix should be relative to
    * the current frame's coordinate space.
    *
    * @param aFrame The frame to compute the transform for.
    * @param aAppUnitsPerPixel The number of app units per graphics unit.
    */
   typedef Matrix4x4 (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
@@ -4271,21 +4276,21 @@ public:
                                                uint32_t aFlags,
                                                const nsRect* aBoundsOverride = nullptr);
   static Matrix4x4 GetResultingTransformMatrix(const FrameTransformProperties& aProperties,
                                                const nsPoint& aOrigin,
                                                float aAppUnitsPerPixel,
                                                uint32_t aFlags,
                                                const nsRect* aBoundsOverride = nullptr);
   /**
-   * Return true when we should try to prerender the entire contents of the
+   * Return FullPrerender when we should try to prerender the entire contents of the
    * transformed frame even when it's not completely visible (yet).
    */
-  static bool ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder,
-                                                nsIFrame* aFrame);
+  static PrerenderDecision ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder,
+                                                             nsIFrame* aFrame);
   bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) override;
 
   bool MayBeAnimated(nsDisplayListBuilder* aBuilder);
 
   virtual void WriteDebugInfo(std::stringstream& aStream) override;
 
   // Force the layer created for this item not to extend 3D context.
   // See nsIFrame::BuildDisplayListForStackingContext()