Add ICU message format support
[chromium-blink-merge.git] / mojo / cc / context_provider_mojo.cc
blob0d27f7153c81aaa07f0537e008dd1371abd6da80
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"
11 namespace mojo {
13 ContextProviderMojo::ContextProviderMojo(
14 ScopedMessagePipeHandle command_buffer_handle)
15 : command_buffer_handle_(command_buffer_handle.Pass()) {
16 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The
17 // implementation of which is used in CommandBufferDriver.
18 capabilities_.gpu.image = true;
21 bool ContextProviderMojo::BindToCurrentThread() {
22 DCHECK(command_buffer_handle_.is_valid());
23 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(),
24 &ContextLostThunk,
25 this,
26 Environment::GetDefaultAsyncWaiter());
27 context_gl_.reset(new MojoGLES2Impl(context_));
28 return !!context_;
31 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() {
32 return context_gl_.get();
35 gpu::ContextSupport* ContextProviderMojo::ContextSupport() {
36 if (!context_)
37 return NULL;
38 return static_cast<gpu::ContextSupport*>(
39 MojoGLES2GetContextSupport(context_));
42 class GrContext* ContextProviderMojo::GrContext() { return NULL; }
44 void ContextProviderMojo::InvalidateGrContext(uint32_t state) {
47 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() {
48 return capabilities_;
51 void ContextProviderMojo::SetupLock() {
54 base::Lock* ContextProviderMojo::GetLock() {
55 return &context_lock_;
58 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; }
60 ContextProviderMojo::~ContextProviderMojo() {
61 context_gl_.reset();
62 if (context_)
63 MojoGLES2DestroyContext(context_);
66 void ContextProviderMojo::ContextLost() {
69 } // namespace mojo