| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // a time, so this should be ok. | 224 // a time, so this should be ok. |
| 225 ServerChangeData data; | 225 ServerChangeData data; |
| 226 data.child_id = child->server_id(); | 226 data.child_id = child->server_id(); |
| 227 ScopedServerChange change(this, ServerChangeType::REORDER, data); | 227 ScopedServerChange change(this, ServerChangeType::REORDER, data); |
| 228 if (direction == ui::mojom::OrderDirection::BELOW) | 228 if (direction == ui::mojom::OrderDirection::BELOW) |
| 229 window_->StackChildBelow(child->GetWindow(), relative->GetWindow()); | 229 window_->StackChildBelow(child->GetWindow(), relative->GetWindow()); |
| 230 else | 230 else |
| 231 window_->StackChildAbove(child->GetWindow(), relative->GetWindow()); | 231 window_->StackChildAbove(child->GetWindow(), relative->GetWindow()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void WindowPortMus::SetBoundsFromServer(const gfx::Rect& bounds) { | 234 void WindowPortMus::SetBoundsFromServer( |
| 235 const gfx::Rect& bounds, |
| 236 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
| 235 ServerChangeData data; | 237 ServerChangeData data; |
| 236 data.bounds_in_dip = bounds; | 238 data.bounds_in_dip = bounds; |
| 237 ScopedServerChange change(this, ServerChangeType::BOUNDS, data); | 239 ScopedServerChange change(this, ServerChangeType::BOUNDS, data); |
| 240 last_surface_size_ = bounds.size(); |
| 241 if (local_surface_id) |
| 242 local_surface_id_ = *local_surface_id; |
| 243 else |
| 244 local_surface_id_ = cc::LocalSurfaceId(); |
| 238 window_->SetBounds(bounds); | 245 window_->SetBounds(bounds); |
| 239 } | 246 } |
| 240 | 247 |
| 241 void WindowPortMus::SetVisibleFromServer(bool visible) { | 248 void WindowPortMus::SetVisibleFromServer(bool visible) { |
| 242 ServerChangeData data; | 249 ServerChangeData data; |
| 243 data.visible = visible; | 250 data.visible = visible; |
| 244 ScopedServerChange change(this, ServerChangeType::VISIBLE, data); | 251 ScopedServerChange change(this, ServerChangeType::VISIBLE, data); |
| 245 if (visible) | 252 if (visible) |
| 246 window_->Show(); | 253 window_->Show(); |
| 247 else | 254 else |
| (...skipping 29 matching lines...) Expand all Loading... |
| 277 // CompositorFrameSinks. | 284 // CompositorFrameSinks. |
| 278 DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type()); | 285 DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type()); |
| 279 DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type()); | 286 DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type()); |
| 280 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); | 287 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); |
| 281 } | 288 } |
| 282 // TODO(fsamuel): If the window type is TOP_LEVEL_IN_WM or EMBED_IN_OWNER then | 289 // TODO(fsamuel): If the window type is TOP_LEVEL_IN_WM or EMBED_IN_OWNER then |
| 283 // we should check if we have a cc::LocalSurfaeId ready as well. If we do, | 290 // we should check if we have a cc::LocalSurfaeId ready as well. If we do, |
| 284 // then we are ready to embed. | 291 // then we are ready to embed. |
| 285 } | 292 } |
| 286 | 293 |
| 294 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( |
| 295 const gfx::Size& surface_size) { |
| 296 if (last_surface_size_ == surface_size && local_surface_id_.is_valid()) |
| 297 return local_surface_id_; |
| 298 |
| 299 local_surface_id_ = local_surface_id_allocator_.GenerateId(); |
| 300 last_surface_size_ = surface_size; |
| 301 |
| 302 // TODO(fsamuel): If surface synchronization is enabled and the FrameSinkId |
| 303 // is available, then immediately embed the SurfaceId. The newly generated |
| 304 // frame by the embedder will block in the display compositor until the |
| 305 // child submits a corresponding CompositorFrame or a deadline hits. |
| 306 |
| 307 return local_surface_id_; |
| 308 } |
| 309 |
| 287 void WindowPortMus::SetSurfaceInfoFromServer( | 310 void WindowPortMus::SetSurfaceInfoFromServer( |
| 288 const cc::SurfaceInfo& surface_info) { | 311 const cc::SurfaceInfo& surface_info) { |
| 289 if (surface_info_.is_valid()) { | 312 if (surface_info_.is_valid()) { |
| 290 const cc::SurfaceId& existing_surface_id = surface_info_.id(); | 313 const cc::SurfaceId& existing_surface_id = surface_info_.id(); |
| 291 const cc::SurfaceId& new_surface_id = surface_info.id(); | 314 const cc::SurfaceId& new_surface_id = surface_info.id(); |
| 292 if (existing_surface_id.is_valid() && | 315 if (existing_surface_id.is_valid() && |
| 293 existing_surface_id != new_surface_id) { | 316 existing_surface_id != new_surface_id) { |
| 294 // TODO(kylechar): Start return reference here? | 317 // TODO(kylechar): Start return reference here? |
| 295 } | 318 } |
| 296 } | 319 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ServerChangeData change_data; | 379 ServerChangeData change_data; |
| 357 change_data.child_id = child->server_id(); | 380 change_data.child_id = child->server_id(); |
| 358 // If there was a change it means we scheduled the change by way of | 381 // If there was a change it means we scheduled the change by way of |
| 359 // RemoveTransientChildFromServer(), which came from the server. | 382 // RemoveTransientChildFromServer(), which came from the server. |
| 360 return RemoveChangeByTypeAndData(ServerChangeType::REMOVE_TRANSIENT, | 383 return RemoveChangeByTypeAndData(ServerChangeType::REMOVE_TRANSIENT, |
| 361 change_data) | 384 change_data) |
| 362 ? ChangeSource::SERVER | 385 ? ChangeSource::SERVER |
| 363 : ChangeSource::LOCAL; | 386 : ChangeSource::LOCAL; |
| 364 } | 387 } |
| 365 | 388 |
| 389 const cc::LocalSurfaceId& WindowPortMus::GetLocalSurfaceId() { |
| 390 return local_surface_id_; |
| 391 } |
| 392 |
| 366 std::unique_ptr<WindowMusChangeData> | 393 std::unique_ptr<WindowMusChangeData> |
| 367 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) { | 394 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) { |
| 368 std::unique_ptr<WindowMusChangeDataImpl> data( | 395 std::unique_ptr<WindowMusChangeDataImpl> data( |
| 369 base::MakeUnique<WindowMusChangeDataImpl>()); | 396 base::MakeUnique<WindowMusChangeDataImpl>()); |
| 370 ServerChangeData change_data; | 397 ServerChangeData change_data; |
| 371 change_data.bounds_in_dip = bounds; | 398 change_data.bounds_in_dip = bounds; |
| 372 data->change = base::MakeUnique<ScopedServerChange>( | 399 data->change = base::MakeUnique<ScopedServerChange>( |
| 373 this, ServerChangeType::BOUNDS, change_data); | 400 this, ServerChangeType::BOUNDS, change_data); |
| 374 return std::move(data); | 401 return std::move(data); |
| 375 } | 402 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 GetPropertyConverter()->GetTransportNameForPropertyKey(key); | 510 GetPropertyConverter()->GetTransportNameForPropertyKey(key); |
| 484 // TODO(sky): investigate to see if we need to compare data. In particular do | 511 // TODO(sky): investigate to see if we need to compare data. In particular do |
| 485 // we ever have a case where changing a property cascades into changing the | 512 // we ever have a case where changing a property cascades into changing the |
| 486 // same property? | 513 // same property? |
| 487 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) | 514 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) |
| 488 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, | 515 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, |
| 489 std::move(data)); | 516 std::move(data)); |
| 490 } | 517 } |
| 491 | 518 |
| 492 } // namespace aura | 519 } // namespace aura |
| OLD | NEW |