Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: cc/animation/property_animation_state.cc

Issue 2357533002: CC Animation: Use std::bitset to update animation state. (Closed)
Patch Set: Reparent. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/property_animation_state.h ('k') | cc/animation/target_property.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/property_animation_state.h" 5 #include "cc/animation/property_animation_state.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 PropertyAnimationState::PropertyAnimationState() {}
12
13 PropertyAnimationState::PropertyAnimationState(
14 const PropertyAnimationState& rhs)
15 : currently_running(rhs.currently_running),
16 potentially_animating(rhs.potentially_animating) {}
17
18 PropertyAnimationState::~PropertyAnimationState() {}
19
11 bool PropertyAnimationState::operator==( 20 bool PropertyAnimationState::operator==(
12 const PropertyAnimationState& other) const { 21 const PropertyAnimationState& other) const {
13 return currently_running_for_active_elements == 22 return currently_running == other.currently_running &&
14 other.currently_running_for_active_elements && 23 potentially_animating == other.potentially_animating;
15 currently_running_for_pending_elements ==
16 other.currently_running_for_pending_elements &&
17 potentially_animating_for_active_elements ==
18 other.potentially_animating_for_active_elements &&
19 potentially_animating_for_pending_elements ==
20 other.potentially_animating_for_pending_elements;
21 } 24 }
22 25
23 bool PropertyAnimationState::operator!=( 26 bool PropertyAnimationState::operator!=(
24 const PropertyAnimationState& other) const { 27 const PropertyAnimationState& other) const {
25 return !operator==(other); 28 return !operator==(other);
26 } 29 }
27 30
28 PropertyAnimationState& PropertyAnimationState::operator|=( 31 PropertyAnimationState& PropertyAnimationState::operator|=(
29 const PropertyAnimationState& other) { 32 const PropertyAnimationState& other) {
30 currently_running_for_active_elements |= 33 currently_running |= other.currently_running;
31 other.currently_running_for_active_elements; 34 potentially_animating |= other.potentially_animating;
32 currently_running_for_pending_elements |=
33 other.currently_running_for_pending_elements;
34 potentially_animating_for_active_elements |=
35 other.potentially_animating_for_active_elements;
36 potentially_animating_for_pending_elements |=
37 other.potentially_animating_for_pending_elements;
38 35
39 return *this; 36 return *this;
40 } 37 }
41 38
42 PropertyAnimationState& PropertyAnimationState::operator^=( 39 PropertyAnimationState& PropertyAnimationState::operator^=(
43 const PropertyAnimationState& other) { 40 const PropertyAnimationState& other) {
44 currently_running_for_active_elements ^= 41 currently_running ^= other.currently_running;
45 other.currently_running_for_active_elements; 42 potentially_animating ^= other.potentially_animating;
46 currently_running_for_pending_elements ^=
47 other.currently_running_for_pending_elements;
48 potentially_animating_for_active_elements ^=
49 other.potentially_animating_for_active_elements;
50 potentially_animating_for_pending_elements ^=
51 other.potentially_animating_for_pending_elements;
52 43
53 return *this; 44 return *this;
54 } 45 }
46
47 PropertyAnimationState& PropertyAnimationState::operator&=(
48 const PropertyAnimationState& other) {
49 currently_running &= other.currently_running;
50 potentially_animating &= other.potentially_animating;
51
52 return *this;
53 }
55 54
56 PropertyAnimationState operator^(const PropertyAnimationState& lhs, 55 PropertyAnimationState operator^(const PropertyAnimationState& lhs,
57 const PropertyAnimationState& rhs) { 56 const PropertyAnimationState& rhs) {
58 PropertyAnimationState result = lhs; 57 PropertyAnimationState result = lhs;
59 result ^= rhs; 58 result ^= rhs;
60 return result; 59 return result;
61 } 60 }
62 61
63 bool PropertyAnimationState::IsValid() const { 62 bool PropertyAnimationState::IsValid() const {
64 // currently_running must be a subset for potentially_animating. 63 // currently_running must be a subset for potentially_animating.
65 // currently <= potentially. 64 // currently <= potentially i.e. potentially || !currently.
66 return currently_running_for_active_elements <= 65 TargetProperties result = potentially_animating | ~currently_running;
67 potentially_animating_for_active_elements && 66 return result.all();
68 currently_running_for_pending_elements <=
69 potentially_animating_for_pending_elements;
70 } 67 }
71 68
72 void PropertyAnimationState::Clear() { 69 void PropertyAnimationState::Clear() {
73 currently_running_for_active_elements = false; 70 currently_running.reset();
74 currently_running_for_pending_elements = false; 71 potentially_animating.reset();
75 potentially_animating_for_active_elements = false;
76 potentially_animating_for_pending_elements = false;
77 } 72 }
78 73
79 } // namespace cc 74 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/property_animation_state.h ('k') | cc/animation/target_property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698