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"
11 ContextProviderMojo::ContextProviderMojo(
12 ScopedMessagePipeHandle command_buffer_handle
)
13 : command_buffer_handle_(command_buffer_handle
.Pass()) {}
15 bool ContextProviderMojo::BindToCurrentThread() {
16 DCHECK(command_buffer_handle_
.is_valid());
17 context_
= MojoGLES2CreateContext(
18 command_buffer_handle_
.release().value(),
25 gpu::gles2::GLES2Interface
* ContextProviderMojo::ContextGL() {
28 return static_cast<gpu::gles2::GLES2Interface
*>(
29 MojoGLES2GetGLES2Interface(context_
));
32 gpu::ContextSupport
* ContextProviderMojo::ContextSupport() {
35 return static_cast<gpu::ContextSupport
*>(
36 MojoGLES2GetContextSupport(context_
));
39 class GrContext
* ContextProviderMojo::GrContext() { return NULL
; }
41 cc::ContextProvider::Capabilities
ContextProviderMojo::ContextCapabilities() {
45 bool ContextProviderMojo::IsContextLost() { return !context_
; }
46 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_
; }
48 ContextProviderMojo::~ContextProviderMojo() {
50 MojoGLES2DestroyContext(context_
);
53 void ContextProviderMojo::ContextLost() {
55 MojoGLES2DestroyContext(context_
);