Bug 947753 / Bug 1122526 - Don't claim to support off-main-thread animations when the nearest widget is not using OMT compositing. r=birtles
authorL. David Baron <dbaron@dbaron.org>
Thu, 16 Apr 2015 18:36:29 -0700
changeset 273449 962e15b8168444b01ecf8ba7ee3d47bda86f369d
parent 273448 d278129865283291c7c992677477597dbeba5c28
child 273450 ade50933c777e0e38e17ae0e7b9e8159663585ba
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs947753, 1122526
milestone40.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 947753 / Bug 1122526 - Don't claim to support off-main-thread animations when the nearest widget is not using OMT compositing. r=birtles This moves the test for whether off-main-thread compositor is enabled *earlier* in CanPerformOnCompositorThread, since CanAnimatePropertyOnCompositor is called only from CanPerformOnCompositorThread. This change means we're using a more accurate test for whether we actually have off-main-thread compositing than the pref, since in some cases we won't use off-main-thread compositing for certain widgets (e.g., transparent widgets on Windows) even when the pref is enabled.
layout/style/AnimationCommon.cpp
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -501,25 +501,16 @@ AnimValuesStyleRule::List(FILE* out, int
 
 bool
 AnimationCollection::CanAnimatePropertyOnCompositor(
   const dom::Element *aElement,
   nsCSSProperty aProperty,
   CanAnimateFlags aFlags)
 {
   bool shouldLog = nsLayoutUtils::IsAnimationLoggingEnabled();
-  if (!gfxPlatform::OffMainThreadCompositingEnabled()) {
-    if (shouldLog) {
-      nsCString message;
-      message.AppendLiteral("Performance warning: Compositor disabled");
-      LogAsyncAnimationFailure(message);
-    }
-    return false;
-  }
-
   nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement);
   if (IsGeometricProperty(aProperty)) {
     if (shouldLog) {
       nsCString message;
       message.AppendLiteral("Performance warning: Async animation of geometric property '");
       message.Append(nsCSSProps::GetStringValue(aProperty));
       message.AppendLiteral("' is disabled");
       LogAsyncAnimationFailure(message, aElement);
@@ -577,16 +568,29 @@ bool
 AnimationCollection::CanPerformOnCompositorThread(
   CanAnimateFlags aFlags) const
 {
   nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement);
   if (!frame) {
     return false;
   }
 
+  nsIWidget* widget = frame->GetNearestWidget();
+  if (!widget ||
+      widget->GetLayerManager()->GetBackendType() !=
+        layers::LayersBackend::LAYERS_CLIENT) {
+    // No widget (huh?), or a widget not using off-main-thread compositor.
+    if (nsLayoutUtils::IsAnimationLoggingEnabled()) {
+      nsCString message;
+      message.AppendLiteral("Performance warning: Compositor disabled");
+      LogAsyncAnimationFailure(message);
+    }
+    return false;
+  }
+
   if (mElementProperty != nsGkAtoms::transitionsProperty &&
       mElementProperty != nsGkAtoms::animationsProperty) {
     if (nsLayoutUtils::IsAnimationLoggingEnabled()) {
       nsCString message;
       message.AppendLiteral("Gecko bug: Async animation of pseudoelements"
                             " not supported.  See bug 771367 (");
       message.Append(nsAtomCString(mElementProperty));
       message.Append(")");