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

Unified Diff: components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc

Issue 1338433002: Mandoline: Add WebGL support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change --enable-webgl to --disable-webgl Created 5 years, 3 months 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
Index: components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc
diff --git a/components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc b/components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4602f30a63972126ddf61a42f81a1892c15029a2
--- /dev/null
+++ b/components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc
@@ -0,0 +1,65 @@
+// Copyright 2015 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 "components/html_viewer/web_graphics_context_3d_command_buffer_impl.h"
+
+#include "components/view_manager/public/interfaces/gpu.mojom.h"
+#include "mojo/application/public/cpp/application_impl.h"
+#include "mojo/cc/context_provider_mojo.h"
+#include "mojo/gles2/gles2_context.h"
+#include "mojo/gpu/mojo_gles2_impl_autogen.h"
+#include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
+
+namespace html_viewer {
+
+WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
+ int surface_id,
+ mojo::ApplicationImpl* app,
+ const GURL& active_url,
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ blink::WebGraphicsContext3D* shareContext,
+ blink::WebGLInfo* glInfo)
+ : surface_id_(surface_id) {
+ mojo::URLRequestPtr request(mojo::URLRequest::New());
+ request->url = mojo::String::From("mojo:view_manager");
+ mojo::GpuPtr gpu_service;
+ app->ConnectToService(request.Pass(), &gpu_service);
+
+ mojo::CommandBufferPtr cb;
+ gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
+ command_buffer_handle_ = cb.PassInterface().PassHandle();
+ CHECK(command_buffer_handle_.is_valid());
+ // TODO(penghuang): Fill glInfo and pass attribuites to GPU.
+ gles2_context_ = MojoGLES2CreateContext(
+ command_buffer_handle_.release().value(),
+ &ContextLostThunk,
+ this,
+ mojo::Environment::GetDefaultAsyncWaiter());
+ context_gl_.reset(new mojo::MojoGLES2Impl(gles2_context_));
+ setGLInterface(context_gl_.get());
+}
+
+WebGraphicsContext3DCommandBufferImpl::
+ ~WebGraphicsContext3DCommandBufferImpl() {
+}
+
+// static
+WebGraphicsContext3DCommandBufferImpl*
+WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
+ mojo::ApplicationImpl* app,
+ const GURL& active_url,
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ blink::WebGraphicsContext3D* shareContext,
+ blink::WebGLInfo* glInfo) {
+ if (!app)
+ return nullptr;
+
+ return new WebGraphicsContext3DCommandBufferImpl(
+ 0, app, active_url, attributes, shareContext, glInfo);
+}
+
+void WebGraphicsContext3DCommandBufferImpl::ContextLost() {
piman 2015/09/14 21:17:12 You'll need to wire that to context_lost_callback_
Peng 2015/09/15 15:07:30 Done.
+}
+
+} // namespace html_viewer

Powered by Google App Engine
This is Rietveld 408576698