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

Unified Diff: gpu/ipc/client/client_gpu_memory_buffer_manager.h

Issue 2490503002: gpu: A common GpuMemoryBufferManager implemenetation for clients. (Closed)
Patch Set: tot merge Created 4 years, 1 month 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 | « gpu/ipc/client/BUILD.gn ('k') | gpu/ipc/client/client_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/ipc/client/client_gpu_memory_buffer_manager.h
diff --git a/gpu/ipc/client/client_gpu_memory_buffer_manager.h b/gpu/ipc/client/client_gpu_memory_buffer_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ba3c49cf2d6f8c835c1b03fcb737717b3114cdf
--- /dev/null
+++ b/gpu/ipc/client/client_gpu_memory_buffer_manager.h
@@ -0,0 +1,72 @@
+// Copyright 2016 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.
+
+#ifndef GPU_IPC_CLIENT_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_
+#define GPU_IPC_CLIENT_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_
+
+#include "base/memory/ref_counted.h"
+#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+
+// Provides a common implementation for GpuMemoryBufferManager. It uses a
+// delegate interface to get a shared memory handle to use for the buffer.
+// Note that this can be accessed from any thread.
+class GPU_EXPORT ClientGpuMemoryBufferManager
+ : public GpuMemoryBufferManager,
+ public base::RefCountedThreadSafe<ClientGpuMemoryBufferManager> {
+ public:
+ class GPU_EXPORT Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Get a handle to the shared memory. Note that this can be called from
+ // multiple threads. Some of those threads may not have a TaskRunner set.
+ virtual gfx::GpuMemoryBufferHandle GetSharedMemoryHandle(
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage) = 0;
+
+ // To notify when the gpu memory buffer is no longer used.
+ virtual void DeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+ const SyncToken& sync_token) = 0;
+ };
+
+ explicit ClientGpuMemoryBufferManager(Delegate* delegate);
+
+ void reset_delegate() { delegate_ = nullptr; }
+
+ protected:
+ void DeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+ const SyncToken& token);
+
+ // GpuMemoryBufferManager:
+ std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage,
+ SurfaceHandle surface_handle) override;
+ std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle(
+ const gfx::GpuMemoryBufferHandle& handle,
+ const gfx::Size& size,
+ gfx::BufferFormat format) override;
+ gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
+ ClientBuffer buffer) override;
+ void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
+ const SyncToken& sync_token) override;
+
+ private:
+ friend class base::RefCountedThreadSafe<ClientGpuMemoryBufferManager>;
+
+ ~ClientGpuMemoryBufferManager() override;
+
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClientGpuMemoryBufferManager);
+};
+
+} // namespace gpu
+
+#endif // GPU_IPC_CLIENT_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_
« no previous file with comments | « gpu/ipc/client/BUILD.gn ('k') | gpu/ipc/client/client_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698