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

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

Issue 2612083002: DirectCompositorFrameSink Uses CompositorFrameSinkSupport (Closed)
Patch Set: Addressed nits Created 3 years, 10 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 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); 34 display_->SetVisible(true);
35 } 35 }
36 } 36 }
37 37
38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { 38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() {
39 for (auto& child_frame_sink_id : child_frame_sinks_) { 39 for (auto& child_frame_sink_id : child_frame_sinks_) {
40 DCHECK(child_frame_sink_id.is_valid()); 40 DCHECK(child_frame_sink_id.is_valid());
(...skipping 14 matching lines...) Expand all
55 55
56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { 56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) {
57 needs_begin_frame_ = needs_begin_frame; 57 needs_begin_frame_ = needs_begin_frame;
58 UpdateNeedsBeginFramesInternal(); 58 UpdateNeedsBeginFramesInternal();
59 } 59 }
60 60
61 void CompositorFrameSinkSupport::SubmitCompositorFrame( 61 void CompositorFrameSinkSupport::SubmitCompositorFrame(
62 const LocalSurfaceId& local_surface_id, 62 const LocalSurfaceId& local_surface_id,
63 CompositorFrame frame) { 63 CompositorFrame frame) {
64 ++ack_pending_count_; 64 ++ack_pending_count_;
65 if (display_) {
danakj 2017/01/31 19:25:01 why this reordering?
Alex Z. 2017/01/31 20:34:18 The reordering was to fix this crash in the state_
danakj 2017/01/31 20:41:38 That crash is from CompositorFrameSinkSupport::Sub
Alex Z. 2017/01/31 21:09:30 I don't know. I did the reordering because SetLoca
danakj 2017/01/31 21:49:40 Er, well, I don't think that's a very good motivat
Alex Z. 2017/02/02 00:17:32 Like we've discussed on slack, CompositorFrameSin
66 display_->SetLocalSurfaceId(local_surface_id,
67 frame.metadata.device_scale_factor);
68 }
65 surface_factory_.SubmitCompositorFrame( 69 surface_factory_.SubmitCompositorFrame(
66 local_surface_id, std::move(frame), 70 local_surface_id, std::move(frame),
67 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, 71 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
68 weak_factory_.GetWeakPtr())); 72 weak_factory_.GetWeakPtr()));
69 if (display_) {
70 display_->SetLocalSurfaceId(local_surface_id,
71 frame.metadata.device_scale_factor);
72 }
73 } 73 }
74 74
75 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id, 75 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id,
76 const SurfaceSequence& sequence) { 76 const SurfaceSequence& sequence) {
77 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id), 77 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id),
78 sequence); 78 sequence);
79 } 79 }
80 80
81 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { 81 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) {
82 surface_manager_->SatisfySequence(sequence); 82 surface_manager_->SatisfySequence(sequence);
83 } 83 }
84 84
85 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { 85 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() {
86 DCHECK_GT(ack_pending_count_, 0); 86 DCHECK_GT(ack_pending_count_, 0);
87 ack_pending_count_--; 87 ack_pending_count_--;
88 88
89 if (!client_) 89 if (!client_)
90 return; 90 return;
91
danakj 2017/01/31 19:25:01 random whitespace?
Alex Z. 2017/01/31 20:34:18 Done.
91 client_->DidReceiveCompositorFrameAck(); 92 client_->DidReceiveCompositorFrameAck();
92 if (!surface_returned_resources_.empty()) { 93 if (!surface_returned_resources_.empty()) {
93 client_->ReclaimResources(surface_returned_resources_); 94 client_->ReclaimResources(surface_returned_resources_);
94 surface_returned_resources_.clear(); 95 surface_returned_resources_.clear();
95 } 96 }
96 } 97 }
97 98
98 void CompositorFrameSinkSupport::AddChildFrameSink( 99 void CompositorFrameSinkSupport::AddChildFrameSink(
99 const FrameSinkId& child_frame_sink_id) { 100 const FrameSinkId& child_frame_sink_id) {
100 child_frame_sinks_.insert(child_frame_sink_id); 101 child_frame_sinks_.insert(child_frame_sink_id);
101 surface_manager_->RegisterFrameSinkHierarchy(frame_sink_id_, 102 surface_manager_->RegisterFrameSinkHierarchy(frame_sink_id_,
102 child_frame_sink_id); 103 child_frame_sink_id);
103 } 104 }
104 105
105 void CompositorFrameSinkSupport::RemoveChildFrameSink( 106 void CompositorFrameSinkSupport::RemoveChildFrameSink(
106 const FrameSinkId& child_frame_sink_id) { 107 const FrameSinkId& child_frame_sink_id) {
107 auto it = child_frame_sinks_.find(child_frame_sink_id); 108 auto it = child_frame_sinks_.find(child_frame_sink_id);
108 DCHECK(it != child_frame_sinks_.end()); 109 DCHECK(it != child_frame_sinks_.end());
109 DCHECK(it->is_valid()); 110 DCHECK(it->is_valid());
110 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 111 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
111 child_frame_sink_id); 112 child_frame_sink_id);
112 child_frame_sinks_.erase(it); 113 child_frame_sinks_.erase(it);
113 } 114 }
114 115
116 void CompositorFrameSinkSupport::ForceReclaimResources() {
117 surface_factory_.ClearSurface();
118 }
119
115 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} 120 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {}
116 121
117 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( 122 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap(
118 bool will_draw_and_swap, 123 bool will_draw_and_swap,
119 const RenderPassList& render_passes) {} 124 const RenderPassList& render_passes) {}
120 125
121 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} 126 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {}
122 127
123 void CompositorFrameSinkSupport::ReturnResources( 128 void CompositorFrameSinkSupport::ReturnResources(
124 const ReturnedResourceArray& resources) { 129 const ReturnedResourceArray& resources) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return; 178 return;
174 179
175 added_frame_observer_ = needs_begin_frame_; 180 added_frame_observer_ = needs_begin_frame_;
176 if (needs_begin_frame_) 181 if (needs_begin_frame_)
177 begin_frame_source_->AddObserver(this); 182 begin_frame_source_->AddObserver(this);
178 else 183 else
179 begin_frame_source_->RemoveObserver(this); 184 begin_frame_source_->RemoveObserver(this);
180 } 185 }
181 186
182 } // namespace cc 187 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698