| 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_GPU_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/gpu/gpu_process_launch_causes.h" | 19 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 20 #include "content/common/gpu/gpu_result_codes.h" | 20 #include "content/common/gpu/gpu_result_codes.h" |
| 21 #include "content/common/message_router.h" | 21 #include "content/common/message_router.h" |
| 22 #include "gpu/config/gpu_info.h" | 22 #include "gpu/config/gpu_info.h" |
| 23 #include "ipc/ipc_channel_handle.h" | 23 #include "ipc/ipc_channel_handle.h" |
| 24 #include "ipc/ipc_sync_channel.h" | 24 #include "ipc/ipc_sync_channel.h" |
| 25 #include "ipc/message_filter.h" | 25 #include "ipc/message_filter.h" |
| 26 #include "ui/events/latency_info.h" |
| 26 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
| 27 #include "ui/gfx/gpu_memory_buffer.h" | 28 #include "ui/gfx/gpu_memory_buffer.h" |
| 28 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
| 29 #include "ui/gl/gpu_preference.h" | 30 #include "ui/gl/gpu_preference.h" |
| 30 | 31 |
| 31 class GURL; | 32 class GURL; |
| 32 class TransportTextureService; | 33 class TransportTextureService; |
| 33 struct GPUCreateCommandBufferConfig; | 34 struct GPUCreateCommandBufferConfig; |
| 34 | 35 |
| 35 namespace base { | 36 namespace base { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 56 class GpuChannelHost; | 57 class GpuChannelHost; |
| 57 | 58 |
| 58 struct GpuListenerInfo { | 59 struct GpuListenerInfo { |
| 59 GpuListenerInfo(); | 60 GpuListenerInfo(); |
| 60 ~GpuListenerInfo(); | 61 ~GpuListenerInfo(); |
| 61 | 62 |
| 62 base::WeakPtr<IPC::Listener> listener; | 63 base::WeakPtr<IPC::Listener> listener; |
| 63 scoped_refptr<base::MessageLoopProxy> loop; | 64 scoped_refptr<base::MessageLoopProxy> loop; |
| 64 }; | 65 }; |
| 65 | 66 |
| 67 struct ProxyFlushInfo { |
| 68 ProxyFlushInfo(); |
| 69 ~ProxyFlushInfo(); |
| 70 |
| 71 bool flush_pending; |
| 72 int route_id; |
| 73 int32 put_offset; |
| 74 unsigned int flush_count; |
| 75 std::vector<ui::LatencyInfo> latency_info; |
| 76 }; |
| 77 |
| 66 class CONTENT_EXPORT GpuChannelHostFactory { | 78 class CONTENT_EXPORT GpuChannelHostFactory { |
| 67 public: | 79 public: |
| 68 virtual ~GpuChannelHostFactory() {} | 80 virtual ~GpuChannelHostFactory() {} |
| 69 | 81 |
| 70 virtual bool IsMainThread() = 0; | 82 virtual bool IsMainThread() = 0; |
| 71 virtual base::MessageLoop* GetMainLoop() = 0; | 83 virtual base::MessageLoop* GetMainLoop() = 0; |
| 72 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() = 0; | 84 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() = 0; |
| 73 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0; | 85 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0; |
| 74 virtual CreateCommandBufferResult CreateViewCommandBuffer( | 86 virtual CreateCommandBufferResult CreateViewCommandBuffer( |
| 75 int32 surface_id, | 87 int32 surface_id, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 96 DCHECK(channel_filter_.get()); | 108 DCHECK(channel_filter_.get()); |
| 97 return channel_filter_->IsLost(); | 109 return channel_filter_->IsLost(); |
| 98 } | 110 } |
| 99 | 111 |
| 100 // The GPU stats reported by the GPU process. | 112 // The GPU stats reported by the GPU process. |
| 101 const gpu::GPUInfo& gpu_info() const { return gpu_info_; } | 113 const gpu::GPUInfo& gpu_info() const { return gpu_info_; } |
| 102 | 114 |
| 103 // IPC::Sender implementation: | 115 // IPC::Sender implementation: |
| 104 bool Send(IPC::Message* msg) override; | 116 bool Send(IPC::Message* msg) override; |
| 105 | 117 |
| 118 // Flush route. |
| 119 void Flush(int route_id, |
| 120 int32 put_offset, |
| 121 unsigned int flush_count, |
| 122 const std::vector<ui::LatencyInfo>& latency_info, |
| 123 bool shallow_flush); |
| 124 |
| 106 // Create and connect to a command buffer in the GPU process. | 125 // Create and connect to a command buffer in the GPU process. |
| 107 CommandBufferProxyImpl* CreateViewCommandBuffer( | 126 CommandBufferProxyImpl* CreateViewCommandBuffer( |
| 108 int32 surface_id, | 127 int32 surface_id, |
| 109 CommandBufferProxyImpl* share_group, | 128 CommandBufferProxyImpl* share_group, |
| 110 const std::vector<int32>& attribs, | 129 const std::vector<int32>& attribs, |
| 111 const GURL& active_url, | 130 const GURL& active_url, |
| 112 gfx::GpuPreference gpu_preference); | 131 gfx::GpuPreference gpu_preference); |
| 113 | 132 |
| 114 // Create and connect to a command buffer in the GPU process. | 133 // Create and connect to a command buffer in the GPU process. |
| 115 CommandBufferProxyImpl* CreateOffscreenCommandBuffer( | 134 CommandBufferProxyImpl* CreateOffscreenCommandBuffer( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 int32 GenerateRouteID(); | 185 int32 GenerateRouteID(); |
| 167 | 186 |
| 168 private: | 187 private: |
| 169 friend class base::RefCountedThreadSafe<GpuChannelHost>; | 188 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
| 170 GpuChannelHost(GpuChannelHostFactory* factory, | 189 GpuChannelHost(GpuChannelHostFactory* factory, |
| 171 const gpu::GPUInfo& gpu_info, | 190 const gpu::GPUInfo& gpu_info, |
| 172 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 191 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
| 173 ~GpuChannelHost() override; | 192 ~GpuChannelHost() override; |
| 174 void Connect(const IPC::ChannelHandle& channel_handle, | 193 void Connect(const IPC::ChannelHandle& channel_handle, |
| 175 base::WaitableEvent* shutdown_event); | 194 base::WaitableEvent* shutdown_event); |
| 195 bool InternalSend(IPC::Message* msg); |
| 196 void InternalFlush(); |
| 176 | 197 |
| 177 // A filter used internally to route incoming messages from the IO thread | 198 // A filter used internally to route incoming messages from the IO thread |
| 178 // to the correct message loop. It also maintains some shared state between | 199 // to the correct message loop. It also maintains some shared state between |
| 179 // all the contexts. | 200 // all the contexts. |
| 180 class MessageFilter : public IPC::MessageFilter { | 201 class MessageFilter : public IPC::MessageFilter { |
| 181 public: | 202 public: |
| 182 MessageFilter(); | 203 MessageFilter(); |
| 183 | 204 |
| 184 // Called on the IO thread. | 205 // Called on the IO thread. |
| 185 void AddRoute(int route_id, | 206 void AddRoute(int route_id, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 base::AtomicSequenceNumber next_image_id_; | 259 base::AtomicSequenceNumber next_image_id_; |
| 239 | 260 |
| 240 // Route IDs are allocated in sequence. | 261 // Route IDs are allocated in sequence. |
| 241 base::AtomicSequenceNumber next_route_id_; | 262 base::AtomicSequenceNumber next_route_id_; |
| 242 | 263 |
| 243 // Protects proxies_. | 264 // Protects proxies_. |
| 244 mutable base::Lock context_lock_; | 265 mutable base::Lock context_lock_; |
| 245 // Used to look up a proxy from its routing id. | 266 // Used to look up a proxy from its routing id. |
| 246 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; | 267 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; |
| 247 ProxyMap proxies_; | 268 ProxyMap proxies_; |
| 269 ProxyFlushInfo flush_info_; |
| 248 | 270 |
| 249 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 271 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
| 250 }; | 272 }; |
| 251 | 273 |
| 252 } // namespace content | 274 } // namespace content |
| 253 | 275 |
| 254 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 276 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
| OLD | NEW |