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 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 | 10 |
11 ContextProviderMojo::ContextProviderMojo(ScopedMessagePipeHandle gl_pipe) | 11 ContextProviderMojo::ContextProviderMojo( |
12 : gl_pipe_(gl_pipe.Pass()) {} | 12 ScopedMessagePipeHandle command_buffer_handle) |
| 13 : command_buffer_handle_(command_buffer_handle.Pass()) {} |
13 | 14 |
14 bool ContextProviderMojo::BindToCurrentThread() { | 15 bool ContextProviderMojo::BindToCurrentThread() { |
15 DCHECK(gl_pipe_.is_valid()); | 16 DCHECK(command_buffer_handle_.is_valid()); |
16 context_ = MojoGLES2CreateContext( | 17 context_ = MojoGLES2CreateContext( |
17 gl_pipe_.release().value(), &ContextLostThunk, NULL, this); | 18 command_buffer_handle_.release().value(), |
| 19 &ContextLostThunk, |
| 20 NULL, |
| 21 this); |
18 return !!context_; | 22 return !!context_; |
19 } | 23 } |
20 | 24 |
21 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { | 25 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { |
22 if (!context_) | 26 if (!context_) |
23 return NULL; | 27 return NULL; |
24 return static_cast<gpu::gles2::GLES2Interface*>( | 28 return static_cast<gpu::gles2::GLES2Interface*>( |
25 MojoGLES2GetGLES2Interface(context_)); | 29 MojoGLES2GetGLES2Interface(context_)); |
26 } | 30 } |
27 | 31 |
(...skipping 19 matching lines...) Expand all Loading... |
47 } | 51 } |
48 | 52 |
49 void ContextProviderMojo::ContextLost() { | 53 void ContextProviderMojo::ContextLost() { |
50 if (context_) { | 54 if (context_) { |
51 MojoGLES2DestroyContext(context_); | 55 MojoGLES2DestroyContext(context_); |
52 context_ = NULL; | 56 context_ = NULL; |
53 } | 57 } |
54 } | 58 } |
55 | 59 |
56 } // namespace mojo | 60 } // namespace mojo |
OLD | NEW |