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

Side by Side Diff: components/viz/common/server_gpu_memory_buffer_manager.h

Issue 2941933002: viz: Convert a sync api in ServerGpuMemoryBufferManager into async. (Closed)
Patch Set: fix test build on windows Created 3 years, 6 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 | « components/viz/common/DEPS ('k') | components/viz/common/server_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
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 #ifndef COMPONENTS_VIZ_COMMON_SERVER_GPU_MEMORY_BUFFER_MANAGER_H_ 5 #ifndef COMPONENTS_VIZ_COMMON_SERVER_GPU_MEMORY_BUFFER_MANAGER_H_
6 #define COMPONENTS_VIZ_COMMON_SERVER_GPU_MEMORY_BUFFER_MANAGER_H_ 6 #define COMPONENTS_VIZ_COMMON_SERVER_GPU_MEMORY_BUFFER_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/synchronization/waitable_event.h"
13 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
14 #include "gpu/ipc/host/gpu_memory_buffer_support.h" 15 #include "gpu/ipc/host/gpu_memory_buffer_support.h"
15 16
16 namespace ui { 17 namespace ui {
17 namespace mojom { 18 namespace mojom {
18 class GpuService; 19 class GpuService;
19 } 20 }
20 } 21 }
21 22
22 namespace viz { 23 namespace viz {
23 24
24 // This GpuMemoryBufferManager implementation is for [de]allocating gpu memory 25 // This GpuMemoryBufferManager implementation is for [de]allocating gpu memory
25 // from the gpu process over the mojom.GpuService api. 26 // from the gpu process over the mojom.GpuService api.
26 class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager, 27 // Note that |CreateGpuMemoryBuffer()| can be called on any thread. All the rest
27 public base::ThreadChecker { 28 // of the functions must be called on the thread this object is created on.
29 class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager {
28 public: 30 public:
29 ServerGpuMemoryBufferManager(ui::mojom::GpuService* gpu_service, 31 ServerGpuMemoryBufferManager(ui::mojom::GpuService* gpu_service,
30 int client_id); 32 int client_id);
31 ~ServerGpuMemoryBufferManager() override; 33 ~ServerGpuMemoryBufferManager() override;
32 34
33 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 35 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
34 int client_id, 36 int client_id,
35 const gpu::SyncToken& sync_token); 37 const gpu::SyncToken& sync_token);
36 38
37 void DestroyAllGpuMemoryBufferForClient(int client_id); 39 void DestroyAllGpuMemoryBufferForClient(int client_id);
38 40
39 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferHandle( 41 void AllocateGpuMemoryBuffer(
40 gfx::GpuMemoryBufferId id, 42 gfx::GpuMemoryBufferId id,
41 int client_id, 43 int client_id,
42 const gfx::Size& size, 44 const gfx::Size& size,
43 gfx::BufferFormat format, 45 gfx::BufferFormat format,
44 gfx::BufferUsage usage, 46 gfx::BufferUsage usage,
45 gpu::SurfaceHandle surface_handle); 47 gpu::SurfaceHandle surface_handle,
48 base::OnceCallback<void(const gfx::GpuMemoryBufferHandle&)> callback);
46 49
47 // Overridden from gpu::GpuMemoryBufferManager: 50 // Overridden from gpu::GpuMemoryBufferManager:
48 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( 51 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer(
49 const gfx::Size& size, 52 const gfx::Size& size,
50 gfx::BufferFormat format, 53 gfx::BufferFormat format,
51 gfx::BufferUsage usage, 54 gfx::BufferUsage usage,
52 gpu::SurfaceHandle surface_handle) override; 55 gpu::SurfaceHandle surface_handle) override;
53 void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, 56 void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
54 const gpu::SyncToken& sync_token) override; 57 const gpu::SyncToken& sync_token) override;
55 58
56 private: 59 private:
60 void OnGpuMemoryBufferAllocated(
61 int client_id,
62 base::OnceCallback<void(const gfx::GpuMemoryBufferHandle&)> callback,
63 const gfx::GpuMemoryBufferHandle& handle);
64
57 ui::mojom::GpuService* gpu_service_; 65 ui::mojom::GpuService* gpu_service_;
58 const int client_id_; 66 const int client_id_;
59 int next_gpu_memory_id_ = 1; 67 int next_gpu_memory_id_ = 1;
60 68
61 using NativeBuffers = 69 using NativeBuffers =
62 std::unordered_set<gfx::GpuMemoryBufferId, 70 std::unordered_set<gfx::GpuMemoryBufferId,
63 BASE_HASH_NAMESPACE::hash<gfx::GpuMemoryBufferId>>; 71 BASE_HASH_NAMESPACE::hash<gfx::GpuMemoryBufferId>>;
64 std::unordered_map<int, NativeBuffers> native_buffers_; 72 std::unordered_map<int, NativeBuffers> native_buffers_;
73 std::unordered_set<int> pending_buffers_;
65 74
66 const gpu::GpuMemoryBufferConfigurationSet native_configurations_; 75 const gpu::GpuMemoryBufferConfigurationSet native_configurations_;
76 scoped_refptr<base::SequencedTaskRunner> task_runner_;
67 base::WeakPtrFactory<ServerGpuMemoryBufferManager> weak_factory_; 77 base::WeakPtrFactory<ServerGpuMemoryBufferManager> weak_factory_;
68 78
69 DISALLOW_COPY_AND_ASSIGN(ServerGpuMemoryBufferManager); 79 DISALLOW_COPY_AND_ASSIGN(ServerGpuMemoryBufferManager);
70 }; 80 };
71 81
72 } // namespace viz 82 } // namespace viz
73 83
74 #endif // COMPONENTS_VIZ_COMMON_SERVER_GPU_MEMORY_BUFFER_MANAGER_H_ 84 #endif // COMPONENTS_VIZ_COMMON_SERVER_GPU_MEMORY_BUFFER_MANAGER_H_
OLDNEW
« no previous file with comments | « components/viz/common/DEPS ('k') | components/viz/common/server_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698