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

Unified Diff: ash/rotator/screen_rotation_animator.h

Issue 2728803002: Handles users rotating screen too early (Closed)
Patch Set: Rebased, reset is_rotating in layerCleanupObserver etc. Created 3 years, 10 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
Index: ash/rotator/screen_rotation_animator.h
diff --git a/ash/rotator/screen_rotation_animator.h b/ash/rotator/screen_rotation_animator.h
index f5b25d69298505c1d7d3d14e4ecb3631b1cb791d..62f527052c99e1d2c675e37d74235b736ba6039c 100644
--- a/ash/rotator/screen_rotation_animator.h
+++ b/ash/rotator/screen_rotation_animator.h
@@ -9,6 +9,7 @@
#include "ash/ash_export.h"
#include "base/macros.h"
+#include "ui/compositor/layer_tree_owner.h"
#include "ui/display/display.h"
namespace ash {
@@ -16,15 +17,26 @@ namespace ash {
// Utility to perform a screen rotation with an animation.
class ASH_EXPORT ScreenRotationAnimator {
public:
+ class ASH_EXPORT ScreenRotationAnimatorObserver {
+ public:
+ ScreenRotationAnimatorObserver();
+ virtual void OnEndedOrAbortedAnimation(ScreenRotationAnimator* animator);
+
+ protected:
+ ~ScreenRotationAnimatorObserver();
bruthig 2017/03/08 22:35:59 This should be virtual because you expect classes
wutao 2017/03/09 22:09:19 Done.
+ };
+
+ struct ScreenRotationRequest {
+ ScreenRotationAnimator* animator;
+ int64_t display_id;
+ display::Display::Rotation initial_rotation;
+ display::Display::Rotation new_rotation;
+ display::Display::RotationSource source;
+ };
+
explicit ScreenRotationAnimator(int64_t display_id);
~ScreenRotationAnimator();
- // Returns true if the screen rotation animation can be completed
- // successfully. For example an animation is not possible if |display_id_|
- // specifies a display::Display that is not currently active. See
- // www.crbug.com/479503.
- bool CanAnimate() const;
-
// Rotates the display::Display specified by |display_id_| to the
// |new_rotation|
// orientation, for the given |source|. The rotation will also become active.
@@ -32,9 +44,36 @@ class ASH_EXPORT ScreenRotationAnimator {
void Rotate(display::Display::Rotation new_rotation,
display::Display::RotationSource source);
+ int64_t display_id() const { return display_id_; };
+
+ bool is_rotating() const { return is_rotating_; };
+ void set_is_rotating(bool rotating) { is_rotating_ = rotating; };
bruthig 2017/03/08 22:35:59 |is_rotating_| seems to me that it should be inter
wutao 2017/03/09 22:09:19 (3) is almost close to what I implemented for the
+
+ ScreenRotationRequest* last_pending_request() const {
+ return last_pending_request_.get();
+ };
+
+ ScreenRotationAnimatorObserver* observer() const { return observer_; };
+ void SetObserver(ScreenRotationAnimatorObserver* observer) {
+ observer_ = observer;
+ };
+ void RemoveObserver() { observer_ = nullptr; };
+
+ ui::LayerTreeOwner* old_layer_tree_owner() const {
+ return old_layer_tree_owner_.get();
+ };
+ void reset_old_layer_tree_owner() { old_layer_tree_owner_.reset(); };
+ void set_old_layer_tree_owner(ui::LayerTreeOwner* layer_tree_owner) {
+ old_layer_tree_owner_.reset(layer_tree_owner);
+ };
+
private:
// The id of the display to rotate.
int64_t display_id_;
+ bool is_rotating_;
+ ScreenRotationAnimatorObserver* observer_;
+ std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_;
+ std::unique_ptr<ScreenRotationRequest> last_pending_request_;
DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator);
};

Powered by Google App Engine
This is Rietveld 408576698