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

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

Issue 2612083002: DirectCompositorFrameSink Uses CompositorFrameSinkSupport (Closed)
Patch Set: Address comments and revert changes in Android 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 handles_frame_sink_id_invalidation,
22 bool needs_sync_points)
22 : client_(client), 23 : client_(client),
23 surface_manager_(surface_manager), 24 surface_manager_(surface_manager),
24 frame_sink_id_(frame_sink_id), 25 frame_sink_id_(frame_sink_id),
25 display_begin_frame_source_(std::move(display_begin_frame_source)), 26 display_(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 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation),
28 weak_factory_(this) { 29 weak_factory_(this) {
29 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 30 if (handles_frame_sink_id_invalidation_)
31 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
32
30 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); 33 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
34 surface_factory_.set_needs_sync_points(needs_sync_points);
31 35
32 if (display_) { 36 if (display_)
33 display_->Initialize(this, surface_manager_); 37 display_->Initialize(this, surface_manager_);
34 display_->SetVisible(true);
35 }
36 } 38 }
37 39
38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { 40 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() {
41 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does
42 // not call into |this| after it's deleted.
43 SetNeedsBeginFrame(false);
44
39 for (auto& child_frame_sink_id : child_frame_sinks_) { 45 for (auto& child_frame_sink_id : child_frame_sinks_) {
40 DCHECK(child_frame_sink_id.is_valid()); 46 DCHECK(child_frame_sink_id.is_valid());
41 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 47 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
42 child_frame_sink_id); 48 child_frame_sink_id);
43 } 49 }
44 // SurfaceFactory's destructor will attempt to return resources which will 50 // SurfaceFactory's destructor will attempt to return resources which will
45 // call back into here and access |client_| so we should destroy 51 // call back into here and access |client_| so we should destroy
46 // |surface_factory_|'s resources early on. 52 // |surface_factory_|'s resources early on.
47 surface_factory_.EvictSurface(); 53 surface_factory_.EvictSurface();
48 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 54 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
49 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); 55 if (handles_frame_sink_id_invalidation_)
56 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
50 } 57 }
51 58
52 void CompositorFrameSinkSupport::EvictFrame() { 59 void CompositorFrameSinkSupport::EvictFrame() {
53 surface_factory_.EvictSurface(); 60 surface_factory_.EvictSurface();
54 } 61 }
55 62
56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { 63 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) {
57 needs_begin_frame_ = needs_begin_frame; 64 needs_begin_frame_ = needs_begin_frame;
58 UpdateNeedsBeginFramesInternal(); 65 UpdateNeedsBeginFramesInternal();
59 } 66 }
60 67
61 void CompositorFrameSinkSupport::SubmitCompositorFrame( 68 void CompositorFrameSinkSupport::SubmitCompositorFrame(
62 const LocalSurfaceId& local_surface_id, 69 const LocalSurfaceId& local_surface_id,
63 CompositorFrame frame) { 70 CompositorFrame frame) {
64 ++ack_pending_count_; 71 ++ack_pending_count_;
72 if (display_) {
73 display_->SetLocalSurfaceId(local_surface_id,
74 frame.metadata.device_scale_factor);
75 }
65 surface_factory_.SubmitCompositorFrame( 76 surface_factory_.SubmitCompositorFrame(
66 local_surface_id, std::move(frame), 77 local_surface_id, std::move(frame),
67 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, 78 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
68 weak_factory_.GetWeakPtr())); 79 weak_factory_.GetWeakPtr()));
69 if (display_) {
70 display_->SetLocalSurfaceId(local_surface_id,
71 frame.metadata.device_scale_factor);
72 }
73 } 80 }
74 81
75 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id, 82 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id,
76 const SurfaceSequence& sequence) { 83 const SurfaceSequence& sequence) {
77 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id), 84 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id),
78 sequence); 85 sequence);
79 } 86 }
80 87
81 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { 88 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) {
82 surface_manager_->SatisfySequence(sequence); 89 surface_manager_->SatisfySequence(sequence);
(...skipping 22 matching lines...) Expand all
105 void CompositorFrameSinkSupport::RemoveChildFrameSink( 112 void CompositorFrameSinkSupport::RemoveChildFrameSink(
106 const FrameSinkId& child_frame_sink_id) { 113 const FrameSinkId& child_frame_sink_id) {
107 auto it = child_frame_sinks_.find(child_frame_sink_id); 114 auto it = child_frame_sinks_.find(child_frame_sink_id);
108 DCHECK(it != child_frame_sinks_.end()); 115 DCHECK(it != child_frame_sinks_.end());
109 DCHECK(it->is_valid()); 116 DCHECK(it->is_valid());
110 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 117 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
111 child_frame_sink_id); 118 child_frame_sink_id);
112 child_frame_sinks_.erase(it); 119 child_frame_sinks_.erase(it);
113 } 120 }
114 121
122 void CompositorFrameSinkSupport::ForceReclaimResources() {
123 surface_factory_.ClearSurface();
124 }
125
115 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} 126 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {}
116 127
117 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( 128 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap(
118 bool will_draw_and_swap, 129 bool will_draw_and_swap,
119 const RenderPassList& render_passes) {} 130 const RenderPassList& render_passes) {}
120 131
121 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} 132 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {}
122 133
123 void CompositorFrameSinkSupport::ReturnResources( 134 void CompositorFrameSinkSupport::ReturnResources(
124 const ReturnedResourceArray& resources) { 135 const ReturnedResourceArray& resources) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return; 184 return;
174 185
175 added_frame_observer_ = needs_begin_frame_; 186 added_frame_observer_ = needs_begin_frame_;
176 if (needs_begin_frame_) 187 if (needs_begin_frame_)
177 begin_frame_source_->AddObserver(this); 188 begin_frame_source_->AddObserver(this);
178 else 189 else
179 begin_frame_source_->RemoveObserver(this); 190 begin_frame_source_->RemoveObserver(this);
180 } 191 }
181 192
182 } // namespace cc 193 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698