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 "mojo/gpu/mojo_gles2_impl_autogen.h"
9 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
13 ContextProviderMojo::ContextProviderMojo(
14 ScopedMessagePipeHandle command_buffer_handle
)
15 : command_buffer_handle_(command_buffer_handle
.Pass()) {
18 bool ContextProviderMojo::BindToCurrentThread() {
19 DCHECK(command_buffer_handle_
.is_valid());
20 context_
= MojoGLES2CreateContext(command_buffer_handle_
.release().value(),
23 Environment::GetDefaultAsyncWaiter());
24 context_gl_
.reset(new MojoGLES2Impl(context_
));
28 gpu::gles2::GLES2Interface
* ContextProviderMojo::ContextGL() {
29 return context_gl_
.get();
32 gpu::ContextSupport
* ContextProviderMojo::ContextSupport() {
35 return static_cast<gpu::ContextSupport
*>(
36 MojoGLES2GetContextSupport(context_
));
39 class GrContext
* ContextProviderMojo::GrContext() { return NULL
; }
41 void ContextProviderMojo::InvalidateGrContext(uint32_t state
) {
44 cc::ContextProvider::Capabilities
ContextProviderMojo::ContextCapabilities() {
48 void ContextProviderMojo::SetupLock() {
51 base::Lock
* ContextProviderMojo::GetLock() {
52 return &context_lock_
;
55 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_
; }
57 ContextProviderMojo::~ContextProviderMojo() {
60 MojoGLES2DestroyContext(context_
);
63 void ContextProviderMojo::ContextLost() {