| 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 #if defined(ENABLE_GPU) | 8 #if defined(ENABLE_GPU) |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "gpu/ipc/command_buffer_proxy.h" | 14 #include "gpu/ipc/command_buffer_proxy.h" |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/hash_tables.h" | 18 #include "base/hash_tables.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "content/common/gpu/gpu_memory_allocation.h" | 21 #include "content/common/gpu/gpu_memory_allocation.h" |
| 22 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" | 22 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
| 23 #include "content/common/gpu/gpu_memory_allocation.h" | 23 #include "content/common/gpu/gpu_memory_allocation.h" |
| 24 #include "gpu/command_buffer/common/command_buffer.h" | 24 #include "gpu/command_buffer/common/command_buffer.h" |
| 25 #include "gpu/command_buffer/common/command_buffer_shared.h" | 25 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 26 #include "ipc/ipc_listener.h" | 26 #include "ipc/ipc_listener.h" |
| 27 #include "webkit/compositor_bindings/web_latency_info_impl.h" |
| 27 | 28 |
| 28 struct GPUCommandBufferConsoleMessage; | 29 struct GPUCommandBufferConsoleMessage; |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| 31 class SharedMemory; | 32 class SharedMemory; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace content { | 35 namespace content { |
| 35 class GpuChannelHost; | 36 class GpuChannelHost; |
| 36 | 37 |
| 37 // Client side proxy that forwards messages synchronously to a | 38 // Client side proxy that forwards messages synchronously to a |
| 38 // CommandBufferStub. | 39 // CommandBufferStub. |
| 39 class CommandBufferProxyImpl | 40 class CommandBufferProxyImpl |
| 40 : public CommandBufferProxy, | 41 : public CommandBufferProxy, |
| 41 public IPC::Listener, | 42 public IPC::Listener, |
| 42 public base::SupportsWeakPtr<CommandBufferProxyImpl> { | 43 public base::SupportsWeakPtr<CommandBufferProxyImpl> { |
| 43 public: | 44 public: |
| 44 typedef base::Callback<void( | 45 typedef base::Callback<void( |
| 45 const std::string& msg, int id)> GpuConsoleMessageCallback; | 46 const std::string& msg, int id)> GpuConsoleMessageCallback; |
| 47 typedef base::Callback<void( |
| 48 const cc::LatencyInfo&)> GpuLatencyInfoCallback; |
| 46 | 49 |
| 47 CommandBufferProxyImpl(GpuChannelHost* channel, int route_id); | 50 CommandBufferProxyImpl(GpuChannelHost* channel, int route_id); |
| 48 virtual ~CommandBufferProxyImpl(); | 51 virtual ~CommandBufferProxyImpl(); |
| 49 | 52 |
| 50 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and | 53 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and |
| 51 // returns a pointer to a GpuVideoDecodeAcceleratorHost. | 54 // returns a pointer to a GpuVideoDecodeAcceleratorHost. |
| 52 // Returns NULL on failure to create the GpuVideoDecodeAcceleratorHost. | 55 // Returns NULL on failure to create the GpuVideoDecodeAcceleratorHost. |
| 53 // Note that the GpuVideoDecodeAccelerator may still fail to be created in | 56 // Note that the GpuVideoDecodeAccelerator may still fail to be created in |
| 54 // the GPU process, even if this returns non-NULL. In this case the client is | 57 // the GPU process, even if this returns non-NULL. In this case the client is |
| 55 // notified of an error later. | 58 // notified of an error later. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // handled only on the GPU process' IO thread, and so is not effectively | 116 // handled only on the GPU process' IO thread, and so is not effectively |
| 114 // a finish. | 117 // a finish. |
| 115 bool GenerateMailboxNames(unsigned num, std::vector<std::string>* names); | 118 bool GenerateMailboxNames(unsigned num, std::vector<std::string>* names); |
| 116 | 119 |
| 117 // Sends an IPC message with the new state of surface visibility. | 120 // Sends an IPC message with the new state of surface visibility. |
| 118 bool SetSurfaceVisible(bool visible); | 121 bool SetSurfaceVisible(bool visible); |
| 119 | 122 |
| 120 void SetOnConsoleMessageCallback( | 123 void SetOnConsoleMessageCallback( |
| 121 const GpuConsoleMessageCallback& callback); | 124 const GpuConsoleMessageCallback& callback); |
| 122 | 125 |
| 126 void SetLatencyInfo(const cc::LatencyInfo& latency_info); |
| 127 |
| 128 void SetLatencyInfoCallback(const GpuLatencyInfoCallback& callback); |
| 129 |
| 123 // TODO(apatrick): this is a temporary optimization while skia is calling | 130 // TODO(apatrick): this is a temporary optimization while skia is calling |
| 124 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 | 131 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 |
| 125 // ints redundantly when only the error is needed for the | 132 // ints redundantly when only the error is needed for the |
| 126 // CommandBufferProxyImpl implementation. | 133 // CommandBufferProxyImpl implementation. |
| 127 virtual gpu::error::Error GetLastError() OVERRIDE; | 134 virtual gpu::error::Error GetLastError() OVERRIDE; |
| 128 | 135 |
| 129 void SendManagedMemoryStats(const GpuManagedMemoryStats& stats); | 136 void SendManagedMemoryStats(const GpuManagedMemoryStats& stats); |
| 130 | 137 |
| 131 GpuChannelHost* channel() const { return channel_; } | 138 GpuChannelHost* channel() const { return channel_; } |
| 132 | 139 |
| 133 private: | 140 private: |
| 134 typedef std::map<int32, gpu::Buffer> TransferBufferMap; | 141 typedef std::map<int32, gpu::Buffer> TransferBufferMap; |
| 135 typedef std::map<int, base::WeakPtr<GpuVideoDecodeAcceleratorHost> > Decoders; | 142 typedef std::map<int, base::WeakPtr<GpuVideoDecodeAcceleratorHost> > Decoders; |
| 136 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; | 143 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; |
| 137 | 144 |
| 138 // Send an IPC message over the GPU channel. This is private to fully | 145 // Send an IPC message over the GPU channel. This is private to fully |
| 139 // encapsulate the channel; all callers of this function must explicitly | 146 // encapsulate the channel; all callers of this function must explicitly |
| 140 // verify that the context has not been lost. | 147 // verify that the context has not been lost. |
| 141 bool Send(IPC::Message* msg); | 148 bool Send(IPC::Message* msg); |
| 142 | 149 |
| 143 // Message handlers: | 150 // Message handlers: |
| 144 void OnUpdateState(const gpu::CommandBuffer::State& state); | 151 void OnUpdateState(const gpu::CommandBuffer::State& state); |
| 145 void OnDestroyed(gpu::error::ContextLostReason reason); | 152 void OnDestroyed(gpu::error::ContextLostReason reason); |
| 146 void OnEchoAck(); | 153 void OnEchoAck(); |
| 147 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); | 154 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); |
| 148 void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); | 155 void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); |
| 149 void OnSignalSyncPointAck(uint32 id); | 156 void OnSignalSyncPointAck(uint32 id); |
| 150 void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); | 157 void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); |
| 158 void OnSetLatencyInfo(const cc::LatencyInfo& latency_info); |
| 151 | 159 |
| 152 // Try to read an updated copy of the state from shared memory. | 160 // Try to read an updated copy of the state from shared memory. |
| 153 void TryUpdateState(); | 161 void TryUpdateState(); |
| 154 | 162 |
| 155 // The shared memory area used to update state. | 163 // The shared memory area used to update state. |
| 156 gpu::CommandBufferSharedState* shared_state() const { | 164 gpu::CommandBufferSharedState* shared_state() const { |
| 157 return reinterpret_cast<gpu::CommandBufferSharedState*>( | 165 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
| 158 shared_state_shm_->memory()); | 166 shared_state_shm_->memory()); |
| 159 } | 167 } |
| 160 | 168 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 181 // Tasks to be invoked in echo responses. | 189 // Tasks to be invoked in echo responses. |
| 182 std::queue<base::Closure> echo_tasks_; | 190 std::queue<base::Closure> echo_tasks_; |
| 183 | 191 |
| 184 base::Closure channel_error_callback_; | 192 base::Closure channel_error_callback_; |
| 185 | 193 |
| 186 base::Callback<void(const GpuMemoryAllocationForRenderer&)> | 194 base::Callback<void(const GpuMemoryAllocationForRenderer&)> |
| 187 memory_allocation_changed_callback_; | 195 memory_allocation_changed_callback_; |
| 188 | 196 |
| 189 GpuConsoleMessageCallback console_message_callback_; | 197 GpuConsoleMessageCallback console_message_callback_; |
| 190 | 198 |
| 199 GpuLatencyInfoCallback latency_info_callback_; |
| 200 |
| 191 // Tasks to be invoked in SignalSyncPoint responses. | 201 // Tasks to be invoked in SignalSyncPoint responses. |
| 192 uint32 next_signal_id_; | 202 uint32 next_signal_id_; |
| 193 SignalTaskMap signal_tasks_; | 203 SignalTaskMap signal_tasks_; |
| 194 | 204 |
| 195 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); | 205 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 196 }; | 206 }; |
| 197 | 207 |
| 198 } // namespace content | 208 } // namespace content |
| 199 | 209 |
| 200 #endif // ENABLE_GPU | 210 #endif // ENABLE_GPU |
| 201 | 211 |
| 202 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 212 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| OLD | NEW |