diff --git a/gfx/layers/Makefile.in b/gfx/layers/Makefile.in index 42906f6cef08..06ce847476ad 100644 --- a/gfx/layers/Makefile.in +++ b/gfx/layers/Makefile.in @@ -31,16 +31,18 @@ EXPORTS = \ BasicLayers.h \ BasicTiledThebesLayer.h \ BasicImplData.h \ + CompositorParent.h \ ImageLayers.h \ Layers.h \ LayersBackend.h \ LayerManagerOGLShaders.h \ LayerManagerOGL.h \ LayerManagerOGLProgram.h \ - ReadbackLayer.h \ LayerSorter.h \ - TexturePoolOGL.h \ + ReadbackLayer.h \ + ShadowLayersManager.h \ SharedTextureImage.h \ + TexturePoolOGL.h \ $(NULL) CPPSRCS = \ diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 9bcbdc9e6e92..ded39f9f0b4e 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4,6 +4,7 @@ * 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 "base/basictypes.h" #include "mozilla/Util.h" #include "nsLayoutUtils.h" @@ -70,7 +71,7 @@ #include "nsTextFrame.h" #include "nsFontFaceList.h" #include "nsFontInflationData.h" - +#include "CompositorParent.h" #include "nsSVGUtils.h" #include "nsSVGIntegrationUtils.h" #include "nsSVGForeignObjectFrame.h" @@ -150,13 +151,43 @@ nsLayoutUtils::Are3DTransformsEnabled() if (!s3DTransformPrefCached) { s3DTransformPrefCached = true; - mozilla::Preferences::AddBoolVarCache(&s3DTransformsEnabled, + mozilla::Preferences::AddBoolVarCache(&s3DTransformsEnabled, "layout.3d-transforms.enabled"); } return s3DTransformsEnabled; } +bool +nsLayoutUtils::AreOpacityAnimationsEnabled() +{ + static bool sAreOpacityAnimationsEnabled; + static bool sOpacityPrefCached = false; + + if (!sOpacityPrefCached) { + sOpacityPrefCached = true; + Preferences::AddBoolVarCache(&sAreOpacityAnimationsEnabled, + "layers.offmainthreadcomposition.animate-opacity"); + } + + return sAreOpacityAnimationsEnabled && CompositorParent::CompositorLoop(); +} + +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(); +} + bool nsLayoutUtils::UseBackgroundNearestFiltering() { diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index abdfe079ff28..307cdf76ed1f 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1509,6 +1509,12 @@ public: */ static bool Are3DTransformsEnabled(); + /** + * Checks if off-main-thread transform and opacity animations are enabled. + */ + static bool AreOpacityAnimationsEnabled(); + static bool AreTransformAnimationsEnabled(); + /** * Checks if we should forcibly use nearest pixel filtering for the * background. diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 71c22cffbcf6..2ecbc8644033 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -9,6 +9,7 @@ #include "nsStyleContext.h" #include "nsIFrame.h" #include "nsAnimationManager.h" +#include "nsLayoutUtils.h" namespace mozilla { namespace css { @@ -41,7 +42,7 @@ CommonAnimationManager::AddElementData(CommonElementAnimationData* aData) nsRefreshDriver *rd = mPresContext->RefreshDriver(); rd->AddRefreshObserver(this, Flush_Style); } - + PR_INSERT_BEFORE(aData, &mElementData); } @@ -221,7 +222,7 @@ CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *a { nsIFrame* frame = aElement->GetPrimaryFrame(); if (aProperty == eCSSProperty_opacity) { - return nsAnimationManager::CanAnimateOpacity(); + return nsLayoutUtils::AreOpacityAnimationsEnabled(); } if (aProperty == eCSSProperty_transform && !(frame && frame->Preserves3D() && @@ -229,7 +230,7 @@ CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *a if (frame && frame->IsSVGTransformed()) { return false; } - return nsAnimationManager::CanAnimateTransform(); + return nsLayoutUtils::AreTransformAnimationsEnabled(); } return false; } diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 158eb0f92e80..2b32baefca4e 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -182,20 +182,6 @@ public: mKeyframesRules.Init(16); // FIXME: make infallible! } - static bool CanAnimateOpacity() { - static bool canAnimateOpacity = - mozilla::Preferences::GetBool("layers.offmainthreadcomposition.animate-opacity", false) && - mozilla::Preferences::GetBool("layers.offmainthreadcomposition.enabled", false); - return canAnimateOpacity; - } - - static bool CanAnimateTransform() { - static bool canAnimateTransform = - mozilla::Preferences::GetBool("layers.offmainthreadcomposition.animate-transform", false) && - mozilla::Preferences::GetBool("layers.offmainthreadcomposition.enabled", false); - return canAnimateTransform; - } - static ElementAnimations* GetAnimationsForCompositor(nsIContent* aContent, nsCSSProperty aProperty) {