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

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

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: First cut propagating LocalSurfaceId when WindowTreeHost requests resize Created 3 years, 9 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/compositor/layer.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 21f55205886f0d4a0183b557759c8f94c3e52d82..9c8e6995f7f0829c2ddc2235b0481a2aad43e190 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -12,8 +12,11 @@
#include "base/auto_reset.h"
#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/debug/stack_trace.h"
#include "base/memory/ptr_util.h"
#include "base/threading/thread.h"
+#include "cc/base/switches.h"
#include "components/discardable_memory/client/client_discardable_shared_memory_manager.h"
#include "mojo/public/cpp/bindings/map.h"
#include "services/service_manager/public/cpp/connector.h"
@@ -223,6 +226,9 @@ WindowTreeClient::WindowTreeClient(
discardable_shared_memory_manager_.get());
}
}
+ enable_surface_synchronization_ =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ cc::switches::kEnableSurfaceSynchronization);
}
WindowTreeClient::~WindowTreeClient() {
@@ -454,8 +460,10 @@ 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_surface_id);
return window_tree_host;
}
@@ -579,15 +587,22 @@ void WindowTreeClient::OnReceivedCursorLocationMemory(
void WindowTreeClient::SetWindowBoundsFromServer(
WindowMus* window,
- const gfx::Rect& revert_bounds_in_pixels) {
+ const gfx::Rect& revert_bounds_in_pixels,
+ const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
+ gfx::Rect bounds_in_pixels(revert_bounds_in_pixels);
if (IsRoot(window)) {
// WindowTreeHost expects bounds to be in pixels.
GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels);
+ if (enable_surface_synchronization_ && local_surface_id &&
+ local_surface_id->is_valid()) {
+ window->GetWindow()->GetHost()->compositor()->SetLocalSurfaceId(
+ *local_surface_id);
+ }
return;
}
window->SetBoundsFromServer(gfx::ConvertRectToDIP(
- ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels));
+ ScaleFactorForDisplay(window->GetWindow()), bounds_in_pixels));
}
void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window,
@@ -610,11 +625,17 @@ 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));
- // TODO(fsamuel): Allocate a new LocalSurfaceId on size change.
+ const uint32_t change_id =
+ ScheduleInFlightChange(base::MakeUnique<InFlightBoundsChange>(
+ this, window, old_bounds, window->GetLocalSurfaceId()));
+ base::Optional<cc::LocalSurfaceId> local_surface_id;
+ if (enable_surface_synchronization_ &&
+ (window->window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
+ window->window_mus_type() == WindowMusType::EMBED_IN_OWNER)) {
+ local_surface_id = window->AllocateLocalSurfaceIdForSize(new_bounds.size());
+ }
tree_->SetWindowBounds(change_id, window->server_id(), new_bounds,
- base::nullopt);
+ local_surface_id);
}
void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
@@ -685,6 +706,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.
@@ -940,6 +962,8 @@ 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 base::Optional<cc::LocalSurfaceId> local_surface_id(
+ data->local_surface_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
@@ -970,14 +994,15 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
const gfx::Rect bounds(data->bounds);
{
- InFlightBoundsChange bounds_change(this, window, bounds);
+ InFlightBoundsChange bounds_change(this, window, bounds, local_surface_id);
InFlightChange* current_change =
GetOldestInFlightChangeMatching(bounds_change);
if (current_change)
current_change->SetRevertValueFrom(bounds_change);
else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()),
- window->GetWindow()->bounds()) != bounds)
- SetWindowBoundsFromServer(window, bounds);
+ window->GetWindow()->bounds()) != bounds) {
+ SetWindowBoundsFromServer(window, bounds, local_surface_id);
+ }
}
// There is currently no API to bulk set properties, so we iterate over each
@@ -1011,11 +1036,11 @@ void WindowTreeClient::OnWindowBoundsChanged(
if (!window)
return;
- InFlightBoundsChange new_change(this, window, new_bounds);
+ InFlightBoundsChange new_change(this, window, new_bounds, local_surface_id);
if (ApplyServerChangeToExistingInFlightChange(new_change))
return;
- SetWindowBoundsFromServer(window, new_bounds);
+ SetWindowBoundsFromServer(window, new_bounds, local_surface_id);
}
void WindowTreeClient::OnClientAreaChanged(
@@ -1267,7 +1292,10 @@ void WindowTreeClient::OnWindowSurfaceChanged(
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
return;
- window->SetSurfaceInfoFromServer(surface_info);
+ if (enable_surface_synchronization_)
+ window->SetFallbackSurfaceInfo(surface_info);
+ else
+ window->SetPrimarySurfaceInfo(surface_info);
}
void WindowTreeClient::OnDragDropStart(
@@ -1301,6 +1329,25 @@ void WindowTreeClient::OnDragDropDone() {
drag_drop_controller_->OnDragDropDone();
}
+void WindowTreeClient::OnSetWindowBoundsResponse(
+ uint32_t change_id,
+ const gfx::Rect& bounds,
+ const cc::LocalSurfaceId& local_surface_id) {
+ auto it = in_flight_map_.find(change_id);
+ DCHECK(it != in_flight_map_.end());
+ // TODO(fsamuel): Fix this.
+ WindowMus* window = const_cast<WindowMus*>(it->second->window());
+ DCHECK(window);
+ OnChangeCompleted(change_id, true);
+ InFlightBoundsChange bounds_change(this, window, bounds, local_surface_id);
+ InFlightChange* current_change =
+ GetOldestInFlightChangeMatching(bounds_change);
+ if (current_change)
+ current_change->SetRevertValueFrom(bounds_change);
+ else
+ SetWindowBoundsFromServer(window, bounds, local_surface_id);
+}
+
void WindowTreeClient::OnCompleteDrop(Id window_id,
uint32_t key_state,
const gfx::Point& position,
@@ -1412,6 +1459,12 @@ void WindowTreeClient::WmSetBounds(uint32_t change_id,
// the client applies the bounds we set below.
result = bounds_in_dip == transit_bounds_in_dip;
window->SetBoundsFromServer(bounds_in_dip);
+ if (window->window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM &&
+ window_manager_internal_client_) {
+ window_manager_internal_client_->WmSetBoundsResponse(
+ change_id, bounds_in_dip, window->GetLocalSurfaceId());
+ return;
+ }
}
} else {
DVLOG(1) << "Unknown window passed to WmSetBounds().";
@@ -1794,6 +1847,7 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW));
tree_->NewTopLevelWindow(change_id, window_port->server_id(),
transport_properties);
+
return window_port;
}
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698