| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/html_viewer/web_graphics_context_3d_command_buffer_impl.h" | 5 #include "components/html_viewer/web_graphics_context_3d_command_buffer_impl.h" |
| 6 | 6 |
| 7 #include "components/mus/public/interfaces/gpu.mojom.h" | 7 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 9 #include "mojo/application/public/cpp/application_impl.h" | 9 #include "mojo/application/public/cpp/application_impl.h" |
| 10 #include "mojo/cc/context_provider_mojo.h" | 10 #include "mojo/cc/context_provider_mojo.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 mojo::GpuPtr gpu_service; | 25 mojo::GpuPtr gpu_service; |
| 26 app->ConnectToService(request.Pass(), &gpu_service); | 26 app->ConnectToService(request.Pass(), &gpu_service); |
| 27 | 27 |
| 28 mojo::CommandBufferPtr cb; | 28 mojo::CommandBufferPtr cb; |
| 29 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); | 29 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 30 command_buffer_handle_ = cb.PassInterface().PassHandle(); | 30 command_buffer_handle_ = cb.PassInterface().PassHandle(); |
| 31 CHECK(command_buffer_handle_.is_valid()); | 31 CHECK(command_buffer_handle_.is_valid()); |
| 32 // TODO(penghuang): Support share context. | 32 // TODO(penghuang): Support share context. |
| 33 // TODO(penghuang): Fill gl_info. | 33 // TODO(penghuang): Fill gl_info. |
| 34 gpu::gles2::ContextCreationAttribHelper attrib_helper; | 34 gpu::gles2::ContextCreationAttribHelper attrib_helper; |
| 35 attrib_helper.alpha_size = attributes.alpha ? 8 : 0; | 35 ConvertAttributes(attributes, &attrib_helper); |
| 36 attrib_helper.depth_size = attributes.depth ? 24 : 0; | |
| 37 attrib_helper.stencil_size = attributes.stencil ? 8 : 0; | |
| 38 attrib_helper.samples = attributes.antialias ? 4 : 0; | |
| 39 attrib_helper.sample_buffers = attributes.antialias ? 1 : 0; | |
| 40 attrib_helper.fail_if_major_perf_caveat = | |
| 41 attributes.failIfMajorPerformanceCaveat; | |
| 42 attrib_helper.bind_generates_resource = false; | |
| 43 attrib_helper.webgl_version = attributes.webGLVersion; | |
| 44 std::vector<int32_t> attrib_vector; | 36 std::vector<int32_t> attrib_vector; |
| 45 attrib_helper.Serialize(&attrib_vector); | 37 attrib_helper.Serialize(&attrib_vector); |
| 46 gles2_context_ = MojoGLES2CreateContext( | 38 gles2_context_ = MojoGLES2CreateContext( |
| 47 command_buffer_handle_.release().value(), | 39 command_buffer_handle_.release().value(), |
| 48 attrib_vector.data(), | 40 attrib_vector.data(), |
| 49 &ContextLostThunk, | 41 &ContextLostThunk, |
| 50 this, | 42 this, |
| 51 mojo::Environment::GetDefaultAsyncWaiter()); | 43 mojo::Environment::GetDefaultAsyncWaiter()); |
| 52 context_gl_.reset(new mojo::MojoGLES2Impl(gles2_context_)); | 44 context_gl_.reset(new mojo::MojoGLES2Impl(gles2_context_)); |
| 53 setGLInterface(context_gl_.get()); | 45 setGLInterface(context_gl_.get()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 return new WebGraphicsContext3DCommandBufferImpl( | 62 return new WebGraphicsContext3DCommandBufferImpl( |
| 71 app, active_url, attributes, share_context, gl_info); | 63 app, active_url, attributes, share_context, gl_info); |
| 72 } | 64 } |
| 73 | 65 |
| 74 void WebGraphicsContext3DCommandBufferImpl::ContextLost() { | 66 void WebGraphicsContext3DCommandBufferImpl::ContextLost() { |
| 75 if (context_lost_callback_) | 67 if (context_lost_callback_) |
| 76 context_lost_callback_->onContextLost(); | 68 context_lost_callback_->onContextLost(); |
| 77 } | 69 } |
| 78 | 70 |
| 79 } // namespace html_viewer | 71 } // namespace html_viewer |
| OLD | NEW |