OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
16 #include "base/hash.h" | 16 #include "base/hash.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/trace_event/memory_dump_provider.h" | 18 #include "base/trace_event/memory_dump_provider.h" |
| 19 #include "content/browser/gpu/gpu_process_host.h" |
19 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
20 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
21 #include "gpu/ipc/common/surface_handle.h" | 22 #include "gpu/ipc/common/surface_handle.h" |
22 #include "gpu/ipc/host/gpu_memory_buffer_support.h" | 23 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 class GpuProcessHost; | |
26 | 26 |
27 class CONTENT_EXPORT BrowserGpuMemoryBufferManager | 27 class CONTENT_EXPORT BrowserGpuMemoryBufferManager |
28 : public gpu::GpuMemoryBufferManager, | 28 : public gpu::GpuMemoryBufferManager, |
29 public base::trace_event::MemoryDumpProvider { | 29 public base::trace_event::MemoryDumpProvider { |
30 public: | 30 public: |
31 using CreateCallback = | 31 using CreateCallback = |
32 base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>; | 32 base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>; |
33 using AllocationCallback = CreateCallback; | 33 using AllocationCallback = CreateCallback; |
34 | 34 |
35 BrowserGpuMemoryBufferManager(int gpu_client_id, | 35 BrowserGpuMemoryBufferManager(int gpu_client_id, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 gfx::Size size; | 81 gfx::Size size; |
82 gfx::GpuMemoryBufferType type = gfx::EMPTY_BUFFER; | 82 gfx::GpuMemoryBufferType type = gfx::EMPTY_BUFFER; |
83 gfx::BufferFormat format = gfx::BufferFormat::RGBA_8888; | 83 gfx::BufferFormat format = gfx::BufferFormat::RGBA_8888; |
84 gfx::BufferUsage usage = gfx::BufferUsage::GPU_READ; | 84 gfx::BufferUsage usage = gfx::BufferUsage::GPU_READ; |
85 int gpu_host_id = 0; | 85 int gpu_host_id = 0; |
86 }; | 86 }; |
87 | 87 |
88 struct CreateGpuMemoryBufferRequest; | 88 struct CreateGpuMemoryBufferRequest; |
89 | 89 |
90 using CreateDelegate = base::Callback<void(GpuProcessHost* host, | |
91 gfx::GpuMemoryBufferId id, | |
92 const gfx::Size& size, | |
93 gfx::BufferFormat format, | |
94 gfx::BufferUsage usage, | |
95 int client_id, | |
96 const CreateCallback& callback)>; | |
97 | |
98 std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( | 90 std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( |
99 const gfx::Size& size, | 91 const gfx::Size& size, |
100 gfx::BufferFormat format, | 92 gfx::BufferFormat format, |
101 gfx::BufferUsage usage, | 93 gfx::BufferUsage usage, |
102 gpu::SurfaceHandle surface_handle); | 94 gpu::SurfaceHandle surface_handle); |
103 | 95 |
104 // Functions that handle synchronous buffer creation requests. | 96 // Functions that handle synchronous buffer creation requests. |
105 void HandleCreateGpuMemoryBufferOnIO(CreateGpuMemoryBufferRequest* request); | 97 void HandleCreateGpuMemoryBufferOnIO(CreateGpuMemoryBufferRequest* request); |
106 void HandleGpuMemoryBufferCreatedOnIO( | 98 void HandleGpuMemoryBufferCreatedOnIO( |
107 CreateGpuMemoryBufferRequest* request, | 99 CreateGpuMemoryBufferRequest* request, |
108 const gfx::GpuMemoryBufferHandle& handle); | 100 const gfx::GpuMemoryBufferHandle& handle); |
109 | 101 |
110 // Functions that implement asynchronous buffer creation. | 102 // Functions that implement asynchronous buffer creation. |
111 void CreateGpuMemoryBufferOnIO(const CreateDelegate& create_delegate, | 103 void CreateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
112 gfx::GpuMemoryBufferId id, | |
113 const gfx::Size& size, | 104 const gfx::Size& size, |
114 gfx::BufferFormat format, | 105 gfx::BufferFormat format, |
115 gfx::BufferUsage usage, | 106 gfx::BufferUsage usage, |
| 107 gpu::SurfaceHandle surface_handle, |
116 int client_id, | 108 int client_id, |
117 bool reused_gpu_process, | |
118 const CreateCallback& callback); | 109 const CreateCallback& callback); |
119 void GpuMemoryBufferCreatedOnIO(const CreateDelegate& create_delegate, | 110 void GpuMemoryBufferCreatedOnIO(gfx::GpuMemoryBufferId id, |
120 gfx::GpuMemoryBufferId id, | 111 gpu::SurfaceHandle surface_handle, |
121 int client_id, | 112 int client_id, |
122 int gpu_host_id, | 113 int gpu_host_id, |
123 bool reused_gpu_process, | |
124 const CreateCallback& callback, | 114 const CreateCallback& callback, |
125 const gfx::GpuMemoryBufferHandle& handle); | 115 const gfx::GpuMemoryBufferHandle& handle, |
| 116 GpuProcessHost::BufferCreationStatus status); |
126 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 117 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
127 int client_id, | 118 int client_id, |
128 const gpu::SyncToken& sync_token); | 119 const gpu::SyncToken& sync_token); |
129 | 120 |
130 uint64_t ClientIdToTracingProcessId(int client_id) const; | 121 uint64_t ClientIdToTracingProcessId(int client_id) const; |
131 | 122 |
132 const gpu::GpuMemoryBufferConfigurationSet native_configurations_; | 123 const gpu::GpuMemoryBufferConfigurationSet native_configurations_; |
133 const int gpu_client_id_; | 124 const int gpu_client_id_; |
134 const uint64_t gpu_client_tracing_id_; | 125 const uint64_t gpu_client_tracing_id_; |
135 | 126 |
136 // The GPU process host ID. This should only be accessed on the IO thread. | |
137 int gpu_host_id_; | |
138 | |
139 // Stores info about buffers for all clients. This should only be accessed | 127 // Stores info about buffers for all clients. This should only be accessed |
140 // on the IO thread. | 128 // on the IO thread. |
141 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; | 129 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; |
142 using ClientMap = base::hash_map<int, BufferMap>; | 130 using ClientMap = base::hash_map<int, BufferMap>; |
143 ClientMap clients_; | 131 ClientMap clients_; |
144 | 132 |
145 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); | 133 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); |
146 }; | 134 }; |
147 | 135 |
148 } // namespace content | 136 } // namespace content |
149 | 137 |
150 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 138 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
OLD | NEW |