chromium/ui/wm/core/window_animations.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/wm/core/window_animations.h"

#include <math.h>

#include <memory>

#include "base/check_op.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
#include "ui/base/class_property.h"
#include "ui/compositor/animation_throughput_reporter.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/transform_util.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/geometry/vector3d_f.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/wm/core/window_properties.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/core/wm_core_switches.h"
#include "ui/wm/public/animation_host.h"

namespace wm {
namespace {

// A base class for hiding animation observer which has two roles:
// 1) Notifies AnimationHost at the end of hiding animation.
// 2) Detaches the window's layers for hiding animation and deletes
// them upon completion of the animation. This is necessary to a)
// ensure that the animation continues in the event of the window being
// deleted, and b) to ensure that the animation is visible even if the
// window gets restacked below other windows when focus or activation
// changes.
// The subclass will determine when the animation is completed.
class HidingWindowAnimationObserverBase : public aura::WindowObserver {};

// TODO(crbug.com/40657251): Find a better home and merge with
//     ash::metris_util::ForSmoothness.
SmoothnessCallback;
ui::AnimationThroughputReporter::ReportCallback ForSmoothness(
    SmoothnessCallback callback) {}

void ReportHideSmoothness(int smoothness) {}

}  // namespace

// A HidingWindowAnimationObserver that deletes observer and detached
// layers upon the completion of the implicit animation.
class ImplicitHidingWindowAnimationObserver
    : public HidingWindowAnimationObserverBase,
      public ui::ImplicitAnimationObserver {};

namespace {

const int kDefaultAnimationDurationForMenuMS =;

const float kWindowAnimation_HideOpacity =;
const float kWindowAnimation_ShowOpacity =;
const float kWindowAnimation_TranslateFactor =;
const float kWindowAnimation_ScaleFactor =;

const int kWindowAnimation_Rotate_DurationMS =;
const int kWindowAnimation_Rotate_OpacityDurationPercent =;
const float kWindowAnimation_Rotate_TranslateY =;
const float kWindowAnimation_Rotate_PerspectiveDepth =;
const float kWindowAnimation_Rotate_DegreesX =;
const float kWindowAnimation_Rotate_ScaleFactor =;

const float kWindowAnimation_Bounce_Scale =;
const int kWindowAnimation_Bounce_DurationMS =;
const int kWindowAnimation_Bounce_GrowShrinkDurationPercent =;

base::TimeDelta GetWindowVisibilityAnimationDuration(
    const aura::Window& window) {}

// Gets/sets the WindowVisibilityAnimationType associated with a window.
// TODO(beng): redundant/fold into method on public api?
int GetWindowVisibilityAnimationType(aura::Window* window) {}

void GetTransformRelativeToRoot(ui::Layer* layer, gfx::Transform* transform) {}

gfx::Rect GetLayerWorldBoundsAfterTransform(ui::Layer* layer,
                                            const gfx::Transform& transform) {}

// Augment the host window so that the enclosing bounds of the full
// animation will fit inside of it.
void AugmentWindowSize(aura::Window* window,
                       const gfx::Transform& end_transform) {}

// Shows a window using an animation, animating its opacity from 0.f to 1.f,
// its visibility to true, and its transform from |start_transform| to
// |end_transform|.
void AnimateShowWindowCommon(aura::Window* window,
                             const gfx::Transform& start_transform,
                             const gfx::Transform& end_transform) {}

// Hides a window using an animation, animating its opacity from 1.f to 0.f,
// its visibility to false, and its transform to |end_transform|.
void AnimateHideWindowCommon(aura::Window* window,
                             const gfx::Transform& end_transform) {}

static gfx::Transform GetScaleForWindow(aura::Window* window) {}

// Show/Hide windows using a shrink animation.
void AnimateShowWindow_Drop(aura::Window* window) {}

void AnimateHideWindow_Drop(aura::Window* window) {}

// Show/Hide windows using a vertical Glenimation.
void AnimateShowWindow_Vertical(aura::Window* window) {}

void AnimateHideWindow_Vertical(aura::Window* window) {}

// Show/Hide windows using a fade.
void AnimateShowWindow_Fade(aura::Window* window) {}

void AnimateHideWindow_Fade(aura::Window* window) {}

std::unique_ptr<ui::LayerAnimationElement> CreateGrowShrinkElement(
    aura::Window* window,
    bool grow) {}

void AnimateBounce(aura::Window* window) {}

// A HidingWindowAnimationObserver that deletes observer and detached
// layers when the last_sequence has been completed or aborted.
class RotateHidingWindowAnimationObserver
    : public HidingWindowAnimationObserverBase,
      public ui::LayerAnimationObserver {};

void AddLayerAnimationsForRotate(aura::Window* window, bool show) {}

void AnimateShowWindow_Rotate(aura::Window* window) {}

void AnimateHideWindow_Rotate(aura::Window* window) {}

bool AnimateShowWindow(aura::Window* window) {}

bool AnimateHideWindow(aura::Window* window) {}

}  // namespace

////////////////////////////////////////////////////////////////////////////////
// ImplicitHidingWindowAnimationObserver

ImplicitHidingWindowAnimationObserver::ImplicitHidingWindowAnimationObserver(
    aura::Window* window,
    ui::ScopedLayerAnimationSettings* settings)
    :{}

void ImplicitHidingWindowAnimationObserver::OnImplicitAnimationsCompleted() {}

////////////////////////////////////////////////////////////////////////////////
// ScopedHidingAnimationSettings

ScopedHidingAnimationSettings::ScopedHidingAnimationSettings(
    aura::Window* window)
    :{}

ScopedHidingAnimationSettings::~ScopedHidingAnimationSettings() {}

////////////////////////////////////////////////////////////////////////////////
// External interface

void SetWindowVisibilityAnimationType(aura::Window* window, int type) {}

int GetWindowVisibilityAnimationType(aura::Window* window) {}

void SetWindowVisibilityAnimationTransition(
    aura::Window* window,
    WindowVisibilityAnimationTransition transition) {}

bool HasWindowVisibilityAnimationTransition(
    aura::Window* window,
    WindowVisibilityAnimationTransition transition) {}

void SetWindowVisibilityAnimationDuration(aura::Window* window,
                                          const base::TimeDelta& duration) {}

base::TimeDelta GetWindowVisibilityAnimationDuration(
    const aura::Window& window) {}

void SetWindowVisibilityAnimationVerticalPosition(aura::Window* window,
                                                  float position) {}

bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) {}

bool AnimateWindow(aura::Window* window, WindowAnimationType type) {}

bool WindowAnimationsDisabled(aura::Window* window) {}

}  // namespace wm