Bug 1340005 - Part 7: Switch compositor animations to Servo backend for desktop. r=birtles,hiro,nical

We want to always use Servo animation backend on the compositor.
However, Android doesn't support Stylo now, so add a defined flag for it.

MozReview-Commit-ID: 63MnTBnq6yv

--HG--
extra : rebase_source : dce46737f81e4e217e9fd67b6bec722994dca6a2
This commit is contained in:
Boris Chiou 2017-10-27 21:13:27 +02:00
parent 3788926119
commit 0576efed8c
2 changed files with 16 additions and 6 deletions

View File

@ -44,6 +44,15 @@ class gfxVarReceiver;
/* Add new entries above this line. */
// Define the default animation backend on the compositor. Now we don't use
// stylo on the compositor only on Android, and this is a fixed flag. If
// we want to update this flag, please add a new gfxVars for it.
#if defined(ANDROID)
#define USE_STYLO_ON_COMPOSITOR false
#else
#define USE_STYLO_ON_COMPOSITOR true
#endif
// Some graphics settings are computed on the UI process and must be
// communicated to content and GPU processes. gfxVars helps facilitate
// this. Its function is similar to gfxPrefs, except rather than hold

View File

@ -9,6 +9,7 @@
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for dom::FillMode
#include "mozilla/dom/KeyframeEffectBinding.h" // for dom::IterationComposite
#include "mozilla/dom/KeyframeEffectReadOnly.h" // for dom::KeyFrameEffectReadOnly
#include "mozilla/gfx/gfxVars.h" // for USE_STYLO_ON_COMPOSITOR
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder
#include "mozilla/layers/LayerAnimationUtils.h" // for TimingFunctionToComputedTimingFunction
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc
@ -276,9 +277,7 @@ AnimationHelper::SampleAnimationForEachNode(
static_cast<dom::CompositeOperation>(segment->endComposite());
// interpolate the property
bool isServo = animSegment.mFromValue.mServo ||
animSegment.mToValue.mServo;
if (isServo) {
if (USE_STYLO_ON_COMPOSITOR) {
dom::IterationCompositeOperation iterCompositeOperation =
static_cast<dom::IterationCompositeOperation>(
animation.iterationComposite());
@ -478,6 +477,9 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
static AnimationValue
ToAnimationValue(const Animatable& aAnimatable)
{
StyleBackendType backend = USE_STYLO_ON_COMPOSITOR
? StyleBackendType::Servo
: StyleBackendType::Gecko;
AnimationValue result;
switch (aAnimatable.type()) {
@ -488,12 +490,11 @@ ToAnimationValue(const Animatable& aAnimatable)
aAnimatable.get_ArrayOfTransformFunction();
RefPtr<nsCSSValueSharedList> list(CreateCSSValueList(transforms));
MOZ_ASSERT(list, "Transform list should be non null");
result = AnimationValue::Transform(StyleBackendType::Gecko, *list);
result = AnimationValue::Transform(backend, *list);
}
break;
case Animatable::Tfloat:
result = AnimationValue::Opacity(StyleBackendType::Gecko,
aAnimatable.get_float());
result = AnimationValue::Opacity(backend, aAnimatable.get_float());
break;
default:
MOZ_ASSERT_UNREACHABLE("Unsupported type");