Commit 9d07df75 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: remove guttering and fallback logic from mus

It would seem neither of these are necessary any longer.

BUG=none
TEST=none

Change-Id: Iec712982e85a80255d270c9818093085f0343841
Reviewed-on: https://chromium-review.googlesource.com/c/1474990
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632804}
parent fbab948b
......@@ -59,8 +59,8 @@ ClientRoot::ClientRoot(WindowTree* window_tree,
window_->AddObserver(this);
if (window_->GetHost())
window->GetHost()->AddObserver(this);
client_surface_embedder_ = std::make_unique<aura::ClientSurfaceEmbedder>(
window_, is_top_level, gfx::Insets());
client_surface_embedder_ =
std::make_unique<aura::ClientSurfaceEmbedder>(window_);
if (ShouldAssignLocalSurfaceIdImpl(window, is_top_level_))
parent_local_surface_id_allocator_.emplace();
// Ensure there is a valid LocalSurfaceId (if necessary).
......@@ -84,13 +84,6 @@ ClientRoot::~ClientRoot() {
host_frame_sink_manager->InvalidateFrameSinkId(proxy_window->frame_sink_id());
}
void ClientRoot::SetClientAreaInsets(const gfx::Insets& client_area_insets) {
if (!is_top_level_)
return;
client_surface_embedder_->SetClientAreaInsets(client_area_insets);
}
void ClientRoot::RegisterVizEmbeddingSupport() {
// This function should only be called once.
viz::HostFrameSinkManager* host_frame_sink_manager =
......@@ -257,12 +250,6 @@ void ClientRoot::UpdateLocalSurfaceIdAndClientSurfaceEmbedder() {
// ensures smooth resizes.
if (ShouldAssignLocalSurfaceId() && window_->GetHost())
window_->GetHost()->compositor()->OnChildResizing();
if (fallback_surface_info_) {
client_surface_embedder_->SetFallbackSurfaceInfo(*fallback_surface_info_);
fallback_surface_info_.reset();
}
client_surface_embedder_->UpdateSizeAndGutters();
}
void ClientRoot::CheckForScaleFactorChange() {
......@@ -414,24 +401,15 @@ void ClientRoot::OnHostResized(aura::WindowTreeHost* host) {
void ClientRoot::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) {
// TODO(sky): saman says the SetFallbackSurfaceInfo() should not be needed
// anymore.
if (window_tree_->client_name().empty())
return;
ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
if (proxy_window->local_surface_id_allocation().has_value()) {
DCHECK(!fallback_surface_info_);
if (!client_surface_embedder_->HasPrimarySurfaceId())
UpdateLocalSurfaceIdAndClientSurfaceEmbedder();
client_surface_embedder_->SetFallbackSurfaceInfo(surface_info);
} else {
fallback_surface_info_ = std::make_unique<viz::SurfaceInfo>(surface_info);
}
if (!window_tree_->client_name().empty()) {
// OnFirstSurfaceActivation() should only be called after
// AttachCompositorFrameSink().
DCHECK(proxy_window->attached_compositor_frame_sink());
window_tree_->window_service()->OnFirstSurfaceActivation(
window_tree_->client_name());
}
// OnFirstSurfaceActivation() should only be called after
// AttachCompositorFrameSink().
DCHECK(proxy_window->attached_compositor_frame_sink());
window_tree_->window_service()->OnFirstSurfaceActivation(
window_tree_->client_name());
}
void ClientRoot::OnFrameTokenChanged(uint32_t frame_token) {
......
......@@ -27,10 +27,6 @@ namespace aura_extra {
class WindowPositionInRootMonitor;
}
namespace gfx {
class Insets;
}
namespace viz {
class LocalSurfaceIdAllocation;
class SurfaceInfo;
......@@ -54,11 +50,6 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
ClientRoot(WindowTree* window_tree, aura::Window* window, bool is_top_level);
~ClientRoot() override;
// Called when the client area of the window changes. If the window is a
// top-level window, then this propagates the insets to the
// ClientSurfaceEmbedder.
void SetClientAreaInsets(const gfx::Insets& client_area_insets);
// Registers the necessary state needed for embedding in viz.
void RegisterVizEmbeddingSupport();
......@@ -167,11 +158,6 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
bool is_moving_across_displays_ = false;
base::Optional<gfx::Rect> scheduled_change_old_bounds_;
// If non-null then the fallback SurfaceInfo was supplied before the primary
// surface. This will be pushed to the Layer once the primary surface is
// supplied.
std::unique_ptr<viz::SurfaceInfo> fallback_surface_info_;
// Used for non-top-levels to watch for changes in screen coordinates.
std::unique_ptr<aura_extra::WindowPositionInRootMonitor>
root_position_monitor_;
......
......@@ -465,11 +465,6 @@ void ProxyWindow::SetClientArea(
additional_client_areas_ = additional_client_areas;
client_area_ = insets;
ClientRoot* client_root =
owning_window_tree_ ? owning_window_tree_->GetClientRootForWindow(window_)
: nullptr;
if (client_root)
client_root->SetClientAreaInsets(insets);
}
void ProxyWindow::SetHitTestInsets(const gfx::Insets& mouse,
......
......@@ -88,23 +88,4 @@ TEST(ProxyWindow, FindTargetForWindowWithResizeInset) {
EXPECT_EQ(top_level, setup.root()->targeter()->FindTargetForEvent(
setup.root(), &mouse_event_2));
}
TEST(ProxyWindow, SetClientAreaPropagatesToClientSurfaceEmbedder) {
WindowServiceTestSetup setup;
aura::Window* top_level =
setup.window_tree_test_helper()->NewTopLevelWindow();
ASSERT_TRUE(top_level);
const gfx::Rect top_level_bounds(100, 200, 200, 200);
top_level->SetBounds(top_level_bounds);
const gfx::Insets top_level_insets(1, 2, 11, 12);
setup.window_tree_test_helper()->SetClientArea(top_level, top_level_insets);
aura::ClientSurfaceEmbedder* client_surface_embedder =
ClientRootTestHelper(
setup.window_tree()->GetClientRootForWindow(top_level))
.GetClientSurfaceEmbedder();
ASSERT_TRUE(client_surface_embedder);
EXPECT_EQ(top_level_insets, client_surface_embedder->client_area_insets());
}
} // namespace ws
......@@ -11,15 +11,10 @@
namespace aura {
ClientSurfaceEmbedder::ClientSurfaceEmbedder(
Window* window,
bool inject_gutter,
const gfx::Insets& client_area_insets)
ClientSurfaceEmbedder::ClientSurfaceEmbedder(Window* window)
: window_(window),
surface_layer_owner_(std::make_unique<ui::LayerOwner>(
std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR))),
inject_gutter_(inject_gutter),
client_area_insets_(client_area_insets) {
std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR))) {
surface_layer_owner_->layer()->set_name("ClientSurfaceEmbedder");
surface_layer_owner_->layer()->SetMasksToBounds(true);
// The frame provided by the parent window->layer() needs to show through
......@@ -39,91 +34,18 @@ ClientSurfaceEmbedder::~ClientSurfaceEmbedder() = default;
void ClientSurfaceEmbedder::SetSurfaceId(const viz::SurfaceId& surface_id) {
// Set the background to transparent to avoid a flash of color before the
// client surface is rendered. See https://crbug.com/930199
const gfx::Size size = window_->bounds().size();
surface_layer_owner_->layer()->SetBounds(gfx::Rect(size));
surface_layer_owner_->layer()->SetShowSurface(
surface_id, window_->bounds().size(), SK_ColorTRANSPARENT,
surface_id, size, SK_ColorTRANSPARENT,
cc::DeadlinePolicy::UseDefaultDeadline(),
false /* stretch_content_to_fill_bounds */);
}
bool ClientSurfaceEmbedder::HasPrimarySurfaceId() const {
return surface_layer_owner_->layer()->GetSurfaceId() != nullptr;
}
void ClientSurfaceEmbedder::SetFallbackSurfaceInfo(
const viz::SurfaceInfo& surface_info) {
fallback_surface_info_ = surface_info;
UpdateSizeAndGutters();
}
void ClientSurfaceEmbedder::SetClientAreaInsets(
const gfx::Insets& client_area_insets) {
if (client_area_insets_ == client_area_insets)
return;
client_area_insets_ = client_area_insets;
if (inject_gutter_)
UpdateSizeAndGutters();
}
void ClientSurfaceEmbedder::UpdateSizeAndGutters() {
surface_layer_owner_->layer()->SetBounds(gfx::Rect(window_->bounds().size()));
if (!inject_gutter_)
return;
gfx::Size fallback_surface_size_in_dip;
if (fallback_surface_info_.is_valid()) {
float fallback_device_scale_factor =
fallback_surface_info_.device_scale_factor();
fallback_surface_size_in_dip = gfx::ConvertSizeToDIP(
fallback_device_scale_factor, fallback_surface_info_.size_in_pixels());
}
gfx::Rect window_bounds(window_->bounds());
if (!window_->transparent() &&
fallback_surface_size_in_dip.width() < window_bounds.width()) {
right_gutter_owner_ = std::make_unique<ui::LayerOwner>(
std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR));
// TODO(fsamuel): Use the embedded client's background color.
right_gutter_owner_->layer()->SetColor(SK_ColorWHITE);
int width = window_bounds.width() - fallback_surface_size_in_dip.width();
// The right gutter also includes the bottom-right corner, if necessary.
int height = window_bounds.height() - client_area_insets_.height();
right_gutter_owner_->layer()->SetBounds(gfx::Rect(
client_area_insets_.left() + fallback_surface_size_in_dip.width(),
client_area_insets_.top(), width, height));
window_->layer()->Add(right_gutter_owner_->layer());
} else {
right_gutter_owner_.reset();
}
// Only create a bottom gutter if a fallback surface is available. Otherwise,
// the right gutter will fill the whole window until a fallback is available.
if (!window_->transparent() && !fallback_surface_size_in_dip.IsEmpty() &&
fallback_surface_size_in_dip.height() < window_bounds.height()) {
bottom_gutter_owner_ = std::make_unique<ui::LayerOwner>(
std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR));
// TODO(fsamuel): Use the embedded client's background color.
bottom_gutter_owner_->layer()->SetColor(SK_ColorWHITE);
int width = fallback_surface_size_in_dip.width();
int height = window_bounds.height() - fallback_surface_size_in_dip.height();
bottom_gutter_owner_->layer()->SetBounds(
gfx::Rect(0, fallback_surface_size_in_dip.height(), width, height));
window_->layer()->Add(bottom_gutter_owner_->layer());
} else {
bottom_gutter_owner_.reset();
}
window_->layer()->StackAtTop(surface_layer_owner_->layer());
}
ui::Layer* ClientSurfaceEmbedder::RightGutterForTesting() {
return right_gutter_owner_ ? right_gutter_owner_->layer() : nullptr;
}
ui::Layer* ClientSurfaceEmbedder::BottomGutterForTesting() {
return bottom_gutter_owner_ ? bottom_gutter_owner_->layer() : nullptr;
}
const viz::SurfaceId& ClientSurfaceEmbedder::GetSurfaceIdForTesting() const {
return *surface_layer_owner_->layer()->GetSurfaceId();
viz::SurfaceId ClientSurfaceEmbedder::GetSurfaceId() const {
const viz::SurfaceId* id = surface_layer_owner_->layer()->GetSurfaceId();
return id ? *id : viz::SurfaceId();
}
} // namespace aura
......@@ -8,53 +8,33 @@
#include <memory>
#include "base/macros.h"
#include "components/viz/common/surfaces/surface_info.h"
#include "ui/aura/aura_export.h"
#include "ui/gfx/geometry/insets.h"
namespace ui {
class Layer;
class LayerOwner;
}
namespace viz {
class SurfaceId;
}
namespace aura {
class Window;
// Used by WindowPortMus when it is embedding a client. Responsible for setting
// up layers containing content from the client, parenting them to the window's
// layer, and updating them when the client submits new surfaces.
// Used to display content from another client. The other client is rendering
// to viz using the SurfaceId supplied to SetSurfaceId().
class AURA_EXPORT ClientSurfaceEmbedder {
public:
// TODO(fsamuel): Insets might differ when the window is maximized. We should
// deal with that case as well.
ClientSurfaceEmbedder(Window* window,
bool inject_gutter,
const gfx::Insets& client_area_insets);
explicit ClientSurfaceEmbedder(Window* window);
~ClientSurfaceEmbedder();
// Updates the clip layer and primary SurfaceId of the surface layer based
// on the provided |surface_id|.
// Sets the current SurfaceId *and* updates the size of the layer to match
// that of the window.
void SetSurfaceId(const viz::SurfaceId& surface_id);
bool HasPrimarySurfaceId() const;
// Sets the fallback SurfaceInfo of the surface layer. The clip layer is not
// updated.
void SetFallbackSurfaceInfo(const viz::SurfaceInfo& surface_info);
void SetClientAreaInsets(const gfx::Insets& client_area_insets);
const gfx::Insets& client_area_insets() const { return client_area_insets_; }
// Update the surface layer size and the right and bottom gutter layers for
// the current window size.
void UpdateSizeAndGutters();
ui::Layer* RightGutterForTesting();
ui::Layer* BottomGutterForTesting();
const viz::SurfaceId& GetSurfaceIdForTesting() const;
// Returns the SurfaceId, empty if SetSurfaceId() has not been called yet.
viz::SurfaceId GetSurfaceId() const;
private:
// The window which embeds the client.
......@@ -64,16 +44,6 @@ class AURA_EXPORT ClientSurfaceEmbedder {
// LayerOwner so that animations clone the layer.
std::unique_ptr<ui::LayerOwner> surface_layer_owner_;
// Information describing the currently set fallback surface.
viz::SurfaceInfo fallback_surface_info_;
// Used for showing a gutter when the content is not available.
std::unique_ptr<ui::LayerOwner> right_gutter_owner_;
std::unique_ptr<ui::LayerOwner> bottom_gutter_owner_;
bool inject_gutter_;
gfx::Insets client_area_insets_;
DISALLOW_COPY_AND_ASSIGN(ClientSurfaceEmbedder);
};
......
......@@ -46,8 +46,8 @@ ParentAllocator::ParentAllocator(WindowPortMus* window_port_mus,
bool is_embedder)
: MusLsiAllocator(window_port_mus, window_tree_client) {
if (is_embedder) {
client_surface_embedder_ = std::make_unique<ClientSurfaceEmbedder>(
GetWindow(), /* inject_gutter */ false, gfx::Insets());
client_surface_embedder_ =
std::make_unique<ClientSurfaceEmbedder>(GetWindow());
}
}
......@@ -129,7 +129,6 @@ void ParentAllocator::Update(bool send_bounds_change) {
viz::SurfaceId surface_id(GetWindow()->GetFrameSinkId(),
GetLocalSurfaceIdAllocation().local_surface_id());
client_surface_embedder_->SetSurfaceId(surface_id);
client_surface_embedder_->UpdateSizeAndGutters();
}
}
......
......@@ -102,8 +102,7 @@ TEST_F(WindowPortMusTest, ClientSurfaceEmbedderUpdatesLayer) {
ClientSurfaceEmbedder* client_surface_embedder =
WindowPortMusTestHelper(&window).GetClientSurfaceEmbedder();
ASSERT_TRUE(client_surface_embedder);
viz::SurfaceId primary_surface_id =
client_surface_embedder->GetSurfaceIdForTesting();
viz::SurfaceId primary_surface_id = client_surface_embedder->GetSurfaceId();
EXPECT_EQ(local_surface_id, primary_surface_id.local_surface_id());
}
......@@ -139,9 +138,8 @@ TEST_F(WindowPortMusTest,
ClientSurfaceEmbedder* client_surface_embedder =
WindowPortMusTestHelper(&window).GetClientSurfaceEmbedder();
ASSERT_TRUE(client_surface_embedder);
EXPECT_EQ(
updated_id,
client_surface_embedder->GetSurfaceIdForTesting().local_surface_id());
EXPECT_EQ(updated_id,
client_surface_embedder->GetSurfaceId().local_surface_id());
// The server is notified of a bounds change, so that it sees the new
// LocalSurfaceId.
......@@ -218,7 +216,7 @@ TEST_F(WindowPortMusTest, PrepareForEmbed) {
ClientSurfaceEmbedder* client_surface_embedder =
WindowPortMusTestHelper(&window).GetClientSurfaceEmbedder();
ASSERT_TRUE(client_surface_embedder);
EXPECT_TRUE(client_surface_embedder->HasPrimarySurfaceId());
EXPECT_TRUE(client_surface_embedder->GetSurfaceId().is_valid());
}
class TestDragDropDelegate : public client::DragDropDelegate {
......
......@@ -347,10 +347,7 @@ TEST_P(WindowTreeClientTestSurfaceSync, ClientSurfaceEmbedderCreated) {
// Once the bounds have been set, the ClientSurfaceEmbedder should be created.
client_surface_embedder = window_test_helper.GetClientSurfaceEmbedder();
ASSERT_NE(nullptr, client_surface_embedder);
EXPECT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting());
EXPECT_EQ(nullptr, client_surface_embedder->RightGutterForTesting());
EXPECT_TRUE(client_surface_embedder);
}
// Verifies that the viz::LocalSurfaceId generated by an embedder changes when
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment