Add remoting and PPAPI tests to GN build
[chromium-blink-merge.git] / content / browser / gpu / browser_gpu_memory_buffer_manager.h
blob60815ded19c530969bc4841b945274f36b890718
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/content_export.h"
11 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
13 namespace content {
14 class GpuMemoryBufferFactoryHost;
15 class GpuMemoryBufferImpl;
17 class CONTENT_EXPORT BrowserGpuMemoryBufferManager
18 : public gpu::GpuMemoryBufferManager {
19 public:
20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>
21 AllocationCallback;
23 BrowserGpuMemoryBufferManager(
24 GpuMemoryBufferFactoryHost* gpu_memory_buffer_factory_host,
25 int gpu_client_id);
26 ~BrowserGpuMemoryBufferManager() override;
28 static BrowserGpuMemoryBufferManager* current();
30 // Overridden from gpu::GpuMemoryBufferManager:
31 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
32 const gfx::Size& size,
33 gfx::GpuMemoryBuffer::Format format,
34 gfx::GpuMemoryBuffer::Usage usage) override;
35 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
36 ClientBuffer buffer) override;
37 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer,
38 uint32 sync_point) override;
40 // Virtual for testing.
41 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout(
42 const gfx::Size& size,
43 gfx::GpuMemoryBuffer::Format format,
44 int32 surface_id);
45 void AllocateGpuMemoryBufferForChildProcess(
46 const gfx::Size& size,
47 gfx::GpuMemoryBuffer::Format format,
48 gfx::GpuMemoryBuffer::Usage usage,
49 base::ProcessHandle child_process_handle,
50 int child_client_id,
51 const AllocationCallback& callback);
52 void ChildProcessDeletedGpuMemoryBuffer(
53 gfx::GpuMemoryBufferId id,
54 base::ProcessHandle child_process_handle,
55 int child_client_id,
56 uint32 sync_point);
57 void ProcessRemoved(base::ProcessHandle process_handle, int client_id);
59 private:
60 struct AllocateGpuMemoryBufferRequest;
62 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferCommon(
63 const gfx::Size& size,
64 gfx::GpuMemoryBuffer::Format format,
65 gfx::GpuMemoryBuffer::Usage usage,
66 int32 surface_id);
67 void AllocateGpuMemoryBufferOnIO(AllocateGpuMemoryBufferRequest* request);
68 void GpuMemoryBufferAllocatedOnIO(AllocateGpuMemoryBufferRequest* request,
69 const gfx::GpuMemoryBufferHandle& handle);
70 void GpuMemoryBufferDeleted(gfx::GpuMemoryBufferId id,
71 int client_id,
72 uint32 sync_point);
73 void GpuMemoryBufferAllocatedForChildProcess(
74 int child_client_id,
75 const AllocationCallback& callback,
76 const gfx::GpuMemoryBufferHandle& handle);
78 GpuMemoryBufferFactoryHost* gpu_memory_buffer_factory_host_;
79 int gpu_client_id_;
81 typedef base::hash_map<gfx::GpuMemoryBufferId, gfx::GpuMemoryBufferType>
82 BufferMap;
83 typedef base::hash_map<int, BufferMap> ClientMap;
84 ClientMap clients_;
86 base::WeakPtrFactory<BrowserGpuMemoryBufferManager> weak_ptr_factory_;
88 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager);
91 } // namespace content
93 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_