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

Side by Side Diff: components/html_viewer/web_graphics_context_3d_command_buffer_impl.cc

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 10 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 unified diff | Download patch
OLDNEW
(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 <stdint.h>
8
9 #include "components/html_viewer/blink_basic_type_converters.h"
10 #include "components/html_viewer/global_state.h"
11 #include "components/mus/public/cpp/context_provider.h"
12 #include "components/mus/public/interfaces/gpu.mojom.h"
13 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
14 #include "mojo/gles2/gles2_context.h"
15 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
16 #include "mojo/public/cpp/environment/environment.h"
17 #include "mojo/public/cpp/system/message_pipe.h"
18 #include "mojo/shell/public/cpp/shell.h"
19
20 namespace html_viewer {
21
22 // static
23 WebGraphicsContext3DCommandBufferImpl*
24 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
25 GlobalState* global_state,
26 mojo::Shell* shell,
27 const GURL& active_url,
28 const blink::WebGraphicsContext3D::Attributes& attributes,
29 blink::WebGraphicsContext3D* share_context,
30 blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info) {
31 DCHECK(gl_info);
32 const mus::mojom::GpuInfo* gpu_info = global_state->GetGpuInfo();
33 gl_info->vendorId = gpu_info->vendor_id;
34 gl_info->deviceId = gpu_info->device_id;
35 gl_info->vendorInfo = gpu_info->vendor_info.To<blink::WebString>();
36 gl_info->rendererInfo = gpu_info->renderer_info.To<blink::WebString>();
37 gl_info->driverVersion = gpu_info->driver_version.To<blink::WebString>();
38
39 mus::mojom::GpuPtr gpu_service;
40 shell->ConnectToService("mojo:mus", &gpu_service);
41 mus::mojom::CommandBufferPtr cb;
42 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
43 return new WebGraphicsContext3DCommandBufferImpl(
44 cb.PassInterface(), active_url, attributes, share_context);
45 }
46
47 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
48 mojo::InterfacePtrInfo<mus::mojom::CommandBuffer> command_buffer_info,
49 const GURL& active_url,
50 const blink::WebGraphicsContext3D::Attributes& attributes,
51 blink::WebGraphicsContext3D* share_context) {
52 mojo::ScopedMessagePipeHandle handle(command_buffer_info.PassHandle());
53 CHECK(handle.is_valid());
54 // TODO(penghuang): Support share context.
55 gpu::gles2::ContextCreationAttribHelper attrib_helper;
56 ConvertAttributes(attributes, &attrib_helper);
57 std::vector<int32_t> attrib_vector;
58 attrib_helper.Serialize(&attrib_vector);
59 gles2_context_ = MojoGLES2CreateContext(
60 handle.release().value(),
61 attrib_vector.data(),
62 &ContextLostThunk,
63 this,
64 mojo::Environment::GetDefaultAsyncWaiter());
65 context_gl_.reset(new mojo::MojoGLES2Impl(gles2_context_));
66 setGLInterface(context_gl_.get());
67 }
68
69 WebGraphicsContext3DCommandBufferImpl::
70 ~WebGraphicsContext3DCommandBufferImpl() {
71 if (gles2_context_)
72 MojoGLES2DestroyContext(gles2_context_);
73 }
74
75 void WebGraphicsContext3DCommandBufferImpl::ContextLost() {
76 if (context_lost_callback_)
77 context_lost_callback_->onContextLost();
78 }
79
80 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698