blob: d6440c0bd3c138e7577cceff7a583fafcf63b2ae [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/views/view.h"
namespace aura {
class Window;
namespace ui {
class LayerTreeOwner;
namespace ash {
namespace wm {
// A view that mirrors the client area of a single (source) window.
class ASH_EXPORT WindowMirrorView : public views::View {
WindowMirrorView(aura::Window* source, bool trilinear_filtering_on_init);
~WindowMirrorView() override;
// Returns the source of the mirror.
aura::Window* source() { return source_; }
// Recreates |layer_owner_|.
void RecreateMirrorLayers();
// views::View:
gfx::Size CalculatePreferredSize() const override;
void Layout() override;
bool GetNeedsNotificationWhenVisibleBoundsChange() const override;
void OnVisibleBoundsChanged() override;
void NativeViewHierarchyChanged() override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void InitLayerOwner();
// Ensures that the |target_| window is in the list of mirror windows that is
// set as a property on the |source_| window. This method triggers the
// OnWindowPropertyChanged() on WindowObservers.
void UpdateSourceWindowProperty();
// Gets the root of the layer tree that was lifted from |source_| (and is now
// a child of |this->layer()|).
ui::Layer* GetMirrorLayer();
// Calculates the bounds of the client area of the Window in the widget
// coordinate space.
gfx::Rect GetClientAreaBounds() const;
// The original window that is being represented by |this|.
aura::Window* source_;
// The window which contains this mirror view.
aura::Window* target_ = nullptr;
// Retains ownership of the mirror layer tree. This is lazily initialized
// the first time the view becomes visible.
std::unique_ptr<ui::LayerTreeOwner> layer_owner_;
// True if trilinear filtering should be performed on the layer in
// InitLayerOwner().
bool trilinear_filtering_on_init_;
} // namespace wm
} // namespace ash