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

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

Issue 2875753002: Implement aura::WindowPortMus::CreateCompositorFrameSink() (Closed)
Patch Set: WIP 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 4c98ed4558a036614237a01cf0d8aa1497009064..c83deffd67d22c4b7c7694c57c5a267a57020203 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -5,9 +5,12 @@
#include "ui/aura/mus/window_port_mus.h"
#include "base/memory/ptr_util.h"
+#include "cc/output/context_provider.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/mus_context_factory.h"
#include "ui/aura/mus/property_converter.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/mus/window_tree_client_delegate.h"
@@ -28,6 +31,25 @@ float ScaleFactorForDisplay(Window* window) {
->GetDisplayNearestWindow(window)
.device_scale_factor();
}
+
+// TODO(mfomitchev, samans): Remove these stub classes once the SurfaceReference
+// work is complete.
+class StubSurfaceReferenceFactory : public cc::SurfaceReferenceFactory {
+ public:
+ StubSurfaceReferenceFactory() = default;
+
+ // cc::SurfaceReferenceFactory:
+ base::Closure CreateReference(
+ cc::SurfaceReferenceOwner* owner,
+ const cc::SurfaceId& surface_id) const override {
+ return base::Closure();
+ }
+
+ protected:
+ ~StubSurfaceReferenceFactory() override = default;
+
+ DISALLOW_COPY_AND_ASSIGN(StubSurfaceReferenceFactory);
+};
} // namespace
WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
@@ -41,7 +63,9 @@ WindowMus* WindowMus::Get(Window* window) {
WindowPortMus::WindowPortMus(WindowTreeClient* client,
WindowMusType window_mus_type)
- : WindowMus(window_mus_type), window_tree_client_(client) {}
+ : WindowMus(window_mus_type),
+ window_tree_client_(client),
+ weak_factory_(this) {}
WindowPortMus::~WindowPortMus() {
client_surface_embedder_.reset();
@@ -121,9 +145,9 @@ void WindowPortMus::RequestCompositorFrameSinkInternal(
std::unique_ptr<ui::ClientCompositorFrameSinkBinding>
compositor_frame_sink_binding;
std::unique_ptr<ui::ClientCompositorFrameSink> compositor_frame_sink =
- ui::ClientCompositorFrameSink::Create(
- frame_sink_id_, std::move(context_provider),
- gpu_memory_buffer_manager, &compositor_frame_sink_binding);
+ ui::ClientCompositorFrameSink::Create(std::move(context_provider),
+ gpu_memory_buffer_manager,
+ &compositor_frame_sink_binding);
AttachCompositorFrameSink(std::move(compositor_frame_sink_binding));
callback.Run(std::move(compositor_frame_sink));
}
@@ -321,8 +345,18 @@ const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
}
void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) {
+ bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
+ window_mus_type() == WindowMusType::EMBED_IN_OWNER;
primary_surface_info_ = surface_info;
- UpdateClientSurfaceEmbedder();
+ if (embeds_surface) {
+ UpdateClientSurfaceEmbedder();
+ } else {
+ if (!ref_factory_)
Fady Samuel 2017/05/16 10:26:41 what calls this?
Peng 2017/05/16 10:55:24 window_->layer()->SetShowPrimarySurface(surface_in
+ ref_factory_ = new StubSurfaceReferenceFactory();
+ window_->layer()->SetBounds(gfx::Rect(window_->layer()->bounds().origin(),
+ surface_info.size_in_pixels()));
+ window_->layer()->SetShowPrimarySurface(surface_info, ref_factory_);
+ }
if (window_->delegate())
window_->delegate()->OnWindowSurfaceChanged(surface_info);
}
@@ -522,19 +556,36 @@ void WindowPortMus::OnPropertyChanged(const void* key,
std::unique_ptr<cc::CompositorFrameSink>
WindowPortMus::CreateCompositorFrameSink() {
- // TODO(penghuang): Implement it for Mus.
- return nullptr;
+ // We only allow creating a compositor frame sink for a local window.
+ if (window_mus_type() != WindowMusType::LOCAL)
+ return nullptr;
+
+ DCHECK(!frame_sink_id_.is_valid());
+ window_tree_client_->GetFrameSinkId(server_id());
Fady Samuel 2017/05/16 10:28:03 Why do we need this?
Peng 2017/05/16 10:55:23 Right now, WS doesn't send frame sink id to client
+
+ ui::ContextFactory* context_factory =
+ aura::Env::GetInstance()->context_factory();
+ std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding;
+ std::unique_ptr<ui::ClientCompositorFrameSink> frame_sink =
+ ui::ClientCompositorFrameSink::Create(
+ nullptr /* context_provider */,
+ context_factory->GetGpuMemoryBufferManager(), &frame_sink_binding);
+ frame_sink->SetSurfaceChangedCallback(
Fady Samuel 2017/05/16 10:28:03 What is the purpose of this callback?
Peng 2017/05/16 10:55:23 The ClientCompositorFrameSink will generate new lo
+ base::Bind(&WindowPortMus::OnSurfaceChanged, weak_factory_.GetWeakPtr()));
+ AttachCompositorFrameSink(std::move(frame_sink_binding));
+ return std::move(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.
return cc::SurfaceId();
}
void WindowPortMus::UpdatePrimarySurfaceInfo() {
bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
window_mus_type() == WindowMusType::EMBED_IN_OWNER;
- if (!embeds_surface || !window_tree_client_->enable_surface_synchronization_)
+ if (embeds_surface && !window_tree_client_->enable_surface_synchronization_)
return;
if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
@@ -560,4 +611,12 @@ void WindowPortMus::UpdateClientSurfaceEmbedder() {
client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_);
}
+void WindowPortMus::OnSurfaceChanged(const cc::LocalSurfaceId& local_surface_id,
Fady Samuel 2017/05/16 10:26:42 I'm confused about when this happens then...
Peng 2017/05/16 10:55:23 See line 103 at https://codereview.chromium.org/28
+ const gfx::Size& surface_size) {
+ DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
+ local_surface_id_ = local_surface_id;
+ last_surface_size_ = surface_size;
+ UpdatePrimarySurfaceInfo();
+}
+
} // namespace aura

Powered by Google App Engine
This is Rietveld 408576698