OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 25 matching lines...) Expand all Loading... | |
36 #include "core/animation/ElementAnimations.h" | 36 #include "core/animation/ElementAnimations.h" |
37 #include "core/animation/CompositorAnimationsImpl.h" | 37 #include "core/animation/CompositorAnimationsImpl.h" |
38 #include "core/animation/animatable/AnimatableDouble.h" | 38 #include "core/animation/animatable/AnimatableDouble.h" |
39 #include "core/animation/animatable/AnimatableFilterOperations.h" | 39 #include "core/animation/animatable/AnimatableFilterOperations.h" |
40 #include "core/animation/animatable/AnimatableTransform.h" | 40 #include "core/animation/animatable/AnimatableTransform.h" |
41 #include "core/animation/animatable/AnimatableValue.h" | 41 #include "core/animation/animatable/AnimatableValue.h" |
42 #include "core/layout/Layer.h" | 42 #include "core/layout/Layer.h" |
43 #include "core/layout/LayoutBoxModelObject.h" | 43 #include "core/layout/LayoutBoxModelObject.h" |
44 #include "core/layout/LayoutObject.h" | 44 #include "core/layout/LayoutObject.h" |
45 #include "core/layout/compositing/CompositedLayerMapping.h" | 45 #include "core/layout/compositing/CompositedLayerMapping.h" |
46 #include "platform/RuntimeEnabledFeatures.h" | |
46 #include "platform/geometry/FloatBox.h" | 47 #include "platform/geometry/FloatBox.h" |
47 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
48 #include "public/platform/WebCompositorAnimation.h" | 49 #include "public/platform/WebCompositorAnimation.h" |
50 #include "public/platform/WebCompositorAnimationPlayer.h" | |
49 #include "public/platform/WebCompositorSupport.h" | 51 #include "public/platform/WebCompositorSupport.h" |
50 #include "public/platform/WebFilterAnimationCurve.h" | 52 #include "public/platform/WebFilterAnimationCurve.h" |
51 #include "public/platform/WebFilterKeyframe.h" | 53 #include "public/platform/WebFilterKeyframe.h" |
52 #include "public/platform/WebFloatAnimationCurve.h" | 54 #include "public/platform/WebFloatAnimationCurve.h" |
53 #include "public/platform/WebFloatKeyframe.h" | 55 #include "public/platform/WebFloatKeyframe.h" |
54 #include "public/platform/WebTransformAnimationCurve.h" | 56 #include "public/platform/WebTransformAnimationCurve.h" |
55 #include "public/platform/WebTransformKeyframe.h" | 57 #include "public/platform/WebTransformKeyframe.h" |
56 | 58 |
57 #include <algorithm> | 59 #include <algorithm> |
58 #include <cmath> | 60 #include <cmath> |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 || (affectsFilter && attachedPlayer->affects(targetElement, CSSPrope rtyWebkitFilter))) | 255 || (affectsFilter && attachedPlayer->affects(targetElement, CSSPrope rtyWebkitFilter))) |
254 attachedPlayer->cancelAnimationOnCompositor(); | 256 attachedPlayer->cancelAnimationOnCompositor(); |
255 } | 257 } |
256 } | 258 } |
257 | 259 |
258 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) | 260 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) |
259 { | 261 { |
260 return element.layoutObject() && element.layoutObject()->compositingState() == PaintsIntoOwnBacking; | 262 return element.layoutObject() && element.layoutObject()->compositingState() == PaintsIntoOwnBacking; |
261 } | 263 } |
262 | 264 |
263 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in t group, double startTime, double timeOffset, const Timing& timing, const Animat ionPlayer* player, const AnimationEffect& effect, Vector<int>& startedAnimationI ds, double playerPlaybackRate) | 265 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in t group, double startTime, double timeOffset, const Timing& timing, const Animat ionPlayer& player, const AnimationEffect& effect, Vector<int>& startedAnimationI ds, double playerPlaybackRate) |
264 { | 266 { |
265 ASSERT(startedAnimationIds.isEmpty()); | 267 ASSERT(startedAnimationIds.isEmpty()); |
266 ASSERT(isCandidateForAnimationOnCompositor(timing, element, player, effect, playerPlaybackRate)); | 268 ASSERT(isCandidateForAnimationOnCompositor(timing, element, &player, effect, playerPlaybackRate)); |
267 ASSERT(canStartAnimationOnCompositor(element)); | 269 ASSERT(canStartAnimationOnCompositor(element)); |
268 | 270 |
269 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); | 271 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); |
270 | 272 |
271 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); | 273 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); |
272 ASSERT(layer); | 274 ASSERT(layer); |
273 | 275 |
274 Vector<OwnPtr<WebCompositorAnimation>> animations; | 276 Vector<OwnPtr<WebCompositorAnimation>> animations; |
275 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, playerPlaybackRate); | 277 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, playerPlaybackRate); |
276 ASSERT(!animations.isEmpty()); | 278 ASSERT(!animations.isEmpty()); |
277 for (auto& animation : animations) { | 279 for (auto& animation : animations) { |
278 int id = animation->id(); | 280 int id = animation->id(); |
279 if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAnimation( animation.release())) { | 281 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
282 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPl ayer(); | |
283 ASSERT(compositorPlayer); | |
284 compositorPlayer->addAnimation(animation.leakPtr()); | |
285 } else if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAni mation(animation.release())) { | |
280 // FIXME: We should know ahead of time whether these animations can be started. | 286 // FIXME: We should know ahead of time whether these animations can be started. |
281 for (int startedAnimationId : startedAnimationIds) | 287 for (int startedAnimationId : startedAnimationIds) |
282 cancelAnimationOnCompositor(element, startedAnimationId); | 288 cancelAnimationOnCompositor(element, player, startedAnimationId) ; |
283 startedAnimationIds.clear(); | 289 startedAnimationIds.clear(); |
284 return false; | 290 return false; |
285 } | 291 } |
286 startedAnimationIds.append(id); | 292 startedAnimationIds.append(id); |
287 } | 293 } |
288 ASSERT(!startedAnimationIds.isEmpty()); | 294 ASSERT(!startedAnimationIds.isEmpty()); |
289 return true; | 295 return true; |
290 } | 296 } |
291 | 297 |
292 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, i nt id) | 298 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c onst AnimationPlayer& player, int id) |
293 { | 299 { |
294 if (!canStartAnimationOnCompositor(element)) { | 300 if (!canStartAnimationOnCompositor(element)) { |
295 // When an element is being detached, we cancel any associated | 301 // When an element is being detached, we cancel any associated |
296 // AnimationPlayers for CSS animations. But by the time we get | 302 // AnimationPlayers for CSS animations. But by the time we get |
297 // here the mapping will have been removed. | 303 // here the mapping will have been removed. |
298 // FIXME: Defer remove/pause operations until after the | 304 // FIXME: Defer remove/pause operations until after the |
299 // compositing update. | 305 // compositing update. |
300 return; | 306 return; |
301 } | 307 } |
302 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayerMapp ing()->mainGraphicsLayer()->removeAnimation(id); | 308 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
309 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer (); | |
310 ASSERT(compositorPlayer); | |
311 compositorPlayer->removeAnimation(id); | |
312 } else { | |
313 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->removeAnimation(id); | |
314 } | |
303 } | 315 } |
304 | 316 |
305 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e lement, int id, double pauseTime) | 317 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e lement, const AnimationPlayer& player, int id, double pauseTime) |
306 { | 318 { |
307 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n ot necessarily up to date. | 319 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n ot necessarily up to date. |
308 // https://code.google.com/p/chromium/issues/detail?id=339847 | 320 // https://code.google.com/p/chromium/issues/detail?id=339847 |
309 DisableCompositingQueryAsserts disabler; | 321 DisableCompositingQueryAsserts disabler; |
310 | 322 |
311 if (!canStartAnimationOnCompositor(element)) { | 323 if (!canStartAnimationOnCompositor(element)) { |
312 ASSERT_NOT_REACHED(); | 324 ASSERT_NOT_REACHED(); |
313 return; | 325 return; |
314 } | 326 } |
315 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayerMapp ing()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); | 327 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
328 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer (); | |
329 ASSERT(compositorPlayer); | |
330 compositorPlayer->pauseAnimation(id, pauseTime); | |
331 } else { | |
332 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); | |
333 } | |
334 } | |
335 | |
336 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con st AnimationPlayer& player) | |
337 { | |
338 if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) | |
339 return false; | |
340 | |
341 if (!player.compositorPlayer()) | |
342 return false; | |
343 | |
344 if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject()) | |
345 return false; | |
346 | |
347 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); | |
348 | |
349 if (!layer || !layer->isAllowedToQueryCompositingState() || !layer->composit edLayerMapping() || !layer->compositedLayerMapping()->mainGraphicsLayer()) | |
dstockwell
2015/03/26 03:04:39
I think isAllowedToQueryCompositingState being fal
loyso (OOO)
2015/03/26 23:36:14
It allows us to defer the actual attachment.
| |
350 return false; | |
351 | |
352 if (!layer->compositedLayerMapping()->mainGraphicsLayer()->platformLayer()) | |
353 return false; | |
354 | |
355 return true; | |
356 } | |
357 | |
358 void CompositorAnimations::attachCompositedLayers(const Element& element, const AnimationPlayer& player) | |
359 { | |
360 ASSERT(element.layoutObject()); | |
361 | |
362 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); | |
363 ASSERT(layer); | |
364 | |
365 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer(); | |
366 ASSERT(compositorPlayer); | |
367 | |
368 ASSERT(layer->compositedLayerMapping()); | |
369 compositorPlayer->attachLayer(layer->compositedLayerMapping()->mainGraphicsL ayer()->platformLayer()); | |
316 } | 370 } |
317 | 371 |
318 // ----------------------------------------------------------------------- | 372 // ----------------------------------------------------------------------- |
319 // CompositorAnimationsImpl | 373 // CompositorAnimationsImpl |
320 // ----------------------------------------------------------------------- | 374 // ----------------------------------------------------------------------- |
321 | 375 |
322 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing, double timeOffset, CompositorTiming& out, double playerPlaybackRate) | 376 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing, double timeOffset, CompositorTiming& out, double playerPlaybackRate) |
323 { | 377 { |
324 timing.assertValid(); | 378 timing.assertValid(); |
325 | 379 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 break; | 675 break; |
622 default: | 676 default: |
623 ASSERT_NOT_REACHED(); | 677 ASSERT_NOT_REACHED(); |
624 } | 678 } |
625 animations.append(animation.release()); | 679 animations.append(animation.release()); |
626 } | 680 } |
627 ASSERT(!animations.isEmpty()); | 681 ASSERT(!animations.isEmpty()); |
628 } | 682 } |
629 | 683 |
630 } // namespace blink | 684 } // namespace blink |
OLD | NEW |