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/feature/compositor/blimp_context_provider.h" | 5 #include "blimp/client/feature/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 "gpu/command_buffer/client/gl_in_process_context.h" | 10 #include "gpu/command_buffer/client/gl_in_process_context.h" |
11 #include "gpu/command_buffer/client/gles2_implementation.h" | 11 #include "gpu/command_buffer/client/gles2_implementation.h" |
12 #include "gpu/command_buffer/client/gles2_lib.h" | 12 #include "gpu/command_buffer/client/gles2_lib.h" |
| 13 #include "gpu/command_buffer/client/shared_memory_limits.h" |
13 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 14 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
14 #include "third_party/skia/include/gpu/GrContext.h" | 15 #include "third_party/skia/include/gpu/GrContext.h" |
15 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 16 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
16 | 17 |
17 namespace blimp { | 18 namespace blimp { |
18 namespace client { | 19 namespace client { |
19 | 20 |
20 // static | 21 // static |
21 scoped_refptr<BlimpContextProvider> BlimpContextProvider::Create( | 22 scoped_refptr<BlimpContextProvider> BlimpContextProvider::Create( |
22 gfx::AcceleratedWidget widget, | 23 gfx::AcceleratedWidget widget, |
(...skipping 13 matching lines...) Expand all Loading... |
36 attribs_for_gles2.samples = 0; | 37 attribs_for_gles2.samples = 0; |
37 attribs_for_gles2.sample_buffers = 0; | 38 attribs_for_gles2.sample_buffers = 0; |
38 attribs_for_gles2.fail_if_major_perf_caveat = false; | 39 attribs_for_gles2.fail_if_major_perf_caveat = false; |
39 attribs_for_gles2.bind_generates_resource = false; | 40 attribs_for_gles2.bind_generates_resource = false; |
40 attribs_for_gles2.context_type = gpu::gles2::CONTEXT_TYPE_OPENGLES2; | 41 attribs_for_gles2.context_type = gpu::gles2::CONTEXT_TYPE_OPENGLES2; |
41 attribs_for_gles2.lose_context_when_out_of_memory = true; | 42 attribs_for_gles2.lose_context_when_out_of_memory = true; |
42 | 43 |
43 context_.reset(gpu::GLInProcessContext::Create( | 44 context_.reset(gpu::GLInProcessContext::Create( |
44 nullptr /* service */, nullptr /* surface */, false /* is_offscreen */, | 45 nullptr /* service */, nullptr /* surface */, false /* is_offscreen */, |
45 widget, gfx::Size(1, 1), nullptr /* share_context */, attribs_for_gles2, | 46 widget, gfx::Size(1, 1), nullptr /* share_context */, attribs_for_gles2, |
46 gfx::PreferDiscreteGpu, gpu::GLInProcessContextSharedMemoryLimits(), | 47 gfx::PreferDiscreteGpu, gpu::SharedMemoryLimits(), |
47 gpu_memory_buffer_manager, nullptr /* memory_limits */)); | 48 gpu_memory_buffer_manager, nullptr /* memory_limits */)); |
48 context_->GetImplementation()->SetLostContextCallback( | 49 context_->GetImplementation()->SetLostContextCallback( |
49 base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this))); | 50 base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this))); |
50 } | 51 } |
51 | 52 |
52 BlimpContextProvider::~BlimpContextProvider() { | 53 BlimpContextProvider::~BlimpContextProvider() { |
53 DCHECK(main_thread_checker_.CalledOnValidThread() || | 54 DCHECK(main_thread_checker_.CalledOnValidThread() || |
54 context_thread_checker_.CalledOnValidThread()); | 55 context_thread_checker_.CalledOnValidThread()); |
55 } | 56 } |
56 | 57 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void BlimpContextProvider::OnLostContext() { | 121 void BlimpContextProvider::OnLostContext() { |
121 DCHECK(context_thread_checker_.CalledOnValidThread()); | 122 DCHECK(context_thread_checker_.CalledOnValidThread()); |
122 if (!lost_context_callback_.is_null()) | 123 if (!lost_context_callback_.is_null()) |
123 lost_context_callback_.Run(); | 124 lost_context_callback_.Run(); |
124 if (gr_context_) | 125 if (gr_context_) |
125 gr_context_->OnLostContext(); | 126 gr_context_->OnLostContext(); |
126 } | 127 } |
127 | 128 |
128 } // namespace client | 129 } // namespace client |
129 } // namespace blimp | 130 } // namespace blimp |
OLD | NEW |