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

Side by Side Diff: content/renderer/mus/renderer_window_tree_client.cc

Issue 2764433003: mus-ws: Plumb FrameSinkId to Children (Closed)
Patch Set: Addressed Antoine's comment 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/mus/renderer_window_tree_client.h" 5 #include "content/renderer/mus/renderer_window_tree_client.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "services/ui/public/cpp/client_compositor_frame_sink.h" 10 #include "services/ui/public/cpp/client_compositor_frame_sink.h"
(...skipping 23 matching lines...) Expand all
34 g_connections.Get().insert(std::make_pair(routing_id, connection)); 34 g_connections.Get().insert(std::make_pair(routing_id, connection));
35 } 35 }
36 36
37 // static 37 // static
38 void RendererWindowTreeClient::Destroy(int routing_id) { 38 void RendererWindowTreeClient::Destroy(int routing_id) {
39 auto* client = Get(routing_id); 39 auto* client = Get(routing_id);
40 if (client) 40 if (client)
41 client->DestroySelf(); 41 client->DestroySelf();
42 } 42 }
43 43
44 void RendererWindowTreeClient::Bind(
45 ui::mojom::WindowTreeClientRequest request) {
46 binding_.Bind(std::move(request));
47 }
48
49 void RendererWindowTreeClient::RequestCompositorFrameSink(
50 scoped_refptr<cc::ContextProvider> context_provider,
51 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
52 const CompositorFrameSinkCallback& callback) {
53 DCHECK(pending_compositor_frame_sink_callback_.is_null());
54 if (frame_sink_id_.is_valid()) {
55 RequestCompositorFrameSinkInternal(std::move(context_provider),
56 gpu_memory_buffer_manager, callback);
57 return;
58 }
59
60 pending_context_provider_ = std::move(context_provider);
61 pending_gpu_memory_buffer_manager_ = gpu_memory_buffer_manager;
62 pending_compositor_frame_sink_callback_ = callback;
63 }
64
44 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) 65 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id)
45 : routing_id_(routing_id), binding_(this) {} 66 : routing_id_(routing_id), binding_(this) {}
46 67
47 RendererWindowTreeClient::~RendererWindowTreeClient() { 68 RendererWindowTreeClient::~RendererWindowTreeClient() {
48 g_connections.Get().erase(routing_id_); 69 g_connections.Get().erase(routing_id_);
49 } 70 }
50 71
51 void RendererWindowTreeClient::Bind( 72 void RendererWindowTreeClient::RequestCompositorFrameSinkInternal(
52 ui::mojom::WindowTreeClientRequest request) {
53 binding_.Bind(std::move(request));
54 }
55
56 std::unique_ptr<cc::CompositorFrameSink>
57 RendererWindowTreeClient::CreateCompositorFrameSink(
58 const cc::FrameSinkId& frame_sink_id,
59 scoped_refptr<cc::ContextProvider> context_provider, 73 scoped_refptr<cc::ContextProvider> context_provider,
60 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { 74 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
75 const CompositorFrameSinkCallback& callback) {
61 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding; 76 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding;
62 auto frame_sink = ui::ClientCompositorFrameSink::Create( 77 auto frame_sink = ui::ClientCompositorFrameSink::Create(
63 frame_sink_id, std::move(context_provider), gpu_memory_buffer_manager, 78 frame_sink_id_, std::move(context_provider), gpu_memory_buffer_manager,
64 &frame_sink_binding); 79 &frame_sink_binding);
65 if (tree_) { 80 tree_->AttachCompositorFrameSink(
66 tree_->AttachCompositorFrameSink( 81 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(),
67 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), 82 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient()));
68 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); 83 callback.Run(std::move(frame_sink));
69 } else {
70 pending_frame_sink_ = std::move(frame_sink_binding);
71 }
72 return std::move(frame_sink);
73 } 84 }
74 85
75 void RendererWindowTreeClient::DestroySelf() { 86 void RendererWindowTreeClient::DestroySelf() {
76 delete this; 87 delete this;
77 } 88 }
78 89
79 void RendererWindowTreeClient::OnEmbed(ui::ClientSpecificId client_id, 90 void RendererWindowTreeClient::OnEmbed(ui::ClientSpecificId client_id,
80 ui::mojom::WindowDataPtr root, 91 ui::mojom::WindowDataPtr root,
81 ui::mojom::WindowTreePtr tree, 92 ui::mojom::WindowTreePtr tree,
82 int64_t display_id, 93 int64_t display_id,
83 ui::Id focused_window_id, 94 ui::Id focused_window_id,
84 bool drawn) { 95 bool drawn,
96 const cc::FrameSinkId& frame_sink_id) {
97 frame_sink_id_ = frame_sink_id;
85 root_window_id_ = root->window_id; 98 root_window_id_ = root->window_id;
86 tree_ = std::move(tree); 99 tree_ = std::move(tree);
87 if (pending_frame_sink_) { 100 if (!pending_compositor_frame_sink_callback_.is_null()) {
88 tree_->AttachCompositorFrameSink( 101 RequestCompositorFrameSinkInternal(std::move(pending_context_provider_),
89 root_window_id_, pending_frame_sink_->TakeFrameSinkRequest(), 102 pending_gpu_memory_buffer_manager_,
90 mojo::MakeProxy(pending_frame_sink_->TakeFrameSinkClient())); 103 pending_compositor_frame_sink_callback_);
91 pending_frame_sink_ = nullptr; 104 pending_context_provider_ = nullptr;
105 pending_gpu_memory_buffer_manager_ = nullptr;
106 pending_compositor_frame_sink_callback_.Reset();
92 } 107 }
93 } 108 }
94 109
95 void RendererWindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) { 110 void RendererWindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) {
96 // TODO(sad): Embedded mus-client (oopif) is gone. Figure out what to do. 111 // TODO(sad): Embedded mus-client (oopif) is gone. Figure out what to do.
97 } 112 }
98 113
99 void RendererWindowTreeClient::OnUnembed(ui::Id window_id) { 114 void RendererWindowTreeClient::OnUnembed(ui::Id window_id) {
100 CHECK_EQ(window_id, root_window_id_); 115 CHECK_EQ(window_id, root_window_id_);
101 DestroySelf(); 116 DestroySelf();
102 } 117 }
103 118
104 void RendererWindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id, 119 void RendererWindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id,
105 ui::Id old_capture_window_id) {} 120 ui::Id old_capture_window_id) {}
106 121
107 void RendererWindowTreeClient::OnTopLevelCreated(uint32_t change_id, 122 void RendererWindowTreeClient::OnTopLevelCreated(
108 ui::mojom::WindowDataPtr data, 123 uint32_t change_id,
109 int64_t display_id, 124 ui::mojom::WindowDataPtr data,
110 bool drawn) { 125 int64_t display_id,
126 bool drawn,
127 const cc::FrameSinkId& frame_sink_id) {
111 NOTREACHED(); 128 NOTREACHED();
112 } 129 }
113 130
114 void RendererWindowTreeClient::OnWindowBoundsChanged( 131 void RendererWindowTreeClient::OnWindowBoundsChanged(
115 ui::Id window_id, 132 ui::Id window_id,
116 const gfx::Rect& old_bounds, 133 const gfx::Rect& old_bounds,
117 const gfx::Rect& new_bounds, 134 const gfx::Rect& new_bounds,
118 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {} 135 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {}
119 136
120 void RendererWindowTreeClient::OnClientAreaChanged( 137 void RendererWindowTreeClient::OnClientAreaChanged(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 bool success) {} 244 bool success) {}
228 245
229 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} 246 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {}
230 247
231 void RendererWindowTreeClient::GetWindowManager( 248 void RendererWindowTreeClient::GetWindowManager(
232 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { 249 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) {
233 NOTREACHED(); 250 NOTREACHED();
234 } 251 }
235 252
236 } // namespace content 253 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mus/renderer_window_tree_client.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698