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

Side by Side Diff: services/ui/public/cpp/lib/gles2_context.cc

Issue 2194893002: services/ui: Revert CLs that broke Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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
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 "services/ui/public/cpp/gles2_context.h" 5 #include "services/ui/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>
11 11
12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
13 #include "gpu/command_buffer/client/shared_memory_limits.h" 13 #include "gpu/command_buffer/client/shared_memory_limits.h"
14 #include "gpu/command_buffer/client/transfer_buffer.h" 14 #include "gpu/command_buffer/client/transfer_buffer.h"
15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 15 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
16 #include "mojo/public/cpp/system/core.h" 16 #include "mojo/public/cpp/system/core.h"
17 #include "services/shell/public/cpp/connector.h"
17 #include "services/ui/common/gpu_service.h" 18 #include "services/ui/common/gpu_service.h"
18 #include "services/ui/public/cpp/lib/command_buffer_client_impl.h" 19 #include "services/ui/public/cpp/lib/command_buffer_client_impl.h"
19 #include "services/ui/public/interfaces/command_buffer.mojom.h" 20 #include "services/ui/public/interfaces/command_buffer.mojom.h"
20 #include "services/ui/public/interfaces/gpu_service.mojom.h" 21 #include "services/ui/public/interfaces/gpu_service.mojom.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 namespace ui { 24 namespace ui {
24 25
25 GLES2Context::GLES2Context() {} 26 GLES2Context::GLES2Context() {}
26 27
27 GLES2Context::~GLES2Context() {} 28 GLES2Context::~GLES2Context() {}
28 29
29 bool GLES2Context::Initialize(const std::vector<int32_t>& attribs) { 30 bool GLES2Context::Initialize(const std::vector<int32_t>& attribs,
30 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = 31 shell::Connector* connector) {
31 GpuService::GetInstance()->EstablishGpuChannelSync(); 32 gpu::CommandBuffer* command_buffer = nullptr;
32 if (!gpu_channel_host) 33 gpu::GpuControl* gpu_control = nullptr;
33 return false; 34 // TODO(penghuang): Use type gpu::gles2::ContextCreationAttribHelper for
34 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; 35 // attribs.
35 // TODO(penghuang): support shared group. 36 if (!ui::GpuService::UseChromeGpuCommandBuffer()) {
36 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; 37 mojom::GpuPtr gpu;
37 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; 38 connector->ConnectToInterface("mojo:ui", &gpu);
38 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; 39 mojom::CommandBufferPtr command_buffer_ptr;
39 gpu::gles2::ContextCreationAttribHelper attributes; 40 gpu->CreateOffscreenGLES2Context(GetProxy(&command_buffer_ptr));
40 // TODO(penghuang): figure a useful active_url. 41 command_buffer_client_impl_.reset(
41 GURL active_url; 42 new CommandBufferClientImpl(attribs, std::move(command_buffer_ptr)));
42 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 43 if (!command_buffer_client_impl_->Initialize())
43 base::ThreadTaskRunnerHandle::Get(); 44 return false;
44 if (!attributes.Parse(attribs)) 45 command_buffer = command_buffer_client_impl_.get();
45 return false; 46 gpu_control = command_buffer_client_impl_.get();
46 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( 47 } else {
47 std::move(gpu_channel_host), surface_handle, shared_command_buffer, 48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host =
48 stream_id, stream_priority, attributes, active_url, 49 GpuService::GetInstance()->EstablishGpuChannelSync();
49 std::move(task_runner)); 50 if (!gpu_channel_host)
50 if (!command_buffer_proxy_impl_) 51 return false;
51 return false; 52 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget;
52 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get(); 53 // TODO(penghuang): support shared group.
53 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get(); 54 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr;
55 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT;
56 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
57 gpu::gles2::ContextCreationAttribHelper attributes;
58 // TODO(penghuang): figure a useful active_url.
59 GURL active_url;
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
61 base::ThreadTaskRunnerHandle::Get();
62 if (!attributes.Parse(attribs))
63 return false;
64 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create(
65 std::move(gpu_channel_host), surface_handle, shared_command_buffer,
66 stream_id, stream_priority, attributes, active_url,
67 std::move(task_runner));
68 if (!command_buffer_proxy_impl_)
69 return false;
70 command_buffer = command_buffer_proxy_impl_.get();
71 gpu_control = command_buffer_proxy_impl_.get();
72 }
54 73
55 constexpr gpu::SharedMemoryLimits default_limits; 74 constexpr gpu::SharedMemoryLimits default_limits;
56 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); 75 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer));
57 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) 76 if (!gles2_helper_->Initialize(default_limits.command_buffer_size))
58 return false; 77 return false;
59 gles2_helper_->SetAutomaticFlushes(false); 78 gles2_helper_->SetAutomaticFlushes(false);
60 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 79 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
61 gpu::Capabilities capabilities = gpu_control->GetCapabilities(); 80 gpu::Capabilities capabilities = gpu_control->GetCapabilities();
62 bool bind_generates_resource = 81 bool bind_generates_resource =
63 !!capabilities.bind_generates_resource_chromium; 82 !!capabilities.bind_generates_resource_chromium;
64 // TODO(piman): Some contexts (such as compositor) want this to be true, so 83 // TODO(piman): Some contexts (such as compositor) want this to be true, so
65 // this needs to be a public parameter. 84 // this needs to be a public parameter.
66 bool lose_context_when_out_of_memory = false; 85 bool lose_context_when_out_of_memory = false;
67 bool support_client_side_arrays = false; 86 bool support_client_side_arrays = false;
68 implementation_.reset(new gpu::gles2::GLES2Implementation( 87 implementation_.reset(new gpu::gles2::GLES2Implementation(
69 gles2_helper_.get(), NULL, transfer_buffer_.get(), 88 gles2_helper_.get(), NULL, transfer_buffer_.get(),
70 bind_generates_resource, lose_context_when_out_of_memory, 89 bind_generates_resource, lose_context_when_out_of_memory,
71 support_client_side_arrays, gpu_control)); 90 support_client_side_arrays, gpu_control));
72 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, 91 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size,
73 default_limits.min_transfer_buffer_size, 92 default_limits.min_transfer_buffer_size,
74 default_limits.max_transfer_buffer_size, 93 default_limits.max_transfer_buffer_size,
75 default_limits.mapped_memory_reclaim_limit)) 94 default_limits.mapped_memory_reclaim_limit))
76 return false; 95 return false;
77 return true; 96 return true;
78 } 97 }
79 98
80 // static 99 // static
81 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( 100 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext(
82 const std::vector<int32_t>& attribs) { 101 const std::vector<int32_t>& attribs,
102 shell::Connector* connector) {
83 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); 103 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context);
84 if (!gles2_context->Initialize(attribs)) 104 if (!gles2_context->Initialize(attribs, connector))
85 gles2_context.reset(); 105 gles2_context.reset();
86 return gles2_context; 106 return gles2_context;
87 } 107 }
88 108
89 } // namespace ui 109 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/lib/context_provider.cc ('k') | services/ui/public/cpp/lib/raster_thread_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698