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

Unified Diff: ash/rotator/screen_rotation_animator.h

Issue 2790583004: Add second copy request after screen rotation to flatten the layers in animation. (Closed)
Patch Set: Move some functions to ash/utility/transformer_util. Created 3 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
Index: ash/rotator/screen_rotation_animator.h
diff --git a/ash/rotator/screen_rotation_animator.h b/ash/rotator/screen_rotation_animator.h
index 1852033b9e6b5c8aff54bd83d0a14275daf44adf..a5c26b16c4e12b280cc373d58642c53cfacb6e6d 100644
--- a/ash/rotator/screen_rotation_animator.h
+++ b/ash/rotator/screen_rotation_animator.h
@@ -14,7 +14,12 @@
#include "base/observer_list.h"
#include "ui/display/display.h"
+namespace aura {
+class Window;
+} // namesapce aura
+
namespace cc {
+class CopyOutputRequest;
class CopyOutputResult;
} // namespace cc
@@ -64,16 +69,22 @@ class ASH_EXPORT ScreenRotationAnimator {
using CopyCallback =
base::Callback<void(std::unique_ptr<cc::CopyOutputResult> result)>;
struct ScreenRotationRequest {
- ScreenRotationRequest(display::Display::Rotation to_rotation,
+ ScreenRotationRequest(display::Display::Rotation from_rotation,
+ display::Display::Rotation to_rotation,
display::Display::RotationSource from_source)
- : new_rotation(to_rotation), source(from_source) {}
+ : old_rotation(from_rotation),
+ new_rotation(to_rotation),
+ source(from_source) {}
+ display::Display::Rotation old_rotation;
display::Display::Rotation new_rotation;
display::Display::RotationSource source;
};
// This function can be overridden in unit test to test removing external
// display.
- virtual CopyCallback CreateAfterCopyCallback(
+ virtual CopyCallback CreateAfterCopyCallbackBeforeRotation(
+ std::unique_ptr<ScreenRotationRequest> rotation_request);
+ virtual CopyCallback CreateAfterCopyCallbackAfterRotation(
std::unique_ptr<ScreenRotationRequest> rotation_request);
private:
@@ -82,20 +93,38 @@ class ASH_EXPORT ScreenRotationAnimator {
void StartRotationAnimation(
std::unique_ptr<ScreenRotationRequest> rotation_request);
- // This is an asynchronous call to request copy output of root layer.
- void RequestCopyRootLayerAndAnimateRotation(
+ // The fallback to slow animation if copy output request cancled or failed.
+ void StartSlowAnimation(
std::unique_ptr<ScreenRotationRequest> rotation_request);
- // The callback in |RequestCopyRootLayerAndAnimateRotation()|.
- void OnRootLayerCopiedBeforeRotation(
+ // A wrapper to call |display_manager| to set screen rotation and rotate the
+ // |old_layer_tree| to the |old_rotation|.
+ void SetRotation(display::Display::Rotation new_rotation,
+ display::Display::Rotation old_rotation,
+ display::Display::RotationSource source);
+
+ // This is an asynchronous call to request copy output of root layer.
+ void RequestCopyScreenRotationContainerLayer(
+ std::unique_ptr<cc::CopyOutputRequest> copy_output_request);
+
+ // The callback in |RequestCopyScreenRotationContainerLayer()| before screen
+ // rotation.
+ void OnScreenRotationContainerLayerCopiedBeforeRotation(
std::unique_ptr<ScreenRotationRequest> rotation_request,
std::unique_ptr<cc::CopyOutputResult> result);
- // Recreates all |root_window| layers.
+ // The callback in |RequestCopyScreenRotationContainerLayer()| after screen
+ // rotation.
+ void OnScreenRotationContainerLayerCopiedAfterRotation(
+ std::unique_ptr<ScreenRotationRequest> rotation_request,
+ std::unique_ptr<cc::CopyOutputResult> result);
+
+ // Recreates all |root_window| layers and their layer tree owner.
void CreateOldLayerTree();
- // Requests a copy of |root_window| root layer output.
- void CopyOldLayerTree(std::unique_ptr<cc::CopyOutputResult> result);
+ // Creates a new layer and its layer tree owner from |CopyOutputResult|.
+ std::unique_ptr<ui::LayerTreeOwner> CopyLayerTree(
+ std::unique_ptr<cc::CopyOutputResult> result);
// Note: Only call this function when the |old_layer_tree_owner_| is set up
// properly.
@@ -119,7 +148,11 @@ class ASH_EXPORT ScreenRotationAnimator {
base::ObserverList<ScreenRotationAnimatorObserver>
screen_rotation_animator_observers_;
std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_;
+ std::unique_ptr<ui::LayerTreeOwner> new_layer_tree_owner_;
std::unique_ptr<ScreenRotationRequest> last_pending_request_;
+ bool has_switch_ash_enable_smooth_screen_rotation_;
+ ui::Layer* screen_rotation_container_layer_;
+ aura::Window* root_window_;
base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator);

Powered by Google App Engine
This is Rietveld 408576698