Bug 785657 - Enable async animations in content processes r=cjones
authorDavid Zbarsky <dzbarsky@gmail.com>
Sat, 25 Aug 2012 21:27:28 -0400
changeset 103469 90c92e55affdf1698371956adf6e24fa182d91b9
parent 103468 9961642b6f0acdb455732b2b33d50a88c21cc87d
child 103470 8a566c3bff64acba851640a8919610e35452202b
push id23350
push userryanvm@gmail.com
push dateSun, 26 Aug 2012 20:02:37 +0000
treeherdermozilla-central@2b9625825da7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs785657
milestone17.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 785657 - Enable async animations in content processes r=cjones
gfx/layers/Makefile.in
gfx/layers/ipc/CompositorChild.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
layout/base/nsDisplayList.cpp
layout/base/nsLayoutUtils.cpp
layout/style/AnimationCommon.cpp
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -28,16 +28,17 @@ DEFINES += -DD3D_DEBUG_INFO
 endif
 
 EXPORTS = \
         BasicLayers.h \
         BasicTiledThebesLayer.h \
         BasicImplData.h \
         GonkIOSurfaceImage.h \
         FrameMetrics.h \
+        CompositorChild.h \
         CompositorParent.h \
         ImageContainer.h \
         ImageLayers.h \
         ImageTypes.h \
         Layers.h \
         LayersTypes.h \
         LayerManagerOGLShaders.h \
         LayerManagerOGL.h \
--- a/gfx/layers/ipc/CompositorChild.h
+++ b/gfx/layers/ipc/CompositorChild.h
@@ -30,16 +30,17 @@ public:
    * or Bridge() request from our parent process.  The Transport is to
    * the compositor's context.
    */
   static PCompositorChild*
   Create(Transport* aTransport, ProcessId aOtherProcess);
 
   static PCompositorChild* Get();
 
+  static bool ChildProcessHasCompositor() { return sCompositor != nullptr; }
 protected:
   virtual PLayersChild* AllocPLayers(const LayersBackend& aBackendHint,
                                      const uint64_t& aId,
                                      LayersBackend* aBackend,
                                      int* aMaxTextureSize);
   virtual bool DeallocPLayers(PLayersChild *aChild);
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2,16 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG /* Allow logging in the release build */
 #endif
 
+#include "mozilla/layers/CompositorChild.h"
 #include "mozilla/layers/CompositorParent.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 
 #include "prlog.h"
 #include "prenv.h"
 
 #include "gfxPlatform.h"
 
@@ -1227,16 +1228,24 @@ gfxPlatform::UseAzureContentDrawing()
     sAzureContentDrawingPrefCached = true;
     mozilla::Preferences::AddBoolVarCache(&sAzureContentDrawingEnabled,
                                           "gfx.content.azure.enabled");
   }
 
   return sAzureContentDrawingEnabled;
 }
 
+bool
+gfxPlatform::OffMainThreadCompositingEnabled()
+{
+  return XRE_GetProcessType() == GeckoProcessType_Default ?
+    CompositorParent::CompositorLoop() != nullptr :
+    CompositorChild::ChildProcessHasCompositor();
+}
+
 eCMSMode
 gfxPlatform::GetCMSMode()
 {
     if (gCMSInitialized == false) {
         gCMSInitialized = true;
         nsresult rv;
 
         int32_t mode;
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -373,17 +373,19 @@ public:
         // platform-specific override, by default do nothing
     }
 
     // Break large OMTC tiled thebes layer painting into small paints.
     static bool UseProgressiveTilePainting();
 
     // helper method to indicate if we want to use Azure content drawing
     static bool UseAzureContentDrawing();
-    
+
+    static bool OffMainThreadCompositingEnabled();
+
     /**
      * Are we going to try color management?
      */
     static eCMSMode GetCMSMode();
 
     /**
      * Determines the rendering intent for color management.
      *
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -3388,17 +3388,18 @@ nsDisplayTransform::ShouldPrerenderTrans
     message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(frameSize.width));
     message.AppendLiteral(", ");
     message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(frameSize.height));
     message.AppendLiteral(") is bigger than the viewport (");
     message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(refSize.width));
     message.AppendLiteral(", ");
     message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(refSize.height));
     message.AppendLiteral(")");
-    CommonElementAnimationData::LogAsyncAnimationFailure(message);
+    CommonElementAnimationData::LogAsyncAnimationFailure(message,
+                                                         aFrame->GetContent());
   }
   return false;
 }
 
 /* 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 gfx3DMatrix& aMatrix)
 {
   if (aMatrix.IsSingular()) {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -66,17 +66,16 @@
 #include "mozilla/dom/Element.h"
 #include "nsCanvasFrame.h"
 #include "gfxDrawable.h"
 #include "gfxUtils.h"
 #include "nsDataHashtable.h"
 #include "nsTextFrame.h"
 #include "nsFontFaceList.h"
 #include "nsFontInflationData.h"
-#include "CompositorParent.h"
 #include "nsSVGUtils.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGForeignObjectFrame.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsStyleStructInlines.h"
 
 #include "mozilla/Preferences.h"
 
@@ -167,32 +166,34 @@ nsLayoutUtils::AreOpacityAnimationsEnabl
   static bool sOpacityPrefCached = false;
 
   if (!sOpacityPrefCached) {
     sOpacityPrefCached = true;
     Preferences::AddBoolVarCache(&sAreOpacityAnimationsEnabled,
                                  "layers.offmainthreadcomposition.animate-opacity");
   }
 
-  return sAreOpacityAnimationsEnabled && CompositorParent::CompositorLoop();
+  return sAreOpacityAnimationsEnabled &&
+    gfxPlatform::OffMainThreadCompositingEnabled();
 }
 
 bool
 nsLayoutUtils::AreTransformAnimationsEnabled()
 {
   static bool sAreTransformAnimationsEnabled;
   static bool sTransformPrefCached = false;
 
   if (!sTransformPrefCached) {
     sTransformPrefCached = true;
     Preferences::AddBoolVarCache(&sAreTransformAnimationsEnabled,
                                  "layers.offmainthreadcomposition.animate-transform");
   }
 
-  return sAreTransformAnimationsEnabled && CompositorParent::CompositorLoop();
+  return sAreTransformAnimationsEnabled &&
+    gfxPlatform::OffMainThreadCompositingEnabled();
 }
 
 bool
 nsLayoutUtils::IsAnimationLoggingEnabled()
 {
   static bool sShouldLog;
   static bool sShouldLogPrefCached;
 
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -1,14 +1,14 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "CompositorParent.h"
+#include "gfxPlatform.h"
 #include "AnimationCommon.h"
 #include "nsRuleData.h"
 #include "nsCSSValue.h"
 #include "nsStyleContext.h"
 #include "nsIFrame.h"
 #include "nsAnimationManager.h"
 #include "nsLayoutUtils.h"
 
@@ -234,17 +234,17 @@ ComputedTimingFunction::GetValue(double 
 }
 
 bool
 CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *aElement,
                                                            nsCSSProperty aProperty,
                                                            bool aHasGeometricProperties)
 {
   bool shouldLog = nsLayoutUtils::IsAnimationLoggingEnabled();
-  if (shouldLog && !layers::CompositorParent::CompositorLoop()) {
+  if (shouldLog && !gfxPlatform::OffMainThreadCompositingEnabled()) {
     nsCString message;
     message.AppendLiteral("Performance warning: Compositor disabled");
     LogAsyncAnimationFailure(message);
     return false;
   }
 
   nsIFrame* frame = aElement->GetPrimaryFrame();
   if (IsGeometricProperty(aProperty)) {