| 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/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 20 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 21 #include "gpu/ipc/common/surface_handle.h" | 21 #include "gpu/ipc/common/surface_handle.h" |
| 22 | 22 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
| 23 namespace content { | |
| 24 | |
| 25 using GpuMemoryBufferConfigurationKey = | |
| 26 std::pair<gfx::BufferFormat, gfx::BufferUsage>; | |
| 27 using GpuMemoryBufferConfigurationSet = | |
| 28 base::hash_set<GpuMemoryBufferConfigurationKey>; | |
| 29 | |
| 30 } // content | |
| 31 | |
| 32 namespace BASE_HASH_NAMESPACE { | |
| 33 | |
| 34 template <> | |
| 35 struct hash<content::GpuMemoryBufferConfigurationKey> { | |
| 36 size_t operator()(const content::GpuMemoryBufferConfigurationKey& key) const { | |
| 37 return base::HashInts(static_cast<int>(key.first), | |
| 38 static_cast<int>(key.second)); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 } // namespace BASE_HASH_NAMESPACE | |
| 43 | 23 |
| 44 namespace content { | 24 namespace content { |
| 45 class GpuProcessHost; | 25 class GpuProcessHost; |
| 46 | 26 |
| 47 class CONTENT_EXPORT BrowserGpuMemoryBufferManager | 27 class CONTENT_EXPORT BrowserGpuMemoryBufferManager |
| 48 : public gpu::GpuMemoryBufferManager, | 28 : public gpu::GpuMemoryBufferManager, |
| 49 public base::trace_event::MemoryDumpProvider { | 29 public base::trace_event::MemoryDumpProvider { |
| 50 public: | 30 public: |
| 51 using CreateCallback = | 31 using CreateCallback = |
| 52 base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>; | 32 base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>; |
| 53 using AllocationCallback = CreateCallback; | 33 using AllocationCallback = CreateCallback; |
| 54 | 34 |
| 55 BrowserGpuMemoryBufferManager(int gpu_client_id, | 35 BrowserGpuMemoryBufferManager(int gpu_client_id, |
| 56 uint64_t gpu_client_tracing_id); | 36 uint64_t gpu_client_tracing_id); |
| 57 ~BrowserGpuMemoryBufferManager() override; | 37 ~BrowserGpuMemoryBufferManager() override; |
| 58 | 38 |
| 59 static BrowserGpuMemoryBufferManager* current(); | 39 static BrowserGpuMemoryBufferManager* current(); |
| 60 | 40 |
| 61 static bool IsNativeGpuMemoryBuffersEnabled(); | |
| 62 | |
| 63 static uint32_t GetImageTextureTarget(gfx::BufferFormat format, | 41 static uint32_t GetImageTextureTarget(gfx::BufferFormat format, |
| 64 gfx::BufferUsage usage); | 42 gfx::BufferUsage usage); |
| 65 | 43 |
| 66 // Overridden from gpu::GpuMemoryBufferManager: | 44 // Overridden from gpu::GpuMemoryBufferManager: |
| 67 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( | 45 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( |
| 68 const gfx::Size& size, | 46 const gfx::Size& size, |
| 69 gfx::BufferFormat format, | 47 gfx::BufferFormat format, |
| 70 gfx::BufferUsage usage, | 48 gfx::BufferUsage usage, |
| 71 gpu::SurfaceHandle surface_handle) override; | 49 gpu::SurfaceHandle surface_handle) override; |
| 72 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( | 50 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 int gpu_host_id, | 132 int gpu_host_id, |
| 155 bool reused_gpu_process, | 133 bool reused_gpu_process, |
| 156 const CreateCallback& callback, | 134 const CreateCallback& callback, |
| 157 const gfx::GpuMemoryBufferHandle& handle); | 135 const gfx::GpuMemoryBufferHandle& handle); |
| 158 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 136 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
| 159 int client_id, | 137 int client_id, |
| 160 const gpu::SyncToken& sync_token); | 138 const gpu::SyncToken& sync_token); |
| 161 | 139 |
| 162 uint64_t ClientIdToTracingProcessId(int client_id) const; | 140 uint64_t ClientIdToTracingProcessId(int client_id) const; |
| 163 | 141 |
| 164 const GpuMemoryBufferConfigurationSet native_configurations_; | 142 const gpu::GpuMemoryBufferConfigurationSet native_configurations_; |
| 165 const int gpu_client_id_; | 143 const int gpu_client_id_; |
| 166 const uint64_t gpu_client_tracing_id_; | 144 const uint64_t gpu_client_tracing_id_; |
| 167 | 145 |
| 168 // The GPU process host ID. This should only be accessed on the IO thread. | 146 // The GPU process host ID. This should only be accessed on the IO thread. |
| 169 int gpu_host_id_; | 147 int gpu_host_id_; |
| 170 | 148 |
| 171 // Stores info about buffers for all clients. This should only be accessed | 149 // Stores info about buffers for all clients. This should only be accessed |
| 172 // on the IO thread. | 150 // on the IO thread. |
| 173 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; | 151 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; |
| 174 using ClientMap = base::hash_map<int, BufferMap>; | 152 using ClientMap = base::hash_map<int, BufferMap>; |
| 175 ClientMap clients_; | 153 ClientMap clients_; |
| 176 | 154 |
| 177 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); | 155 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); |
| 178 }; | 156 }; |
| 179 | 157 |
| 180 } // namespace content | 158 } // namespace content |
| 181 | 159 |
| 182 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 160 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
| OLD | NEW |