| 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 "services/ui/surfaces/display_compositor.h" | 7 #include "services/ui/surfaces/display_compositor.h" |
| 8 #include "services/ui/ws/ids.h" | 8 #include "services/ui/ws/ids.h" |
| 9 #include "services/ui/ws/server_window.h" | 9 #include "services/ui/ws/server_window.h" |
| 10 #include "services/ui/ws/server_window_compositor_frame_sink.h" | 10 #include "services/ui/ws/server_window_compositor_frame_sink.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return !waiting_for_initial_frames_; | 38 return !waiting_for_initial_frames_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSink( | 41 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSink( |
| 42 mojom::CompositorFrameSinkType compositor_frame_sink_type, | 42 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
| 43 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, | 43 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, |
| 44 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 44 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 45 cc::FrameSinkId frame_sink_id( | 45 cc::FrameSinkId frame_sink_id( |
| 46 WindowIdToTransportId(window_->id()), | 46 WindowIdToTransportId(window_->id()), |
| 47 static_cast<uint32_t>(compositor_frame_sink_type)); | 47 static_cast<uint32_t>(compositor_frame_sink_type)); |
| 48 std::unique_ptr<ServerWindowCompositorFrameSink> compositor_frame_sink( | 48 CompositorFrameSinkData& data = |
| 49 new ServerWindowCompositorFrameSink( | 49 type_to_compositor_frame_sink_map_[compositor_frame_sink_type]; |
| 50 this, frame_sink_id, std::move(request), std::move(client))); | 50 data.compositor_frame_sink = |
| 51 type_to_compositor_frame_sink_map_[compositor_frame_sink_type] = | 51 base::MakeUnique<ServerWindowCompositorFrameSink>( |
| 52 std::move(compositor_frame_sink); | 52 this, frame_sink_id, std::move(request), std::move(client)); |
| 53 data.surface_sequence_generator.set_frame_sink_id(frame_sink_id); |
| 53 } | 54 } |
| 54 | 55 |
| 55 ServerWindowCompositorFrameSink* | 56 ServerWindowCompositorFrameSink* |
| 56 ServerWindowCompositorFrameSinkManager::GetDefaultCompositorFrameSink() const { | 57 ServerWindowCompositorFrameSinkManager::GetDefaultCompositorFrameSink() const { |
| 57 return GetCompositorFrameSinkByType(mojom::CompositorFrameSinkType::DEFAULT); | 58 return GetCompositorFrameSinkByType(mojom::CompositorFrameSinkType::DEFAULT); |
| 58 } | 59 } |
| 59 | 60 |
| 60 ServerWindowCompositorFrameSink* | 61 ServerWindowCompositorFrameSink* |
| 61 ServerWindowCompositorFrameSinkManager::GetUnderlayCompositorFrameSink() const { | 62 ServerWindowCompositorFrameSinkManager::GetUnderlayCompositorFrameSink() const { |
| 62 return GetCompositorFrameSinkByType(mojom::CompositorFrameSinkType::UNDERLAY); | 63 return GetCompositorFrameSinkByType(mojom::CompositorFrameSinkType::UNDERLAY); |
| 63 } | 64 } |
| 64 | 65 |
| 65 ServerWindowCompositorFrameSink* | 66 ServerWindowCompositorFrameSink* |
| 66 ServerWindowCompositorFrameSinkManager::GetCompositorFrameSinkByType( | 67 ServerWindowCompositorFrameSinkManager::GetCompositorFrameSinkByType( |
| 67 mojom::CompositorFrameSinkType type) const { | 68 mojom::CompositorFrameSinkType type) const { |
| 68 auto iter = type_to_compositor_frame_sink_map_.find(type); | 69 auto iter = type_to_compositor_frame_sink_map_.find(type); |
| 69 return iter == type_to_compositor_frame_sink_map_.end() ? nullptr | 70 return iter == type_to_compositor_frame_sink_map_.end() |
| 70 : iter->second.get(); | 71 ? nullptr |
| 72 : iter->second.compositor_frame_sink.get(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 bool ServerWindowCompositorFrameSinkManager::HasCompositorFrameSinkOfType( | 75 bool ServerWindowCompositorFrameSinkManager::HasCompositorFrameSinkOfType( |
| 74 mojom::CompositorFrameSinkType type) const { | 76 mojom::CompositorFrameSinkType type) const { |
| 75 return type_to_compositor_frame_sink_map_.count(type) > 0; | 77 return type_to_compositor_frame_sink_map_.count(type) > 0; |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool ServerWindowCompositorFrameSinkManager::HasAnyCompositorFrameSink() const { | 80 bool ServerWindowCompositorFrameSinkManager::HasAnyCompositorFrameSink() const { |
| 79 return GetDefaultCompositorFrameSink() || GetUnderlayCompositorFrameSink(); | 81 return GetDefaultCompositorFrameSink() || GetUnderlayCompositorFrameSink(); |
| 80 } | 82 } |
| 81 | 83 |
| 84 cc::SurfaceSequence |
| 85 ServerWindowCompositorFrameSinkManager::CreateSurfaceSequence( |
| 86 mojom::CompositorFrameSinkType type) { |
| 87 cc::FrameSinkId frame_sink_id(WindowIdToTransportId(window_->id()), |
| 88 static_cast<uint32_t>(type)); |
| 89 CompositorFrameSinkData& data = type_to_compositor_frame_sink_map_[type]; |
| 90 data.surface_sequence_generator.set_frame_sink_id(frame_sink_id); |
| 91 return data.surface_sequence_generator.CreateSurfaceSequence(); |
| 92 } |
| 93 |
| 94 gfx::Size ServerWindowCompositorFrameSinkManager::GetLatestFrameSize( |
| 95 mojom::CompositorFrameSinkType type) const { |
| 96 auto it = type_to_compositor_frame_sink_map_.find(type); |
| 97 if (it == type_to_compositor_frame_sink_map_.end()) |
| 98 return gfx::Size(); |
| 99 |
| 100 return it->second.latest_submitted_frame_size; |
| 101 } |
| 102 |
| 103 cc::SurfaceId ServerWindowCompositorFrameSinkManager::GetLatestSurfaceId( |
| 104 mojom::CompositorFrameSinkType type) const { |
| 105 auto it = type_to_compositor_frame_sink_map_.find(type); |
| 106 if (it == type_to_compositor_frame_sink_map_.end()) |
| 107 return cc::SurfaceId(); |
| 108 |
| 109 return it->second.latest_submitted_surface_id; |
| 110 } |
| 111 |
| 112 void ServerWindowCompositorFrameSinkManager::SetLatestSurfaceInfo( |
| 113 mojom::CompositorFrameSinkType type, |
| 114 const cc::SurfaceId& surface_id, |
| 115 const gfx::Size& frame_size) { |
| 116 CompositorFrameSinkData& data = type_to_compositor_frame_sink_map_[type]; |
| 117 data.latest_submitted_surface_id = surface_id; |
| 118 data.latest_submitted_frame_size = frame_size; |
| 119 } |
| 120 |
| 82 cc::SurfaceManager* | 121 cc::SurfaceManager* |
| 83 ServerWindowCompositorFrameSinkManager::GetCompositorFrameSinkManager() { | 122 ServerWindowCompositorFrameSinkManager::GetCompositorFrameSinkManager() { |
| 84 return window()->delegate()->GetDisplayCompositor()->manager(); | 123 return window()->delegate()->GetDisplayCompositor()->manager(); |
| 85 } | 124 } |
| 86 | 125 |
| 87 bool ServerWindowCompositorFrameSinkManager:: | 126 bool ServerWindowCompositorFrameSinkManager:: |
| 88 IsCompositorFrameSinkReadyAndNonEmpty( | 127 IsCompositorFrameSinkReadyAndNonEmpty( |
| 89 mojom::CompositorFrameSinkType type) const { | 128 mojom::CompositorFrameSinkType type) const { |
| 90 auto iter = type_to_compositor_frame_sink_map_.find(type); | 129 auto iter = type_to_compositor_frame_sink_map_.find(type); |
| 91 if (iter == type_to_compositor_frame_sink_map_.end()) | 130 if (iter == type_to_compositor_frame_sink_map_.end()) |
| 92 return false; | 131 return false; |
| 93 if (iter->second->last_submitted_frame_size().IsEmpty()) | 132 if (iter->second.latest_submitted_frame_size.IsEmpty()) |
| 94 return false; | 133 return false; |
| 95 const gfx::Size& last_submitted_frame_size = | 134 const gfx::Size& latest_submitted_frame_size = |
| 96 iter->second->last_submitted_frame_size(); | 135 iter->second.latest_submitted_frame_size; |
| 97 return last_submitted_frame_size.width() >= window_->bounds().width() && | 136 return latest_submitted_frame_size.width() >= window_->bounds().width() && |
| 98 last_submitted_frame_size.height() >= window_->bounds().height(); | 137 latest_submitted_frame_size.height() >= window_->bounds().height(); |
| 138 } |
| 139 |
| 140 CompositorFrameSinkData::CompositorFrameSinkData() {} |
| 141 |
| 142 CompositorFrameSinkData::~CompositorFrameSinkData() {} |
| 143 |
| 144 CompositorFrameSinkData::CompositorFrameSinkData( |
| 145 CompositorFrameSinkData&& other) |
| 146 : latest_submitted_surface_id(other.latest_submitted_surface_id), |
| 147 compositor_frame_sink(std::move(other.compositor_frame_sink)) {} |
| 148 |
| 149 CompositorFrameSinkData& CompositorFrameSinkData::operator=( |
| 150 CompositorFrameSinkData&& other) { |
| 151 latest_submitted_surface_id = other.latest_submitted_surface_id; |
| 152 compositor_frame_sink = std::move(other.compositor_frame_sink); |
| 153 return *this; |
| 99 } | 154 } |
| 100 | 155 |
| 101 } // namespace ws | 156 } // namespace ws |
| 102 } // namespace ui | 157 } // namespace ui |
| OLD | NEW |