| 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 GPU_IPC_SERVICE_GPU_CHANNEL_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
| 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_H_ | 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.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 "base/process/process.h" | 19 #include "base/process/process.h" |
| 20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| 21 #include "base/trace_event/memory_dump_provider.h" | 21 #include "base/trace_event/memory_dump_provider.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "gpu/command_buffer/service/valuebuffer_manager.h" | |
| 24 #include "gpu/gpu_export.h" | 23 #include "gpu/gpu_export.h" |
| 25 #include "gpu/ipc/common/gpu_stream_constants.h" | 24 #include "gpu/ipc/common/gpu_stream_constants.h" |
| 26 #include "gpu/ipc/service/gpu_command_buffer_stub.h" | 25 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 27 #include "gpu/ipc/service/gpu_memory_manager.h" | 26 #include "gpu/ipc/service/gpu_memory_manager.h" |
| 28 #include "ipc/ipc_sync_channel.h" | 27 #include "ipc/ipc_sync_channel.h" |
| 29 #include "ipc/message_router.h" | 28 #include "ipc/message_router.h" |
| 30 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| 31 #include "ui/gfx/native_widget_types.h" | 30 #include "ui/gfx/native_widget_types.h" |
| 32 #include "ui/gl/gl_share_group.h" | 31 #include "ui/gl/gl_share_group.h" |
| 33 #include "ui/gl/gpu_preference.h" | 32 #include "ui/gl/gpu_preference.h" |
| 34 | 33 |
| 35 struct GPUCreateCommandBufferConfig; | 34 struct GPUCreateCommandBufferConfig; |
| 36 | 35 |
| 37 namespace base { | 36 namespace base { |
| 38 class WaitableEvent; | 37 class WaitableEvent; |
| 39 } | 38 } |
| 40 | 39 |
| 41 namespace IPC { | 40 namespace IPC { |
| 42 class MessageFilter; | 41 class MessageFilter; |
| 43 } | 42 } |
| 44 | 43 |
| 45 namespace gpu { | 44 namespace gpu { |
| 46 | 45 |
| 47 class PreemptionFlag; | 46 class PreemptionFlag; |
| 48 class SyncPointOrderData; | 47 class SyncPointOrderData; |
| 49 class SyncPointManager; | 48 class SyncPointManager; |
| 50 union ValueState; | |
| 51 class ValueStateMap; | |
| 52 class GpuChannelManager; | 49 class GpuChannelManager; |
| 53 class GpuChannelMessageFilter; | 50 class GpuChannelMessageFilter; |
| 54 class GpuChannelMessageQueue; | 51 class GpuChannelMessageQueue; |
| 55 class GpuWatchdog; | 52 class GpuWatchdog; |
| 56 | 53 |
| 57 namespace gles2 { | |
| 58 class SubscriptionRefSet; | |
| 59 } | |
| 60 | |
| 61 // Encapsulates an IPC channel between the GPU process and one renderer | 54 // Encapsulates an IPC channel between the GPU process and one renderer |
| 62 // process. On the renderer side there's a corresponding GpuChannelHost. | 55 // process. On the renderer side there's a corresponding GpuChannelHost. |
| 63 class GPU_EXPORT GpuChannel | 56 class GPU_EXPORT GpuChannel |
| 64 : public IPC::Listener, | 57 : public IPC::Listener, |
| 65 public IPC::Sender, | 58 public IPC::Sender { |
| 66 public gles2::SubscriptionRefSet::Observer { | |
| 67 public: | 59 public: |
| 68 // Takes ownership of the renderer process handle. | 60 // Takes ownership of the renderer process handle. |
| 69 GpuChannel(GpuChannelManager* gpu_channel_manager, | 61 GpuChannel(GpuChannelManager* gpu_channel_manager, |
| 70 SyncPointManager* sync_point_manager, | 62 SyncPointManager* sync_point_manager, |
| 71 GpuWatchdog* watchdog, | 63 GpuWatchdog* watchdog, |
| 72 gfx::GLShareGroup* share_group, | 64 gfx::GLShareGroup* share_group, |
| 73 gles2::MailboxManager* mailbox_manager, | 65 gles2::MailboxManager* mailbox_manager, |
| 74 PreemptionFlag* preempting_flag, | 66 PreemptionFlag* preempting_flag, |
| 75 PreemptionFlag* preempted_flag, | 67 PreemptionFlag* preempted_flag, |
| 76 base::SingleThreadTaskRunner* task_runner, | 68 base::SingleThreadTaskRunner* task_runner, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 106 return io_task_runner_; | 98 return io_task_runner_; |
| 107 } | 99 } |
| 108 | 100 |
| 109 // IPC::Listener implementation: | 101 // IPC::Listener implementation: |
| 110 bool OnMessageReceived(const IPC::Message& msg) override; | 102 bool OnMessageReceived(const IPC::Message& msg) override; |
| 111 void OnChannelError() override; | 103 void OnChannelError() override; |
| 112 | 104 |
| 113 // IPC::Sender implementation: | 105 // IPC::Sender implementation: |
| 114 bool Send(IPC::Message* msg) override; | 106 bool Send(IPC::Message* msg) override; |
| 115 | 107 |
| 116 // SubscriptionRefSet::Observer implementation | |
| 117 void OnAddSubscription(unsigned int target) override; | |
| 118 void OnRemoveSubscription(unsigned int target) override; | |
| 119 | |
| 120 void OnStreamRescheduled(int32_t stream_id, bool scheduled); | 108 void OnStreamRescheduled(int32_t stream_id, bool scheduled); |
| 121 | 109 |
| 122 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | 110 gfx::GLShareGroup* share_group() const { return share_group_.get(); } |
| 123 | 111 |
| 124 GpuCommandBufferStub* LookupCommandBuffer(int32_t route_id); | 112 GpuCommandBufferStub* LookupCommandBuffer(int32_t route_id); |
| 125 | 113 |
| 126 void LoseAllContexts(); | 114 void LoseAllContexts(); |
| 127 void MarkAllContextsLost(); | 115 void MarkAllContextsLost(); |
| 128 | 116 |
| 129 // Called to add a listener for a particular message routing ID. | 117 // Called to add a listener for a particular message routing ID. |
| 130 // Returns true if succeeded. | 118 // Returns true if succeeded. |
| 131 bool AddRoute(int32_t route_id, int32_t stream_id, IPC::Listener* listener); | 119 bool AddRoute(int32_t route_id, int32_t stream_id, IPC::Listener* listener); |
| 132 | 120 |
| 133 // Called to remove a listener for a particular message routing ID. | 121 // Called to remove a listener for a particular message routing ID. |
| 134 void RemoveRoute(int32_t route_id); | 122 void RemoveRoute(int32_t route_id); |
| 135 | 123 |
| 136 void CacheShader(const std::string& key, const std::string& shader); | 124 void CacheShader(const std::string& key, const std::string& shader); |
| 137 | 125 |
| 138 void AddFilter(IPC::MessageFilter* filter); | 126 void AddFilter(IPC::MessageFilter* filter); |
| 139 void RemoveFilter(IPC::MessageFilter* filter); | 127 void RemoveFilter(IPC::MessageFilter* filter); |
| 140 | 128 |
| 141 uint64_t GetMemoryUsage(); | 129 uint64_t GetMemoryUsage(); |
| 142 | 130 |
| 143 scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer( | 131 scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer( |
| 144 const gfx::GpuMemoryBufferHandle& handle, | 132 const gfx::GpuMemoryBufferHandle& handle, |
| 145 const gfx::Size& size, | 133 const gfx::Size& size, |
| 146 gfx::BufferFormat format, | 134 gfx::BufferFormat format, |
| 147 uint32_t internalformat); | 135 uint32_t internalformat); |
| 148 | 136 |
| 149 void HandleUpdateValueState(unsigned int target, | |
| 150 const ValueState& state); | |
| 151 | |
| 152 GpuChannelMessageFilter* filter() const { return filter_.get(); } | 137 GpuChannelMessageFilter* filter() const { return filter_.get(); } |
| 153 | 138 |
| 154 // Visible for testing. | |
| 155 const ValueStateMap* pending_valuebuffer_state() const { | |
| 156 return pending_valuebuffer_state_.get(); | |
| 157 } | |
| 158 | |
| 159 // Returns the global order number for the last processed IPC message. | 139 // Returns the global order number for the last processed IPC message. |
| 160 uint32_t GetProcessedOrderNum() const; | 140 uint32_t GetProcessedOrderNum() const; |
| 161 | 141 |
| 162 // Returns the global order number for the last unprocessed IPC message. | 142 // Returns the global order number for the last unprocessed IPC message. |
| 163 uint32_t GetUnprocessedOrderNum() const; | 143 uint32_t GetUnprocessedOrderNum() const; |
| 164 | 144 |
| 165 // Returns the shared sync point global order data for the stream. | 145 // Returns the shared sync point global order data for the stream. |
| 166 scoped_refptr<SyncPointOrderData> GetSyncPointOrderData( | 146 scoped_refptr<SyncPointOrderData> GetSyncPointOrderData( |
| 167 int32_t stream_id); | 147 int32_t stream_id); |
| 168 | 148 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // The task runners for the main thread and the io thread. | 233 // The task runners for the main thread and the io thread. |
| 254 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 234 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 255 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 235 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 256 | 236 |
| 257 // The share group that all contexts associated with a particular renderer | 237 // The share group that all contexts associated with a particular renderer |
| 258 // process use. | 238 // process use. |
| 259 scoped_refptr<gfx::GLShareGroup> share_group_; | 239 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 260 | 240 |
| 261 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 241 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
| 262 | 242 |
| 263 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set_; | |
| 264 | |
| 265 scoped_refptr<ValueStateMap> pending_valuebuffer_state_; | |
| 266 | |
| 267 gles2::DisallowedFeatures disallowed_features_; | 243 gles2::DisallowedFeatures disallowed_features_; |
| 268 GpuWatchdog* const watchdog_; | 244 GpuWatchdog* const watchdog_; |
| 269 | 245 |
| 270 // Map of stream id to appropriate message queue. | 246 // Map of stream id to appropriate message queue. |
| 271 base::hash_map<int32_t, scoped_refptr<GpuChannelMessageQueue>> streams_; | 247 base::hash_map<int32_t, scoped_refptr<GpuChannelMessageQueue>> streams_; |
| 272 | 248 |
| 273 // Multimap of stream id to route ids. | 249 // Multimap of stream id to route ids. |
| 274 base::hash_map<int32_t, int> streams_to_num_routes_; | 250 base::hash_map<int32_t, int> streams_to_num_routes_; |
| 275 | 251 |
| 276 // Map of route id to stream id; | 252 // Map of route id to stream id; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 scoped_refptr<PreemptionFlag> preempting_flag_; | 450 scoped_refptr<PreemptionFlag> preempting_flag_; |
| 475 scoped_refptr<PreemptionFlag> preempted_flag_; | 451 scoped_refptr<PreemptionFlag> preempted_flag_; |
| 476 SyncPointManager* const sync_point_manager_; | 452 SyncPointManager* const sync_point_manager_; |
| 477 | 453 |
| 478 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); | 454 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); |
| 479 }; | 455 }; |
| 480 | 456 |
| 481 } // namespace gpu | 457 } // namespace gpu |
| 482 | 458 |
| 483 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_H_ | 459 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
| OLD | NEW |