Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.h

Issue 1189943002: content: Fix lost context handling when using native GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/trace_event/memory_dump_provider.h" 11 #include "base/trace_event/memory_dump_provider.h"
11 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/common/gpu/gpu_memory_buffer_factory.h"
12 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
13 15
14 namespace content { 16 namespace content {
15 class GpuMemoryBufferFactoryHost;
16 class GpuMemoryBufferImpl;
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 BrowserGpuMemoryBufferManager( 25 BrowserGpuMemoryBufferManager();
26 GpuMemoryBufferFactoryHost* gpu_memory_buffer_factory_host,
27 int gpu_client_id);
28 ~BrowserGpuMemoryBufferManager() override; 26 ~BrowserGpuMemoryBufferManager() override;
29 27
30 static BrowserGpuMemoryBufferManager* current(); 28 static BrowserGpuMemoryBufferManager* current();
31 29
32 // Overridden from gpu::GpuMemoryBufferManager: 30 // Overridden from gpu::GpuMemoryBufferManager:
33 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( 31 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
34 const gfx::Size& size, 32 const gfx::Size& size,
35 gfx::GpuMemoryBuffer::Format format, 33 gfx::GpuMemoryBuffer::Format format,
36 gfx::GpuMemoryBuffer::Usage usage) override; 34 gfx::GpuMemoryBuffer::Usage usage) override;
37 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( 35 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
38 ClientBuffer buffer) override; 36 ClientBuffer buffer) override;
39 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, 37 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer,
40 uint32 sync_point) override; 38 uint32 sync_point) override;
41 39
42 // Overridden from base::trace_event::MemoryDumpProvider: 40 // Overridden from base::trace_event::MemoryDumpProvider:
43 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; 41 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override;
44 42
45 // Virtual for testing. 43 // Virtual for testing.
46 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( 44 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout(
47 const gfx::Size& size, 45 const gfx::Size& size,
48 gfx::GpuMemoryBuffer::Format format, 46 gfx::GpuMemoryBuffer::Format format,
49 int32 surface_id); 47 int32 surface_id);
50 48
49 uint32 GetImageTextureTarget(gfx::GpuMemoryBuffer::Format format,
50 gfx::GpuMemoryBuffer::Usage usage) const;
51
51 void AllocateGpuMemoryBufferForChildProcess( 52 void AllocateGpuMemoryBufferForChildProcess(
52 const gfx::Size& size, 53 const gfx::Size& size,
53 gfx::GpuMemoryBuffer::Format format, 54 gfx::GpuMemoryBuffer::Format format,
54 gfx::GpuMemoryBuffer::Usage usage, 55 gfx::GpuMemoryBuffer::Usage usage,
55 base::ProcessHandle child_process_handle, 56 base::ProcessHandle child_process_handle,
56 int child_client_id, 57 int child_client_id,
57 const AllocationCallback& callback); 58 const AllocationCallback& callback);
58 void ChildProcessDeletedGpuMemoryBuffer( 59 void ChildProcessDeletedGpuMemoryBuffer(
59 gfx::GpuMemoryBufferId id, 60 gfx::GpuMemoryBufferId id,
60 base::ProcessHandle child_process_handle, 61 base::ProcessHandle child_process_handle,
61 int child_client_id, 62 int child_client_id,
62 uint32 sync_point); 63 uint32 sync_point);
63 void ProcessRemoved(base::ProcessHandle process_handle, int client_id); 64 void ProcessRemoved(base::ProcessHandle process_handle, int client_id);
64 65
65 private: 66 private:
66 struct BufferInfo { 67 struct BufferInfo {
67 BufferInfo() 68 BufferInfo()
68 : format(gfx::GpuMemoryBuffer::RGBA_8888), type(gfx::EMPTY_BUFFER) {} 69 : format(gfx::GpuMemoryBuffer::RGBA_8888),
70 type(gfx::EMPTY_BUFFER),
71 gpu_host_id(0) {}
69 BufferInfo(const gfx::Size& size, 72 BufferInfo(const gfx::Size& size,
70 gfx::GpuMemoryBuffer::Format format, 73 gfx::GpuMemoryBuffer::Format format,
71 gfx::GpuMemoryBufferType type) 74 gfx::GpuMemoryBufferType type,
72 : size(size), format(format), type(type) {} 75 int gpu_host_id)
76 : size(size), format(format), type(type), gpu_host_id(gpu_host_id) {}
73 77
74 gfx::Size size; 78 gfx::Size size;
75 gfx::GpuMemoryBuffer::Format format; 79 gfx::GpuMemoryBuffer::Format format;
76 gfx::GpuMemoryBufferType type; 80 gfx::GpuMemoryBufferType type;
81 int gpu_host_id;
77 }; 82 };
78 struct AllocateGpuMemoryBufferRequest; 83 struct AllocateGpuMemoryBufferRequest;
79 84
80 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferCommon( 85 static std::vector<GpuMemoryBufferFactory::Configuration>
86 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type);
87
88 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface(
81 const gfx::Size& size, 89 const gfx::Size& size,
82 gfx::GpuMemoryBuffer::Format format, 90 gfx::GpuMemoryBuffer::Format format,
83 gfx::GpuMemoryBuffer::Usage usage, 91 gfx::GpuMemoryBuffer::Usage usage,
84 int32 surface_id); 92 int32 surface_id);
85 void AllocateGpuMemoryBufferOnIO(AllocateGpuMemoryBufferRequest* request);
86 void GpuMemoryBufferAllocatedOnIO(AllocateGpuMemoryBufferRequest* request,
87 const gfx::GpuMemoryBufferHandle& handle);
88 void GpuMemoryBufferDeleted(gfx::GpuMemoryBufferId id, 93 void GpuMemoryBufferDeleted(gfx::GpuMemoryBufferId id,
89 int client_id, 94 int client_id,
90 uint32 sync_point); 95 uint32 sync_point);
91 void GpuMemoryBufferAllocatedForChildProcess( 96 bool IsGpuMemoryBufferConfigurationSupported(
92 gfx::GpuMemoryBufferId id, 97 gfx::GpuMemoryBuffer::Format format,
93 int child_client_id, 98 gfx::GpuMemoryBuffer::Usage usage) const;
94 const AllocationCallback& callback, 99 void AllocateGpuMemoryBufferForSurfaceOnIO(
100 AllocateGpuMemoryBufferRequest* request);
101 void GpuMemoryBufferAllocatedForSurfaceOnIO(
102 AllocateGpuMemoryBufferRequest* request,
95 const gfx::GpuMemoryBufferHandle& handle); 103 const gfx::GpuMemoryBufferHandle& handle);
104 void AllocateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
105 const gfx::Size& size,
106 gfx::GpuMemoryBuffer::Format format,
107 gfx::GpuMemoryBuffer::Usage usage,
108 int client_id,
109 int surface_id,
110 const AllocationCallback& callback);
111 void GpuMemoryBufferAllocatedOnIO(gfx::GpuMemoryBufferId id,
112 int child_client_id,
113 int gpu_host_id,
114 const AllocationCallback& callback,
115 const gfx::GpuMemoryBufferHandle& handle);
116 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
117 int client_id,
118 uint32 sync_point);
96 119
97 GpuMemoryBufferFactoryHost* gpu_memory_buffer_factory_host_; 120 const gfx::GpuMemoryBufferType factory_type_;
98 int gpu_client_id_; 121 const std::vector<GpuMemoryBufferFactory::Configuration>
122 supported_configurations_;
99 123
100 typedef base::hash_map<gfx::GpuMemoryBufferId, BufferInfo> BufferMap; 124 // The GPU process host ID. This should only be accessed on the IO thread.
101 typedef base::hash_map<int, BufferMap> ClientMap; 125 int gpu_host_id_;
126
127 // Stores info about buffers for all clients. This should only be accessed
128 // on the IO thread.
129 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>;
130 using ClientMap = base::hash_map<int, BufferMap>;
102 ClientMap clients_; 131 ClientMap clients_;
103 132
104 base::WeakPtrFactory<BrowserGpuMemoryBufferManager> weak_ptr_factory_;
105
106 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); 133 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager);
107 }; 134 };
108 135
109 } // namespace content 136 } // namespace content
110 137
111 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ 138 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698