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

Side by Side Diff: services/ui/ws/server_window_compositor_frame_sink_manager.cc

Issue 2474113002: Mus+Ash: Unified BeginFrame Skeleton (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/ui/ws/server_window_compositor_frame_sink_manager.h" 5 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h"
6 6
7 #include "mojo/public/cpp/bindings/strong_binding.h"
7 #include "services/ui/surfaces/display_compositor.h" 8 #include "services/ui/surfaces/display_compositor.h"
8 #include "services/ui/ws/ids.h" 9 #include "services/ui/ws/ids.h"
9 #include "services/ui/ws/server_window.h" 10 #include "services/ui/ws/server_window.h"
10 #include "services/ui/ws/server_window_compositor_frame_sink.h" 11 #include "services/ui/ws/server_window_compositor_frame_sink.h"
11 #include "services/ui/ws/server_window_delegate.h" 12 #include "services/ui/ws/server_window_delegate.h"
12 13
13 namespace ui { 14 namespace ui {
14 namespace ws { 15 namespace ws {
15 16
16 ServerWindowCompositorFrameSinkManager::ServerWindowCompositorFrameSinkManager( 17 ServerWindowCompositorFrameSinkManager::ServerWindowCompositorFrameSinkManager(
17 ServerWindow* window) 18 ServerWindow* window)
18 : window_(window), 19 : window_(window),
19 waiting_for_initial_frames_( 20 waiting_for_initial_frames_(
20 window_->properties().count(ui::mojom::kWaitForUnderlay_Property) > 21 window_->properties().count(ui::mojom::kWaitForUnderlay_Property) >
21 0) {} 22 0) {}
22 23
23 ServerWindowCompositorFrameSinkManager:: 24 ServerWindowCompositorFrameSinkManager::
24 ~ServerWindowCompositorFrameSinkManager() { 25 ~ServerWindowCompositorFrameSinkManager() {
25 // Explicitly clear the type to surface manager so that this manager
26 // is still valid prior during ~ServerWindowCompositorFrameSink.
27 type_to_compositor_frame_sink_map_.clear();
28 } 26 }
29 27
30 bool ServerWindowCompositorFrameSinkManager::ShouldDraw() { 28 bool ServerWindowCompositorFrameSinkManager::ShouldDraw() {
31 if (!waiting_for_initial_frames_) 29 if (!waiting_for_initial_frames_)
32 return true; 30 return true;
33 31
34 waiting_for_initial_frames_ = !IsCompositorFrameSinkReadyAndNonEmpty( 32 waiting_for_initial_frames_ = !IsCompositorFrameSinkReadyAndNonEmpty(
35 mojom::CompositorFrameSinkType::DEFAULT) || 33 mojom::CompositorFrameSinkType::DEFAULT) ||
36 !IsCompositorFrameSinkReadyAndNonEmpty( 34 !IsCompositorFrameSinkReadyAndNonEmpty(
37 mojom::CompositorFrameSinkType::UNDERLAY); 35 mojom::CompositorFrameSinkType::UNDERLAY);
38 return !waiting_for_initial_frames_; 36 return !waiting_for_initial_frames_;
39 } 37 }
40 38
41 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSink( 39 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSink(
42 mojom::CompositorFrameSinkType compositor_frame_sink_type, 40 mojom::CompositorFrameSinkType compositor_frame_sink_type,
43 gfx::AcceleratedWidget widget, 41 gfx::AcceleratedWidget widget,
44 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 42 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
45 scoped_refptr<SurfacesContextProvider> context_provider, 43 scoped_refptr<SurfacesContextProvider> context_provider,
46 cc::mojom::MojoCompositorFrameSinkRequest request, 44 cc::mojom::MojoCompositorFrameSinkRequest request,
47 cc::mojom::MojoCompositorFrameSinkClientPtr client) { 45 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
48 cc::FrameSinkId frame_sink_id( 46 cc::FrameSinkId frame_sink_id(
49 WindowIdToTransportId(window_->id()), 47 WindowIdToTransportId(window_->id()),
50 static_cast<uint32_t>(compositor_frame_sink_type)); 48 static_cast<uint32_t>(compositor_frame_sink_type));
51 CompositorFrameSinkData& data = 49 CompositorFrameSinkData& data =
52 type_to_compositor_frame_sink_map_[compositor_frame_sink_type]; 50 type_to_compositor_frame_sink_map_[compositor_frame_sink_type];
51
52 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request;
53 if (data.pending_compositor_frame_sink_request.is_pending()) {
54 private_request = std::move(data.pending_compositor_frame_sink_request);
55 } else {
56 private_request = mojo::GetProxy(&data.compositor_frame_sink);
57 }
58
53 // TODO(fsamuel): Create the CompositorFrameSink through the DisplayCompositor 59 // TODO(fsamuel): Create the CompositorFrameSink through the DisplayCompositor
54 // mojo interface and hold on to a MojoCompositorFrameSinkPtr. 60 // mojo interface.
55 data.compositor_frame_sink = 61 mojo::MakeStrongBinding(
56 base::MakeUnique<ServerWindowCompositorFrameSink>( 62 base::MakeUnique<ServerWindowCompositorFrameSink>(
57 this, frame_sink_id, widget, gpu_memory_buffer_manager, 63 window_->delegate()->GetDisplayCompositor(), frame_sink_id, widget,
58 std::move(context_provider), std::move(request), std::move(client)); 64 gpu_memory_buffer_manager, std::move(context_provider),
65 std::move(request), std::move(client)),
66 std::move(private_request));
67 if (window_->parent()) {
68 window_->delegate()
69 ->GetRootWindow(window_)
70 ->GetOrCreateCompositorFrameSinkManager()
71 ->AddChildFrameSinkId(mojom::CompositorFrameSinkType::DEFAULT,
72 frame_sink_id);
73 }
74
59 data.surface_sequence_generator.set_frame_sink_id(frame_sink_id); 75 data.surface_sequence_generator.set_frame_sink_id(frame_sink_id);
60 } 76 }
61 77
78 void ServerWindowCompositorFrameSinkManager::AddChildFrameSinkId(
79 mojom::CompositorFrameSinkType compositor_frame_sink_type,
80 const cc::FrameSinkId& frame_sink_id) {
81 auto it = type_to_compositor_frame_sink_map_.find(compositor_frame_sink_type);
82 if (it != type_to_compositor_frame_sink_map_.end()) {
83 it->second.compositor_frame_sink->AddChildFrameSink(frame_sink_id);
84 return;
85 }
86 CompositorFrameSinkData& data =
87 type_to_compositor_frame_sink_map_[compositor_frame_sink_type];
88 data.pending_compositor_frame_sink_request =
89 mojo::GetProxy(&data.compositor_frame_sink);
90 data.compositor_frame_sink->AddChildFrameSink(frame_sink_id);
91 }
92
93 void ServerWindowCompositorFrameSinkManager::RemoveChildFrameSinkId(
94 mojom::CompositorFrameSinkType compositor_frame_sink_type,
95 const cc::FrameSinkId& frame_sink_id) {
96 auto it = type_to_compositor_frame_sink_map_.find(compositor_frame_sink_type);
97 DCHECK(it != type_to_compositor_frame_sink_map_.end());
98 it->second.compositor_frame_sink->AddChildFrameSink(frame_sink_id);
99 }
100
62 bool ServerWindowCompositorFrameSinkManager::HasCompositorFrameSinkOfType( 101 bool ServerWindowCompositorFrameSinkManager::HasCompositorFrameSinkOfType(
63 mojom::CompositorFrameSinkType type) const { 102 mojom::CompositorFrameSinkType type) const {
64 return type_to_compositor_frame_sink_map_.count(type) > 0; 103 return type_to_compositor_frame_sink_map_.count(type) > 0;
65 } 104 }
66 105
67 bool ServerWindowCompositorFrameSinkManager::HasAnyCompositorFrameSink() const { 106 bool ServerWindowCompositorFrameSinkManager::HasAnyCompositorFrameSink() const {
68 return HasCompositorFrameSinkOfType( 107 return HasCompositorFrameSinkOfType(
69 mojom::CompositorFrameSinkType::DEFAULT) || 108 mojom::CompositorFrameSinkType::DEFAULT) ||
70 HasCompositorFrameSinkOfType(mojom::CompositorFrameSinkType::UNDERLAY); 109 HasCompositorFrameSinkOfType(mojom::CompositorFrameSinkType::UNDERLAY);
71 } 110 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 176
138 CompositorFrameSinkData& CompositorFrameSinkData::operator=( 177 CompositorFrameSinkData& CompositorFrameSinkData::operator=(
139 CompositorFrameSinkData&& other) { 178 CompositorFrameSinkData&& other) {
140 latest_submitted_surface_id = other.latest_submitted_surface_id; 179 latest_submitted_surface_id = other.latest_submitted_surface_id;
141 compositor_frame_sink = std::move(other.compositor_frame_sink); 180 compositor_frame_sink = std::move(other.compositor_frame_sink);
142 return *this; 181 return *this;
143 } 182 }
144 183
145 } // namespace ws 184 } // namespace ws
146 } // namespace ui 185 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/server_window_compositor_frame_sink_manager.h ('k') | services/ui/ws/server_window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698