Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: cc/surfaces/compositor_frame_sink_support.cc

Issue 2612083002: DirectCompositorFrameSink Uses CompositorFrameSinkSupport (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 std::unique_ptr<BeginFrameSource> display_begin_frame_source)
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_begin_frame_source_(std::move(display_begin_frame_source)),
26 display_(std::move(display)), 26 display_(std::move(display)),
27 surface_factory_(frame_sink_id_, surface_manager_, this), 27 surface_factory_(frame_sink_id_, surface_manager_, this),
28 weak_factory_(this) { 28 weak_factory_(this) {}
29 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
30 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
31
32 if (display_) {
33 display_->Initialize(this, surface_manager_);
34 display_->SetVisible(true);
35 }
36 }
37 29
38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { 30 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() {
39 for (auto& child_frame_sink_id : child_frame_sinks_) { 31 for (auto& child_frame_sink_id : child_frame_sinks_) {
40 DCHECK(child_frame_sink_id.is_valid()); 32 DCHECK(child_frame_sink_id.is_valid());
41 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 33 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
42 child_frame_sink_id); 34 child_frame_sink_id);
43 } 35 }
44 // SurfaceFactory's destructor will attempt to return resources which will
45 // call back into here and access |client_| so we should destroy
46 // |surface_factory_|'s resources early on.
47 surface_factory_.EvictSurface();
48 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
49 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
50 } 36 }
51 37
52 void CompositorFrameSinkSupport::EvictFrame() { 38 void CompositorFrameSinkSupport::EvictFrame() {
53 surface_factory_.EvictSurface(); 39 surface_factory_.EvictSurface();
54 } 40 }
55 41
56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { 42 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) {
57 needs_begin_frame_ = needs_begin_frame; 43 needs_begin_frame_ = needs_begin_frame;
58 UpdateNeedsBeginFramesInternal(); 44 UpdateNeedsBeginFramesInternal();
59 } 45 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void CompositorFrameSinkSupport::RemoveChildFrameSink( 111 void CompositorFrameSinkSupport::RemoveChildFrameSink(
126 const FrameSinkId& child_frame_sink_id) { 112 const FrameSinkId& child_frame_sink_id) {
127 auto it = child_frame_sinks_.find(child_frame_sink_id); 113 auto it = child_frame_sinks_.find(child_frame_sink_id);
128 DCHECK(it != child_frame_sinks_.end()); 114 DCHECK(it != child_frame_sinks_.end());
129 DCHECK(it->is_valid()); 115 DCHECK(it->is_valid());
130 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 116 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
131 child_frame_sink_id); 117 child_frame_sink_id);
132 child_frame_sinks_.erase(it); 118 child_frame_sinks_.erase(it);
133 } 119 }
134 120
121 void CompositorFrameSinkSupport::SetFactoryNeedsSyncPoints(
Fady Samuel 2017/01/04 20:59:25 nit: Call it SetNeedsSyncPoints?
Alex Z. 2017/01/04 21:36:09 Done.
122 bool needs_sync_points) {
123 surface_factory_.set_needs_sync_points(needs_sync_points);
124 }
125
126 void CompositorFrameSinkSupport::ForceReclaimResources() {
127 if (local_frame_id_.is_valid())
128 surface_factory_.ClearSurface();
129 }
130
131 void CompositorFrameSinkSupport::BindToClient() {
Fady Samuel 2017/01/04 20:59:25 Instead of calling BindToClient, create the Compos
Alex Z. 2017/01/04 21:36:09 Done.
132 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
133 if (display_)
134 display_->Initialize(this, surface_manager_);
135 }
136
137 void CompositorFrameSinkSupport::DetachFromClient() {
Fady Samuel 2017/01/04 20:59:25 Instead of calling DetachFromClient here, destroy
Alex Z. 2017/01/04 21:36:09 Done.
138 // Unregister the SurfaceFactoryClient here instead of the dtor so that only
139 // one client is alive for this namespace at any given time.
140 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
141 surface_factory_.EvictSurface();
142 }
143
144 void CompositorFrameSinkSupport::SetDisplayVisible(bool visible) {
Fady Samuel 2017/01/04 20:59:25 No need to introduce this. support_->display()->Se
Alex Z. 2017/01/04 21:36:10 Done.
145 if (display_)
146 display_->SetVisible(visible);
147 }
148
149 void CompositorFrameSinkSupport::RegisterFrameSinkId() {
150 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
Fady Samuel 2017/01/04 20:59:25 Remove this. This is unnecessary.
Alex Z. 2017/01/04 21:36:09 DirectCompositorFrameSink doesn't register and inv
151 }
152
153 void CompositorFrameSinkSupport::InvalidateFrameSinkId() {
Fady Samuel 2017/01/04 20:59:25 Remove this. This is unnecessary.
Alex Z. 2017/01/04 21:36:10 DirectCompositorFrameSink doesn't register and inv
154 // SurfaceFactory's destructor will attempt to return resources which will
155 // call back into here and access |client_| so we should destroy
156 // |surface_factory_|'s resources early on.
157 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
158 }
159
135 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} 160 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {}
136 161
137 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( 162 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap(
138 bool will_draw_and_swap, 163 bool will_draw_and_swap,
139 const RenderPassList& render_passes) {} 164 const RenderPassList& render_passes) {}
140 165
141 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} 166 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {}
142 167
143 void CompositorFrameSinkSupport::ReturnResources( 168 void CompositorFrameSinkSupport::ReturnResources(
144 const ReturnedResourceArray& resources) { 169 const ReturnedResourceArray& resources) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return; 218 return;
194 219
195 added_frame_observer_ = needs_begin_frame_; 220 added_frame_observer_ = needs_begin_frame_;
196 if (needs_begin_frame_) 221 if (needs_begin_frame_)
197 begin_frame_source_->AddObserver(this); 222 begin_frame_source_->AddObserver(this);
198 else 223 else
199 begin_frame_source_->RemoveObserver(this); 224 begin_frame_source_->RemoveObserver(this);
200 } 225 }
201 226
202 } // namespace cc 227 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698