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

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

Issue 2176303002: services/ui: Remove deprecated gpu code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge 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
« no previous file with comments | « services/ui/public/cpp/BUILD.gn ('k') | services/ui/public/cpp/lib/raster_thread_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 11 matching lines...) Expand all
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 namespace ui { 24 namespace ui {
25 25
26 GLES2Context::GLES2Context() {} 26 GLES2Context::GLES2Context() {}
27 27
28 GLES2Context::~GLES2Context() {} 28 GLES2Context::~GLES2Context() {}
29 29
30 bool GLES2Context::Initialize(const std::vector<int32_t>& attribs, 30 bool GLES2Context::Initialize(const std::vector<int32_t>& attribs,
31 shell::Connector* connector) { 31 shell::Connector* connector) {
32 gpu::CommandBuffer* command_buffer = nullptr; 32 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host =
33 gpu::GpuControl* gpu_control = nullptr; 33 GpuService::GetInstance()->EstablishGpuChannelSync();
34 // TODO(penghuang): Use type gpu::gles2::ContextCreationAttribHelper for 34 if (!gpu_channel_host)
35 // attribs. 35 return false;
36 if (!ui::GpuService::UseChromeGpuCommandBuffer()) { 36 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget;
37 mojom::GpuPtr gpu; 37 // TODO(penghuang): support shared group.
38 connector->ConnectToInterface("mojo:ui", &gpu); 38 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr;
39 mojom::CommandBufferPtr command_buffer_ptr; 39 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT;
40 gpu->CreateOffscreenGLES2Context(GetProxy(&command_buffer_ptr)); 40 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
41 command_buffer_client_impl_.reset( 41 gpu::gles2::ContextCreationAttribHelper attributes;
42 new CommandBufferClientImpl(attribs, std::move(command_buffer_ptr))); 42 // TODO(penghuang): figure a useful active_url.
43 if (!command_buffer_client_impl_->Initialize()) 43 GURL active_url;
44 return false; 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
45 command_buffer = command_buffer_client_impl_.get(); 45 base::ThreadTaskRunnerHandle::Get();
46 gpu_control = command_buffer_client_impl_.get(); 46 if (!attributes.Parse(attribs))
47 } else { 47 return false;
48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = 48 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create(
49 GpuService::GetInstance()->EstablishGpuChannelSync(); 49 std::move(gpu_channel_host), surface_handle, shared_command_buffer,
50 if (!gpu_channel_host) 50 stream_id, stream_priority, attributes, active_url,
51 return false; 51 std::move(task_runner));
52 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; 52 if (!command_buffer_proxy_impl_)
53 // TODO(penghuang): support shared group. 53 return false;
54 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; 54 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get();
55 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; 55 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get();
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 }
73 56
74 constexpr gpu::SharedMemoryLimits default_limits; 57 constexpr gpu::SharedMemoryLimits default_limits;
75 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); 58 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer));
76 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) 59 if (!gles2_helper_->Initialize(default_limits.command_buffer_size))
77 return false; 60 return false;
78 gles2_helper_->SetAutomaticFlushes(false); 61 gles2_helper_->SetAutomaticFlushes(false);
79 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 62 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
80 gpu::Capabilities capabilities = gpu_control->GetCapabilities(); 63 gpu::Capabilities capabilities = gpu_control->GetCapabilities();
81 bool bind_generates_resource = 64 bool bind_generates_resource =
82 !!capabilities.bind_generates_resource_chromium; 65 !!capabilities.bind_generates_resource_chromium;
(...skipping 17 matching lines...) Expand all
100 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( 83 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext(
101 const std::vector<int32_t>& attribs, 84 const std::vector<int32_t>& attribs,
102 shell::Connector* connector) { 85 shell::Connector* connector) {
103 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); 86 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context);
104 if (!gles2_context->Initialize(attribs, connector)) 87 if (!gles2_context->Initialize(attribs, connector))
105 gles2_context.reset(); 88 gles2_context.reset();
106 return gles2_context; 89 return gles2_context;
107 } 90 }
108 91
109 } // namespace ui 92 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/BUILD.gn ('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