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 "mojo/cc/context_provider_mojo.h" | 5 #include "mojo/cc/context_provider_mojo.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/gles2/gles2_context.h" | 8 #include "mojo/gles2/gles2_context.h" |
9 #include "mojo/gpu/mojo_gles2_impl_autogen.h" | 9 #include "mojo/gpu/mojo_gles2_impl_autogen.h" |
10 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" | 10 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 | 13 |
14 ContextProviderMojo::ContextProviderMojo( | 14 ContextProviderMojo::ContextProviderMojo( |
15 ScopedMessagePipeHandle command_buffer_handle) | 15 ScopedMessagePipeHandle command_buffer_handle) |
16 : command_buffer_handle_(command_buffer_handle.Pass()), | 16 : command_buffer_handle_(command_buffer_handle.Pass()), |
17 context_(nullptr) { | 17 context_(nullptr) { |
18 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The | 18 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The |
19 // implementation of which is used in CommandBufferDriver. | 19 // implementation of which is used in CommandBufferDriver. |
20 capabilities_.gpu.image = true; | 20 capabilities_.gpu.image = true; |
21 } | 21 } |
22 | 22 |
23 bool ContextProviderMojo::BindToCurrentThread() { | 23 bool ContextProviderMojo::BindToCurrentThread() { |
24 DCHECK(command_buffer_handle_.is_valid()); | 24 DCHECK(command_buffer_handle_.is_valid()); |
25 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), | 25 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), |
| 26 nullptr, |
26 &ContextLostThunk, | 27 &ContextLostThunk, |
27 this, | 28 this, |
28 Environment::GetDefaultAsyncWaiter()); | 29 Environment::GetDefaultAsyncWaiter()); |
29 context_gl_.reset(new MojoGLES2Impl(context_)); | 30 context_gl_.reset(new MojoGLES2Impl(context_)); |
30 return !!context_; | 31 return !!context_; |
31 } | 32 } |
32 | 33 |
33 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { | 34 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { |
34 return context_gl_.get(); | 35 return context_gl_.get(); |
35 } | 36 } |
(...skipping 26 matching lines...) Expand all Loading... |
62 ContextProviderMojo::~ContextProviderMojo() { | 63 ContextProviderMojo::~ContextProviderMojo() { |
63 context_gl_.reset(); | 64 context_gl_.reset(); |
64 if (context_) | 65 if (context_) |
65 MojoGLES2DestroyContext(context_); | 66 MojoGLES2DestroyContext(context_); |
66 } | 67 } |
67 | 68 |
68 void ContextProviderMojo::ContextLost() { | 69 void ContextProviderMojo::ContextLost() { |
69 } | 70 } |
70 | 71 |
71 } // namespace mojo | 72 } // namespace mojo |
OLD | NEW |