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

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

Issue 2878113002: mus: Embedder can request and observe BeginFrame for embedded client. (Closed)
Patch Set: . Created 3 years, 7 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 "cc/ipc/frame_sink_manager.mojom.h"
8 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/transient_window_client.h" 10 #include "ui/aura/client/transient_window_client.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"
20 21
21 namespace aura { 22 namespace aura {
22 23
23 namespace { 24 namespace {
24 // Helper function to get the device_scale_factor() of the display::Display 25 // Helper function to get the device_scale_factor() of the display::Display
25 // nearest to |window|. 26 // nearest to |window|.
26 float ScaleFactorForDisplay(Window* window) { 27 float ScaleFactorForDisplay(Window* window) {
27 return display::Screen::GetScreen() 28 return display::Screen::GetScreen()
28 ->GetDisplayNearestWindow(window) 29 ->GetDisplayNearestWindow(window)
29 .device_scale_factor(); 30 .device_scale_factor();
30 } 31 }
31 } // namespace 32 } // namespace
32 33
33 WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default; 34 WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
34 35
35 WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default; 36 WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default;
36 37
38 class WindowPortMus::FrameSinkObserver : public cc::mojom::FrameSinkObserver {
39 public:
40 explicit FrameSinkObserver(base::RepeatingClosure begin_frame_callback)
41 : binding_(this),
42 begin_frame_callback_(std::move(begin_frame_callback)) {}
43 ~FrameSinkObserver() override {}
44
45 cc::mojom::FrameSinkObserverPtr GetPtr() {
46 return binding_.CreateInterfacePtrAndBind();
47 }
48
49 private:
50 // cc::mojom::FrameSinkObserver:
51 void OnBeginFrame() override { begin_frame_callback_.Run(); }
52
53 mojo::Binding<cc::mojom::FrameSinkObserver> binding_;
54 base::RepeatingClosure begin_frame_callback_;
55
56 DISALLOW_COPY_AND_ASSIGN(FrameSinkObserver);
57 };
58
37 // static 59 // static
38 WindowMus* WindowMus::Get(Window* window) { 60 WindowMus* WindowMus::Get(Window* window) {
39 return WindowPortMus::Get(window); 61 return WindowPortMus::Get(window);
40 } 62 }
41 63
42 WindowPortMus::WindowPortMus(WindowTreeClient* client, 64 WindowPortMus::WindowPortMus(WindowTreeClient* client,
43 WindowMusType window_mus_type) 65 WindowMusType window_mus_type)
44 : WindowMus(window_mus_type), window_tree_client_(client) {} 66 : WindowMus(window_mus_type), window_tree_client_(client) {}
45 67
46 WindowPortMus::~WindowPortMus() { 68 WindowPortMus::~WindowPortMus() {
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 WindowPortMus::CreateCompositorFrameSink() { 546 WindowPortMus::CreateCompositorFrameSink() {
525 // TODO(penghuang): Implement it for Mus. 547 // TODO(penghuang): Implement it for Mus.
526 return nullptr; 548 return nullptr;
527 } 549 }
528 550
529 cc::SurfaceId WindowPortMus::GetSurfaceId() const { 551 cc::SurfaceId WindowPortMus::GetSurfaceId() const {
530 // TODO(penghuang): Implement it for Mus. 552 // TODO(penghuang): Implement it for Mus.
531 return cc::SurfaceId(); 553 return cc::SurfaceId();
532 } 554 }
533 555
556 void WindowPortMus::SetNeedsBeginFrames(bool needs,
557 base::RepeatingClosure callback) {
558 if (!needs) {
559 frame_sink_observer_ = nullptr;
560 return;
561 }
562 if (frame_sink_observer_)
563 return;
564 frame_sink_observer_ =
565 base::MakeUnique<FrameSinkObserver>(std::move(callback));
566 window_tree_client_->RequestBeginFrames(this, frame_sink_observer_->GetPtr());
567 }
568
534 void WindowPortMus::UpdatePrimarySurfaceInfo() { 569 void WindowPortMus::UpdatePrimarySurfaceInfo() {
535 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || 570 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
536 window_mus_type() == WindowMusType::EMBED_IN_OWNER; 571 window_mus_type() == WindowMusType::EMBED_IN_OWNER;
537 if (!embeds_surface || !window_tree_client_->enable_surface_synchronization_) 572 if (!embeds_surface || !window_tree_client_->enable_surface_synchronization_)
538 return; 573 return;
539 574
540 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) 575 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
541 return; 576 return;
542 577
543 SetPrimarySurfaceInfo( 578 SetPrimarySurfaceInfo(
(...skipping 10 matching lines...) Expand all
554 if (!client_surface_embedder_) { 589 if (!client_surface_embedder_) {
555 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( 590 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>(
556 window_, window_tree_client_->normal_client_area_insets_); 591 window_, window_tree_client_->normal_client_area_insets_);
557 } 592 }
558 593
559 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); 594 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_);
560 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); 595 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_);
561 } 596 }
562 597
563 } // namespace aura 598 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698