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