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

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

Issue 2875753002: Implement aura::WindowPortMus::CreateCompositorFrameSink() (Closed)
Patch Set: Update Created 3 years, 7 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
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 14ae20a368daca4d74ce4909e70545b361551f90..93d1d8884b17dba006005e15b813cb5a5aa8c19d 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -7,6 +7,7 @@
#include "base/memory/ptr_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/transient_window_client.h"
+#include "ui/aura/env.h"
#include "ui/aura/mus/client_surface_embedder.h"
#include "ui/aura/mus/property_converter.h"
#include "ui/aura/mus/window_tree_client.h"
@@ -273,6 +274,12 @@ void WindowPortMus::SetFrameSinkIdFromServer(
const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
const gfx::Size& surface_size) {
+ if (window_mus_type() == WindowMusType::LOCAL &&
+ !frame_sink_for_local_window_.get()) {
+ local_surface_id_ = cc::LocalSurfaceId();
+ return local_surface_id_;
Fady Samuel 2017/06/07 17:36:27 Do we need this change?
Peng 2017/06/07 19:30:29 We don't want to generate local surface id, if a l
+ }
+
if (last_surface_size_ == surface_size && local_surface_id_.is_valid())
return local_surface_id_;
@@ -286,18 +293,32 @@ const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
if (frame_sink_id_.is_valid())
UpdatePrimarySurfaceInfo();
- return local_surface_id_;
-}
+ if (frame_sink_for_local_window_)
+ frame_sink_for_local_window_->SetLocalSurfaceId(local_surface_id_);
Fady Samuel 2017/06/07 17:36:27 Just call this compositor_frame_sink_. No point in
Peng 2017/06/07 19:30:29 Done.
-void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) {
- primary_surface_info_ = surface_info;
- UpdateClientSurfaceEmbedder();
- if (window_->delegate())
- window_->delegate()->OnWindowSurfaceChanged(surface_info);
+ return local_surface_id_;
}
-void WindowPortMus::SetFallbackSurfaceInfo(
+void WindowPortMus::SetSurfaceInfoFromServer(
const cc::SurfaceInfo& surface_info) {
+ if (!frame_sink_id_.is_valid()) {
+ // This only happens for a "local" window, because the
+ // |SetFrameSinkIdFromServer| will not be called for a "local" window.
+ DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
+ // |primary_surface_info_| shold not be valid, since we didn't know the
+ // |frame_sink_id_|.
+ DCHECK(!primary_surface_info_.is_valid());
+ frame_sink_id_ = surface_info.id().frame_sink_id();
+ UpdatePrimarySurfaceInfo();
Fady Samuel 2017/06/07 17:36:27 Do we need this change?
Peng 2017/06/07 19:30:29 Yes. Because we don't know frame sink id for a loc
+ }
+
+ // The frame sink id should never be changed.
+ DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_);
+
+ // If the window is informed of a surface from server then that surface ID is
+ // guaranteed to be available in the display compositor so we set it as the
+ // fallback. For embedded window, the primary SurfaceInfo is created by the
+ // embedder, and the LocalSurfaceId is allocated by the embedder.
fallback_surface_info_ = surface_info;
UpdateClientSurfaceEmbedder();
}
@@ -491,37 +512,46 @@ void WindowPortMus::OnPropertyChanged(const void* key,
std::unique_ptr<cc::CompositorFrameSink>
WindowPortMus::CreateCompositorFrameSink() {
- // TODO(penghuang): Implement it for Mus.
- return nullptr;
+ DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
Fady Samuel 2017/06/07 17:36:26 Can we just have a single code path? Let's not spe
Peng 2017/06/07 19:30:29 We need make sure this function is used on a embed
+ DCHECK(!frame_sink_for_local_window_);
+ auto frame_sink = RequestCompositorFrameSink(
+ nullptr,
+ aura::Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager());
+ auto* viz_frame_sink =
+ static_cast<viz::ClientCompositorFrameSink*>(frame_sink.get());
+ frame_sink_for_local_window_ = viz_frame_sink->GetWeakPtr();
+ return frame_sink;
}
cc::SurfaceId WindowPortMus::GetSurfaceId() const {
- // TODO(penghuang): Implement it for Mus.
+ // This method is only used by exo unittests which are not running against
+ // mus, so don't implement it now.
Fady Samuel 2017/06/07 17:36:27 Just say this is only used by WindowPortLocal in u
Peng 2017/06/07 19:30:29 Done.
return cc::SurfaceId();
}
void WindowPortMus::UpdatePrimarySurfaceInfo() {
- bool embeds_surface =
- window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
- window_mus_type() == WindowMusType::EMBED_IN_OWNER ||
- window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED;
- if (!embeds_surface)
+ if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
+ window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
+ window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
+ window_mus_type() != WindowMusType::LOCAL)
return;
if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
return;
- SetPrimarySurfaceInfo(
+ primary_surface_info_ =
cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_),
- ScaleFactorForDisplay(window_), last_surface_size_));
+ ScaleFactorForDisplay(window_), last_surface_size_);
+ UpdateClientSurfaceEmbedder();
+ if (window_->delegate())
+ window_->delegate()->OnWindowSurfaceChanged(primary_surface_info_);
}
void WindowPortMus::UpdateClientSurfaceEmbedder() {
- bool embeds_surface =
- window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
- window_mus_type() == WindowMusType::EMBED_IN_OWNER ||
- window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED;
- if (!embeds_surface)
+ if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
+ window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
+ window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
+ window_mus_type() != WindowMusType::LOCAL)
return;
if (!client_surface_embedder_) {

Powered by Google App Engine
This is Rietveld 408576698