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/view_manager/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 int surface_id, | |
18 mojo::ApplicationImpl* app, | |
19 const GURL& active_url, | |
20 const blink::WebGraphicsContext3D::Attributes& attributes, | |
21 blink::WebGraphicsContext3D* shareContext, | |
22 blink::WebGLInfo* glInfo) | |
23 : surface_id_(surface_id) { | |
24 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
25 request->url = mojo::String::From("mojo:view_manager"); | |
26 mojo::GpuPtr gpu_service; | |
27 app->ConnectToService(request.Pass(), &gpu_service); | |
28 | |
29 mojo::CommandBufferPtr cb; | |
30 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); | |
31 command_buffer_handle_ = cb.PassInterface().PassHandle(); | |
32 CHECK(command_buffer_handle_.is_valid()); | |
33 // TODO(penghuang): Fill glInfo and pass attribuites to GPU. | |
34 gles2_context_ = MojoGLES2CreateContext( | |
35 command_buffer_handle_.release().value(), | |
36 &ContextLostThunk, | |
37 this, | |
38 mojo::Environment::GetDefaultAsyncWaiter()); | |
39 context_gl_.reset(new mojo::MojoGLES2Impl(gles2_context_)); | |
40 setGLInterface(context_gl_.get()); | |
41 } | |
42 | |
43 WebGraphicsContext3DCommandBufferImpl:: | |
44 ~WebGraphicsContext3DCommandBufferImpl() { | |
45 } | |
46 | |
47 // static | |
48 WebGraphicsContext3DCommandBufferImpl* | |
49 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | |
50 mojo::ApplicationImpl* app, | |
51 const GURL& active_url, | |
52 const blink::WebGraphicsContext3D::Attributes& attributes, | |
53 blink::WebGraphicsContext3D* shareContext, | |
54 blink::WebGLInfo* glInfo) { | |
55 if (!app) | |
56 return nullptr; | |
57 | |
58 return new WebGraphicsContext3DCommandBufferImpl( | |
59 0, app, active_url, attributes, shareContext, glInfo); | |
60 } | |
61 | |
62 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.
| |
63 } | |
64 | |
65 } // namespace html_viewer | |
OLD | NEW |