Bug 755084 Part 3: Move checks for whether to animate opacity and transforms on the compositor thread to nsLayoutUtils, and make them also check whether the compositor is actually running r=cjones,dbaron

This commit is contained in:
David Zbarsky 2012-07-25 01:55:00 -07:00
Родитель 6b4c02cd9f
Коммит c31bdbe970
5 изменённых файлов: 47 добавлений и 21 удалений

Просмотреть файл

@ -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 = \

Просмотреть файл

@ -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"
@ -157,6 +158,36 @@ nsLayoutUtils::Are3DTransformsEnabled()
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()
{

Просмотреть файл

@ -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.

Просмотреть файл

@ -9,6 +9,7 @@
#include "nsStyleContext.h"
#include "nsIFrame.h"
#include "nsAnimationManager.h"
#include "nsLayoutUtils.h"
namespace mozilla {
namespace css {
@ -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;
}

Просмотреть файл

@ -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)
{