OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 output_surface_map_.Remove(data->surface_id); | 433 output_surface_map_.Remove(data->surface_id); |
434 if (data->surface_id) | 434 if (data->surface_id) |
435 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); | 435 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); |
436 delete data; | 436 delete data; |
437 per_compositor_data_.erase(it); | 437 per_compositor_data_.erase(it); |
438 if (per_compositor_data_.empty()) { | 438 if (per_compositor_data_.empty()) { |
439 // Destroying the GLHelper may cause some async actions to be cancelled, | 439 // Destroying the GLHelper may cause some async actions to be cancelled, |
440 // causing things to request a new GLHelper. Due to crbug.com/176091 the | 440 // causing things to request a new GLHelper. Due to crbug.com/176091 the |
441 // GLHelper created in this case would be lost/leaked if we just reset() | 441 // GLHelper created in this case would be lost/leaked if we just reset() |
442 // on the |gl_helper_| variable directly. So instead we call reset() on a | 442 // on the |gl_helper_| variable directly. So instead we call reset() on a |
443 // local scoped_ptr. | 443 // local std::unique_ptr. |
444 std::unique_ptr<GLHelper> helper = std::move(gl_helper_); | 444 std::unique_ptr<GLHelper> helper = std::move(gl_helper_); |
445 | 445 |
446 // If there are any observer left at this point, make sure they clean up | 446 // If there are any observer left at this point, make sure they clean up |
447 // before we destroy the GLHelper. | 447 // before we destroy the GLHelper. |
448 FOR_EACH_OBSERVER( | 448 FOR_EACH_OBSERVER( |
449 ImageTransportFactoryObserver, observer_list_, OnLostResources()); | 449 ImageTransportFactoryObserver, observer_list_, OnLostResources()); |
450 | 450 |
451 helper.reset(); | 451 helper.reset(); |
452 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " | 452 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " |
453 "GLHelper to be created."; | 453 "GLHelper to be created."; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 675 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
676 observer_list_, | 676 observer_list_, |
677 OnLostResources()); | 677 OnLostResources()); |
678 | 678 |
679 // Kill things that use the shared context before killing the shared context. | 679 // Kill things that use the shared context before killing the shared context. |
680 lost_gl_helper.reset(); | 680 lost_gl_helper.reset(); |
681 lost_shared_main_thread_contexts = NULL; | 681 lost_shared_main_thread_contexts = NULL; |
682 } | 682 } |
683 | 683 |
684 } // namespace content | 684 } // namespace content |
OLD | NEW |