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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/animation/Player.h" | 32 #include "core/animation/Player.h" |
33 | 33 |
34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
35 #include "core/animation/DocumentTimeline.h" | 35 #include "core/animation/DocumentTimeline.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
| 39 namespace { |
| 40 |
| 41 static unsigned nextSequenceNumber() |
| 42 { |
| 43 static unsigned next = 0; |
| 44 return ++next; |
| 45 } |
| 46 |
| 47 } |
| 48 |
39 PassRefPtr<Player> Player::create(DocumentTimeline& timeline, TimedItem* content
) | 49 PassRefPtr<Player> Player::create(DocumentTimeline& timeline, TimedItem* content
) |
40 { | 50 { |
41 return adoptRef(new Player(timeline, content)); | 51 return adoptRef(new Player(timeline, content)); |
42 } | 52 } |
43 | 53 |
44 Player::Player(DocumentTimeline& timeline, TimedItem* content) | 54 Player::Player(DocumentTimeline& timeline, TimedItem* content) |
45 : m_playbackRate(1) | 55 : m_playbackRate(1) |
46 , m_startTime(nullValue()) | 56 , m_startTime(nullValue()) |
47 , m_holdTime(nullValue()) | 57 , m_holdTime(nullValue()) |
48 , m_storedTimeLag(0) | 58 , m_storedTimeLag(0) |
49 , m_content(content) | 59 , m_content(content) |
50 , m_timeline(&timeline) | 60 , m_timeline(&timeline) |
51 , m_paused(false) | 61 , m_paused(false) |
52 , m_held(false) | 62 , m_held(false) |
53 , m_isPausedForTesting(false) | 63 , m_isPausedForTesting(false) |
54 , m_outdated(false) | 64 , m_outdated(false) |
| 65 , m_sequenceNumber(nextSequenceNumber()) |
55 { | 66 { |
56 if (m_content) { | 67 if (m_content) { |
57 if (m_content->player()) | 68 if (m_content->player()) |
58 m_content->player()->cancel(); | 69 m_content->player()->cancel(); |
59 m_content->attach(this); | 70 m_content->attach(this); |
60 } | 71 } |
61 } | 72 } |
62 | 73 |
63 Player::~Player() | 74 Player::~Player() |
64 { | 75 { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void Player::cancel() | 303 void Player::cancel() |
293 { | 304 { |
294 if (!m_content) | 305 if (!m_content) |
295 return; | 306 return; |
296 | 307 |
297 ASSERT(m_content->player() == this); | 308 ASSERT(m_content->player() == this); |
298 m_content->detach(); | 309 m_content->detach(); |
299 m_content = nullptr; | 310 m_content = nullptr; |
300 } | 311 } |
301 | 312 |
| 313 bool Player::hasLowerPriority(Player* player1, Player* player2) |
| 314 { |
| 315 if (player1->m_startTime < player2->m_startTime) |
| 316 return true; |
| 317 if (player1->m_startTime > player2->m_startTime) |
| 318 return false; |
| 319 if (isNull(player1->m_startTime) != isNull(player2->m_startTime)) |
| 320 return isNull(player1->m_startTime); |
| 321 return player1->m_sequenceNumber < player2->m_sequenceNumber; |
| 322 } |
| 323 |
302 void Player::pauseForTesting(double pauseTime) | 324 void Player::pauseForTesting(double pauseTime) |
303 { | 325 { |
304 RELEASE_ASSERT(!paused()); | 326 RELEASE_ASSERT(!paused()); |
305 updateTimingState(pauseTime); | 327 updateTimingState(pauseTime); |
306 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) | 328 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) |
307 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre
ntTime()); | 329 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre
ntTime()); |
308 m_isPausedForTesting = true; | 330 m_isPausedForTesting = true; |
309 pause(); | 331 pause(); |
310 } | 332 } |
311 | 333 |
312 } // namespace | 334 } // namespace |
OLD | NEW |