OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/mus/public/cpp/gles2_context.h" | 5 #include "components/mus/public/cpp/gles2_context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } else { | 47 } else { |
48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = | 48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = |
49 GpuService::GetInstance()->EstablishGpuChannelSync(); | 49 GpuService::GetInstance()->EstablishGpuChannelSync(); |
50 if (!gpu_channel_host) | 50 if (!gpu_channel_host) |
51 return false; | 51 return false; |
52 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; | 52 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; |
53 // TODO(penghuang): support shared group. | 53 // TODO(penghuang): support shared group. |
54 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; | 54 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; |
55 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; | 55 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; |
56 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 56 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; |
| 57 gl::GpuPreference gpu_preference = gl::PreferIntegratedGpu; |
57 gpu::gles2::ContextCreationAttribHelper attributes; | 58 gpu::gles2::ContextCreationAttribHelper attributes; |
58 // TODO(penghuang): figure a useful active_url. | 59 // TODO(penghuang): figure a useful active_url. |
59 GURL active_url; | 60 GURL active_url; |
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
61 base::ThreadTaskRunnerHandle::Get(); | 62 base::ThreadTaskRunnerHandle::Get(); |
62 if (!attributes.Parse(attribs)) | 63 if (!attributes.Parse(attribs)) |
63 return false; | 64 return false; |
64 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 65 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
65 std::move(gpu_channel_host), surface_handle, shared_command_buffer, | 66 std::move(gpu_channel_host), surface_handle, gfx::Size(), |
66 stream_id, stream_priority, attributes, active_url, | 67 shared_command_buffer, stream_id, stream_priority, attributes, |
67 std::move(task_runner)); | 68 active_url, gpu_preference, std::move(task_runner)); |
68 if (!command_buffer_proxy_impl_) | 69 if (!command_buffer_proxy_impl_) |
69 return false; | 70 return false; |
70 command_buffer = command_buffer_proxy_impl_.get(); | 71 command_buffer = command_buffer_proxy_impl_.get(); |
71 gpu_control = command_buffer_proxy_impl_.get(); | 72 gpu_control = command_buffer_proxy_impl_.get(); |
72 } | 73 } |
73 | 74 |
74 constexpr gpu::SharedMemoryLimits default_limits; | 75 constexpr gpu::SharedMemoryLimits default_limits; |
75 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); | 76 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); |
76 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) | 77 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) |
77 return false; | 78 return false; |
(...skipping 22 matching lines...) Expand all Loading... |
100 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( | 101 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( |
101 const std::vector<int32_t>& attribs, | 102 const std::vector<int32_t>& attribs, |
102 shell::Connector* connector) { | 103 shell::Connector* connector) { |
103 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); | 104 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); |
104 if (!gles2_context->Initialize(attribs, connector)) | 105 if (!gles2_context->Initialize(attribs, connector)) |
105 gles2_context.reset(); | 106 gles2_context.reset(); |
106 return gles2_context; | 107 return gles2_context; |
107 } | 108 } |
108 | 109 |
109 } // namespace mus | 110 } // namespace mus |
OLD | NEW |