Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "cc/ipc/display_compositor.mojom.h" | 7 #include "cc/ipc/display_compositor.mojom.h" |
| 8 #include "mojo/public/cpp/bindings/strong_binding.h" | 8 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 9 #include "services/ui/ws/ids.h" | 9 #include "services/ui/ws/ids.h" |
| 10 #include "services/ui/ws/server_window.h" | 10 #include "services/ui/ws/server_window.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 if (!waiting_for_initial_frames_) | 28 if (!waiting_for_initial_frames_) |
| 29 return true; | 29 return true; |
| 30 | 30 |
| 31 waiting_for_initial_frames_ = !IsCompositorFrameSinkReadyAndNonEmpty( | 31 waiting_for_initial_frames_ = !IsCompositorFrameSinkReadyAndNonEmpty( |
| 32 mojom::CompositorFrameSinkType::DEFAULT) || | 32 mojom::CompositorFrameSinkType::DEFAULT) || |
| 33 !IsCompositorFrameSinkReadyAndNonEmpty( | 33 !IsCompositorFrameSinkReadyAndNonEmpty( |
| 34 mojom::CompositorFrameSinkType::UNDERLAY); | 34 mojom::CompositorFrameSinkType::UNDERLAY); |
| 35 return !waiting_for_initial_frames_; | 35 return !waiting_for_initial_frames_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSink( | 38 void ServerWindowCompositorFrameSinkManager::CreateDisplayCompositorFrameSink( |
| 39 mojom::CompositorFrameSinkType compositor_frame_sink_type, | 39 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
|
Fady Samuel
2016/12/14 17:19:01
This will always be DEFAULT. I'd drop this paramet
Alex Z.
2016/12/14 18:44:12
Done.
| |
| 40 gfx::AcceleratedWidget widget, | 40 gfx::AcceleratedWidget widget, |
| 41 cc::mojom::MojoCompositorFrameSinkRequest request, | 41 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 42 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 42 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 43 cc::FrameSinkId frame_sink_id( | 43 CreateCompositorFrameSinkInternal(compositor_frame_sink_type, widget, |
| 44 WindowIdToTransportId(window_->id()), | 44 std::move(request), std::move(client)); |
| 45 static_cast<uint32_t>(compositor_frame_sink_type)); | 45 } |
| 46 CompositorFrameSinkData& data = | |
| 47 type_to_compositor_frame_sink_map_[compositor_frame_sink_type]; | |
| 48 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request; | |
| 49 if (data.pending_compositor_frame_sink_request.is_pending()) { | |
| 50 private_request = std::move(data.pending_compositor_frame_sink_request); | |
| 51 } else { | |
| 52 private_request = mojo::GetProxy(&data.compositor_frame_sink); | |
| 53 } | |
| 54 | 46 |
| 55 // TODO(fsamuel): AcceleratedWidget cannot be transported over IPC for Mac or | 47 void ServerWindowCompositorFrameSinkManager::CreateOffscreenCompositorFrameSink( |
| 56 // Android. We should instead use GpuSurfaceTracker here on those platforms. | 48 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
| 57 window_->delegate()->GetDisplayCompositor()->CreateCompositorFrameSink( | 49 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 58 frame_sink_id, widget, std::move(request), std::move(private_request), | 50 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 59 std::move(client)); | 51 CreateCompositorFrameSinkInternal(compositor_frame_sink_type, |
| 60 | 52 gfx::kNullAcceleratedWidget, |
| 61 if (window_->parent()) { | 53 std::move(request), std::move(client)); |
| 62 window_->delegate() | |
| 63 ->GetRootWindow(window_) | |
| 64 ->GetOrCreateCompositorFrameSinkManager() | |
| 65 ->AddChildFrameSinkId(mojom::CompositorFrameSinkType::DEFAULT, | |
| 66 frame_sink_id); | |
| 67 } | |
| 68 } | 54 } |
| 69 | 55 |
| 70 void ServerWindowCompositorFrameSinkManager::AddChildFrameSinkId( | 56 void ServerWindowCompositorFrameSinkManager::AddChildFrameSinkId( |
| 71 mojom::CompositorFrameSinkType compositor_frame_sink_type, | 57 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
| 72 const cc::FrameSinkId& frame_sink_id) { | 58 const cc::FrameSinkId& frame_sink_id) { |
| 73 auto it = type_to_compositor_frame_sink_map_.find(compositor_frame_sink_type); | 59 auto it = type_to_compositor_frame_sink_map_.find(compositor_frame_sink_type); |
| 74 if (it != type_to_compositor_frame_sink_map_.end()) { | 60 if (it != type_to_compositor_frame_sink_map_.end()) { |
| 75 it->second.compositor_frame_sink->AddChildFrameSink(frame_sink_id); | 61 it->second.compositor_frame_sink->AddChildFrameSink(frame_sink_id); |
| 76 return; | 62 return; |
| 77 } | 63 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 if (iter == type_to_compositor_frame_sink_map_.end()) | 121 if (iter == type_to_compositor_frame_sink_map_.end()) |
| 136 return false; | 122 return false; |
| 137 if (iter->second.latest_submitted_frame_size.IsEmpty()) | 123 if (iter->second.latest_submitted_frame_size.IsEmpty()) |
| 138 return false; | 124 return false; |
| 139 const gfx::Size& latest_submitted_frame_size = | 125 const gfx::Size& latest_submitted_frame_size = |
| 140 iter->second.latest_submitted_frame_size; | 126 iter->second.latest_submitted_frame_size; |
| 141 return latest_submitted_frame_size.width() >= window_->bounds().width() && | 127 return latest_submitted_frame_size.width() >= window_->bounds().width() && |
| 142 latest_submitted_frame_size.height() >= window_->bounds().height(); | 128 latest_submitted_frame_size.height() >= window_->bounds().height(); |
| 143 } | 129 } |
| 144 | 130 |
| 131 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSinkInternal( | |
| 132 mojom::CompositorFrameSinkType compositor_frame_sink_type, | |
| 133 gfx::AcceleratedWidget widget, | |
| 134 cc::mojom::MojoCompositorFrameSinkRequest request, | |
| 135 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | |
| 136 cc::FrameSinkId frame_sink_id( | |
| 137 WindowIdToTransportId(window_->id()), | |
| 138 static_cast<uint32_t>(compositor_frame_sink_type)); | |
| 139 CompositorFrameSinkData& data = | |
| 140 type_to_compositor_frame_sink_map_[compositor_frame_sink_type]; | |
| 141 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request; | |
| 142 if (data.pending_compositor_frame_sink_request.is_pending()) { | |
| 143 private_request = std::move(data.pending_compositor_frame_sink_request); | |
| 144 } else { | |
| 145 private_request = mojo::GetProxy(&data.compositor_frame_sink); | |
| 146 } | |
| 147 | |
| 148 if (widget != gfx::kNullAcceleratedWidget) { | |
| 149 // TODO(fsamuel): AcceleratedWidget cannot be transported over IPC for Mac | |
| 150 // or | |
|
Fady Samuel
2016/12/14 17:19:01
fix alignment.
Alex Z.
2016/12/14 18:44:12
Done.
| |
| 151 // Android. We should instead use GpuSurfaceTracker here on those platforms. | |
| 152 window_->delegate() | |
| 153 ->GetDisplayCompositor() | |
| 154 ->CreateDisplayCompositorFrameSink( | |
| 155 frame_sink_id, widget, std::move(request), | |
| 156 std::move(private_request), std::move(client)); | |
| 157 } else { | |
| 158 window_->delegate() | |
| 159 ->GetDisplayCompositor() | |
| 160 ->CreateDisplayCompositorFrameSink( | |
| 161 frame_sink_id, gfx::kNullAcceleratedWidget, std::move(request), | |
| 162 std::move(private_request), std::move(client)); | |
| 163 } | |
| 164 | |
| 165 if (window_->parent()) { | |
| 166 window_->delegate() | |
| 167 ->GetRootWindow(window_) | |
| 168 ->GetOrCreateCompositorFrameSinkManager() | |
| 169 ->AddChildFrameSinkId(mojom::CompositorFrameSinkType::DEFAULT, | |
| 170 frame_sink_id); | |
| 171 } | |
| 172 } | |
| 173 | |
| 145 CompositorFrameSinkData::CompositorFrameSinkData() {} | 174 CompositorFrameSinkData::CompositorFrameSinkData() {} |
| 146 | 175 |
| 147 CompositorFrameSinkData::~CompositorFrameSinkData() {} | 176 CompositorFrameSinkData::~CompositorFrameSinkData() {} |
| 148 | 177 |
| 149 CompositorFrameSinkData::CompositorFrameSinkData( | 178 CompositorFrameSinkData::CompositorFrameSinkData( |
| 150 CompositorFrameSinkData&& other) | 179 CompositorFrameSinkData&& other) |
| 151 : latest_submitted_surface_id(other.latest_submitted_surface_id), | 180 : latest_submitted_surface_id(other.latest_submitted_surface_id), |
| 152 compositor_frame_sink(std::move(other.compositor_frame_sink)) {} | 181 compositor_frame_sink(std::move(other.compositor_frame_sink)) {} |
| 153 | 182 |
| 154 CompositorFrameSinkData& CompositorFrameSinkData::operator=( | 183 CompositorFrameSinkData& CompositorFrameSinkData::operator=( |
| 155 CompositorFrameSinkData&& other) { | 184 CompositorFrameSinkData&& other) { |
| 156 latest_submitted_surface_id = other.latest_submitted_surface_id; | 185 latest_submitted_surface_id = other.latest_submitted_surface_id; |
| 157 compositor_frame_sink = std::move(other.compositor_frame_sink); | 186 compositor_frame_sink = std::move(other.compositor_frame_sink); |
| 158 return *this; | 187 return *this; |
| 159 } | 188 } |
| 160 | 189 |
| 161 } // namespace ws | 190 } // namespace ws |
| 162 } // namespace ui | 191 } // namespace ui |
| OLD | NEW |