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

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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 << surface_id.ToString(); 247 << surface_id.ToString();
248 return; 248 return;
249 } 249 }
250 SurfaceDependency dependency = { 250 SurfaceDependency dependency = {
251 surface_id.local_frame_id(), 251 surface_id.local_frame_id(),
252 surface_sequence_generator_.CreateSurfaceSequence()}; 252 surface_sequence_generator_.CreateSurfaceSequence()};
253 surface->AddDestructionDependency(dependency.sequence); 253 surface->AddDestructionDependency(dependency.sequence);
254 dependencies_[surface_id.frame_sink_id()] = dependency; 254 dependencies_[surface_id.frame_sink_id()] = dependency;
255 // Observe |window_surface|'s window so that we can release references when 255 // Observe |window_surface|'s window so that we can release references when
256 // the window is destroyed. 256 // the window is destroyed.
257 if (!window_surface->window()->HasObserver(this)) 257 Add(window_surface->window());
258 window_surface->window()->AddObserver(this);
259 return; 258 return;
260 } 259 }
261 260
262 // We are already holding a reference to this surface so there's no work to do 261 // We are already holding a reference to this surface so there's no work to do
263 // here. 262 // here.
264 if (surface_id.local_frame_id() == it->second.local_frame_id) 263 if (surface_id.local_frame_id() == it->second.local_frame_id)
265 return; 264 return;
266 265
267 // If we have have an existing reference to a surface from the given 266 // If we have have an existing reference to a surface from the given
268 // FrameSink, then we should release the reference, and then add this new 267 // FrameSink, then we should release the reference, and then add this new
(...skipping 24 matching lines...) Expand all
293 void FrameGenerator::ReleaseAllSurfaceReferences() { 292 void FrameGenerator::ReleaseAllSurfaceReferences() {
294 cc::SurfaceManager* surface_manager = display_compositor_->manager(); 293 cc::SurfaceManager* surface_manager = display_compositor_->manager();
295 std::vector<uint32_t> sequences; 294 std::vector<uint32_t> sequences;
296 for (auto& dependency : dependencies_) 295 for (auto& dependency : dependencies_)
297 sequences.push_back(dependency.second.sequence.sequence); 296 sequences.push_back(dependency.second.sequence.sequence);
298 surface_manager->DidSatisfySequences(frame_sink_id_, &sequences); 297 surface_manager->DidSatisfySequences(frame_sink_id_, &sequences);
299 dependencies_.clear(); 298 dependencies_.clear();
300 } 299 }
301 300
302 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { 301 void FrameGenerator::OnWindowDestroying(ServerWindow* window) {
303 window->RemoveObserver(this); 302 ServerWindowTracker::OnWindowDestroying(window);
sky 2016/10/26 17:48:41 Seems weird to call OnWindowDestroying (which is r
sadrul 2016/10/27 04:59:44 Done.
304 ServerWindowCompositorFrameSinkManager* surface_manager = 303 ServerWindowCompositorFrameSinkManager* surface_manager =
305 window->compositor_frame_sink_manager(); 304 window->compositor_frame_sink_manager();
306 // If FrameGenerator was observing |window|, then that means it had a surface 305 // If FrameGenerator was observing |window|, then that means it had a surface
307 // at some point in time and should have a 306 // at some point in time and should have a
308 // ServerWindowCompositorFrameSinkManager. 307 // ServerWindowCompositorFrameSinkManager.
309 DCHECK(surface_manager); 308 DCHECK(surface_manager);
310 ServerWindowCompositorFrameSink* default_compositor_frame_sink = 309 ServerWindowCompositorFrameSink* default_compositor_frame_sink =
311 surface_manager->GetDefaultCompositorFrameSink(); 310 surface_manager->GetDefaultCompositorFrameSink();
312 if (default_compositor_frame_sink) 311 if (default_compositor_frame_sink)
313 ReleaseFrameSinkReference(default_compositor_frame_sink->frame_sink_id()); 312 ReleaseFrameSinkReference(default_compositor_frame_sink->frame_sink_id());
314 ServerWindowCompositorFrameSink* underlay_compositor_frame_sink = 313 ServerWindowCompositorFrameSink* underlay_compositor_frame_sink =
315 surface_manager->GetUnderlayCompositorFrameSink(); 314 surface_manager->GetUnderlayCompositorFrameSink();
316 if (underlay_compositor_frame_sink) 315 if (underlay_compositor_frame_sink)
317 ReleaseFrameSinkReference(underlay_compositor_frame_sink->frame_sink_id()); 316 ReleaseFrameSinkReference(underlay_compositor_frame_sink->frame_sink_id());
318 } 317 }
319 318
320 } // namespace ws 319 } // namespace ws
321 320
322 } // namespace ui 321 } // 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