Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // ints redundantly when only the error is needed for the | 143 // ints redundantly when only the error is needed for the |
| 144 // CommandBufferProxyImpl implementation. | 144 // CommandBufferProxyImpl implementation. |
| 145 gpu::error::Error GetLastError() override; | 145 gpu::error::Error GetLastError() override; |
| 146 | 146 |
| 147 GpuChannelHost* channel() const { return channel_; } | 147 GpuChannelHost* channel() const { return channel_; } |
| 148 | 148 |
| 149 base::SharedMemoryHandle GetSharedStateHandle() const { | 149 base::SharedMemoryHandle GetSharedStateHandle() const { |
| 150 return shared_state_shm_->handle(); | 150 return shared_state_shm_->handle(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void WaitForPendingGpuMemoryBufferUsageToComplete( | |
| 154 const base::Closure& callback); | |
| 155 | |
| 153 private: | 156 private: |
| 154 typedef std::map<int32, scoped_refptr<gpu::Buffer> > TransferBufferMap; | 157 typedef std::map<int32, scoped_refptr<gpu::Buffer> > TransferBufferMap; |
| 155 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; | 158 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; |
| 156 typedef base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer> | 159 typedef base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer> |
| 157 GpuMemoryBufferMap; | 160 GpuMemoryBufferMap; |
| 158 | 161 |
| 162 struct CallbackMessageLoopPair { | |
| 163 CallbackMessageLoopPair(const base::Closure& callback, | |
| 164 scoped_refptr<base::MessageLoopProxy> message_loop); | |
| 165 ~CallbackMessageLoopPair(); | |
| 166 base::Closure callback; | |
| 167 scoped_refptr<base::MessageLoopProxy> message_loop; | |
|
reveman
2014/10/23 19:46:43
I just realized that GpuChannelHost::MessageFilter
| |
| 168 }; | |
| 169 | |
| 170 class GpuMemoryBufferUsageTracker | |
| 171 : public base::RefCountedThreadSafe<GpuMemoryBufferUsageTracker>, | |
| 172 public DeletionObserver { | |
| 173 public: | |
| 174 GpuMemoryBufferUsageTracker(); | |
| 175 | |
| 176 // DeletionObserver implementation: | |
| 177 void OnWillDeleteImpl() override; | |
| 178 | |
| 179 uint32 AddUsage(const CallbackMessageLoopPair& task); | |
| 180 void UsageCompleted(uint32 task_id); | |
| 181 | |
| 182 private: | |
| 183 typedef base::hash_map<uint32, CallbackMessageLoopPair> | |
| 184 GpuMemoryBufferUsageCompletedMap; | |
| 185 friend class base::RefCountedThreadSafe<GpuMemoryBufferUsageTracker>; | |
| 186 ~GpuMemoryBufferUsageTracker(); | |
| 187 | |
| 188 void UsageCompletedOnCaller(uint32 task_id); | |
| 189 | |
| 190 uint32 next_gpu_memory_buffer_usage_id_; | |
| 191 GpuMemoryBufferUsageCompletedMap gpu_memory_buffer_tasks_; | |
| 192 mutable base::Lock gpu_memory_buffer_task_lock_; | |
| 193 }; | |
| 194 | |
| 195 void WaitForPendingGpuMemoryBufferUsageToCompleteOnMain(uint32 usage_id); | |
| 196 | |
| 159 // Send an IPC message over the GPU channel. This is private to fully | 197 // Send an IPC message over the GPU channel. This is private to fully |
| 160 // encapsulate the channel; all callers of this function must explicitly | 198 // encapsulate the channel; all callers of this function must explicitly |
| 161 // verify that the context has not been lost. | 199 // verify that the context has not been lost. |
| 162 bool Send(IPC::Message* msg); | 200 bool Send(IPC::Message* msg); |
| 163 | 201 |
| 164 // Message handlers: | 202 // Message handlers: |
| 165 void OnUpdateState(const gpu::CommandBuffer::State& state); | 203 void OnUpdateState(const gpu::CommandBuffer::State& state); |
| 166 void OnDestroyed(gpu::error::ContextLostReason reason); | 204 void OnDestroyed(gpu::error::ContextLostReason reason); |
| 167 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); | 205 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); |
| 168 void OnSetMemoryAllocation(const gpu::MemoryAllocation& allocation); | 206 void OnSetMemoryAllocation(const gpu::MemoryAllocation& allocation); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 | 241 |
| 204 // Local cache of id to gpu memory buffer mapping. | 242 // Local cache of id to gpu memory buffer mapping. |
| 205 GpuMemoryBufferMap gpu_memory_buffers_; | 243 GpuMemoryBufferMap gpu_memory_buffers_; |
| 206 | 244 |
| 207 gpu::Capabilities capabilities_; | 245 gpu::Capabilities capabilities_; |
| 208 | 246 |
| 209 std::vector<ui::LatencyInfo> latency_info_; | 247 std::vector<ui::LatencyInfo> latency_info_; |
| 210 | 248 |
| 211 SwapBuffersCompletionCallback swap_buffers_completion_callback_; | 249 SwapBuffersCompletionCallback swap_buffers_completion_callback_; |
| 212 | 250 |
| 251 scoped_refptr<base::MessageLoopProxy> main_loop_proxy_; | |
| 252 scoped_refptr<GpuMemoryBufferUsageTracker> tracker_; | |
| 253 | |
| 213 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); | 254 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 214 }; | 255 }; |
| 215 | 256 |
| 216 } // namespace content | 257 } // namespace content |
| 217 | 258 |
| 218 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 259 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| OLD | NEW |