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

Unified Diff: ui/aura/mus/window_port_mus.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_port_mus.h ('k') | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_port_mus.cc
diff --git a/ui/aura/mus/window_port_mus.cc b/ui/aura/mus/window_port_mus.cc
index 1ad03c8900ca322f41f9a2f32b1493dea0c1f3bd..df71c8e520ad9eb025f8f06d113a51dac688bd13 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -14,10 +14,23 @@
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/base/class_property.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
namespace aura {
+namespace {
+// Helper function to get the device_scale_factor() of the display::Display
+// nearest to |window|.
+float ScaleFactorForDisplay(Window* window) {
+ return display::Screen::GetScreen()
+ ->GetDisplayNearestWindow(window)
+ .device_scale_factor();
+}
+}
+
WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default;
@@ -33,7 +46,7 @@ WindowPortMus::WindowPortMus(WindowTreeClient* client,
WindowPortMus::~WindowPortMus() {
if (surface_info_.is_valid())
- SetSurfaceInfoFromServer(cc::SurfaceInfo());
+ SetPrimarySurfaceInfo(cc::SurfaceInfo());
// DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is
// present then the server originated the change.
@@ -268,6 +281,30 @@ void WindowPortMus::SetPropertyFromServer(
property_data);
}
+void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) {
+ // The fact that SetSurfaceIdFromServer was called means that this window
+ // corresponds to an embedded client.
+ if (!client_surface_embedder && window_ && surface_info.is_valid())
+ client_surface_embedder = base::MakeUnique<ClientSurfaceEmbedder>(window_);
+
+ if (surface_info.is_valid() && window_->IsVisible())
+ client_surface_embedder->UpdateSurface(surface_info);
+ else
+ client_surface_embedder.reset();
+
+ surface_info_ = surface_info;
+}
+
+void WindowPortMus::SetFallbackSurfaceInfo(
+ const cc::SurfaceInfo& surface_info) {
+ // The fact that SetSurfaceIdFromServer was called means that this window
+ // corresponds to an embedded client.
+ if (!client_surface_embedder)
+ client_surface_embedder = base::MakeUnique<ClientSurfaceEmbedder>(window_);
+
+ client_surface_embedder->SetFallbackSurfaceInfo(surface_info);
+}
+
void WindowPortMus::SetFrameSinkIdFromServer(
const cc::FrameSinkId& frame_sink_id) {
frame_sink_id_ = frame_sink_id;
@@ -277,34 +314,43 @@ void WindowPortMus::SetFrameSinkIdFromServer(
DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type());
DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type());
base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run();
+ return;
}
// TODO(fsamuel): If the window type is TOP_LEVEL_IN_WM or EMBED_IN_OWNER then
// we should check if we have a cc::LocalSurfaeId ready as well. If we do,
// then we are ready to embed.
+ if ((window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
+ window_mus_type() == WindowMusType::EMBED_IN_OWNER) &&
+ local_surface_id_.is_valid()) {
+ cc::SurfaceInfo surface_info(
+ cc::SurfaceId(frame_sink_id_, local_surface_id_),
+ ScaleFactorForDisplay(window_), window_->bounds().size());
+ SetPrimarySurfaceInfo(surface_info);
+ }
}
-void WindowPortMus::SetSurfaceInfoFromServer(
- const cc::SurfaceInfo& surface_info) {
- if (surface_info_.is_valid()) {
- const cc::SurfaceId& existing_surface_id = surface_info_.id();
- const cc::SurfaceId& new_surface_id = surface_info.id();
- if (existing_surface_id.is_valid() &&
- existing_surface_id != new_surface_id) {
- // TODO(kylechar): Start return reference here?
- }
- }
+const cc::LocalSurfaceId& WindowPortMus::GetLocalSurfaceId() {
+ return local_surface_id_;
+}
- // The fact that SetSurfaceIdFromServer was called means that this window
- // corresponds to an embedded client.
- if (!client_surface_embedder && surface_info.is_valid())
- client_surface_embedder = base::MakeUnique<ClientSurfaceEmbedder>(window_);
+const cc::LocalSurfaceId& WindowPortMus::AllocateLocalSurfaceIdForSize(
+ const gfx::Size& new_size) {
+ if (last_size_ == new_size && local_surface_id_.is_valid())
+ return local_surface_id_;
- if (surface_info.is_valid())
- client_surface_embedder->UpdateSurface(surface_info);
- else
- client_surface_embedder.reset();
+ local_surface_id_ = local_surface_id_allocator_.GenerateId();
+ last_size_ = new_size;
- surface_info_ = surface_info;
+ // If we have a valid FrameSinkId and LocalSurfaceId then we can embed
+ // the content of the window now.
+ if (frame_sink_id_.is_valid()) {
+ // TODO(fsamuel): DCHECK That we have the right window type.
+ cc::SurfaceInfo surface_info(
+ cc::SurfaceId(frame_sink_id_, local_surface_id_),
+ ScaleFactorForDisplay(window_), new_size);
+ SetPrimarySurfaceInfo(surface_info);
+ }
+ return local_surface_id_;
}
void WindowPortMus::DestroyFromServer() {
@@ -448,6 +494,9 @@ void WindowPortMus::OnVisibilityChanged(bool visible) {
change_data.visible = visible;
if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data))
window_tree_client_->OnWindowMusSetVisible(this, visible);
+ // Update the ClientSurfaceEmbedder on visibility change.
+ if (surface_info_.is_valid())
+ SetPrimarySurfaceInfo(surface_info_);
}
void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds,
« no previous file with comments | « ui/aura/mus/window_port_mus.h ('k') | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698