| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 mojo::MakeRequest(&frame_sink_data_->compositor_frame_sink); | 102 mojo::MakeRequest(&frame_sink_data_->compositor_frame_sink); |
| 103 frame_sink_data_->compositor_frame_sink->AddChildFrameSink(frame_sink_id); | 103 frame_sink_data_->compositor_frame_sink->AddChildFrameSink(frame_sink_id); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ServerWindowCompositorFrameSinkManager::RemoveChildFrameSinkId( | 106 void ServerWindowCompositorFrameSinkManager::RemoveChildFrameSinkId( |
| 107 const cc::FrameSinkId& frame_sink_id) { | 107 const cc::FrameSinkId& frame_sink_id) { |
| 108 DCHECK(frame_sink_data_); | 108 DCHECK(frame_sink_data_); |
| 109 frame_sink_data_->compositor_frame_sink->RemoveChildFrameSink(frame_sink_id); | 109 frame_sink_data_->compositor_frame_sink->RemoveChildFrameSink(frame_sink_id); |
| 110 } | 110 } |
| 111 | 111 |
| 112 gfx::Size ServerWindowCompositorFrameSinkManager::GetLatestFrameSize() const { | |
| 113 if (!frame_sink_data_) | |
| 114 return gfx::Size(); | |
| 115 | |
| 116 return frame_sink_data_->latest_submitted_surface_info.size_in_pixels(); | |
| 117 } | |
| 118 | |
| 119 void ServerWindowCompositorFrameSinkManager::SetLatestSurfaceInfo( | |
| 120 const cc::SurfaceInfo& surface_info) { | |
| 121 if (!frame_sink_data_) | |
| 122 frame_sink_data_ = base::MakeUnique<CompositorFrameSinkData>(); | |
| 123 | |
| 124 frame_sink_data_->latest_submitted_surface_info = surface_info; | |
| 125 } | |
| 126 | |
| 127 void ServerWindowCompositorFrameSinkManager::OnRootChanged( | 112 void ServerWindowCompositorFrameSinkManager::OnRootChanged( |
| 128 ServerWindow* old_root, | 113 ServerWindow* old_root, |
| 129 ServerWindow* new_root) { | 114 ServerWindow* new_root) { |
| 130 if (!frame_sink_data_) | 115 if (!frame_sink_data_) |
| 131 return; | 116 return; |
| 132 | 117 |
| 133 if (old_root) { | 118 if (old_root) { |
| 134 old_root->GetOrCreateCompositorFrameSinkManager()->RemoveChildFrameSinkId( | 119 old_root->GetOrCreateCompositorFrameSinkManager()->RemoveChildFrameSinkId( |
| 135 frame_sink_data_->frame_sink_id); | 120 frame_sink_data_->frame_sink_id); |
| 136 } | 121 } |
| 137 if (new_root) { | 122 if (new_root) { |
| 138 new_root->GetOrCreateCompositorFrameSinkManager()->AddChildFrameSinkId( | 123 new_root->GetOrCreateCompositorFrameSinkManager()->AddChildFrameSinkId( |
| 139 frame_sink_data_->frame_sink_id); | 124 frame_sink_data_->frame_sink_id); |
| 140 } | 125 } |
| 141 } | 126 } |
| 142 | 127 |
| 143 CompositorFrameSinkData::CompositorFrameSinkData() {} | 128 CompositorFrameSinkData::CompositorFrameSinkData() {} |
| 144 | 129 |
| 145 CompositorFrameSinkData::~CompositorFrameSinkData() {} | 130 CompositorFrameSinkData::~CompositorFrameSinkData() {} |
| 146 | 131 |
| 147 CompositorFrameSinkData::CompositorFrameSinkData( | 132 CompositorFrameSinkData::CompositorFrameSinkData( |
| 148 CompositorFrameSinkData&& other) | 133 CompositorFrameSinkData&& other) |
| 149 : latest_submitted_surface_info(other.latest_submitted_surface_info), | 134 : compositor_frame_sink(std::move(other.compositor_frame_sink)) {} |
| 150 compositor_frame_sink(std::move(other.compositor_frame_sink)) {} | |
| 151 | 135 |
| 152 CompositorFrameSinkData& CompositorFrameSinkData::operator=( | 136 CompositorFrameSinkData& CompositorFrameSinkData::operator=( |
| 153 CompositorFrameSinkData&& other) { | 137 CompositorFrameSinkData&& other) { |
| 154 latest_submitted_surface_info = other.latest_submitted_surface_info; | |
| 155 compositor_frame_sink = std::move(other.compositor_frame_sink); | 138 compositor_frame_sink = std::move(other.compositor_frame_sink); |
| 156 return *this; | 139 return *this; |
| 157 } | 140 } |
| 158 | 141 |
| 159 } // namespace ws | 142 } // namespace ws |
| 160 } // namespace ui | 143 } // namespace ui |
| OLD | NEW |