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
3 // found in the LICENSE file.
5 #include "mojo/cc/context_provider_mojo.h"
7 #include "base/logging.h"
8 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
12 ContextProviderMojo::ContextProviderMojo(
13 ScopedMessagePipeHandle command_buffer_handle
)
14 : command_buffer_handle_(command_buffer_handle
.Pass()),
15 context_lost_(false) {
18 bool ContextProviderMojo::BindToCurrentThread() {
19 DCHECK(command_buffer_handle_
.is_valid());
20 context_
= MojoGLES2CreateContext(command_buffer_handle_
.release().value(),
23 Environment::GetDefaultAsyncWaiter());
27 gpu::gles2::GLES2Interface
* ContextProviderMojo::ContextGL() {
30 return static_cast<gpu::gles2::GLES2Interface
*>(
31 MojoGLES2GetGLES2Interface(context_
));
34 gpu::ContextSupport
* ContextProviderMojo::ContextSupport() {
37 return static_cast<gpu::ContextSupport
*>(
38 MojoGLES2GetContextSupport(context_
));
41 class GrContext
* ContextProviderMojo::GrContext() { return NULL
; }
43 cc::ContextProvider::Capabilities
ContextProviderMojo::ContextCapabilities() {
47 void ContextProviderMojo::SetupLock() {
50 base::Lock
* ContextProviderMojo::GetLock() {
51 return &context_lock_
;
54 bool ContextProviderMojo::IsContextLost() {
57 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_
; }
59 ContextProviderMojo::~ContextProviderMojo() {
61 MojoGLES2DestroyContext(context_
);
64 void ContextProviderMojo::ContextLost() {