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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/message_loop/message_loop.h" | |
13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
14 #include "base/profiler/scoped_tracker.h" | 13 #include "base/profiler/scoped_tracker.h" |
| 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/thread_task_runner_handle.h" |
15 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
17 #include "cc/output/compositor_frame.h" | 18 #include "cc/output/compositor_frame.h" |
18 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
19 #include "cc/raster/task_graph_runner.h" | 20 #include "cc/raster/task_graph_runner.h" |
20 #include "cc/surfaces/onscreen_display_client.h" | 21 #include "cc/surfaces/onscreen_display_client.h" |
21 #include "cc/surfaces/surface_display_output_surface.h" | 22 #include "cc/surfaces/surface_display_output_surface.h" |
22 #include "cc/surfaces/surface_manager.h" | 23 #include "cc/surfaces/surface_manager.h" |
23 #include "content/browser/compositor/browser_compositor_output_surface.h" | 24 #include "content/browser/compositor/browser_compositor_output_surface.h" |
24 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 25 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 url, | 588 url, |
588 gpu_channel_host.get(), | 589 gpu_channel_host.get(), |
589 attrs, | 590 attrs, |
590 lose_context_when_out_of_memory, | 591 lose_context_when_out_of_memory, |
591 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 592 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
592 NULL)); | 593 NULL)); |
593 return context.Pass(); | 594 return context.Pass(); |
594 } | 595 } |
595 | 596 |
596 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { | 597 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { |
597 base::MessageLoop::current()->PostTask( | 598 base::ThreadTaskRunnerHandle::Get()->PostTask( |
598 FROM_HERE, | 599 FROM_HERE, |
599 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, | 600 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, |
600 callback_factory_.GetWeakPtr())); | 601 callback_factory_.GetWeakPtr())); |
601 } | 602 } |
602 | 603 |
603 void GpuProcessTransportFactory::OnLostMainThreadSharedContext() { | 604 void GpuProcessTransportFactory::OnLostMainThreadSharedContext() { |
604 LOG(ERROR) << "Lost UI shared context."; | 605 LOG(ERROR) << "Lost UI shared context."; |
605 | 606 |
606 // Keep old resources around while we call the observers, but ensure that | 607 // Keep old resources around while we call the observers, but ensure that |
607 // new resources are created if needed. | 608 // new resources are created if needed. |
608 // Kill shared contexts for both threads in tandem so they are always in | 609 // Kill shared contexts for both threads in tandem so they are always in |
609 // the same share group. | 610 // the same share group. |
610 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = | 611 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = |
611 shared_main_thread_contexts_; | 612 shared_main_thread_contexts_; |
612 shared_main_thread_contexts_ = NULL; | 613 shared_main_thread_contexts_ = NULL; |
613 | 614 |
614 scoped_ptr<GLHelper> lost_gl_helper = gl_helper_.Pass(); | 615 scoped_ptr<GLHelper> lost_gl_helper = gl_helper_.Pass(); |
615 | 616 |
616 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 617 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
617 observer_list_, | 618 observer_list_, |
618 OnLostResources()); | 619 OnLostResources()); |
619 | 620 |
620 // Kill things that use the shared context before killing the shared context. | 621 // Kill things that use the shared context before killing the shared context. |
621 lost_gl_helper.reset(); | 622 lost_gl_helper.reset(); |
622 lost_shared_main_thread_contexts = NULL; | 623 lost_shared_main_thread_contexts = NULL; |
623 } | 624 } |
624 | 625 |
625 } // namespace content | 626 } // namespace content |
OLD | NEW |