GN: Stop setting android.jar in both -classpath and -bootclasspath
[chromium-blink-merge.git] / mojo / cc / context_provider_mojo.cc
blob801d9f5e478b0322c8863a47a86390e906ef7473
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/gles2/gles2_context.h"
9 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
10 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
12 namespace mojo {
14 ContextProviderMojo::ContextProviderMojo(
15 ScopedMessagePipeHandle command_buffer_handle)
16 : command_buffer_handle_(command_buffer_handle.Pass()),
17 context_(nullptr) {
18 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The
19 // implementation of which is used in CommandBufferDriver.
20 capabilities_.gpu.image = true;
23 bool ContextProviderMojo::BindToCurrentThread() {
24 DCHECK(command_buffer_handle_.is_valid());
25 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(),
26 &ContextLostThunk,
27 this,
28 Environment::GetDefaultAsyncWaiter());
29 context_gl_.reset(new MojoGLES2Impl(context_));
30 return !!context_;
33 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() {
34 return context_gl_.get();
37 gpu::ContextSupport* ContextProviderMojo::ContextSupport() {
38 if (!context_)
39 return NULL;
40 // TODO(rjkroege): Ensure that UIP does not take this code path.
41 return static_cast<gles2::GLES2Context*>(context_)->context_support();
44 class GrContext* ContextProviderMojo::GrContext() { return NULL; }
46 void ContextProviderMojo::InvalidateGrContext(uint32_t state) {
49 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() {
50 return capabilities_;
53 void ContextProviderMojo::SetupLock() {
56 base::Lock* ContextProviderMojo::GetLock() {
57 return &context_lock_;
60 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; }
62 ContextProviderMojo::~ContextProviderMojo() {
63 context_gl_.reset();
64 if (context_)
65 MojoGLES2DestroyContext(context_);
68 void ContextProviderMojo::ContextLost() {
71 } // namespace mojo