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

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

Issue 2875753002: Implement aura::WindowPortMus::CreateCompositorFrameSink() (Closed)
Patch Set: Address review issues Created 3 years, 6 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 e550ddb761d9bf617553d822362b026a327642c5..2f7304e1b7ec0dbb41e3860d00aa27ed699b9e41 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"
@@ -288,6 +289,12 @@ void WindowPortMus::SetFrameSinkIdFromServer(
const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
const gfx::Size& surface_size_in_pixels) {
+ if (window_mus_type() == WindowMusType::LOCAL &&
+ !compositor_frame_sink_.get()) {
+ local_surface_id_ = cc::LocalSurfaceId();
+ return local_surface_id_;
+ }
+
Fady Samuel 2017/06/07 20:36:11 Remove this change above?
Peng 2017/06/07 21:14:29 Done.
if (last_surface_size_in_pixels_ == surface_size_in_pixels &&
local_surface_id_.is_valid()) {
return local_surface_id_;
@@ -303,18 +310,32 @@ const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
if (frame_sink_id_.is_valid())
UpdatePrimarySurfaceInfo();
- return local_surface_id_;
-}
+ if (compositor_frame_sink_)
+ compositor_frame_sink_->SetLocalSurfaceId(local_surface_id_);
-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(
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);
Fady Samuel 2017/06/07 20:36:11 This seems like an unnecessary check.
Peng 2017/06/07 21:14:28 Done.
+ // |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();
+ }
+
+ // 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
Fady Samuel 2017/06/07 20:36:11 For embedded windows
Peng 2017/06/07 21:14:28 Done. Move this comment back to window_tree_client
+ // embedder, and the LocalSurfaceId is allocated by the embedder.
fallback_surface_info_ = surface_info;
UpdateClientSurfaceEmbedder();
}
@@ -518,37 +539,45 @@ 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);
+ DCHECK(!compositor_frame_sink_);
+ auto frame_sink = RequestCompositorFrameSink(
+ nullptr,
+ aura::Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager());
+ auto* viz_frame_sink =
+ static_cast<viz::ClientCompositorFrameSink*>(frame_sink.get());
+ compositor_frame_sink_ = viz_frame_sink->GetWeakPtr();
+ return frame_sink;
}
cc::SurfaceId WindowPortMus::GetSurfaceId() const {
- // TODO(penghuang): Implement it for Mus.
+ // This is only used by WindowPortLocal in unit tests.
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)
Fady Samuel 2017/06/07 20:36:11 {..}
Peng 2017/06/07 21:14:29 Done.
return;
if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
return;
- SetPrimarySurfaceInfo(cc::SurfaceInfo(
+ primary_surface_info_ = cc::SurfaceInfo(
cc::SurfaceId(frame_sink_id_, local_surface_id_),
- ScaleFactorForDisplay(window_), last_surface_size_in_pixels_));
+ ScaleFactorForDisplay(window_), last_surface_size_in_pixels_);
+ 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)
Fady Samuel 2017/06/07 20:36:11 {..}
Peng 2017/06/07 21:14:29 Done.
return;
if (!client_surface_embedder_) {

Powered by Google App Engine
This is Rietveld 408576698