Bug 1321412 - If the animated content is already fully rendered, enable async animation regardless of size. r=mattwoodrow draft
authorBotond Ballo <botond@mozilla.com>
Thu, 08 Dec 2016 19:44:19 -0500
changeset 449696 26f0f947faf34251003f6d6b5092f24f73d062f9
parent 449695 76da9754419e00962b1ac96dd8046032ecce1e77
child 539545 81cf9f67753872186128853c81898b41157c06c5
push id38627
push userbballo@mozilla.com
push dateWed, 14 Dec 2016 19:32:02 +0000
reviewersmattwoodrow
bugs1321412
milestone53.0a1
Bug 1321412 - If the animated content is already fully rendered, enable async animation regardless of size. r=mattwoodrow MozReview-Commit-ID: OePAkUqp2Q
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6183,31 +6183,37 @@ nsDisplayTransform::ShouldPrerenderTrans
     EffectCompositor::SetPerformanceWarning(
       aFrame, eCSSProperty_transform,
       AnimationPerformanceWarning(
         AnimationPerformanceWarning::Type::TransformFrameInactive));
 
     return NoPrerender;
   }
 
+  // If the incoming dirty rect already contains the entire overflow area,
+  // we are already rendering the entire content.
+  nsRect overflow = aFrame->GetVisualOverflowRectRelativeToSelf();
+  if (aDirtyRect->Contains(overflow)) {
+    return FullPrerender;
+  }
+
   float viewportRatioX = gfxPrefs::AnimationPrerenderViewportRatioLimitX();
   float viewportRatioY = gfxPrefs::AnimationPrerenderViewportRatioLimitY();
   uint32_t absoluteLimitX = gfxPrefs::AnimationPrerenderAbsoluteLimitX();
   uint32_t absoluteLimitY = gfxPrefs::AnimationPrerenderAbsoluteLimitY();
   nsSize refSize = aBuilder->RootReferenceFrame()->GetSize();
   // Only prerender if the transformed frame's size is <= a multiple of the
   // reference frame size (~viewport), and less than an absolute limit.
   // Both the ratio and the absolute limit are configurable.
   nsSize relativeLimit(nscoord(refSize.width * viewportRatioX),
                        nscoord(refSize.height * viewportRatioY));
   nsSize absoluteLimit(aFrame->PresContext()->DevPixelsToAppUnits(absoluteLimitX),
                        aFrame->PresContext()->DevPixelsToAppUnits(absoluteLimitY));
   nsSize maxSize = Min(relativeLimit, absoluteLimit);
   gfxSize scale = nsLayoutUtils::GetTransformToAncestorScale(aFrame);
-  nsRect overflow = aFrame->GetVisualOverflowRectRelativeToSelf();
   nsSize frameSize = nsSize(overflow.Size().width * scale.width,
                             overflow.Size().height * scale.height);
   if (frameSize <= maxSize) {
     *aDirtyRect = overflow;
     return FullPrerender;
   } else if (gfxPrefs::PartiallyPrerenderAnimatedContent()) {
     *aDirtyRect = ComputePartialPrerenderArea(*aDirtyRect, overflow, maxSize);
     return PartialPrerender;