OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/support/compositor/blimp_context_provider.h" | 5 #include "blimp/client/support/compositor/blimp_context_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
10 #include "cc/output/context_cache_controller.h" | 11 #include "cc/output/context_cache_controller.h" |
11 #include "gpu/command_buffer/client/gl_in_process_context.h" | 12 #include "gpu/command_buffer/client/gl_in_process_context.h" |
12 #include "gpu/command_buffer/client/gles2_implementation.h" | 13 #include "gpu/command_buffer/client/gles2_implementation.h" |
13 #include "gpu/command_buffer/client/gles2_lib.h" | 14 #include "gpu/command_buffer/client/gles2_lib.h" |
14 #include "gpu/command_buffer/client/shared_memory_limits.h" | 15 #include "gpu/command_buffer/client/shared_memory_limits.h" |
15 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 16 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
16 #include "third_party/skia/include/gpu/GrContext.h" | 17 #include "third_party/skia/include/gpu/GrContext.h" |
17 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 18 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
18 | 19 |
19 namespace blimp { | 20 namespace blimp { |
(...skipping 15 matching lines...) Expand all Loading... |
35 attribs_for_gles2.alpha_size = 8; | 36 attribs_for_gles2.alpha_size = 8; |
36 attribs_for_gles2.depth_size = 0; | 37 attribs_for_gles2.depth_size = 0; |
37 attribs_for_gles2.stencil_size = 0; | 38 attribs_for_gles2.stencil_size = 0; |
38 attribs_for_gles2.samples = 0; | 39 attribs_for_gles2.samples = 0; |
39 attribs_for_gles2.sample_buffers = 0; | 40 attribs_for_gles2.sample_buffers = 0; |
40 attribs_for_gles2.fail_if_major_perf_caveat = false; | 41 attribs_for_gles2.fail_if_major_perf_caveat = false; |
41 attribs_for_gles2.bind_generates_resource = false; | 42 attribs_for_gles2.bind_generates_resource = false; |
42 attribs_for_gles2.context_type = gpu::gles2::CONTEXT_TYPE_OPENGLES2; | 43 attribs_for_gles2.context_type = gpu::gles2::CONTEXT_TYPE_OPENGLES2; |
43 attribs_for_gles2.lose_context_when_out_of_memory = true; | 44 attribs_for_gles2.lose_context_when_out_of_memory = true; |
44 | 45 |
| 46 auto task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 47 |
45 context_.reset(gpu::GLInProcessContext::Create( | 48 context_.reset(gpu::GLInProcessContext::Create( |
46 nullptr /* service */, nullptr /* surface */, | 49 nullptr /* service */, nullptr /* surface */, |
47 widget == gfx::kNullAcceleratedWidget /* is_offscreen */, widget, | 50 widget == gfx::kNullAcceleratedWidget /* is_offscreen */, widget, |
48 nullptr /* share_context */, attribs_for_gles2, gpu::SharedMemoryLimits(), | 51 nullptr /* share_context */, attribs_for_gles2, gpu::SharedMemoryLimits(), |
49 gpu_memory_buffer_manager, nullptr /* memory_limits */)); | 52 gpu_memory_buffer_manager, nullptr /* memory_limits */, task_runner)); |
50 context_->GetImplementation()->SetLostContextCallback( | 53 context_->GetImplementation()->SetLostContextCallback( |
51 base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this))); | 54 base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this))); |
52 | 55 |
53 cache_controller_.reset( | 56 cache_controller_.reset(new cc::ContextCacheController( |
54 new cc::ContextCacheController(context_->GetImplementation())); | 57 context_->GetImplementation(), std::move(task_runner))); |
55 } | 58 } |
56 | 59 |
57 BlimpContextProvider::~BlimpContextProvider() { | 60 BlimpContextProvider::~BlimpContextProvider() { |
58 DCHECK(main_thread_checker_.CalledOnValidThread() || | 61 DCHECK(main_thread_checker_.CalledOnValidThread() || |
59 context_thread_checker_.CalledOnValidThread()); | 62 context_thread_checker_.CalledOnValidThread()); |
60 } | 63 } |
61 | 64 |
62 bool BlimpContextProvider::BindToCurrentThread() { | 65 bool BlimpContextProvider::BindToCurrentThread() { |
63 DCHECK(context_thread_checker_.CalledOnValidThread()); | 66 DCHECK(context_thread_checker_.CalledOnValidThread()); |
64 return true; | 67 return true; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void BlimpContextProvider::OnLostContext() { | 124 void BlimpContextProvider::OnLostContext() { |
122 DCHECK(context_thread_checker_.CalledOnValidThread()); | 125 DCHECK(context_thread_checker_.CalledOnValidThread()); |
123 if (!lost_context_callback_.is_null()) | 126 if (!lost_context_callback_.is_null()) |
124 lost_context_callback_.Run(); | 127 lost_context_callback_.Run(); |
125 if (gr_context_) | 128 if (gr_context_) |
126 gr_context_->OnLostContext(); | 129 gr_context_->OnLostContext(); |
127 } | 130 } |
128 | 131 |
129 } // namespace client | 132 } // namespace client |
130 } // namespace blimp | 133 } // namespace blimp |
OLD | NEW |