Chromium Code Reviews| Index: ash/rotator/screen_rotation_animator.cc |
| diff --git a/ash/rotator/screen_rotation_animator.cc b/ash/rotator/screen_rotation_animator.cc |
| index 9610b827db43fedb4679e7d6d674df448f9d1b1a..bc5a932c57cc6cfc224945df03c8179636d4ea9a 100644 |
| --- a/ash/rotator/screen_rotation_animator.cc |
| +++ b/ash/rotator/screen_rotation_animator.cc |
| @@ -190,6 +190,7 @@ class ScreenRotationAnimationMetricsReporter |
| ScreenRotationAnimator::ScreenRotationAnimator(int64_t display_id) |
| : display_id_(display_id), |
| screen_rotation_state_(IDLE), |
| + rotation_request_id_(0), |
| metrics_reporter_( |
| base::MakeUnique<ScreenRotationAnimationMetricsReporter>()), |
| disable_animation_timers_for_test_(false), |
| @@ -241,6 +242,13 @@ ScreenRotationAnimator::CreateAfterCopyCallback( |
| void ScreenRotationAnimator::OnRootLayerCopiedBeforeRotation( |
| std::unique_ptr<ScreenRotationRequest> rotation_request, |
| std::unique_ptr<cc::CopyOutputResult> result) { |
| + // The |rotation_request_id_| changed since last copy request, which means a |
| + // new rotation stated, we need to ignore this copy result. |
| + if (rotation_request->id != rotation_request_id_) { |
|
oshima
2017/04/13 17:24:41
it's probably better to have DCHECK
rotation_requ
wutao
2017/04/13 17:51:12
Done.
|
| + rotation_request.reset(); |
|
oshima
2017/04/13 17:24:41
it'll be reset upon return (sorry I missed others
wutao
2017/04/13 17:51:12
I removed this reset at 3 places. Please check it
|
| + return; |
| + } |
| + |
| // In the following cases, abort rotation: |
| // 1) if the display was removed, |
| // 2) the copy request has been canceled or failed. It would fail if, |
| @@ -378,11 +386,14 @@ void ScreenRotationAnimator::Rotate(display::Display::Rotation new_rotation, |
| if (GetCurrentScreenRotation(display_id_) == new_rotation) |
| return; |
| + rotation_request_id_++; |
| std::unique_ptr<ScreenRotationRequest> rotation_request = |
| - base::MakeUnique<ScreenRotationRequest>(new_rotation, source); |
| + base::MakeUnique<ScreenRotationRequest>(rotation_request_id_, |
| + new_rotation, source); |
| switch (screen_rotation_state_) { |
| case IDLE: |
| + case COPY_REQUESTED: |
| StartRotationAnimation(std::move(rotation_request)); |
| break; |
| case ROTATING: |
| @@ -392,10 +403,8 @@ void ScreenRotationAnimator::Rotate(display::Display::Rotation new_rotation, |
| // |StopAnimating()|. |
| StopAnimating(); |
| break; |
| - case COPY_REQUESTED: |
| - // TODO(wutao): We need to handle this otherwise the device will be in |
| - // inconsistent state. |
| - break; |
| + default: |
|
oshima
2017/04/13 17:24:41
remove default (so that compiler can catch an erro
wutao
2017/04/13 17:51:12
Done.
|
| + NOTREACHED(); |
| } |
| } |
| @@ -413,10 +422,9 @@ void ScreenRotationAnimator::ProcessAnimationQueue() { |
| screen_rotation_state_ = IDLE; |
| old_layer_tree_owner_.reset(); |
| if (last_pending_request_ && IsDisplayIdValid(display_id_)) { |
| - std::unique_ptr<ScreenRotationRequest> rotation_request = |
| - std::move(last_pending_request_); |
| - Rotate(rotation_request->new_rotation, rotation_request->source); |
| - rotation_request.reset(); |
| + ScreenRotationRequest rotation_request = *last_pending_request_.get(); |
|
oshima
2017/04/13 17:24:41
can you just keep the new_rotation and source on s
wutao
2017/04/13 17:51:12
Done.
|
| + last_pending_request_.reset(); |
| + Rotate(rotation_request.new_rotation, rotation_request.source); |
| return; |
| } |