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 "components/viz/client/local_surface_id_provider.h" | 8 #include "components/viz/client/local_surface_id_provider.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/transient_window_client.h" | 10 #include "ui/aura/client/transient_window_client.h" |
11 #include "ui/aura/env.h" | |
11 #include "ui/aura/mus/client_surface_embedder.h" | 12 #include "ui/aura/mus/client_surface_embedder.h" |
12 #include "ui/aura/mus/property_converter.h" | 13 #include "ui/aura/mus/property_converter.h" |
13 #include "ui/aura/mus/window_tree_client.h" | 14 #include "ui/aura/mus/window_tree_client.h" |
14 #include "ui/aura/mus/window_tree_client_delegate.h" | 15 #include "ui/aura/mus/window_tree_client_delegate.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
17 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
18 #include "ui/base/class_property.h" | 19 #include "ui/base/class_property.h" |
19 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
20 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 local_surface_id_ = local_surface_id_allocator_.GenerateId(); | 300 local_surface_id_ = local_surface_id_allocator_.GenerateId(); |
300 last_surface_size_in_pixels_ = surface_size_in_pixels; | 301 last_surface_size_in_pixels_ = surface_size_in_pixels; |
301 | 302 |
302 // If the FrameSinkId is available, then immediately embed the SurfaceId. | 303 // If the FrameSinkId is available, then immediately embed the SurfaceId. |
303 // The newly generated frame by the embedder will block in the display | 304 // The newly generated frame by the embedder will block in the display |
304 // compositor until the child submits a corresponding CompositorFrame or a | 305 // compositor until the child submits a corresponding CompositorFrame or a |
305 // deadline hits. | 306 // deadline hits. |
306 if (frame_sink_id_.is_valid()) | 307 if (frame_sink_id_.is_valid()) |
307 UpdatePrimarySurfaceInfo(); | 308 UpdatePrimarySurfaceInfo(); |
308 | 309 |
310 if (local_compositor_frame_sink_) | |
311 local_compositor_frame_sink_->SetLocalSurfaceId(local_surface_id_); | |
312 | |
309 return local_surface_id_; | 313 return local_surface_id_; |
310 } | 314 } |
311 | 315 |
312 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { | |
313 primary_surface_info_ = surface_info; | |
314 UpdateClientSurfaceEmbedder(); | |
315 if (window_->delegate()) | |
316 window_->delegate()->OnWindowSurfaceChanged(surface_info); | |
317 } | |
318 | |
319 void WindowPortMus::SetFallbackSurfaceInfo( | 316 void WindowPortMus::SetFallbackSurfaceInfo( |
320 const cc::SurfaceInfo& surface_info) { | 317 const cc::SurfaceInfo& surface_info) { |
318 if (!frame_sink_id_.is_valid()) { | |
319 // |primary_surface_info_| shold not be valid, since we didn't know the | |
320 // |frame_sink_id_|. | |
321 DCHECK(!primary_surface_info_.is_valid()); | |
322 frame_sink_id_ = surface_info.id().frame_sink_id(); | |
323 UpdatePrimarySurfaceInfo(); | |
324 } | |
325 | |
326 // The frame sink id should never be changed. | |
327 DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_); | |
328 | |
321 fallback_surface_info_ = surface_info; | 329 fallback_surface_info_ = surface_info; |
322 UpdateClientSurfaceEmbedder(); | 330 UpdateClientSurfaceEmbedder(); |
323 } | 331 } |
324 | 332 |
325 void WindowPortMus::DestroyFromServer() { | 333 void WindowPortMus::DestroyFromServer() { |
326 std::unique_ptr<ScopedServerChange> remove_from_parent_change; | 334 std::unique_ptr<ScopedServerChange> remove_from_parent_change; |
327 if (window_->parent()) { | 335 if (window_->parent()) { |
328 ServerChangeData data; | 336 ServerChangeData data; |
329 data.child_id = server_id(); | 337 data.child_id = server_id(); |
330 WindowPortMus* parent = Get(window_->parent()); | 338 WindowPortMus* parent = Get(window_->parent()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 const bool removed = RemoveChangeByTypeAndData( | 427 const bool removed = RemoveChangeByTypeAndData( |
420 ServerChangeType::TRANSIENT_REORDER, change_data); | 428 ServerChangeType::TRANSIENT_REORDER, change_data); |
421 DCHECK(removed); | 429 DCHECK(removed); |
422 } | 430 } |
423 | 431 |
424 void WindowPortMus::NotifyEmbeddedAppDisconnected() { | 432 void WindowPortMus::NotifyEmbeddedAppDisconnected() { |
425 for (WindowObserver& observer : *GetObservers(window_)) | 433 for (WindowObserver& observer : *GetObservers(window_)) |
426 observer.OnEmbeddedAppDisconnected(window_); | 434 observer.OnEmbeddedAppDisconnected(window_); |
427 } | 435 } |
428 | 436 |
437 bool WindowPortMus::HasLocalCompositorFrameSink() { | |
438 return !!local_compositor_frame_sink_; | |
439 } | |
440 | |
429 void WindowPortMus::OnPreInit(Window* window) { | 441 void WindowPortMus::OnPreInit(Window* window) { |
430 window_ = window; | 442 window_ = window; |
431 window_tree_client_->OnWindowMusCreated(this); | 443 window_tree_client_->OnWindowMusCreated(this); |
432 } | 444 } |
433 | 445 |
434 void WindowPortMus::OnDeviceScaleFactorChanged(float device_scale_factor) { | 446 void WindowPortMus::OnDeviceScaleFactorChanged(float device_scale_factor) { |
435 if (window_->delegate()) | 447 if (window_->delegate()) |
436 window_->delegate()->OnDeviceScaleFactorChanged(device_scale_factor); | 448 window_->delegate()->OnDeviceScaleFactorChanged(device_scale_factor); |
437 } | 449 } |
438 | 450 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 // TODO(sky): investigate to see if we need to compare data. In particular do | 526 // TODO(sky): investigate to see if we need to compare data. In particular do |
515 // we ever have a case where changing a property cascades into changing the | 527 // we ever have a case where changing a property cascades into changing the |
516 // same property? | 528 // same property? |
517 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) | 529 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) |
518 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, | 530 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, |
519 std::move(data)); | 531 std::move(data)); |
520 } | 532 } |
521 | 533 |
522 std::unique_ptr<cc::CompositorFrameSink> | 534 std::unique_ptr<cc::CompositorFrameSink> |
523 WindowPortMus::CreateCompositorFrameSink() { | 535 WindowPortMus::CreateCompositorFrameSink() { |
524 // TODO(penghuang): Implement it for Mus. | 536 DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL); |
525 return nullptr; | 537 DCHECK(!local_compositor_frame_sink_); |
538 auto frame_sink = RequestCompositorFrameSink( | |
539 nullptr, | |
540 aura::Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager()); | |
541 auto* viz_frame_sink = | |
542 static_cast<viz::ClientCompositorFrameSink*>(frame_sink.get()); | |
sky
2017/06/08 21:18:49
Why do you need the static_cast here?
Peng
2017/06/08 22:14:59
frame_sink is a cc:CFS. It doesn't have the GetWea
Fady Samuel
2017/06/08 22:16:45
Maybe create a "RequestCompositorFrameSinkInternal
Peng
2017/06/09 14:01:26
Done. By changing return type of RequestCompositor
| |
543 local_compositor_frame_sink_ = viz_frame_sink->GetWeakPtr(); | |
544 return frame_sink; | |
526 } | 545 } |
527 | 546 |
528 cc::SurfaceId WindowPortMus::GetSurfaceId() const { | 547 cc::SurfaceId WindowPortMus::GetSurfaceId() const { |
529 // TODO(penghuang): Implement it for Mus. | 548 // This is only used by WindowPortLocal in unit tests. |
530 return cc::SurfaceId(); | 549 return cc::SurfaceId(); |
531 } | 550 } |
532 | 551 |
533 void WindowPortMus::UpdatePrimarySurfaceInfo() { | 552 void WindowPortMus::UpdatePrimarySurfaceInfo() { |
534 bool embeds_surface = | 553 if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM && |
535 window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || | 554 window_mus_type() != WindowMusType::EMBED_IN_OWNER && |
536 window_mus_type() == WindowMusType::EMBED_IN_OWNER || | 555 window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED && |
537 window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED; | 556 window_mus_type() != WindowMusType::LOCAL) { |
538 if (!embeds_surface) | |
539 return; | 557 return; |
558 } | |
540 | 559 |
541 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) | 560 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) |
542 return; | 561 return; |
543 | 562 |
544 SetPrimarySurfaceInfo(cc::SurfaceInfo( | 563 primary_surface_info_ = cc::SurfaceInfo( |
545 cc::SurfaceId(frame_sink_id_, local_surface_id_), | 564 cc::SurfaceId(frame_sink_id_, local_surface_id_), |
546 ScaleFactorForDisplay(window_), last_surface_size_in_pixels_)); | 565 ScaleFactorForDisplay(window_), last_surface_size_in_pixels_); |
566 UpdateClientSurfaceEmbedder(); | |
567 if (window_->delegate()) | |
568 window_->delegate()->OnWindowSurfaceChanged(primary_surface_info_); | |
547 } | 569 } |
548 | 570 |
549 void WindowPortMus::UpdateClientSurfaceEmbedder() { | 571 void WindowPortMus::UpdateClientSurfaceEmbedder() { |
550 bool embeds_surface = | 572 if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM && |
551 window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || | 573 window_mus_type() != WindowMusType::EMBED_IN_OWNER && |
552 window_mus_type() == WindowMusType::EMBED_IN_OWNER || | 574 window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED && |
553 window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED; | 575 window_mus_type() != WindowMusType::LOCAL) { |
554 if (!embeds_surface) | |
555 return; | 576 return; |
577 } | |
556 | 578 |
557 if (!client_surface_embedder_) { | 579 if (!client_surface_embedder_) { |
558 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( | 580 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( |
559 window_, window_tree_client_->normal_client_area_insets_); | 581 window_, window_tree_client_->normal_client_area_insets_); |
560 } | 582 } |
561 | 583 |
562 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); | 584 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); |
563 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); | 585 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); |
564 } | 586 } |
565 | 587 |
566 } // namespace aura | 588 } // namespace aura |
OLD | NEW |