Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Unified Diff: services/surfaces/context_provider_mojo.cc

Issue 1537803002: Revert "Delete the Surfaces service." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/surfaces/context_provider_mojo.h ('k') | services/surfaces/display_factory_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/surfaces/context_provider_mojo.cc
diff --git a/services/surfaces/context_provider_mojo.cc b/services/surfaces/context_provider_mojo.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9bc4ee53e614900ff5a934a50c603cbed55d5287
--- /dev/null
+++ b/services/surfaces/context_provider_mojo.cc
@@ -0,0 +1,79 @@
+// 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 "services/surfaces/context_provider_mojo.h"
+
+#include "base/logging.h"
+#include "mojo/gpu/mojo_context_support.h"
+#include "mojo/gpu/mojo_gles2_impl_autogen.h"
+#include "mojo/public/cpp/environment/environment.h"
+
+namespace mojo {
+
+ContextProviderMojo::ContextProviderMojo(
+ ScopedMessagePipeHandle command_buffer_handle)
+ : command_buffer_handle_(command_buffer_handle.Pass()),
+ context_(nullptr),
+ context_lost_(false) {
+}
+
+bool ContextProviderMojo::BindToCurrentThread() {
+ DCHECK(command_buffer_handle_.is_valid());
+ context_ = MGLCreateContext(MGL_API_VERSION_GLES2,
+ command_buffer_handle_.release().value(),
+ MGL_NO_CONTEXT, &ContextLostThunk, this,
+ Environment::GetDefaultAsyncWaiter());
+ DCHECK(context_);
+ context_support_.reset(new MojoContextSupport(context_));
+ gles2_impl_.reset(new MojoGLES2Impl(context_));
+ return !!context_;
+}
+
+gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() {
+ return gles2_impl_.get();
+}
+
+gpu::ContextSupport* ContextProviderMojo::ContextSupport() {
+ return context_support_.get();
+}
+
+class GrContext* ContextProviderMojo::GrContext() {
+ return NULL;
+}
+
+cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() {
+ return capabilities_;
+}
+
+void ContextProviderMojo::SetupLock() {
+}
+
+base::Lock* ContextProviderMojo::GetLock() {
+ return &context_lock_;
+}
+
+bool ContextProviderMojo::IsContextLost() {
+ return context_lost_;
+}
+bool ContextProviderMojo::DestroyedOnMainThread() {
+ return !context_;
+}
+
+void ContextProviderMojo::SetLostContextCallback(
+ const LostContextCallback& lost_context_callback) {
+ lost_context_callback_ = lost_context_callback;
+}
+
+ContextProviderMojo::~ContextProviderMojo() {
+ if (context_)
+ MGLDestroyContext(context_);
+}
+
+void ContextProviderMojo::ContextLost() {
+ context_lost_ = true;
+ if (!lost_context_callback_.is_null())
+ lost_context_callback_.Run();
+}
+
+} // namespace mojo
« no previous file with comments | « services/surfaces/context_provider_mojo.h ('k') | services/surfaces/display_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698