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