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 |
| 159 // Send an IPC message over the GPU channel. This is private to fully | 162 // Send an IPC message over the GPU channel. This is private to fully |
| 160 // encapsulate the channel; all callers of this function must explicitly | 163 // encapsulate the channel; all callers of this function must explicitly |
| 161 // verify that the context has not been lost. | 164 // verify that the context has not been lost. |
| 162 bool Send(IPC::Message* msg); | 165 bool Send(IPC::Message* msg); |
| 163 | 166 |
| 164 // Message handlers: | 167 // Message handlers: |
| 165 void OnUpdateState(const gpu::CommandBuffer::State& state); | 168 void OnUpdateState(const gpu::CommandBuffer::State& state); |
| 166 void OnDestroyed(gpu::error::ContextLostReason reason); | 169 void OnDestroyed(gpu::error::ContextLostReason reason); |
| 167 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); | 170 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); |
| 168 void OnSetMemoryAllocation(const gpu::MemoryAllocation& allocation); | 171 void OnSetMemoryAllocation(const gpu::MemoryAllocation& allocation); |
| 169 void OnSignalSyncPointAck(uint32 id); | 172 void OnSignalSyncPointAck(uint32 id); |
| 170 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info); | 173 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info); |
| 171 | 174 |
| 172 // Try to read an updated copy of the state from shared memory. | 175 // Try to read an updated copy of the state from shared memory. |
| 173 void TryUpdateState(); | 176 void TryUpdateState(); |
| 174 | 177 |
| 175 // The shared memory area used to update state. | 178 // The shared memory area used to update state. |
| 176 gpu::CommandBufferSharedState* shared_state() const; | 179 gpu::CommandBufferSharedState* shared_state() const; |
| 177 | 180 |
| 181 void GpuMemoryBufferSyncPointSignalled(uint32 sync_point); | |
|
reveman
2014/10/22 22:42:47
GpuMemoryBufferUsageCompleted?
| |
| 182 uint32 GetNextSignalId(); | |
| 183 | |
| 178 // Unowned list of DeletionObservers. | 184 // Unowned list of DeletionObservers. |
| 179 ObserverList<DeletionObserver> deletion_observers_; | 185 ObserverList<DeletionObserver> deletion_observers_; |
| 180 | 186 |
| 181 // The last cached state received from the service. | 187 // The last cached state received from the service. |
| 182 State last_state_; | 188 State last_state_; |
| 183 | 189 |
| 184 // The shared memory area used to update state. | 190 // The shared memory area used to update state. |
| 185 scoped_ptr<base::SharedMemory> shared_state_shm_; | 191 scoped_ptr<base::SharedMemory> shared_state_shm_; |
| 186 | 192 |
| 187 // |*this| is owned by |*channel_| and so is always outlived by it, so using a | 193 // |*this| is owned by |*channel_| and so is always outlived by it, so using a |
| 188 // raw pointer is ok. | 194 // raw pointer is ok. |
| 189 GpuChannelHost* channel_; | 195 GpuChannelHost* channel_; |
| 190 int route_id_; | 196 int route_id_; |
| 191 unsigned int flush_count_; | 197 unsigned int flush_count_; |
| 192 int32 last_put_offset_; | 198 int32 last_put_offset_; |
| 193 | 199 |
| 194 base::Closure channel_error_callback_; | 200 base::Closure channel_error_callback_; |
| 195 | 201 |
| 196 MemoryAllocationChangedCallback memory_allocation_changed_callback_; | 202 MemoryAllocationChangedCallback memory_allocation_changed_callback_; |
| 197 | 203 |
| 198 GpuConsoleMessageCallback console_message_callback_; | 204 GpuConsoleMessageCallback console_message_callback_; |
| 199 | 205 |
| 200 // Tasks to be invoked in SignalSyncPoint responses. | 206 // Tasks to be invoked in SignalSyncPoint responses. |
| 201 uint32 next_signal_id_; | 207 uint32 next_signal_id_; |
| 202 SignalTaskMap signal_tasks_; | 208 SignalTaskMap signal_tasks_; |
| 209 // Protects signal_tasks_. | |
| 210 mutable base::Lock signal_lock_; | |
| 203 | 211 |
| 204 // Local cache of id to gpu memory buffer mapping. | 212 // Local cache of id to gpu memory buffer mapping. |
| 205 GpuMemoryBufferMap gpu_memory_buffers_; | 213 GpuMemoryBufferMap gpu_memory_buffers_; |
| 206 | 214 |
| 207 gpu::Capabilities capabilities_; | 215 gpu::Capabilities capabilities_; |
| 208 | 216 |
| 209 std::vector<ui::LatencyInfo> latency_info_; | 217 std::vector<ui::LatencyInfo> latency_info_; |
| 210 | 218 |
| 211 SwapBuffersCompletionCallback swap_buffers_completion_callback_; | 219 SwapBuffersCompletionCallback swap_buffers_completion_callback_; |
| 212 | 220 |
| 221 SignalTaskMap gpu_memory_buffer_tasks_; | |
|
reveman
2014/10/22 22:42:47
I think we should use a different id namespace and
| |
| 222 mutable base::Lock gpu_memory_buffer_task_lock_; | |
| 223 | |
| 213 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); | 224 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 214 }; | 225 }; |
| 215 | 226 |
| 216 } // namespace content | 227 } // namespace content |
| 217 | 228 |
| 218 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 229 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| OLD | NEW |