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

Side by Side Diff: ui/aura/mus/window_port_mus.cc

Issue 2875753002: Implement aura::WindowPortMus::CreateCompositorFrameSink() (Closed)
Patch Set: Address review issues Created 3 years, 6 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 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/env.h"
10 #include "ui/aura/mus/client_surface_embedder.h" 11 #include "ui/aura/mus/client_surface_embedder.h"
11 #include "ui/aura/mus/property_converter.h" 12 #include "ui/aura/mus/property_converter.h"
12 #include "ui/aura/mus/window_tree_client.h" 13 #include "ui/aura/mus/window_tree_client.h"
13 #include "ui/aura/mus/window_tree_client_delegate.h" 14 #include "ui/aura/mus/window_tree_client_delegate.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/aura/window_delegate.h" 16 #include "ui/aura/window_delegate.h"
16 #include "ui/aura/window_observer.h" 17 #include "ui/aura/window_observer.h"
17 #include "ui/base/class_property.h" 18 #include "ui/base/class_property.h"
18 #include "ui/display/display.h" 19 #include "ui/display/display.h"
19 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void WindowPortMus::SetFrameSinkIdFromServer( 282 void WindowPortMus::SetFrameSinkIdFromServer(
282 const cc::FrameSinkId& frame_sink_id) { 283 const cc::FrameSinkId& frame_sink_id) {
283 DCHECK(window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || 284 DCHECK(window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
284 window_mus_type() == WindowMusType::EMBED_IN_OWNER); 285 window_mus_type() == WindowMusType::EMBED_IN_OWNER);
285 frame_sink_id_ = frame_sink_id; 286 frame_sink_id_ = frame_sink_id;
286 UpdatePrimarySurfaceInfo(); 287 UpdatePrimarySurfaceInfo();
287 } 288 }
288 289
289 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( 290 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
290 const gfx::Size& surface_size_in_pixels) { 291 const gfx::Size& surface_size_in_pixels) {
292 if (window_mus_type() == WindowMusType::LOCAL &&
293 !compositor_frame_sink_.get()) {
294 local_surface_id_ = cc::LocalSurfaceId();
295 return local_surface_id_;
296 }
297
Fady Samuel 2017/06/07 20:36:11 Remove this change above?
Peng 2017/06/07 21:14:29 Done.
291 if (last_surface_size_in_pixels_ == surface_size_in_pixels && 298 if (last_surface_size_in_pixels_ == surface_size_in_pixels &&
292 local_surface_id_.is_valid()) { 299 local_surface_id_.is_valid()) {
293 return local_surface_id_; 300 return local_surface_id_;
294 } 301 }
295 302
296 local_surface_id_ = local_surface_id_allocator_.GenerateId(); 303 local_surface_id_ = local_surface_id_allocator_.GenerateId();
297 last_surface_size_in_pixels_ = surface_size_in_pixels; 304 last_surface_size_in_pixels_ = surface_size_in_pixels;
298 305
299 // If the FrameSinkId is available, then immediately embed the SurfaceId. 306 // If the FrameSinkId is available, then immediately embed the SurfaceId.
300 // The newly generated frame by the embedder will block in the display 307 // The newly generated frame by the embedder will block in the display
301 // compositor until the child submits a corresponding CompositorFrame or a 308 // compositor until the child submits a corresponding CompositorFrame or a
302 // deadline hits. 309 // deadline hits.
303 if (frame_sink_id_.is_valid()) 310 if (frame_sink_id_.is_valid())
304 UpdatePrimarySurfaceInfo(); 311 UpdatePrimarySurfaceInfo();
305 312
313 if (compositor_frame_sink_)
314 compositor_frame_sink_->SetLocalSurfaceId(local_surface_id_);
315
306 return local_surface_id_; 316 return local_surface_id_;
307 } 317 }
308 318
309 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) {
310 primary_surface_info_ = surface_info;
311 UpdateClientSurfaceEmbedder();
312 if (window_->delegate())
313 window_->delegate()->OnWindowSurfaceChanged(surface_info);
314 }
315
316 void WindowPortMus::SetFallbackSurfaceInfo( 319 void WindowPortMus::SetFallbackSurfaceInfo(
317 const cc::SurfaceInfo& surface_info) { 320 const cc::SurfaceInfo& surface_info) {
321 if (!frame_sink_id_.is_valid()) {
322 // This only happens for a "local" window, because the
323 // |SetFrameSinkIdFromServer| will not be called for a "local" window.
324 DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
Fady Samuel 2017/06/07 20:36:11 This seems like an unnecessary check.
Peng 2017/06/07 21:14:28 Done.
325 // |primary_surface_info_| shold not be valid, since we didn't know the
326 // |frame_sink_id_|.
327 DCHECK(!primary_surface_info_.is_valid());
328 frame_sink_id_ = surface_info.id().frame_sink_id();
329 UpdatePrimarySurfaceInfo();
330 }
331
332 // The frame sink id should never be changed.
333 DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_);
334
335 // If the window is informed of a surface from server then that surface ID is
336 // guaranteed to be available in the display compositor so we set it as the
337 // fallback. For embedded window, the primary SurfaceInfo is created by the
Fady Samuel 2017/06/07 20:36:11 For embedded windows
Peng 2017/06/07 21:14:28 Done. Move this comment back to window_tree_client
338 // embedder, and the LocalSurfaceId is allocated by the embedder.
318 fallback_surface_info_ = surface_info; 339 fallback_surface_info_ = surface_info;
319 UpdateClientSurfaceEmbedder(); 340 UpdateClientSurfaceEmbedder();
320 } 341 }
321 342
322 void WindowPortMus::DestroyFromServer() { 343 void WindowPortMus::DestroyFromServer() {
323 std::unique_ptr<ScopedServerChange> remove_from_parent_change; 344 std::unique_ptr<ScopedServerChange> remove_from_parent_change;
324 if (window_->parent()) { 345 if (window_->parent()) {
325 ServerChangeData data; 346 ServerChangeData data;
326 data.child_id = server_id(); 347 data.child_id = server_id();
327 WindowPortMus* parent = Get(window_->parent()); 348 WindowPortMus* parent = Get(window_->parent());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // TODO(sky): investigate to see if we need to compare data. In particular do 532 // TODO(sky): investigate to see if we need to compare data. In particular do
512 // we ever have a case where changing a property cascades into changing the 533 // we ever have a case where changing a property cascades into changing the
513 // same property? 534 // same property?
514 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) 535 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data))
515 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, 536 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value,
516 std::move(data)); 537 std::move(data));
517 } 538 }
518 539
519 std::unique_ptr<cc::CompositorFrameSink> 540 std::unique_ptr<cc::CompositorFrameSink>
520 WindowPortMus::CreateCompositorFrameSink() { 541 WindowPortMus::CreateCompositorFrameSink() {
521 // TODO(penghuang): Implement it for Mus. 542 DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
522 return nullptr; 543 DCHECK(!compositor_frame_sink_);
544 auto frame_sink = RequestCompositorFrameSink(
545 nullptr,
546 aura::Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager());
547 auto* viz_frame_sink =
548 static_cast<viz::ClientCompositorFrameSink*>(frame_sink.get());
549 compositor_frame_sink_ = viz_frame_sink->GetWeakPtr();
550 return frame_sink;
523 } 551 }
524 552
525 cc::SurfaceId WindowPortMus::GetSurfaceId() const { 553 cc::SurfaceId WindowPortMus::GetSurfaceId() const {
526 // TODO(penghuang): Implement it for Mus. 554 // This is only used by WindowPortLocal in unit tests.
527 return cc::SurfaceId(); 555 return cc::SurfaceId();
528 } 556 }
529 557
530 void WindowPortMus::UpdatePrimarySurfaceInfo() { 558 void WindowPortMus::UpdatePrimarySurfaceInfo() {
531 bool embeds_surface = 559 if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
532 window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || 560 window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
533 window_mus_type() == WindowMusType::EMBED_IN_OWNER || 561 window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
534 window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED; 562 window_mus_type() != WindowMusType::LOCAL)
Fady Samuel 2017/06/07 20:36:11 {..}
Peng 2017/06/07 21:14:29 Done.
535 if (!embeds_surface)
536 return; 563 return;
537 564
538 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) 565 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
539 return; 566 return;
540 567
541 SetPrimarySurfaceInfo(cc::SurfaceInfo( 568 primary_surface_info_ = cc::SurfaceInfo(
542 cc::SurfaceId(frame_sink_id_, local_surface_id_), 569 cc::SurfaceId(frame_sink_id_, local_surface_id_),
543 ScaleFactorForDisplay(window_), last_surface_size_in_pixels_)); 570 ScaleFactorForDisplay(window_), last_surface_size_in_pixels_);
571 UpdateClientSurfaceEmbedder();
572 if (window_->delegate())
573 window_->delegate()->OnWindowSurfaceChanged(primary_surface_info_);
544 } 574 }
545 575
546 void WindowPortMus::UpdateClientSurfaceEmbedder() { 576 void WindowPortMus::UpdateClientSurfaceEmbedder() {
547 bool embeds_surface = 577 if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
548 window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || 578 window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
549 window_mus_type() == WindowMusType::EMBED_IN_OWNER || 579 window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
550 window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED; 580 window_mus_type() != WindowMusType::LOCAL)
Fady Samuel 2017/06/07 20:36:11 {..}
Peng 2017/06/07 21:14:29 Done.
551 if (!embeds_surface)
552 return; 581 return;
553 582
554 if (!client_surface_embedder_) { 583 if (!client_surface_embedder_) {
555 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( 584 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>(
556 window_, window_tree_client_->normal_client_area_insets_); 585 window_, window_tree_client_->normal_client_area_insets_);
557 } 586 }
558 587
559 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); 588 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_);
560 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); 589 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_);
561 } 590 }
562 591
563 } // namespace aura 592 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698