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..1cafcd0493320e04a231ff8192410575843dd196 |
--- /dev/null |
+++ b/components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc |
@@ -0,0 +1,68 @@ |
+// 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/mus/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"); |
Fady Samuel
2015/09/16 00:15:39
mojo:mus now.
Peng
2015/09/16 13:54:59
Done.
|
+ 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): Support share context. |
+ // 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) |
sky
2015/09/15 22:10:58
Under what circumstances is app null?
Peng
2015/09/16 13:54:59
Done.
|
+ return nullptr; |
+ |
+ return new WebGraphicsContext3DCommandBufferImpl( |
+ 0, app, active_url, attributes, shareContext, glInfo); |
sky
2015/09/15 22:10:58
I don't see surface_id_ used. Is it needed?
Peng
2015/09/16 13:54:59
It is not useful right now. Removed.
|
+} |
+ |
+void WebGraphicsContext3DCommandBufferImpl::ContextLost() { |
+ if (context_lost_callback_) |
+ context_lost_callback_->onContextLost(); |
+} |
+ |
+} // namespace html_viewer |