Add ICU message format support
[chromium-blink-merge.git] / content / browser / gpu / browser_gpu_memory_buffer_manager.h
blobb11faf870219478a21913d2c5387edfbadb1c66b
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 <vector>
10 #include "base/callback.h"
11 #include "base/trace_event/memory_dump_provider.h"
12 #include "content/common/content_export.h"
13 #include "content/common/gpu/gpu_memory_buffer_factory.h"
14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
16 namespace content {
18 class CONTENT_EXPORT BrowserGpuMemoryBufferManager
19 : public gpu::GpuMemoryBufferManager,
20 public base::trace_event::MemoryDumpProvider {
21 public:
22 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>
23 AllocationCallback;
25 BrowserGpuMemoryBufferManager(int gpu_client_id,
26 uint64_t gpu_client_tracing_id);
27 ~BrowserGpuMemoryBufferManager() override;
29 static BrowserGpuMemoryBufferManager* current();
31 static uint32 GetImageTextureTarget(gfx::BufferFormat format,
32 gfx::BufferUsage usage);
34 // Overridden from gpu::GpuMemoryBufferManager:
35 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
36 const gfx::Size& size,
37 gfx::BufferFormat format,
38 gfx::BufferUsage usage) override;
39 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
40 ClientBuffer buffer) override;
41 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer,
42 uint32 sync_point) override;
44 // Overridden from base::trace_event::MemoryDumpProvider:
45 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
46 base::trace_event::ProcessMemoryDump* pmd) override;
48 // Virtual for testing.
49 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout(
50 const gfx::Size& size,
51 gfx::BufferFormat format,
52 int32 surface_id);
54 void AllocateGpuMemoryBufferForChildProcess(
55 const gfx::Size& size,
56 gfx::BufferFormat format,
57 gfx::BufferUsage usage,
58 base::ProcessHandle child_process_handle,
59 int child_client_id,
60 const AllocationCallback& callback);
61 void ChildProcessDeletedGpuMemoryBuffer(
62 gfx::GpuMemoryBufferId id,
63 base::ProcessHandle child_process_handle,
64 int child_client_id,
65 uint32 sync_point);
66 void ProcessRemoved(base::ProcessHandle process_handle, int client_id);
68 private:
69 struct BufferInfo {
70 BufferInfo()
71 : type(gfx::EMPTY_BUFFER),
72 format(gfx::BufferFormat::RGBA_8888),
73 usage(gfx::BufferUsage::MAP),
74 gpu_host_id(0) {}
75 BufferInfo(const gfx::Size& size,
76 gfx::GpuMemoryBufferType type,
77 gfx::BufferFormat format,
78 gfx::BufferUsage usage,
79 int gpu_host_id)
80 : size(size),
81 type(type),
82 format(format),
83 usage(usage),
84 gpu_host_id(gpu_host_id) {}
86 gfx::Size size;
87 gfx::GpuMemoryBufferType type;
88 gfx::BufferFormat format;
89 gfx::BufferUsage usage;
90 int gpu_host_id;
92 struct AllocateGpuMemoryBufferRequest;
94 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface(
95 const gfx::Size& size,
96 gfx::BufferFormat format,
97 gfx::BufferUsage usage,
98 int32 surface_id);
99 bool IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format,
100 gfx::BufferUsage usage) const;
101 void AllocateGpuMemoryBufferForSurfaceOnIO(
102 AllocateGpuMemoryBufferRequest* request);
103 void GpuMemoryBufferAllocatedForSurfaceOnIO(
104 AllocateGpuMemoryBufferRequest* request,
105 const gfx::GpuMemoryBufferHandle& handle);
106 void AllocateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
107 const gfx::Size& size,
108 gfx::BufferFormat format,
109 gfx::BufferUsage usage,
110 int client_id,
111 int surface_id,
112 bool reused_gpu_process,
113 const AllocationCallback& callback);
114 void GpuMemoryBufferAllocatedOnIO(gfx::GpuMemoryBufferId id,
115 int client_id,
116 int surface_id,
117 int gpu_host_id,
118 bool reused_gpu_process,
119 const AllocationCallback& callback,
120 const gfx::GpuMemoryBufferHandle& handle);
121 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
122 int client_id,
123 uint32 sync_point);
125 uint64_t ClientIdToTracingProcessId(int client_id) const;
127 const gfx::GpuMemoryBufferType factory_type_;
128 const std::vector<GpuMemoryBufferFactory::Configuration>
129 supported_configurations_;
130 const int gpu_client_id_;
131 const uint64_t gpu_client_tracing_id_;
133 // The GPU process host ID. This should only be accessed on the IO thread.
134 int gpu_host_id_;
136 // Stores info about buffers for all clients. This should only be accessed
137 // on the IO thread.
138 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>;
139 using ClientMap = base::hash_map<int, BufferMap>;
140 ClientMap clients_;
142 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager);
145 } // namespace content
147 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_