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

Side by Side Diff: services/ui/ws/gpu_service_proxy.cc

Issue 2562623005: mus/gpu: Rename the client/server side memory buffer managers. (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ws/gpu_service_proxy.h" 5 #include "services/ui/ws/gpu_service_proxy.h"
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "gpu/ipc/client/gpu_channel_host.h" 11 #include "gpu/ipc/client/gpu_channel_host.h"
12 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" 12 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 13 #include "mojo/public/cpp/bindings/strong_binding.h"
14 #include "mojo/public/cpp/system/buffer.h" 14 #include "mojo/public/cpp/system/buffer.h"
15 #include "mojo/public/cpp/system/platform_handle.h" 15 #include "mojo/public/cpp/system/platform_handle.h"
16 #include "services/service_manager/public/cpp/connection.h" 16 #include "services/service_manager/public/cpp/connection.h"
17 #include "services/ui/common/mus_gpu_memory_buffer_manager.h" 17 #include "services/ui/common/server_gpu_memory_buffer_manager.h"
18 #include "services/ui/ws/gpu_service_proxy_delegate.h" 18 #include "services/ui/ws/gpu_service_proxy_delegate.h"
19 #include "ui/gfx/buffer_format_util.h" 19 #include "ui/gfx/buffer_format_util.h"
20 20
21 namespace ui { 21 namespace ui {
22 namespace ws { 22 namespace ws {
23 23
24 namespace { 24 namespace {
25 25
26 // The client Id 1 is reserved for the display compositor. 26 // The client Id 1 is reserved for the display compositor.
27 const int32_t kInternalGpuChannelClientId = 2; 27 const int32_t kInternalGpuChannelClientId = 2;
28 28
29 // The implementation that relays requests from clients to the real 29 // The implementation that relays requests from clients to the real
30 // service implementation in the GPU process over mojom.GpuServiceInternal. 30 // service implementation in the GPU process over mojom.GpuServiceInternal.
31 class GpuServiceImpl : public mojom::GpuService { 31 class GpuServiceImpl : public mojom::GpuService {
32 public: 32 public:
33 GpuServiceImpl(int client_id, 33 GpuServiceImpl(int client_id,
34 gpu::GPUInfo* gpu_info, 34 gpu::GPUInfo* gpu_info,
35 MusGpuMemoryBufferManager* gpu_memory_buffer_manager, 35 ServerGpuMemoryBufferManager* gpu_memory_buffer_manager,
36 mojom::GpuServiceInternal* gpu_service_internal) 36 mojom::GpuServiceInternal* gpu_service_internal)
37 : client_id_(client_id), 37 : client_id_(client_id),
38 gpu_info_(gpu_info), 38 gpu_info_(gpu_info),
39 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 39 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
40 gpu_service_internal_(gpu_service_internal) { 40 gpu_service_internal_(gpu_service_internal) {
41 DCHECK(gpu_memory_buffer_manager_); 41 DCHECK(gpu_memory_buffer_manager_);
42 DCHECK(gpu_service_internal_); 42 DCHECK(gpu_service_internal_);
43 } 43 }
44 ~GpuServiceImpl() override { 44 ~GpuServiceImpl() override {
45 gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_); 45 gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const gpu::SyncToken& sync_token) override { 80 const gpu::SyncToken& sync_token) override {
81 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_, 81 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_,
82 sync_token); 82 sync_token);
83 } 83 }
84 84
85 const int client_id_; 85 const int client_id_;
86 86
87 // The objects these pointers refer to are owned by the GpuServiceProxy 87 // The objects these pointers refer to are owned by the GpuServiceProxy
88 // object. 88 // object.
89 const gpu::GPUInfo* gpu_info_; 89 const gpu::GPUInfo* gpu_info_;
90 MusGpuMemoryBufferManager* gpu_memory_buffer_manager_; 90 ServerGpuMemoryBufferManager* gpu_memory_buffer_manager_;
91 mojom::GpuServiceInternal* gpu_service_internal_; 91 mojom::GpuServiceInternal* gpu_service_internal_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(GpuServiceImpl); 93 DISALLOW_COPY_AND_ASSIGN(GpuServiceImpl);
94 }; 94 };
95 95
96 } // namespace 96 } // namespace
97 97
98 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate) 98 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate)
99 : delegate_(delegate), 99 : delegate_(delegate),
100 next_client_id_(kInternalGpuChannelClientId + 1), 100 next_client_id_(kInternalGpuChannelClientId + 1),
101 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) { 101 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {
102 gpu_main_impl_ = base::MakeUnique<GpuMain>(GetProxy(&gpu_main_)); 102 gpu_main_impl_ = base::MakeUnique<GpuMain>(GetProxy(&gpu_main_));
103 gpu_main_impl_->OnStart(); 103 gpu_main_impl_->OnStart();
104 // TODO(sad): Once GPU process is split, this would look like: 104 // TODO(sad): Once GPU process is split, this would look like:
105 // connector->ConnectToInterface("gpu", &gpu_main_); 105 // connector->ConnectToInterface("gpu", &gpu_main_);
106 gpu_main_->CreateGpuService( 106 gpu_main_->CreateGpuService(
107 GetProxy(&gpu_service_), 107 GetProxy(&gpu_service_),
108 base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this))); 108 base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this)));
109 gpu_memory_buffer_manager_ = base::MakeUnique<MusGpuMemoryBufferManager>( 109 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>(
110 gpu_service_.get(), next_client_id_++); 110 gpu_service_.get(), next_client_id_++);
111 } 111 }
112 112
113 GpuServiceProxy::~GpuServiceProxy() { 113 GpuServiceProxy::~GpuServiceProxy() {
114 } 114 }
115 115
116 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { 116 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) {
117 mojo::MakeStrongBinding( 117 mojo::MakeStrongBinding(
118 base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_, 118 base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_,
119 gpu_memory_buffer_manager_.get(), 119 gpu_memory_buffer_manager_.get(),
120 gpu_service_.get()), 120 gpu_service_.get()),
121 std::move(request)); 121 std::move(request));
122 } 122 }
123 123
124 void GpuServiceProxy::CreateDisplayCompositor( 124 void GpuServiceProxy::CreateDisplayCompositor(
125 cc::mojom::DisplayCompositorRequest request, 125 cc::mojom::DisplayCompositorRequest request,
126 cc::mojom::DisplayCompositorClientPtr client) { 126 cc::mojom::DisplayCompositorClientPtr client) {
127 gpu_main_->CreateDisplayCompositor(std::move(request), std::move(client)); 127 gpu_main_->CreateDisplayCompositor(std::move(request), std::move(client));
128 } 128 }
129 129
130 void GpuServiceProxy::OnInitialized(const gpu::GPUInfo& gpu_info) { 130 void GpuServiceProxy::OnInitialized(const gpu::GPUInfo& gpu_info) {
131 gpu_info_ = gpu_info; 131 gpu_info_ = gpu_info;
132 delegate_->OnGpuServiceInitialized(); 132 delegate_->OnGpuServiceInitialized();
133 } 133 }
134 134
135 } // namespace ws 135 } // namespace ws
136 } // namespace ui 136 } // namespace ui
OLDNEW
« services/ui/common/server_gpu_memory_buffer_manager.h ('K') | « services/ui/ws/gpu_service_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698