summaryrefslogtreecommitdiffstats
path: root/chromium/mojo/cc/context_provider_mojo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/mojo/cc/context_provider_mojo.cc')
-rw-r--r--chromium/mojo/cc/context_provider_mojo.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/chromium/mojo/cc/context_provider_mojo.cc b/chromium/mojo/cc/context_provider_mojo.cc
new file mode 100644
index 00000000000..7356b587c40
--- /dev/null
+++ b/chromium/mojo/cc/context_provider_mojo.cc
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/cc/context_provider_mojo.h"
+
+#include "base/logging.h"
+
+namespace mojo {
+
+ContextProviderMojo::ContextProviderMojo(
+ ScopedMessagePipeHandle command_buffer_handle)
+ : command_buffer_handle_(command_buffer_handle.Pass()) {}
+
+bool ContextProviderMojo::BindToCurrentThread() {
+ DCHECK(command_buffer_handle_.is_valid());
+ context_ = MojoGLES2CreateContext(
+ command_buffer_handle_.release().value(),
+ &ContextLostThunk,
+ NULL,
+ this);
+ return !!context_;
+}
+
+gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() {
+ if (!context_)
+ return NULL;
+ return static_cast<gpu::gles2::GLES2Interface*>(
+ MojoGLES2GetGLES2Interface(context_));
+}
+
+gpu::ContextSupport* ContextProviderMojo::ContextSupport() {
+ if (!context_)
+ return NULL;
+ return static_cast<gpu::ContextSupport*>(
+ MojoGLES2GetContextSupport(context_));
+}
+
+class GrContext* ContextProviderMojo::GrContext() { return NULL; }
+
+cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() {
+ return capabilities_;
+}
+
+bool ContextProviderMojo::IsContextLost() { return !context_; }
+bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; }
+
+ContextProviderMojo::~ContextProviderMojo() {
+ if (context_)
+ MojoGLES2DestroyContext(context_);
+}
+
+void ContextProviderMojo::ContextLost() {
+ if (context_) {
+ MojoGLES2DestroyContext(context_);
+ context_ = NULL;
+ }
+}
+
+} // namespace mojo