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

Side by Side Diff: services/ui/ws/frame_generator.cc

Issue 2451863003: mus: Fix a teardown crash. (Closed)
Patch Set: . Created 4 years, 1 month 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 | « services/ui/ws/frame_generator.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 "services/ui/ws/frame_generator.h" 5 #include "services/ui/ws/frame_generator.h"
6 6
7 #include "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/quads/render_pass.h" 9 #include "cc/quads/render_pass.h"
10 #include "cc/quads/render_pass_draw_quad.h" 10 #include "cc/quads/render_pass_draw_quad.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 << surface_id.ToString(); 250 << surface_id.ToString();
251 return; 251 return;
252 } 252 }
253 SurfaceDependency dependency = { 253 SurfaceDependency dependency = {
254 surface_id.local_frame_id(), 254 surface_id.local_frame_id(),
255 surface_sequence_generator_.CreateSurfaceSequence()}; 255 surface_sequence_generator_.CreateSurfaceSequence()};
256 surface->AddDestructionDependency(dependency.sequence); 256 surface->AddDestructionDependency(dependency.sequence);
257 dependencies_[surface_id.frame_sink_id()] = dependency; 257 dependencies_[surface_id.frame_sink_id()] = dependency;
258 // Observe |window_surface|'s window so that we can release references when 258 // Observe |window_surface|'s window so that we can release references when
259 // the window is destroyed. 259 // the window is destroyed.
260 if (!window_surface->window()->HasObserver(this)) 260 Add(window_surface->window());
261 window_surface->window()->AddObserver(this);
262 return; 261 return;
263 } 262 }
264 263
265 // We are already holding a reference to this surface so there's no work to do 264 // We are already holding a reference to this surface so there's no work to do
266 // here. 265 // here.
267 if (surface_id.local_frame_id() == it->second.local_frame_id) 266 if (surface_id.local_frame_id() == it->second.local_frame_id)
268 return; 267 return;
269 268
270 // If we have have an existing reference to a surface from the given 269 // If we have have an existing reference to a surface from the given
271 // FrameSink, then we should release the reference, and then add this new 270 // FrameSink, then we should release the reference, and then add this new
(...skipping 24 matching lines...) Expand all
296 void FrameGenerator::ReleaseAllSurfaceReferences() { 295 void FrameGenerator::ReleaseAllSurfaceReferences() {
297 cc::SurfaceManager* surface_manager = display_compositor_->manager(); 296 cc::SurfaceManager* surface_manager = display_compositor_->manager();
298 std::vector<uint32_t> sequences; 297 std::vector<uint32_t> sequences;
299 for (auto& dependency : dependencies_) 298 for (auto& dependency : dependencies_)
300 sequences.push_back(dependency.second.sequence.sequence); 299 sequences.push_back(dependency.second.sequence.sequence);
301 surface_manager->DidSatisfySequences(frame_sink_id_, &sequences); 300 surface_manager->DidSatisfySequences(frame_sink_id_, &sequences);
302 dependencies_.clear(); 301 dependencies_.clear();
303 } 302 }
304 303
305 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { 304 void FrameGenerator::OnWindowDestroying(ServerWindow* window) {
306 window->RemoveObserver(this); 305 Remove(window);
307 ServerWindowCompositorFrameSinkManager* surface_manager = 306 ServerWindowCompositorFrameSinkManager* surface_manager =
308 window->compositor_frame_sink_manager(); 307 window->compositor_frame_sink_manager();
309 // If FrameGenerator was observing |window|, then that means it had a surface 308 // If FrameGenerator was observing |window|, then that means it had a surface
310 // at some point in time and should have a 309 // at some point in time and should have a
311 // ServerWindowCompositorFrameSinkManager. 310 // ServerWindowCompositorFrameSinkManager.
312 DCHECK(surface_manager); 311 DCHECK(surface_manager);
313 ServerWindowCompositorFrameSink* default_compositor_frame_sink = 312 ServerWindowCompositorFrameSink* default_compositor_frame_sink =
314 surface_manager->GetDefaultCompositorFrameSink(); 313 surface_manager->GetDefaultCompositorFrameSink();
315 if (default_compositor_frame_sink) 314 if (default_compositor_frame_sink)
316 ReleaseFrameSinkReference(default_compositor_frame_sink->frame_sink_id()); 315 ReleaseFrameSinkReference(default_compositor_frame_sink->frame_sink_id());
317 ServerWindowCompositorFrameSink* underlay_compositor_frame_sink = 316 ServerWindowCompositorFrameSink* underlay_compositor_frame_sink =
318 surface_manager->GetUnderlayCompositorFrameSink(); 317 surface_manager->GetUnderlayCompositorFrameSink();
319 if (underlay_compositor_frame_sink) 318 if (underlay_compositor_frame_sink)
320 ReleaseFrameSinkReference(underlay_compositor_frame_sink->frame_sink_id()); 319 ReleaseFrameSinkReference(underlay_compositor_frame_sink->frame_sink_id());
321 } 320 }
322 321
323 } // namespace ws 322 } // namespace ws
324 323
325 } // namespace ui 324 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/frame_generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698