OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #include "components/html_viewer/web_graphics_context_3d_command_buffer_impl.h" |
| 6 |
| 7 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 8 #include "mojo/application/public/cpp/application_impl.h" |
| 9 #include "mojo/cc/context_provider_mojo.h" |
| 10 #include "mojo/gles2/gles2_context.h" |
| 11 #include "mojo/gpu/mojo_gles2_impl_autogen.h" |
| 12 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" |
| 13 |
| 14 namespace html_viewer { |
| 15 |
| 16 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( |
| 17 mojo::ApplicationImpl* app, |
| 18 const GURL& active_url, |
| 19 const blink::WebGraphicsContext3D::Attributes& attributes, |
| 20 blink::WebGraphicsContext3D* share_context, |
| 21 blink::WebGLInfo* gl_info) { |
| 22 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 23 request->url = mojo::String::From("mojo:mus"); |
| 24 mojo::GpuPtr gpu_service; |
| 25 app->ConnectToService(request.Pass(), &gpu_service); |
| 26 |
| 27 mojo::CommandBufferPtr cb; |
| 28 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 29 command_buffer_handle_ = cb.PassInterface().PassHandle(); |
| 30 CHECK(command_buffer_handle_.is_valid()); |
| 31 // TODO(penghuang): Support share context. |
| 32 // TODO(penghuang): Fill gl_info and pass attribuites to GPU. |
| 33 gles2_context_ = MojoGLES2CreateContext( |
| 34 command_buffer_handle_.release().value(), |
| 35 &ContextLostThunk, |
| 36 this, |
| 37 mojo::Environment::GetDefaultAsyncWaiter()); |
| 38 context_gl_.reset(new mojo::MojoGLES2Impl(gles2_context_)); |
| 39 setGLInterface(context_gl_.get()); |
| 40 } |
| 41 |
| 42 WebGraphicsContext3DCommandBufferImpl:: |
| 43 ~WebGraphicsContext3DCommandBufferImpl() { |
| 44 } |
| 45 |
| 46 // static |
| 47 WebGraphicsContext3DCommandBufferImpl* |
| 48 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 49 mojo::ApplicationImpl* app, |
| 50 const GURL& active_url, |
| 51 const blink::WebGraphicsContext3D::Attributes& attributes, |
| 52 blink::WebGraphicsContext3D* share_context, |
| 53 blink::WebGLInfo* gl_info) { |
| 54 return new WebGraphicsContext3DCommandBufferImpl( |
| 55 app, active_url, attributes, share_context, gl_info); |
| 56 } |
| 57 |
| 58 void WebGraphicsContext3DCommandBufferImpl::ContextLost() { |
| 59 if (context_lost_callback_) |
| 60 context_lost_callback_->onContextLost(); |
| 61 } |
| 62 |
| 63 } // namespace html_viewer |
OLD | NEW |