Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: ui/aura/mus/window_tree_client.cc

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_host_mus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client.cc
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc
index 0ae7b855248f0aec78dd4bf89bc0c5cdef6ea326..8277c55ce4084dca0c9f2e995562c432bc8df131 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -12,7 +12,9 @@
#include "base/auto_reset.h"
#include "base/bind.h"
+#include "base/debug/stack_trace.h"
#include "base/memory/ptr_util.h"
+#include "cc/surfaces/frame_sink_id.h"
#include "mojo/public/cpp/bindings/map.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/ui/common/accelerator_util.h"
@@ -178,6 +180,7 @@ WindowTreeClient::WindowTreeClient(
}
WindowTreeClient::~WindowTreeClient() {
+ fprintf(stderr, ">>>%s\n", __PRETTY_FUNCTION__);
in_destructor_ = true;
for (WindowTreeClientObserver& observer : observers_)
@@ -283,9 +286,10 @@ void WindowTreeClient::Embed(
callback.Run(false);
return;
}
-
- tree_->Embed(WindowMus::Get(window)->server_id(), std::move(client), flags,
- callback);
+ WindowMus* window_mus = WindowMus::Get(window);
+ tree_->Embed(window_mus->server_id(), std::move(client), flags, callback);
+ fprintf(stderr, ">>>>WindowTreeClient::Embed\n");
+ // window->SetLocalFrameIdFromServer(local_frame_id);
}
void WindowTreeClient::AttachCompositorFrameSink(
@@ -393,6 +397,8 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus(
base::MakeUnique<WindowPortMus>(this, window_mus_type));
window_port_mus->set_server_id(window_data.window_id);
RegisterWindowMus(window_port_mus.get());
+ // If (window_port_mus->server_id() == 65566)
+ // base::debug::StackTrace().Print();
return window_port_mus;
}
@@ -420,8 +426,15 @@ std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()),
true);
}
- SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()),
- window_data.bounds);
+ WindowMus* window = WindowMus::Get(window_tree_host->window());
+
+ SetWindowBoundsFromServer(window, window_data.bounds,
+ window_data.local_frame_id);
+ fprintf(stderr, ">>>WindowTreeClient::CreateWindowTreeHost %s\n",
+ cc::SurfaceId(cc::FrameSinkId(window->server_id(), 0),
+ window_data.local_frame_id)
+ .ToString()
+ .c_str());
return window_tree_host;
}
@@ -438,7 +451,8 @@ WindowMus* WindowTreeClient::NewWindowFromWindowData(
window->Init(ui::LAYER_NOT_DRAWN);
SetLocalPropertiesFromServerProperties(window_mus, window_data);
window_mus->SetBoundsFromServer(
- gfx::ConvertRectToDIP(ScaleFactorForDisplay(window), window_data.bounds));
+ gfx::ConvertRectToDIP(ScaleFactorForDisplay(window), window_data.bounds),
+ window_data.local_frame_id);
if (parent)
parent->AddChildFromServer(window_port_mus_ptr);
if (window_data.visible)
@@ -502,6 +516,7 @@ void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree,
int64_t display_id,
Id focused_window_id,
bool drawn) {
+ fprintf(stderr, ">>%s\n", __PRETTY_FUNCTION__);
// WARNING: this is only called if WindowTreeClient was created as the
// result of an embedding.
client_id_ = client_id;
@@ -549,15 +564,23 @@ void WindowTreeClient::OnReceivedCursorLocationMemory(
void WindowTreeClient::SetWindowBoundsFromServer(
WindowMus* window,
- const gfx::Rect& revert_bounds_in_pixels) {
+ const gfx::Rect& revert_bounds_in_pixels,
+ const cc::LocalFrameId& local_frame_id) {
+ cc::FrameSinkId frame_sink_id(window->server_id(), 0);
+ cc::SurfaceId surface_id(frame_sink_id, local_frame_id);
+ fprintf(stderr,
+ ">>>>WindowTreeClient::SetWindowBoundsFromServer %s root? %d\n",
+ surface_id.ToString().c_str(), IsRoot(window));
+
if (IsRoot(window)) {
// WindowTreeHost expects bounds to be in pixels.
GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels);
- return;
mfomitchev 2017/01/25 21:41:18 Removing this might be problematic. Not entirely s
}
- window->SetBoundsFromServer(gfx::ConvertRectToDIP(
- ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels));
+ window->SetBoundsFromServer(
+ gfx::ConvertRectToDIP(ScaleFactorForDisplay(window->GetWindow()),
+ revert_bounds_in_pixels),
+ local_frame_id);
}
void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window,
@@ -580,12 +603,34 @@ void WindowTreeClient::ScheduleInFlightBoundsChange(
WindowMus* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
- const uint32_t change_id = ScheduleInFlightChange(
- base::MakeUnique<InFlightBoundsChange>(this, window, old_bounds));
- tree_->SetWindowBounds(change_id, window->server_id(), new_bounds);
+ cc::FrameSinkId frame_sink_id(window->server_id(), 0);
+ std::unique_ptr<cc::SurfaceIdAllocator>& allocator =
+ local_frame_id_allocators_[frame_sink_id];
+ if (!allocator)
+ allocator.reset(new cc::SurfaceIdAllocator());
+ const uint32_t change_id =
+ ScheduleInFlightChange(base::MakeUnique<InFlightBoundsChange>(
+ this, window, old_bounds, allocator->GenerateId()));
+ cc::LocalFrameId local_frame_id;
+ if (!allocator->current_local_frame_id().is_valid() ||
+ new_bounds.size() != old_bounds.size()) {
+ local_frame_id = allocator->GenerateId();
+ } else {
+ local_frame_id = allocator->current_local_frame_id();
+ }
+
+ tree_->SetWindowBounds(change_id, window->server_id(), new_bounds,
+ local_frame_id);
+ // fprintf(stderr, ">>>ScheduleInFlightBoundsChange window_type: %d\n",
+ // window->window_mus_type());
+ // if (window->server_id() == 65566)
+ // base::debug::StackTrace().Print();
+ if (window->GetLayerType() == ui::LAYER_SURFACE)
+ window->SetLocalFrameIdFromServer(local_frame_id);
}
-void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
+void WindowTreeClient::OnWindowMusCreated(WindowMus* window,
+ ui::LayerType layer_type) {
if (window->server_id() != kInvalidServerId)
return;
@@ -614,8 +659,20 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
const uint32_t change_id = ScheduleInFlightChange(
base::MakeUnique<CrashInFlightChange>(window, ChangeType::NEW_WINDOW));
+ cc::FrameSinkId frame_sink_id(window->server_id(), 0);
+ std::unique_ptr<cc::SurfaceIdAllocator>& allocator =
+ local_frame_id_allocators_[frame_sink_id];
+ if (!allocator)
+ allocator.reset(new cc::SurfaceIdAllocator());
+ cc::LocalFrameId local_frame_id = allocator->GenerateId();
tree_->NewWindow(change_id, window->server_id(),
- std::move(transport_properties));
+ std::move(transport_properties), local_frame_id);
+ window->SetLayerType(layer_type);
+ fprintf(stderr, ">>>New Window window_type: %d\n", window->window_mus_type());
+ // if (window->server_id() == 65566)
+ // base::debug::StackTrace().Print();
+ if (layer_type == ui::LAYER_SURFACE)
+ window->SetLocalFrameIdFromServer(local_frame_id);
}
void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
@@ -656,6 +713,7 @@ void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
+ // Called from window->SetBounds in aura.
// Changes to bounds of root windows are routed through
// OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side
// effect of those and can be ignored.
@@ -916,10 +974,15 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
// have changes in flight for we can update them immediately. For properties
// with changes in flight we set the revert value from the server.
+ const cc::LocalFrameId local_frame_id(data->local_frame_id);
if (!in_flight_map_.count(change_id)) {
// The window may have been destroyed locally before the server could finish
// creating the window, and before the server received the notification that
// the window has been destroyed.
+ fprintf(stderr,
+ ">>>WindowTreeClient::OnTopLevelCreated early exit server_id: %d, "
+ "localframeid: %s\n",
+ data->window_id, local_frame_id.ToString().c_str());
return;
}
std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
@@ -945,15 +1008,23 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
}
const gfx::Rect bounds(data->bounds);
+ fprintf(stderr,
+ ">>>WindowTreeClient::OnTopLevelCreated server_id: %d, localframeid: "
+ "%s\n",
+ window->server_id(), local_frame_id.ToString().c_str());
{
- InFlightBoundsChange bounds_change(this, window, bounds);
+ InFlightBoundsChange bounds_change(this, window, bounds, local_frame_id);
InFlightChange* current_change =
GetOldestInFlightChangeMatching(bounds_change);
+ // TODO(fsamuel): We need to inform the window even if bounds have not
+ // changed because the embedded LocalFrameId might have changed.
if (current_change)
current_change->SetRevertValueFrom(bounds_change);
- else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()),
+ else /*if
+ (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()),
window->GetWindow()->bounds()) != bounds)
- SetWindowBoundsFromServer(window, bounds);
+ */
+ SetWindowBoundsFromServer(window, bounds, local_frame_id);
}
// There is currently no API to bulk set properties, so we iterate over each
@@ -976,18 +1047,20 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
DCHECK_EQ(0u, data->parent_id);
}
-void WindowTreeClient::OnWindowBoundsChanged(Id window_id,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
+void WindowTreeClient::OnWindowBoundsChanged(
+ Id window_id,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds,
+ const cc::LocalFrameId& local_frame_id) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
return;
- InFlightBoundsChange new_change(this, window, new_bounds);
+ InFlightBoundsChange new_change(this, window, new_bounds, local_frame_id);
if (ApplyServerChangeToExistingInFlightChange(new_change))
return;
- SetWindowBoundsFromServer(window, new_bounds);
+ SetWindowBoundsFromServer(window, new_bounds, local_frame_id);
}
void WindowTreeClient::OnClientAreaChanged(
@@ -1375,7 +1448,8 @@ void WindowTreeClient::WmDisplayModified(const display::Display& display) {
void WindowTreeClient::WmSetBounds(uint32_t change_id,
Id window_id,
- const gfx::Rect& transit_bounds_in_pixels) {
+ const gfx::Rect& transit_bounds_in_pixels,
+ const cc::LocalFrameId& local_frame_id) {
WindowMus* window = GetWindowByServerId(window_id);
bool result = false;
if (window) {
@@ -1391,7 +1465,7 @@ void WindowTreeClient::WmSetBounds(uint32_t change_id,
// If the resulting bounds differ return false. Returning false ensures
// the client applies the bounds we set below.
result = bounds_in_dip == transit_bounds_in_dip;
- window->SetBoundsFromServer(bounds_in_dip);
+ window->SetBoundsFromServer(bounds_in_dip, local_frame_id);
}
}
if (window_manager_internal_client_)
@@ -1670,6 +1744,9 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
roots_.insert(window_port.get());
window_port->set_server_id(MakeTransportId(client_id_, next_window_id_++));
+ fprintf(stderr,
+ ">>>WindowTreeClient::CreateWindowPortForTopLevel server_id: %d\n",
+ window_port->server_id());
RegisterWindowMus(window_port.get());
std::unordered_map<std::string, std::vector<uint8_t>> transport_properties;
@@ -1683,6 +1760,9 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW));
tree_->NewTopLevelWindow(change_id, window_port->server_id(),
transport_properties);
+
+ // if (window_port->server_id() == 65566)
+ // base::debug::StackTrace().Print();
return window_port;
}
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698