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

Unified Diff: services/ui/ws/gpu_client.cc

Issue 2741343003: Update liftetime management of GpuClient (Closed)
Patch Set: fix x11 re-definition Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/gpu_client.h ('k') | services/ui/ws/gpu_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/gpu_client.cc
diff --git a/services/ui/ws/gpu_client.cc b/services/ui/ws/gpu_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c0ec4e6b5286054068e08380c6c5e083a8394106
--- /dev/null
+++ b/services/ui/ws/gpu_client.cc
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/ui/ws/gpu_client.h"
+
+#include "services/ui/common/server_gpu_memory_buffer_manager.h"
+#include "services/ui/gpu/interfaces/gpu_service.mojom.h"
+
+namespace ui {
+namespace ws {
+
+GpuClient::GpuClient(int client_id,
+ gpu::GPUInfo* gpu_info,
+ ServerGpuMemoryBufferManager* gpu_memory_buffer_manager,
+ mojom::GpuService* gpu_service)
+ : client_id_(client_id),
+ gpu_info_(gpu_info),
+ gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
+ gpu_service_(gpu_service),
+ weak_factory_(this) {
+ DCHECK(gpu_memory_buffer_manager_);
+ DCHECK(gpu_service_);
+}
+
+GpuClient::~GpuClient() {
+ gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_);
+}
+
+void GpuClient::OnGpuChannelEstablished(
+ const EstablishGpuChannelCallback& callback,
+ mojo::ScopedMessagePipeHandle channel_handle) {
+ callback.Run(client_id_, std::move(channel_handle), *gpu_info_);
+}
+
+// mojom::Gpu overrides:
+void GpuClient::EstablishGpuChannel(
+ const EstablishGpuChannelCallback& callback) {
+ // TODO(sad): crbug.com/617415 figure out how to generate a meaningful
+ // tracing id.
+ const uint64_t client_tracing_id = 0;
+ constexpr bool is_gpu_host = false;
+ gpu_service_->EstablishGpuChannel(
+ client_id_, client_tracing_id, is_gpu_host,
+ base::Bind(&GpuClient::OnGpuChannelEstablished,
+ weak_factory_.GetWeakPtr(), callback));
+}
+
+void GpuClient::CreateGpuMemoryBuffer(
+ gfx::GpuMemoryBufferId id,
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage,
+ const mojom::Gpu::CreateGpuMemoryBufferCallback& callback) {
+ auto handle = gpu_memory_buffer_manager_->CreateGpuMemoryBufferHandle(
+ id, client_id_, size, format, usage, gpu::kNullSurfaceHandle);
+ callback.Run(handle);
+}
+
+void GpuClient::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+ const gpu::SyncToken& sync_token) {
+ gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_,
+ sync_token);
+}
+
+} // namespace ws
+} // namespace ui
« no previous file with comments | « services/ui/ws/gpu_client.h ('k') | services/ui/ws/gpu_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698