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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/trace_event/memory_dump_provider.h" | 11 #include "base/trace_event/memory_dump_provider.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 13 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 class CONTENT_EXPORT BrowserGpuMemoryBufferManager | 18 class CONTENT_EXPORT BrowserGpuMemoryBufferManager |
19 : public gpu::GpuMemoryBufferManager, | 19 : public gpu::GpuMemoryBufferManager, |
20 public base::trace_event::MemoryDumpProvider { | 20 public base::trace_event::MemoryDumpProvider { |
21 public: | 21 public: |
22 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 22 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
23 AllocationCallback; | 23 AllocationCallback; |
24 | 24 |
25 explicit BrowserGpuMemoryBufferManager(int gpu_client_id); | 25 explicit BrowserGpuMemoryBufferManager(int gpu_client_id); |
26 ~BrowserGpuMemoryBufferManager() override; | 26 ~BrowserGpuMemoryBufferManager() override; |
27 | 27 |
28 static BrowserGpuMemoryBufferManager* current(); | 28 static BrowserGpuMemoryBufferManager* current(); |
29 | 29 |
30 static uint32 GetImageTextureTarget(gfx::GpuMemoryBuffer::Format format, | 30 static uint32 GetImageTextureTarget(gfx::BufferFormat format, |
31 gfx::GpuMemoryBuffer::Usage usage); | 31 gfx::BufferUsage usage); |
32 | 32 |
33 // Overridden from gpu::GpuMemoryBufferManager: | 33 // Overridden from gpu::GpuMemoryBufferManager: |
34 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( | 34 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( |
35 const gfx::Size& size, | 35 const gfx::Size& size, |
36 gfx::GpuMemoryBuffer::Format format, | 36 gfx::BufferFormat format, |
37 gfx::GpuMemoryBuffer::Usage usage) override; | 37 gfx::BufferUsage usage) override; |
38 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( | 38 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( |
39 ClientBuffer buffer) override; | 39 ClientBuffer buffer) override; |
40 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, | 40 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, |
41 uint32 sync_point) override; | 41 uint32 sync_point) override; |
42 | 42 |
43 // Overridden from base::trace_event::MemoryDumpProvider: | 43 // Overridden from base::trace_event::MemoryDumpProvider: |
44 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; | 44 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; |
45 | 45 |
46 // Virtual for testing. | 46 // Virtual for testing. |
47 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( | 47 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( |
48 const gfx::Size& size, | 48 const gfx::Size& size, |
49 gfx::GpuMemoryBuffer::Format format, | 49 gfx::BufferFormat format, |
50 int32 surface_id); | 50 int32 surface_id); |
51 | 51 |
52 void AllocateGpuMemoryBufferForChildProcess( | 52 void AllocateGpuMemoryBufferForChildProcess( |
53 const gfx::Size& size, | 53 const gfx::Size& size, |
54 gfx::GpuMemoryBuffer::Format format, | 54 gfx::BufferFormat format, |
55 gfx::GpuMemoryBuffer::Usage usage, | 55 gfx::BufferUsage usage, |
56 base::ProcessHandle child_process_handle, | 56 base::ProcessHandle child_process_handle, |
57 int child_client_id, | 57 int child_client_id, |
58 const AllocationCallback& callback); | 58 const AllocationCallback& callback); |
59 void ChildProcessDeletedGpuMemoryBuffer( | 59 void ChildProcessDeletedGpuMemoryBuffer( |
60 gfx::GpuMemoryBufferId id, | 60 gfx::GpuMemoryBufferId id, |
61 base::ProcessHandle child_process_handle, | 61 base::ProcessHandle child_process_handle, |
62 int child_client_id, | 62 int child_client_id, |
63 uint32 sync_point); | 63 uint32 sync_point); |
64 void ProcessRemoved(base::ProcessHandle process_handle, int client_id); | 64 void ProcessRemoved(base::ProcessHandle process_handle, int client_id); |
65 | 65 |
66 private: | 66 private: |
67 struct BufferInfo { | 67 struct BufferInfo { |
68 BufferInfo() | 68 BufferInfo() |
69 : type(gfx::EMPTY_BUFFER), | 69 : type(gfx::EMPTY_BUFFER), |
70 format(gfx::GpuMemoryBuffer::RGBA_8888), | 70 format(gfx::BufferFormat::RGBA_8888), |
71 usage(gfx::GpuMemoryBuffer::MAP), | 71 usage(gfx::BufferUsage::MAP), |
72 gpu_host_id(0) {} | 72 gpu_host_id(0) {} |
73 BufferInfo(const gfx::Size& size, | 73 BufferInfo(const gfx::Size& size, |
74 gfx::GpuMemoryBufferType type, | 74 gfx::GpuMemoryBufferType type, |
75 gfx::GpuMemoryBuffer::Format format, | 75 gfx::BufferFormat format, |
76 gfx::GpuMemoryBuffer::Usage usage, | 76 gfx::BufferUsage usage, |
77 int gpu_host_id) | 77 int gpu_host_id) |
78 : size(size), | 78 : size(size), |
79 type(type), | 79 type(type), |
80 format(format), | 80 format(format), |
81 usage(usage), | 81 usage(usage), |
82 gpu_host_id(gpu_host_id) {} | 82 gpu_host_id(gpu_host_id) {} |
83 | 83 |
84 gfx::Size size; | 84 gfx::Size size; |
85 gfx::GpuMemoryBufferType type; | 85 gfx::GpuMemoryBufferType type; |
86 gfx::GpuMemoryBuffer::Format format; | 86 gfx::BufferFormat format; |
87 gfx::GpuMemoryBuffer::Usage usage; | 87 gfx::BufferUsage usage; |
88 int gpu_host_id; | 88 int gpu_host_id; |
89 }; | 89 }; |
90 struct AllocateGpuMemoryBufferRequest; | 90 struct AllocateGpuMemoryBufferRequest; |
91 | 91 |
92 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( | 92 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( |
93 const gfx::Size& size, | 93 const gfx::Size& size, |
94 gfx::GpuMemoryBuffer::Format format, | 94 gfx::BufferFormat format, |
95 gfx::GpuMemoryBuffer::Usage usage, | 95 gfx::BufferUsage usage, |
96 int32 surface_id); | 96 int32 surface_id); |
97 bool IsGpuMemoryBufferConfigurationSupported( | 97 bool IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, |
98 gfx::GpuMemoryBuffer::Format format, | 98 gfx::BufferUsage usage) const; |
99 gfx::GpuMemoryBuffer::Usage usage) const; | |
100 void AllocateGpuMemoryBufferForSurfaceOnIO( | 99 void AllocateGpuMemoryBufferForSurfaceOnIO( |
101 AllocateGpuMemoryBufferRequest* request); | 100 AllocateGpuMemoryBufferRequest* request); |
102 void GpuMemoryBufferAllocatedForSurfaceOnIO( | 101 void GpuMemoryBufferAllocatedForSurfaceOnIO( |
103 AllocateGpuMemoryBufferRequest* request, | 102 AllocateGpuMemoryBufferRequest* request, |
104 const gfx::GpuMemoryBufferHandle& handle); | 103 const gfx::GpuMemoryBufferHandle& handle); |
105 void AllocateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 104 void AllocateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
106 const gfx::Size& size, | 105 const gfx::Size& size, |
107 gfx::GpuMemoryBuffer::Format format, | 106 gfx::BufferFormat format, |
108 gfx::GpuMemoryBuffer::Usage usage, | 107 gfx::BufferUsage usage, |
109 int client_id, | 108 int client_id, |
110 int surface_id, | 109 int surface_id, |
111 bool reused_gpu_process, | 110 bool reused_gpu_process, |
112 const AllocationCallback& callback); | 111 const AllocationCallback& callback); |
113 void GpuMemoryBufferAllocatedOnIO(gfx::GpuMemoryBufferId id, | 112 void GpuMemoryBufferAllocatedOnIO(gfx::GpuMemoryBufferId id, |
114 int client_id, | 113 int client_id, |
115 int surface_id, | 114 int surface_id, |
116 int gpu_host_id, | 115 int gpu_host_id, |
117 bool reused_gpu_process, | 116 bool reused_gpu_process, |
118 const AllocationCallback& callback, | 117 const AllocationCallback& callback, |
(...skipping 15 matching lines...) Expand all Loading... |
134 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; | 133 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; |
135 using ClientMap = base::hash_map<int, BufferMap>; | 134 using ClientMap = base::hash_map<int, BufferMap>; |
136 ClientMap clients_; | 135 ClientMap clients_; |
137 | 136 |
138 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); | 137 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); |
139 }; | 138 }; |
140 | 139 |
141 } // namespace content | 140 } // namespace content |
142 | 141 |
143 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 142 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
OLD | NEW |