chromium/ui/aura/window_occlusion_tracker.cc

// Copyright 2017 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/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 {

// When one of these properties is animated, a window is considered non-occluded
// and cannot occlude other windows.
// TODO(crbug.com/40677173): Mark a window VISIBLE when COLOR animation starts.
constexpr ui::LayerAnimationElement::AnimatableProperties
    kSkipWindowWhenPropertiesAnimated =;

// When an animation ends for one of these properties, occlusion states might
// be affected. The end of an animation for a property in
// |kSkipWindowWhenPropertiesAnimated| might affect occlusion states because
// a window suddenly stops being excluded from occlusion computations. The
// end of a visibility animation might affect occlusion states because a
// window is suddenly considered drawn/not drawn.
constexpr ui::LayerAnimationElement::AnimatableProperties
    kOcclusionCanChangeWhenPropertyAnimationEnds =;

// Maximum number of times that MaybeComputeOcclusion() should have to recompute
// occlusion states before they become stable.
//
// TODO(fdoray): This can be changed to 2 once showing/hiding a WebContents
// doesn't cause a call to Show()/Hide() on the Window of a
// RenderWidgetHostViewAura. https://crbug.com/827268
constexpr int kMaxRecomputeOcclusion =;

bool WindowOrParentHasShape(const Window* window) {}

bool WindowHasOpaqueRegionsForOcclusion(const Window* window) {}

// Returns the transform of |window| relative to its root.
// |parent_transform_relative_to_root| is the transform of |window->parent()|
// relative to its root.
gfx::Transform GetWindowTransformRelativeToRoot(
    Window* window,
    const gfx::Transform& parent_transform_relative_to_root,
    bool use_target_values) {}

// Applies `transform_relative_to_root` to `bounds` and returns the enclosing
// bounds.
SkIRect ComputeTransformedBoundsEnclosing(
    const gfx::Rect& bounds,
    const gfx::Transform& transform_relative_to_root) {}

// Applies `transform_relative_to_root` to `bounds` and returns the enclosed
// bounds.
SkIRect ComputeTransformedBoundsEnclosed(
    const gfx::Rect& bounds,
    const gfx::Transform& transform_relative_to_root) {}

SkIRect ComputeClippedBounds(SkIRect bounds, const SkIRect* clipped_bounds) {}

// Returns the bounds of |window| relative to its |root|.
// |transform_relative_to_root| is the transform of |window| relative to its
// root. If |clipped_bounds| is not null, the returned bounds are clipped by it.
// If the bounds after transform have fractional coordinates, enclosed bounds in
// integers are used.
SkIRect GetWindowBoundsInRootWindow(
    Window* window,
    const gfx::Transform& transform_relative_to_root,
    const SkIRect* clipped_bounds,
    bool use_target_values) {}

// Returns the bounds that |window| should contribute to be used for occluding
// other windows. This is different to the bounds of the window if |window|
// has opaque regions for occlusion set. We need to use different sets of bounds
// for computing the occlusion of a window itself versus what it should
// contribute to occluding other windows because a translucent region should
// not be considered to occlude other windows, but must be covered by something
// opaque for it itself to be occluded.
// If the bounds after transform have fractional coordinates, enclosing bounds
// in integers are used.
SkIRect GetOpaqueBoundsInRootWindow(
    Window* window,
    const gfx::Transform& transform_relative_to_root,
    const SkIRect* clipped_bounds) {}

float GetLayerCombinedTargetOpacity(const ui::Layer* layer) {}

}  // namespace

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) {}

}  // namespace aura