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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef GPU_IPC_CLIENT_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_
6 #define GPU_IPC_CLIENT_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
10 #include "gpu/gpu_export.h"
11
12 namespace gpu {
13
14 // Provides a common implementation for GpuMemoryBufferManager. It uses a
15 // delegate interface to get a shared memory handle to use for the buffer.
16 // Note that this can be accessed from any thread.
17 class GPU_EXPORT ClientGpuMemoryBufferManager
18 : public GpuMemoryBufferManager,
19 public base::RefCountedThreadSafe<ClientGpuMemoryBufferManager> {
20 public:
21 class GPU_EXPORT Delegate {
22 public:
23 virtual ~Delegate() {}
24
25 // Get a handle to the shared memory. Note that this can be called from
26 // multiple threads. Some of those threads may not have a TaskRunner set.
27 virtual gfx::GpuMemoryBufferHandle GetSharedMemoryHandle(
28 const gfx::Size& size,
29 gfx::BufferFormat format,
30 gfx::BufferUsage usage) = 0;
31
32 // To notify when the gpu memory buffer is no longer used.
33 virtual void DeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
34 const SyncToken& sync_token) = 0;
35 };
36
37 explicit ClientGpuMemoryBufferManager(Delegate* delegate);
38
39 void reset_delegate() { delegate_ = nullptr; }
40
41 protected:
42 void DeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
43 const SyncToken& token);
44
45 // GpuMemoryBufferManager:
46 std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
47 const gfx::Size& size,
48 gfx::BufferFormat format,
49 gfx::BufferUsage usage,
50 SurfaceHandle surface_handle) override;
51 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle(
52 const gfx::GpuMemoryBufferHandle& handle,
53 const gfx::Size& size,
54 gfx::BufferFormat format) override;
55 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
56 ClientBuffer buffer) override;
57 void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
58 const SyncToken& sync_token) override;
59
60 private:
61 friend class base::RefCountedThreadSafe<ClientGpuMemoryBufferManager>;
62
63 ~ClientGpuMemoryBufferManager() override;
64
65 Delegate* delegate_;
66
67 DISALLOW_COPY_AND_ASSIGN(ClientGpuMemoryBufferManager);
68 };
69
70 } // namespace gpu
71
72 #endif // GPU_IPC_CLIENT_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_
OLDNEW
« 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