| 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 WebKit::WebLatencyInfoImpl&)> 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // Set a task that will be invoked the next time the window becomes invalid | 122 // Set a task that will be invoked the next time the window becomes invalid |
| 120 // and needs to be repainted. Takes ownership of task. | 123 // and needs to be repainted. Takes ownership of task. |
| 121 void SetNotifyRepaintTask(const base::Closure& callback); | 124 void SetNotifyRepaintTask(const base::Closure& callback); |
| 122 | 125 |
| 123 // Sends an IPC message with the new state of surface visibility. | 126 // Sends an IPC message with the new state of surface visibility. |
| 124 bool SetSurfaceVisible(bool visible); | 127 bool SetSurfaceVisible(bool visible); |
| 125 | 128 |
| 126 void SetOnConsoleMessageCallback( | 129 void SetOnConsoleMessageCallback( |
| 127 const GpuConsoleMessageCallback& callback); | 130 const GpuConsoleMessageCallback& callback); |
| 128 | 131 |
| 132 void SetLatencyInfo(const WebKit::WebLatencyInfoImpl& latency_info); |
| 133 |
| 134 void SetLatencyInfoCallback(const GpuLatencyInfoCallback& callback); |
| 135 |
| 129 // TODO(apatrick): this is a temporary optimization while skia is calling | 136 // TODO(apatrick): this is a temporary optimization while skia is calling |
| 130 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 | 137 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 |
| 131 // ints redundantly when only the error is needed for the | 138 // ints redundantly when only the error is needed for the |
| 132 // CommandBufferProxyImpl implementation. | 139 // CommandBufferProxyImpl implementation. |
| 133 virtual gpu::error::Error GetLastError() OVERRIDE; | 140 virtual gpu::error::Error GetLastError() OVERRIDE; |
| 134 | 141 |
| 135 void SendManagedMemoryStats(const GpuManagedMemoryStats& stats); | 142 void SendManagedMemoryStats(const GpuManagedMemoryStats& stats); |
| 136 | 143 |
| 137 GpuChannelHost* channel() const { return channel_; } | 144 GpuChannelHost* channel() const { return channel_; } |
| 138 | 145 |
| 139 private: | 146 private: |
| 140 typedef std::map<int32, gpu::Buffer> TransferBufferMap; | 147 typedef std::map<int32, gpu::Buffer> TransferBufferMap; |
| 141 typedef std::map<int, base::WeakPtr<GpuVideoDecodeAcceleratorHost> > Decoders; | 148 typedef std::map<int, base::WeakPtr<GpuVideoDecodeAcceleratorHost> > Decoders; |
| 142 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; | 149 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; |
| 143 | 150 |
| 144 // Send an IPC message over the GPU channel. This is private to fully | 151 // Send an IPC message over the GPU channel. This is private to fully |
| 145 // encapsulate the channel; all callers of this function must explicitly | 152 // encapsulate the channel; all callers of this function must explicitly |
| 146 // verify that the context has not been lost. | 153 // verify that the context has not been lost. |
| 147 bool Send(IPC::Message* msg); | 154 bool Send(IPC::Message* msg); |
| 148 | 155 |
| 149 // Message handlers: | 156 // Message handlers: |
| 150 void OnUpdateState(const gpu::CommandBuffer::State& state); | 157 void OnUpdateState(const gpu::CommandBuffer::State& state); |
| 151 void OnNotifyRepaint(); | 158 void OnNotifyRepaint(); |
| 152 void OnDestroyed(gpu::error::ContextLostReason reason); | 159 void OnDestroyed(gpu::error::ContextLostReason reason); |
| 153 void OnEchoAck(); | 160 void OnEchoAck(); |
| 154 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); | 161 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); |
| 155 void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); | 162 void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); |
| 156 void OnSignalSyncPointAck(uint32 id); | 163 void OnSignalSyncPointAck(uint32 id); |
| 157 void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); | 164 void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); |
| 165 void OnSetLatencyInfo(const WebKit::WebLatencyInfoImpl& latency_info); |
| 158 | 166 |
| 159 // Try to read an updated copy of the state from shared memory. | 167 // Try to read an updated copy of the state from shared memory. |
| 160 void TryUpdateState(); | 168 void TryUpdateState(); |
| 161 | 169 |
| 162 // Local cache of id to transfer buffer mapping. | 170 // Local cache of id to transfer buffer mapping. |
| 163 TransferBufferMap transfer_buffers_; | 171 TransferBufferMap transfer_buffers_; |
| 164 | 172 |
| 165 // Zero or more (unowned!) video decoder hosts using this proxy, keyed by | 173 // Zero or more (unowned!) video decoder hosts using this proxy, keyed by |
| 166 // their decoder_route_id. | 174 // their decoder_route_id. |
| 167 Decoders video_decoder_hosts_; | 175 Decoders video_decoder_hosts_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 184 | 192 |
| 185 base::Closure notify_repaint_task_; | 193 base::Closure notify_repaint_task_; |
| 186 | 194 |
| 187 base::Closure channel_error_callback_; | 195 base::Closure channel_error_callback_; |
| 188 | 196 |
| 189 base::Callback<void(const GpuMemoryAllocationForRenderer&)> | 197 base::Callback<void(const GpuMemoryAllocationForRenderer&)> |
| 190 memory_allocation_changed_callback_; | 198 memory_allocation_changed_callback_; |
| 191 | 199 |
| 192 GpuConsoleMessageCallback console_message_callback_; | 200 GpuConsoleMessageCallback console_message_callback_; |
| 193 | 201 |
| 202 GpuLatencyInfoCallback latency_info_callback_; |
| 203 |
| 194 // Tasks to be invoked in SignalSyncPoint responses. | 204 // Tasks to be invoked in SignalSyncPoint responses. |
| 195 uint32 next_signal_id_; | 205 uint32 next_signal_id_; |
| 196 SignalTaskMap signal_tasks_; | 206 SignalTaskMap signal_tasks_; |
| 197 | 207 |
| 198 // ID of transfer buffer containing shared state. | 208 // ID of transfer buffer containing shared state. |
| 199 int32 state_buffer_; | 209 int32 state_buffer_; |
| 200 | 210 |
| 201 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); | 211 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 202 }; | 212 }; |
| 203 | 213 |
| 204 } // namespace content | 214 } // namespace content |
| 205 | 215 |
| 206 #endif // ENABLE_GPU | 216 #endif // ENABLE_GPU |
| 207 | 217 |
| 208 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 218 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| OLD | NEW |