| 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) { |
| 15 } |
| 14 | 16 |
| 15 bool ContextProviderMojo::BindToCurrentThread() { | 17 bool ContextProviderMojo::BindToCurrentThread() { |
| 16 DCHECK(command_buffer_handle_.is_valid()); | 18 DCHECK(command_buffer_handle_.is_valid()); |
| 17 context_ = MojoGLES2CreateContext( | 19 context_ = MojoGLES2CreateContext( |
| 18 command_buffer_handle_.release().value(), | 20 command_buffer_handle_.release().value(), |
| 19 &ContextLostThunk, | 21 &ContextLostThunk, |
| 20 NULL, | 22 NULL, |
| 21 this); | 23 this); |
| 22 return !!context_; | 24 return !!context_; |
| 23 } | 25 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 return static_cast<gpu::ContextSupport*>( | 37 return static_cast<gpu::ContextSupport*>( |
| 36 MojoGLES2GetContextSupport(context_)); | 38 MojoGLES2GetContextSupport(context_)); |
| 37 } | 39 } |
| 38 | 40 |
| 39 class GrContext* ContextProviderMojo::GrContext() { return NULL; } | 41 class GrContext* ContextProviderMojo::GrContext() { return NULL; } |
| 40 | 42 |
| 41 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() { | 43 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() { |
| 42 return capabilities_; | 44 return capabilities_; |
| 43 } | 45 } |
| 44 | 46 |
| 45 bool ContextProviderMojo::IsContextLost() { return !context_; } | 47 bool ContextProviderMojo::IsContextLost() { |
| 48 return context_lost_; |
| 49 } |
| 46 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; } | 50 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; } |
| 47 | 51 |
| 48 ContextProviderMojo::~ContextProviderMojo() { | 52 ContextProviderMojo::~ContextProviderMojo() { |
| 49 if (context_) | 53 if (context_) |
| 50 MojoGLES2DestroyContext(context_); | 54 MojoGLES2DestroyContext(context_); |
| 51 } | 55 } |
| 52 | 56 |
| 53 void ContextProviderMojo::ContextLost() { | 57 void ContextProviderMojo::ContextLost() { |
| 54 if (context_) { | 58 context_lost_ = true; |
| 55 MojoGLES2DestroyContext(context_); | |
| 56 context_ = NULL; | |
| 57 } | |
| 58 } | 59 } |
| 59 | 60 |
| 60 } // namespace mojo | 61 } // namespace mojo |
| OLD | NEW |