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

Unified Diff: cc/animation/layer_animation_controller.cc

Issue 1882733005: CC Animation: Make LayerAnimationController to have just one value observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@privatelac
Patch Set: Fix codereview issues. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/layer_animation_controller.h ('k') | cc/animation/layer_animation_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/layer_animation_controller.cc
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc
index c373e1fdb93e2d7ad1740219f1d4f3f6830a1630..b2130b8a6ab1f2e65e3adb6f85e53585fa1c3753 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -28,8 +28,11 @@ LayerAnimationController::LayerAnimationController(int id)
: host_(0),
id_(id),
is_active_(false),
+ value_observer_(nullptr),
value_provider_(nullptr),
layer_animation_delegate_(nullptr),
+ needs_active_value_observations_(false),
+ needs_pending_value_observations_(false),
needs_to_start_animations_(false),
scroll_offset_animation_was_interrupted_(false),
potentially_animating_transform_for_active_observers_(false),
@@ -485,17 +488,6 @@ void LayerAnimationController::NotifyAnimationPropertyUpdate(
}
}
-void LayerAnimationController::AddValueObserver(
- LayerAnimationValueObserver* observer) {
- if (!value_observers_.HasObserver(observer))
- value_observers_.AddObserver(observer);
-}
-
-void LayerAnimationController::RemoveValueObserver(
- LayerAnimationValueObserver* observer) {
- value_observers_.RemoveObserver(observer);
-}
-
void LayerAnimationController::AddEventObserver(
LayerAnimationEventObserver* observer) {
if (!event_observers_.HasObserver(observer))
@@ -1182,114 +1174,84 @@ void LayerAnimationController::NotifyObserversOpacityAnimated(
float opacity,
bool notify_active_observers,
bool notify_pending_observers) {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- LayerAnimationValueObserver* obs;
- while ((obs = it.GetNext()) != nullptr) {
- if ((notify_active_observers && notify_pending_observers) ||
- (notify_active_observers && obs->IsActive()) ||
- (notify_pending_observers && !obs->IsActive()))
- obs->OnOpacityAnimated(opacity);
- }
- }
+ if (!value_observer_)
+ return;
+ if (notify_active_observers && needs_active_value_observations())
+ value_observer_->OnOpacityAnimated(LayerTreeType::ACTIVE, opacity);
+ if (notify_pending_observers && needs_pending_value_observations())
+ value_observer_->OnOpacityAnimated(LayerTreeType::PENDING, opacity);
}
void LayerAnimationController::NotifyObserversTransformAnimated(
const gfx::Transform& transform,
bool notify_active_observers,
bool notify_pending_observers) {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- LayerAnimationValueObserver* obs;
- while ((obs = it.GetNext()) != nullptr) {
- if ((notify_active_observers && notify_pending_observers) ||
- (notify_active_observers && obs->IsActive()) ||
- (notify_pending_observers && !obs->IsActive()))
- obs->OnTransformAnimated(transform);
- }
- }
+ if (!value_observer_)
+ return;
+ if (notify_active_observers && needs_active_value_observations())
+ value_observer_->OnTransformAnimated(LayerTreeType::ACTIVE, transform);
+ if (notify_pending_observers && needs_pending_value_observations())
+ value_observer_->OnTransformAnimated(LayerTreeType::PENDING, transform);
}
void LayerAnimationController::NotifyObserversFilterAnimated(
const FilterOperations& filters,
bool notify_active_observers,
bool notify_pending_observers) {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- LayerAnimationValueObserver* obs;
- while ((obs = it.GetNext()) != nullptr) {
- if ((notify_active_observers && notify_pending_observers) ||
- (notify_active_observers && obs->IsActive()) ||
- (notify_pending_observers && !obs->IsActive()))
- obs->OnFilterAnimated(filters);
- }
- }
+ if (!value_observer_)
+ return;
+ if (notify_active_observers && needs_active_value_observations())
+ value_observer_->OnFilterAnimated(LayerTreeType::ACTIVE, filters);
+ if (notify_pending_observers && needs_pending_value_observations())
+ value_observer_->OnFilterAnimated(LayerTreeType::PENDING, filters);
}
void LayerAnimationController::NotifyObserversScrollOffsetAnimated(
const gfx::ScrollOffset& scroll_offset,
bool notify_active_observers,
bool notify_pending_observers) {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- LayerAnimationValueObserver* obs;
- while ((obs = it.GetNext()) != nullptr) {
- if ((notify_active_observers && notify_pending_observers) ||
- (notify_active_observers && obs->IsActive()) ||
- (notify_pending_observers && !obs->IsActive()))
- obs->OnScrollOffsetAnimated(scroll_offset);
- }
- }
+ if (!value_observer_)
+ return;
+ if (notify_active_observers && needs_active_value_observations())
+ value_observer_->OnScrollOffsetAnimated(LayerTreeType::ACTIVE,
+ scroll_offset);
+ if (notify_pending_observers && needs_pending_value_observations())
+ value_observer_->OnScrollOffsetAnimated(LayerTreeType::PENDING,
+ scroll_offset);
}
void LayerAnimationController::NotifyObserversAnimationWaitingForDeletion() {
- FOR_EACH_OBSERVER(LayerAnimationValueObserver,
- value_observers_,
- OnAnimationWaitingForDeletion());
+ if (value_observer_)
+ value_observer_->OnAnimationWaitingForDeletion();
}
void LayerAnimationController::
NotifyObserversTransformIsPotentiallyAnimatingChanged(
bool notify_active_observers,
bool notify_pending_observers) {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- LayerAnimationValueObserver* obs;
- while ((obs = it.GetNext()) != nullptr) {
- if (notify_active_observers && obs->IsActive())
- obs->OnTransformIsPotentiallyAnimatingChanged(
- potentially_animating_transform_for_active_observers_);
- else if (notify_pending_observers && !obs->IsActive())
- obs->OnTransformIsPotentiallyAnimatingChanged(
- potentially_animating_transform_for_pending_observers_);
- }
- }
+ if (!value_observer_)
+ return;
+ if (notify_active_observers && needs_active_value_observations())
+ value_observer_->OnTransformIsPotentiallyAnimatingChanged(
+ LayerTreeType::ACTIVE,
+ potentially_animating_transform_for_active_observers_);
+ if (notify_pending_observers && needs_pending_value_observations())
+ value_observer_->OnTransformIsPotentiallyAnimatingChanged(
+ LayerTreeType::PENDING,
+ potentially_animating_transform_for_pending_observers_);
}
bool LayerAnimationController::HasValueObserver() {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- return it.GetNext() != nullptr;
- }
- return false;
+ if (!value_observer_)
+ return false;
+ return needs_active_value_observations() ||
+ needs_pending_value_observations();
}
bool LayerAnimationController::HasActiveValueObserver() {
- if (value_observers_.might_have_observers()) {
- base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
- &value_observers_);
- LayerAnimationValueObserver* obs;
- while ((obs = it.GetNext()) != nullptr)
- if (obs->IsActive())
- return true;
- }
- return false;
+ if (!value_observer_)
+ return false;
+ return needs_active_value_observations();
}
} // namespace cc
« no previous file with comments | « cc/animation/layer_animation_controller.h ('k') | cc/animation/layer_animation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698