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 "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/scheduler/begin_frame_source.h" | 8 #include "cc/scheduler/begin_frame_source.h" |
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
11 #include "cc/surfaces/surface.h" | 11 #include "cc/surfaces/surface.h" |
12 #include "cc/surfaces/surface_manager.h" | 12 #include "cc/surfaces/surface_manager.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 CompositorFrameSinkSupport::CompositorFrameSinkSupport( | 16 CompositorFrameSinkSupport::CompositorFrameSinkSupport( |
17 CompositorFrameSinkSupportClient* client, | 17 CompositorFrameSinkSupportClient* client, |
18 SurfaceManager* surface_manager, | 18 SurfaceManager* surface_manager, |
19 const FrameSinkId& frame_sink_id, | 19 const FrameSinkId& frame_sink_id, |
20 std::unique_ptr<Display> display, | 20 Display* display, |
21 std::unique_ptr<BeginFrameSource> display_begin_frame_source) | 21 bool needs_sync_points) |
22 : client_(client), | 22 : client_(client), |
23 surface_manager_(surface_manager), | 23 surface_manager_(surface_manager), |
24 frame_sink_id_(frame_sink_id), | 24 frame_sink_id_(frame_sink_id), |
25 display_begin_frame_source_(std::move(display_begin_frame_source)), | 25 display_(display), |
26 display_(std::move(display)), | |
27 surface_factory_(frame_sink_id_, surface_manager_, this), | 26 surface_factory_(frame_sink_id_, surface_manager_, this), |
28 weak_factory_(this) { | 27 weak_factory_(this) { |
29 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 28 surface_manager_->RegisterFrameSinkId(frame_sink_id_); |
30 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 29 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| 30 surface_factory_.set_needs_sync_points(needs_sync_points); |
31 | 31 |
32 if (display_) { | 32 if (display_) |
33 display_->Initialize(this, surface_manager_); | 33 display_->Initialize(this, surface_manager_); |
34 display_->SetVisible(true); | |
35 } | |
36 } | 34 } |
37 | 35 |
38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { | 36 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { |
39 for (auto& child_frame_sink_id : child_frame_sinks_) { | 37 for (auto& child_frame_sink_id : child_frame_sinks_) { |
40 DCHECK(child_frame_sink_id.is_valid()); | 38 DCHECK(child_frame_sink_id.is_valid()); |
41 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 39 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
42 child_frame_sink_id); | 40 child_frame_sink_id); |
43 } | 41 } |
44 // SurfaceFactory's destructor will attempt to return resources which will | 42 // SurfaceFactory's destructor will attempt to return resources which will |
45 // call back into here and access |client_| so we should destroy | 43 // call back into here and access |client_| so we should destroy |
46 // |surface_factory_|'s resources early on. | 44 // |surface_factory_|'s resources early on. |
47 surface_factory_.EvictSurface(); | 45 surface_factory_.EvictSurface(); |
48 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 46 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
49 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 47 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
50 } | 48 } |
51 | 49 |
52 void CompositorFrameSinkSupport::EvictFrame() { | 50 void CompositorFrameSinkSupport::EvictFrame() { |
53 surface_factory_.EvictSurface(); | 51 surface_factory_.EvictSurface(); |
54 } | 52 } |
55 | 53 |
56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 54 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
57 needs_begin_frame_ = needs_begin_frame; | 55 needs_begin_frame_ = needs_begin_frame; |
58 UpdateNeedsBeginFramesInternal(); | 56 UpdateNeedsBeginFramesInternal(); |
59 } | 57 } |
60 | 58 |
61 void CompositorFrameSinkSupport::SubmitCompositorFrame( | 59 void CompositorFrameSinkSupport::SubmitCompositorFrame( |
62 const LocalSurfaceId& local_surface_id, | 60 const LocalSurfaceId& local_surface_id, |
63 CompositorFrame frame) { | 61 CompositorFrame frame) { |
64 ++ack_pending_count_; | 62 ++ack_pending_count_; |
| 63 if (display_) { |
| 64 display_->SetLocalSurfaceId(local_surface_id, |
| 65 frame.metadata.device_scale_factor); |
| 66 } |
65 surface_factory_.SubmitCompositorFrame( | 67 surface_factory_.SubmitCompositorFrame( |
66 local_surface_id, std::move(frame), | 68 local_surface_id, std::move(frame), |
67 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, | 69 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, |
68 weak_factory_.GetWeakPtr())); | 70 weak_factory_.GetWeakPtr())); |
69 if (display_) { | |
70 display_->SetLocalSurfaceId(local_surface_id, | |
71 frame.metadata.device_scale_factor); | |
72 } | |
73 } | 71 } |
74 | 72 |
75 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id, | 73 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id, |
76 const SurfaceSequence& sequence) { | 74 const SurfaceSequence& sequence) { |
77 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id), | 75 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id), |
78 sequence); | 76 sequence); |
79 } | 77 } |
80 | 78 |
81 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { | 79 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { |
82 surface_manager_->SatisfySequence(sequence); | 80 surface_manager_->SatisfySequence(sequence); |
(...skipping 22 matching lines...) Expand all Loading... |
105 void CompositorFrameSinkSupport::RemoveChildFrameSink( | 103 void CompositorFrameSinkSupport::RemoveChildFrameSink( |
106 const FrameSinkId& child_frame_sink_id) { | 104 const FrameSinkId& child_frame_sink_id) { |
107 auto it = child_frame_sinks_.find(child_frame_sink_id); | 105 auto it = child_frame_sinks_.find(child_frame_sink_id); |
108 DCHECK(it != child_frame_sinks_.end()); | 106 DCHECK(it != child_frame_sinks_.end()); |
109 DCHECK(it->is_valid()); | 107 DCHECK(it->is_valid()); |
110 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 108 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
111 child_frame_sink_id); | 109 child_frame_sink_id); |
112 child_frame_sinks_.erase(it); | 110 child_frame_sinks_.erase(it); |
113 } | 111 } |
114 | 112 |
| 113 void CompositorFrameSinkSupport::ForceReclaimResources() { |
| 114 surface_factory_.ClearSurface(); |
| 115 } |
| 116 |
115 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} | 117 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} |
116 | 118 |
117 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( | 119 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( |
118 bool will_draw_and_swap, | 120 bool will_draw_and_swap, |
119 const RenderPassList& render_passes) {} | 121 const RenderPassList& render_passes) {} |
120 | 122 |
121 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} | 123 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} |
122 | 124 |
123 void CompositorFrameSinkSupport::ReturnResources( | 125 void CompositorFrameSinkSupport::ReturnResources( |
124 const ReturnedResourceArray& resources) { | 126 const ReturnedResourceArray& resources) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 return; | 175 return; |
174 | 176 |
175 added_frame_observer_ = needs_begin_frame_; | 177 added_frame_observer_ = needs_begin_frame_; |
176 if (needs_begin_frame_) | 178 if (needs_begin_frame_) |
177 begin_frame_source_->AddObserver(this); | 179 begin_frame_source_->AddObserver(this); |
178 else | 180 else |
179 begin_frame_source_->RemoveObserver(this); | 181 begin_frame_source_->RemoveObserver(this); |
180 } | 182 } |
181 | 183 |
182 } // namespace cc | 184 } // namespace cc |
OLD | NEW |