OLD | NEW |
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 "components/mus/gpu/display_compositor/compositor_frame_sink_impl.h" | 5 #include "components/mus/gpu/display_compositor/compositor_frame_sink_impl.h" |
6 | 6 |
7 #include "cc/ipc/compositor_frame.mojom.h" | 7 #include "cc/ipc/compositor_frame.mojom.h" |
8 #include "cc/surfaces/surface_factory.h" | 8 #include "cc/surfaces/surface_factory.h" |
9 #include "components/mus/gpu/display_compositor/compositor_frame_sink_delegate.h
" | 9 #include "components/mus/gpu/display_compositor/compositor_frame_sink_delegate.h
" |
10 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" | |
11 | 10 |
12 namespace mus { | 11 namespace mus { |
13 namespace gpu { | 12 namespace gpu { |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 void CallCallback( | 16 void CallCallback( |
18 const mojom::CompositorFrameSink::SubmitCompositorFrameCallback& callback, | 17 const mojom::CompositorFrameSink::SubmitCompositorFrameCallback& callback, |
19 cc::SurfaceDrawStatus draw_status) { | 18 cc::SurfaceDrawStatus draw_status) { |
20 callback.Run(static_cast<mojom::CompositorFrameDrawStatus>(draw_status)); | 19 callback.Run(static_cast<mojom::CompositorFrameDrawStatus>(draw_status)); |
(...skipping 28 matching lines...) Expand all Loading... |
49 needs_begin_frame_ = needs_begin_frame; | 48 needs_begin_frame_ = needs_begin_frame; |
50 if (begin_frame_source_) { | 49 if (begin_frame_source_) { |
51 if (needs_begin_frame_) | 50 if (needs_begin_frame_) |
52 begin_frame_source_->AddObserver(this); | 51 begin_frame_source_->AddObserver(this); |
53 else | 52 else |
54 begin_frame_source_->RemoveObserver(this); | 53 begin_frame_source_->RemoveObserver(this); |
55 } | 54 } |
56 } | 55 } |
57 | 56 |
58 void CompositorFrameSinkImpl::SubmitCompositorFrame( | 57 void CompositorFrameSinkImpl::SubmitCompositorFrame( |
59 cc::mojom::CompositorFramePtr frame, | 58 cc::CompositorFrame compositor_frame, |
60 const SubmitCompositorFrameCallback& callback) { | 59 const SubmitCompositorFrameCallback& callback) { |
61 // TODO(fsamuel): Validate that SurfaceDrawQuad refer to allowable surface | |
62 // IDs. | |
63 std::unique_ptr<cc::CompositorFrame> compositor_frame = | |
64 ConvertToCompositorFrame(frame); | |
65 gfx::Size frame_size = | 60 gfx::Size frame_size = |
66 compositor_frame->delegated_frame_data->render_pass_list.back() | 61 compositor_frame.delegated_frame_data->render_pass_list.back() |
67 ->output_rect.size(); | 62 ->output_rect.size(); |
68 if (frame_size.IsEmpty() || frame_size != last_submitted_frame_size_) { | 63 if (frame_size.IsEmpty() || frame_size != last_submitted_frame_size_) { |
69 if (!surface_id_.is_null()) | 64 if (!surface_id_.is_null()) |
70 factory_.Destroy(surface_id_); | 65 factory_.Destroy(surface_id_); |
71 // TODO(fsamuel): The allocator should live on CompositorFrameSinkFactory. | 66 // TODO(fsamuel): The allocator should live on CompositorFrameSinkFactory. |
72 surface_id_ = delegate_->GenerateSurfaceId(); | 67 surface_id_ = delegate_->GenerateSurfaceId(); |
73 factory_.Create(surface_id_); | 68 factory_.Create(surface_id_); |
74 last_submitted_frame_size_ = frame_size; | 69 last_submitted_frame_size_ = frame_size; |
75 } | 70 } |
76 factory_.SubmitCompositorFrame(surface_id_, std::move(compositor_frame), | 71 std::unique_ptr<cc::CompositorFrame> compositor_frame_copy( |
| 72 new cc::CompositorFrame); |
| 73 *compositor_frame_copy = std::move(compositor_frame); |
| 74 factory_.SubmitCompositorFrame(surface_id_, std::move(compositor_frame_copy), |
77 base::Bind(&CallCallback, callback)); | 75 base::Bind(&CallCallback, callback)); |
78 } | 76 } |
79 | 77 |
80 void CompositorFrameSinkImpl::ReturnResources( | 78 void CompositorFrameSinkImpl::ReturnResources( |
81 const cc::ReturnedResourceArray& resources) { | 79 const cc::ReturnedResourceArray& resources) { |
82 if (!client_) | 80 if (!client_) |
83 return; | 81 return; |
84 | 82 |
85 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); | 83 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); |
86 } | 84 } |
(...skipping 21 matching lines...) Expand all Loading... |
108 void CompositorFrameSinkImpl::OnBeginFrameSourcePausedChanged(bool paused) { | 106 void CompositorFrameSinkImpl::OnBeginFrameSourcePausedChanged(bool paused) { |
109 // TODO(fsamuel): Implement this. | 107 // TODO(fsamuel): Implement this. |
110 } | 108 } |
111 | 109 |
112 void CompositorFrameSinkImpl::OnConnectionLost() { | 110 void CompositorFrameSinkImpl::OnConnectionLost() { |
113 delegate_->CompositorFrameSinkConnectionLost(sink_id_); | 111 delegate_->CompositorFrameSinkConnectionLost(sink_id_); |
114 } | 112 } |
115 | 113 |
116 } // namespace gpu | 114 } // namespace gpu |
117 } // namespace mus | 115 } // namespace mus |
OLD | NEW |