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

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
« 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 4c98ed4558a036614237a01cf0d8aa1497009064..7db8427bcd435e2b447d2b48d02b861b2e70e318 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();
@@ -522,8 +546,29 @@ 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());
+ frame_sink_id_ = window_tree_client_->GetFrameSinkId(server_id());
+
+ 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(
+ frame_sink_id_, nullptr /* context_provider */,
+ context_factory->GetGpuMemoryBufferManager(), &frame_sink_binding);
+ // ui::ClientCompositorFrameSink allocates local surface id if surface
+ // synchronization is disabled, so we need set the SurfaceChangedCallback
+ // for updating primary surface.
+ if (!window_tree_client_->enable_surface_synchronization_) {
+ frame_sink->SetSurfaceChangedCallback(base::Bind(
+ &WindowPortMus::OnSurfaceChanged, weak_factory_.GetWeakPtr()));
+ }
+ AttachCompositorFrameSink(std::move(frame_sink_binding));
+ return std::move(frame_sink);
}
cc::SurfaceId WindowPortMus::GetSurfaceId() const {
@@ -560,4 +605,18 @@ void WindowPortMus::UpdateClientSurfaceEmbedder() {
client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_);
}
+void WindowPortMus::OnSurfaceChanged(const cc::SurfaceId& surface_id,
+ const gfx::Size& surface_size) {
+ DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
+ DCHECK(!window_tree_client_->enable_surface_synchronization_);
+ DCHECK_EQ(surface_id.frame_sink_id(), frame_sink_id_);
+ if (!ref_factory_)
+ ref_factory_ = new StubSurfaceReferenceFactory();
+
+ window_->layer()->SetBounds(
+ gfx::Rect(window_->layer()->bounds().origin(), surface_size));
+ window_->layer()->SetShowPrimarySurface(
+ cc::SurfaceInfo(surface_id, 1.0f, surface_size), ref_factory_);
+}
+
} // namespace aura
« 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