Ejemplo n.º 1
0
bool
CommonElementAnimationData::CanThrottleAnimation(TimeStamp aTime)
{
  nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement);
  if (!frame) {
    return false;
  }

  bool hasTransform = HasAnimationOfProperty(eCSSProperty_transform);
  bool hasOpacity = HasAnimationOfProperty(eCSSProperty_opacity);
  if (hasOpacity) {
    Layer* layer = FrameLayerBuilder::GetDedicatedLayer(
                     frame, nsDisplayItem::TYPE_OPACITY);
    if (!layer || mAnimationGeneration > layer->GetAnimationGeneration()) {
      return false;
    }
  }

  if (!hasTransform) {
    return true;
  }

  Layer* layer = FrameLayerBuilder::GetDedicatedLayer(
                   frame, nsDisplayItem::TYPE_TRANSFORM);
  if (!layer || mAnimationGeneration > layer->GetAnimationGeneration()) {
    return false;
  }

  return CanThrottleTransformChanges(aTime);
}
Ejemplo n.º 2
0
bool
AnimationCollection::CanThrottleAnimation(TimeStamp aTime)
{
  dom::Element* element = GetElementToRestyle();
  if (!element) {
    return false;
  }
  nsIFrame* frame = nsLayoutUtils::GetStyleFrame(element);
  if (!frame) {
    return false;
  }

  const auto& info = CommonAnimationManager::sLayerAnimationInfo;
  for (size_t i = 0; i < ArrayLength(info); i++) {
    auto record = info[i];
    // We only need to worry about *current* animations here.
    // - If we have a newly-finished animation, Animation::CanThrottle will
    //   detect that and force an unthrottled sample.
    // - If we have a newly-idle animation, then whatever caused the animation
    //   to be idle will update the animation generation so we'll return false
    //   from the layer generation check below for any other running compositor
    //   animations (and if no other compositor animations exist we won't get
    //   this far).
    if (!HasCurrentAnimationOfProperty(record.mProperty)) {
      continue;
    }

    Layer* layer = FrameLayerBuilder::GetDedicatedLayer(
                     frame, record.mLayerType);
    if (!layer || mAnimationGeneration > layer->GetAnimationGeneration()) {
      return false;
    }

    if (record.mProperty == eCSSProperty_transform &&
        !CanThrottleTransformChanges(aTime)) {
      return false;
    }
  }

  return true;
}