#include "ui/aura/window_occlusion_tracker.h"
#include "base/auto_reset.h"
#include "base/containers/adapters.h"
#include "base/containers/contains.h"
#include "base/not_fatal_until.h"
#include "base/trace_event/trace_event.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/aura/env.h"
#include "ui/aura/native_window_occlusion_tracker.h"
#include "ui/aura/window_occlusion_change_builder.h"
#include "ui/aura/window_tree_host.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/geometry/transform.h"
namespace aura {
namespace {
constexpr ui::LayerAnimationElement::AnimatableProperties
kSkipWindowWhenPropertiesAnimated = …;
constexpr ui::LayerAnimationElement::AnimatableProperties
kOcclusionCanChangeWhenPropertyAnimationEnds = …;
constexpr int kMaxRecomputeOcclusion = …;
bool WindowOrParentHasShape(const Window* window) { … }
bool WindowHasOpaqueRegionsForOcclusion(const Window* window) { … }
gfx::Transform GetWindowTransformRelativeToRoot(
Window* window,
const gfx::Transform& parent_transform_relative_to_root,
bool use_target_values) { … }
SkIRect ComputeTransformedBoundsEnclosing(
const gfx::Rect& bounds,
const gfx::Transform& transform_relative_to_root) { … }
SkIRect ComputeTransformedBoundsEnclosed(
const gfx::Rect& bounds,
const gfx::Transform& transform_relative_to_root) { … }
SkIRect ComputeClippedBounds(SkIRect bounds, const SkIRect* clipped_bounds) { … }
SkIRect GetWindowBoundsInRootWindow(
Window* window,
const gfx::Transform& transform_relative_to_root,
const SkIRect* clipped_bounds,
bool use_target_values) { … }
SkIRect GetOpaqueBoundsInRootWindow(
Window* window,
const gfx::Transform& transform_relative_to_root,
const SkIRect* clipped_bounds) { … }
float GetLayerCombinedTargetOpacity(const ui::Layer* layer) { … }
}
WindowOcclusionTracker::InnerClient::InnerClient(
WindowOcclusionTracker* occlusion_tracker)
: … { … }
WindowOcclusionTracker::InnerClient::~InnerClient() = default;
WindowOcclusionTracker::ScopedPause::ScopedPause(
WindowOcclusionTracker* occlusion_tracker)
: … { … }
WindowOcclusionTracker::ScopedPause::~ScopedPause() { … }
WindowOcclusionTracker::ScopedExclude::ScopedExclude(
Window* window,
WindowOcclusionTracker* occlusion_tracker)
: … { … }
WindowOcclusionTracker::ScopedExclude::~ScopedExclude() { … }
void WindowOcclusionTracker::ScopedExclude::OnWindowDestroying(Window* window) { … }
void WindowOcclusionTracker::ScopedExclude::Shutdown() { … }
WindowOcclusionTracker::ScopedForceVisible::ScopedForceVisible(
Window* window,
WindowOcclusionTracker* occlusion_tracker)
: … { … }
WindowOcclusionTracker::ScopedForceVisible::~ScopedForceVisible() { … }
void WindowOcclusionTracker::ScopedForceVisible::OnWindowDestroying(
Window* window) { … }
void WindowOcclusionTracker::ScopedForceVisible::Shutdown() { … }
void WindowOcclusionTracker::Track(Window* window) { … }
WindowOcclusionTracker::OcclusionData
WindowOcclusionTracker::ComputeTargetOcclusionForWindow(Window* window) { … }
WindowOcclusionTracker::WindowOcclusionTracker() = default;
WindowOcclusionTracker::~WindowOcclusionTracker() = default;
bool WindowOcclusionTracker::OcclusionStatesMatch(
const base::flat_map<Window*, OcclusionData>& tracked_windows) { … }
void WindowOcclusionTracker::MaybeComputeOcclusion() { … }
bool WindowOcclusionTracker::RecomputeOcclusionImpl(
Window* window,
const gfx::Transform& parent_transform_relative_to_root,
const SkIRect* clipped_bounds,
SkRegion* occluded_region) { … }
bool WindowOcclusionTracker::VisibleWindowCanOccludeOtherWindows(
const Window* window) const { … }
bool WindowOcclusionTracker::WindowHasContent(const Window* window) const { … }
void WindowOcclusionTracker::CleanupAnimatedWindows() { … }
bool WindowOcclusionTracker::MaybeObserveAnimatedWindow(Window* window) { … }
void WindowOcclusionTracker::SetWindowAndDescendantsAreOccluded(
Window* window,
bool is_occluded,
bool is_parent_visible) { … }
void WindowOcclusionTracker::SetOccluded(Window* window,
bool is_occluded,
bool is_parent_visible,
const SkRegion& occluded_region) { … }
bool WindowOcclusionTracker::WindowIsTracked(Window* window) const { … }
bool WindowOcclusionTracker::WindowIsAnimated(Window* window) const { … }
bool WindowOcclusionTracker::WindowIsExcluded(Window* window) const { … }
bool WindowOcclusionTracker::WindowIsVisible(Window* window) const { … }
bool WindowOcclusionTracker::WindowIsForcedVisible(Window* window) const { … }
template <typename Predicate>
void WindowOcclusionTracker::MarkRootWindowAsDirtyAndMaybeComputeOcclusionIf(
Window* window,
Predicate predicate) { … }
void WindowOcclusionTracker::MarkRootWindowStateAsDirty(
RootWindowState* root_window_state) { … }
bool WindowOcclusionTracker::MarkRootWindowAsDirty(Window* root_window) { … }
bool WindowOcclusionTracker::WindowOrParentIsAnimated(Window* window) const { … }
bool WindowOcclusionTracker::WindowOrDescendantIsTrackedAndVisible(
Window* window) const { … }
bool WindowOcclusionTracker::WindowOrDescendantCanOccludeOtherWindows(
Window* window,
bool assume_parent_opaque,
bool assume_window_opaque) const { … }
bool WindowOcclusionTracker::WindowOpacityChangeMayAffectOcclusionStates(
Window* window) const { … }
bool WindowOcclusionTracker::WindowMoveMayAffectOcclusionStates(
Window* window) const { … }
void WindowOcclusionTracker::TrackedWindowAddedToRoot(Window* window) { … }
void WindowOcclusionTracker::TrackedWindowRemovedFromRoot(Window* window) { … }
void WindowOcclusionTracker::RemoveObserverFromWindowAndDescendants(
Window* window) { … }
void WindowOcclusionTracker::AddObserverToWindowAndDescendants(Window* window) { … }
void WindowOcclusionTracker::Pause() { … }
void WindowOcclusionTracker::Unpause() { … }
void WindowOcclusionTracker::Exclude(Window* window) { … }
void WindowOcclusionTracker::Unexclude(Window* window) { … }
void WindowOcclusionTracker::ForceWindowVisible(Window* window) { … }
void WindowOcclusionTracker::RemoveForceWindowVisible(Window* window) { … }
bool WindowOcclusionTracker::ShouldUseTargetValues() const { … }
void WindowOcclusionTracker::OnLayerAnimationEnded(
ui::LayerAnimationSequence* sequence) { … }
void WindowOcclusionTracker::OnLayerAnimationAborted(
ui::LayerAnimationSequence* sequence) { … }
void WindowOcclusionTracker::OnLayerAnimationScheduled(
ui::LayerAnimationSequence* sequence) { … }
bool WindowOcclusionTracker::RequiresNotificationWhenAnimatorDestroyed() const { … }
void WindowOcclusionTracker::LayerDestroyed(ui::Layer* layer) { … }
void WindowOcclusionTracker::OnWindowHierarchyChanged(
const HierarchyChangeParams& params) { … }
void WindowOcclusionTracker::OnWindowAdded(Window* window) { … }
void WindowOcclusionTracker::OnWillRemoveWindow(Window* window) { … }
void WindowOcclusionTracker::OnWindowVisibilityChanged(Window* window,
bool visible) { … }
void WindowOcclusionTracker::OnWindowBoundsChanged(
Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) { … }
void WindowOcclusionTracker::OnWindowOpacitySet(
Window* window,
ui::PropertyChangeReason reason) { … }
void WindowOcclusionTracker::OnWindowAlphaShapeSet(Window* window) { … }
void WindowOcclusionTracker::OnWindowTransparentChanged(
Window* window,
ui::PropertyChangeReason reason) { … }
void WindowOcclusionTracker::OnWindowTransformed(
Window* window,
ui::PropertyChangeReason reason) { … }
void WindowOcclusionTracker::OnWindowStackingChanged(Window* window) { … }
void WindowOcclusionTracker::OnWindowDestroyed(Window* window) { … }
void WindowOcclusionTracker::OnWindowAddedToRootWindow(Window* window) { … }
void WindowOcclusionTracker::OnWindowRemovingFromRootWindow(Window* window,
Window* new_root) { … }
void WindowOcclusionTracker::OnWindowLayerRecreated(Window* window) { … }
void WindowOcclusionTracker::OnWindowOpaqueRegionsForOcclusionChanged(
Window* window) { … }
void WindowOcclusionTracker::OnOcclusionStateChanged(
WindowTreeHost* host,
Window::OcclusionState new_state,
const SkRegion& occluded_region) { … }
void WindowOcclusionTracker::RemoveAnimationObservationForLayer(
ui::Layer* layer) { … }
}