OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/aura/mus/window_port_mus.h" | 5 #include "ui/aura/mus/window_port_mus.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/client/transient_window_client.h" | 9 #include "ui/aura/client/transient_window_client.h" |
10 #include "ui/aura/mus/client_surface_embedder.h" | 10 #include "ui/aura/mus/client_surface_embedder.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 window_tree_client_->SetCanAcceptDrops(this, can_accept_drops); | 75 window_tree_client_->SetCanAcceptDrops(this, can_accept_drops); |
76 } | 76 } |
77 | 77 |
78 void WindowPortMus::Embed( | 78 void WindowPortMus::Embed( |
79 ui::mojom::WindowTreeClientPtr client, | 79 ui::mojom::WindowTreeClientPtr client, |
80 uint32_t flags, | 80 uint32_t flags, |
81 const ui::mojom::WindowTree::EmbedCallback& callback) { | 81 const ui::mojom::WindowTree::EmbedCallback& callback) { |
82 window_tree_client_->Embed(window_, std::move(client), flags, callback); | 82 window_tree_client_->Embed(window_, std::move(client), flags, callback); |
83 } | 83 } |
84 | 84 |
85 std::unique_ptr<ui::ClientCompositorFrameSink> | 85 void WindowPortMus::RequestCompositorFrameSink( |
86 WindowPortMus::RequestCompositorFrameSink( | |
87 scoped_refptr<cc::ContextProvider> context_provider, | 86 scoped_refptr<cc::ContextProvider> context_provider, |
88 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { | 87 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 88 const CompositorFrameSinkCallback& callback) { |
| 89 DCHECK(pending_compositor_frame_sink_request_.is_null()); |
| 90 // If we haven't received a FrameSinkId from the window server yet then we |
| 91 // bind the parameters to a closure that will be called once the FrameSinkId |
| 92 // is available. |
| 93 if (!frame_sink_id_.is_valid()) { |
| 94 pending_compositor_frame_sink_request_ = |
| 95 base::Bind(&WindowPortMus::RequestCompositorFrameSinkInternal, |
| 96 base::Unretained(this), std::move(context_provider), |
| 97 gpu_memory_buffer_manager, callback); |
| 98 return; |
| 99 } |
| 100 |
| 101 RequestCompositorFrameSinkInternal(std::move(context_provider), |
| 102 gpu_memory_buffer_manager, callback); |
| 103 } |
| 104 |
| 105 void WindowPortMus::RequestCompositorFrameSinkInternal( |
| 106 scoped_refptr<cc::ContextProvider> context_provider, |
| 107 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 108 const CompositorFrameSinkCallback& callback) { |
| 109 DCHECK(frame_sink_id_.is_valid()); |
89 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> | 110 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> |
90 compositor_frame_sink_binding; | 111 compositor_frame_sink_binding; |
91 std::unique_ptr<ui::ClientCompositorFrameSink> compositor_frame_sink = | 112 std::unique_ptr<ui::ClientCompositorFrameSink> compositor_frame_sink = |
92 ui::ClientCompositorFrameSink::Create( | 113 ui::ClientCompositorFrameSink::Create( |
93 cc::FrameSinkId(server_id(), 0), std::move(context_provider), | 114 frame_sink_id_, std::move(context_provider), |
94 gpu_memory_buffer_manager, &compositor_frame_sink_binding); | 115 gpu_memory_buffer_manager, &compositor_frame_sink_binding); |
95 AttachCompositorFrameSink(std::move(compositor_frame_sink_binding)); | 116 AttachCompositorFrameSink(std::move(compositor_frame_sink_binding)); |
96 return compositor_frame_sink; | 117 callback.Run(std::move(compositor_frame_sink)); |
97 } | 118 } |
98 | 119 |
99 void WindowPortMus::AttachCompositorFrameSink( | 120 void WindowPortMus::AttachCompositorFrameSink( |
100 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> | 121 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> |
101 compositor_frame_sink_binding) { | 122 compositor_frame_sink_binding) { |
102 window_tree_client_->AttachCompositorFrameSink( | 123 window_tree_client_->AttachCompositorFrameSink( |
103 server_id(), compositor_frame_sink_binding->TakeFrameSinkRequest(), | 124 server_id(), compositor_frame_sink_binding->TakeFrameSinkRequest(), |
104 mojo::MakeProxy(compositor_frame_sink_binding->TakeFrameSinkClient())); | 125 mojo::MakeProxy(compositor_frame_sink_binding->TakeFrameSinkClient())); |
105 } | 126 } |
106 | 127 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void WindowPortMus::SetPropertyFromServer( | 261 void WindowPortMus::SetPropertyFromServer( |
241 const std::string& property_name, | 262 const std::string& property_name, |
242 const std::vector<uint8_t>* property_data) { | 263 const std::vector<uint8_t>* property_data) { |
243 ServerChangeData data; | 264 ServerChangeData data; |
244 data.property_name = property_name; | 265 data.property_name = property_name; |
245 ScopedServerChange change(this, ServerChangeType::PROPERTY, data); | 266 ScopedServerChange change(this, ServerChangeType::PROPERTY, data); |
246 GetPropertyConverter()->SetPropertyFromTransportValue(window_, property_name, | 267 GetPropertyConverter()->SetPropertyFromTransportValue(window_, property_name, |
247 property_data); | 268 property_data); |
248 } | 269 } |
249 | 270 |
| 271 void WindowPortMus::SetFrameSinkIdFromServer( |
| 272 const cc::FrameSinkId& frame_sink_id) { |
| 273 frame_sink_id_ = frame_sink_id; |
| 274 if (!pending_compositor_frame_sink_request_.is_null()) |
| 275 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); |
| 276 } |
| 277 |
250 void WindowPortMus::SetSurfaceInfoFromServer( | 278 void WindowPortMus::SetSurfaceInfoFromServer( |
251 const cc::SurfaceInfo& surface_info) { | 279 const cc::SurfaceInfo& surface_info) { |
252 if (surface_info_.is_valid()) { | 280 if (surface_info_.is_valid()) { |
253 const cc::SurfaceId& existing_surface_id = surface_info_.id(); | 281 const cc::SurfaceId& existing_surface_id = surface_info_.id(); |
254 const cc::SurfaceId& new_surface_id = surface_info.id(); | 282 const cc::SurfaceId& new_surface_id = surface_info.id(); |
255 if (existing_surface_id.is_valid() && | 283 if (existing_surface_id.is_valid() && |
256 existing_surface_id != new_surface_id) { | 284 existing_surface_id != new_surface_id) { |
257 // TODO(kylechar): Start return reference here? | 285 // TODO(kylechar): Start return reference here? |
258 } | 286 } |
259 } | 287 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 GetPropertyConverter()->GetTransportNameForPropertyKey(key); | 474 GetPropertyConverter()->GetTransportNameForPropertyKey(key); |
447 // TODO(sky): investigate to see if we need to compare data. In particular do | 475 // TODO(sky): investigate to see if we need to compare data. In particular do |
448 // we ever have a case where changing a property cascades into changing the | 476 // we ever have a case where changing a property cascades into changing the |
449 // same property? | 477 // same property? |
450 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) | 478 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) |
451 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, | 479 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, |
452 std::move(data)); | 480 std::move(data)); |
453 } | 481 } |
454 | 482 |
455 } // namespace aura | 483 } // namespace aura |
OLD | NEW |