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

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

Issue 2557853002: cc: Unregister FrameSink hierarchy on CompositorFrameSinkSupport destruction (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 15 matching lines...) Expand all
26 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 26 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
27 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); 27 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
28 28
29 if (display_) { 29 if (display_) {
30 display_->Initialize(this, surface_manager_); 30 display_->Initialize(this, surface_manager_);
31 display_->SetVisible(true); 31 display_->SetVisible(true);
32 } 32 }
33 } 33 }
34 34
35 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { 35 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() {
36 for (auto& child_frame_sink_id : child_frame_sinks_) {
37 DCHECK(child_frame_sink_id.is_valid());
38 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
39 child_frame_sink_id);
40 }
36 // SurfaceFactory's destructor will attempt to return resources which will 41 // SurfaceFactory's destructor will attempt to return resources which will
37 // call back into here and access |client_| so we should destroy 42 // call back into here and access |client_| so we should destroy
38 // |surface_factory_|'s resources early on. 43 // |surface_factory_|'s resources early on.
39 surface_factory_.EvictSurface(); 44 surface_factory_.EvictSurface();
40 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 45 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
41 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); 46 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
42 } 47 }
43 48
44 void CompositorFrameSinkSupport::EvictFrame() { 49 void CompositorFrameSinkSupport::EvictFrame() {
45 surface_factory_.EvictSurface(); 50 surface_factory_.EvictSurface();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return; 91 return;
87 client_->DidReceiveCompositorFrameAck(); 92 client_->DidReceiveCompositorFrameAck();
88 if (!surface_returned_resources_.empty()) { 93 if (!surface_returned_resources_.empty()) {
89 client_->ReclaimResources(surface_returned_resources_); 94 client_->ReclaimResources(surface_returned_resources_);
90 surface_returned_resources_.clear(); 95 surface_returned_resources_.clear();
91 } 96 }
92 } 97 }
93 98
94 void CompositorFrameSinkSupport::AddChildFrameSink( 99 void CompositorFrameSinkSupport::AddChildFrameSink(
95 const FrameSinkId& child_frame_sink_id) { 100 const FrameSinkId& child_frame_sink_id) {
101 child_frame_sinks_.insert(child_frame_sink_id);
96 surface_manager_->RegisterFrameSinkHierarchy(frame_sink_id_, 102 surface_manager_->RegisterFrameSinkHierarchy(frame_sink_id_,
97 child_frame_sink_id); 103 child_frame_sink_id);
98 } 104 }
99 105
100 void CompositorFrameSinkSupport::RemoveChildFrameSink( 106 void CompositorFrameSinkSupport::RemoveChildFrameSink(
101 const FrameSinkId& child_frame_sink_id) { 107 const FrameSinkId& child_frame_sink_id) {
108 auto it = child_frame_sinks_.find(child_frame_sink_id);
109 DCHECK(it != child_frame_sinks_.end());
110 DCHECK(it->is_valid());
102 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 111 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
103 child_frame_sink_id); 112 child_frame_sink_id);
113 child_frame_sinks_.erase(it);
104 } 114 }
105 115
106 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} 116 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {}
107 117
108 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( 118 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap(
109 bool will_draw_and_swap, 119 bool will_draw_and_swap,
110 const RenderPassList& render_passes) {} 120 const RenderPassList& render_passes) {}
111 121
112 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} 122 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {}
113 123
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return; 174 return;
165 175
166 added_frame_observer_ = needs_begin_frame_; 176 added_frame_observer_ = needs_begin_frame_;
167 if (needs_begin_frame_) 177 if (needs_begin_frame_)
168 begin_frame_source_->AddObserver(this); 178 begin_frame_source_->AddObserver(this);
169 else 179 else
170 begin_frame_source_->RemoveObserver(this); 180 begin_frame_source_->RemoveObserver(this);
171 } 181 }
172 182
173 } // namespace cc 183 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698