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_GPU_CHANNEL_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/containers/scoped_ptr_hash_map.h" |
11 #include "base/id_map.h" | 12 #include "base/id_map.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "base/process/process.h" | 17 #include "base/process/process.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "content/common/gpu/gpu_command_buffer_stub.h" | 19 #include "content/common/gpu/gpu_command_buffer_stub.h" |
19 #include "content/common/gpu/gpu_memory_manager.h" | 20 #include "content/common/gpu/gpu_memory_manager.h" |
20 #include "content/common/gpu/gpu_result_codes.h" | 21 #include "content/common/gpu/gpu_result_codes.h" |
| 22 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
21 #include "content/common/message_router.h" | 23 #include "content/common/message_router.h" |
22 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 24 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
23 #include "ipc/ipc_sync_channel.h" | 25 #include "ipc/ipc_sync_channel.h" |
24 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
25 #include "ui/gfx/native_widget_types.h" | 27 #include "ui/gfx/native_widget_types.h" |
26 #include "ui/gl/gl_share_group.h" | 28 #include "ui/gl/gl_share_group.h" |
27 #include "ui/gl/gpu_preference.h" | 29 #include "ui/gl/gpu_preference.h" |
28 | 30 |
29 struct GPUCreateCommandBufferConfig; | 31 struct GPUCreateCommandBufferConfig; |
30 | 32 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 bool allow_future_sync_points() const { return allow_future_sync_points_; } | 163 bool allow_future_sync_points() const { return allow_future_sync_points_; } |
162 | 164 |
163 void HandleUpdateValueState(unsigned int target, | 165 void HandleUpdateValueState(unsigned int target, |
164 const gpu::ValueState& state); | 166 const gpu::ValueState& state); |
165 | 167 |
166 // Visible for testing. | 168 // Visible for testing. |
167 const gpu::ValueStateMap* pending_valuebuffer_state() const { | 169 const gpu::ValueStateMap* pending_valuebuffer_state() const { |
168 return pending_valuebuffer_state_.get(); | 170 return pending_valuebuffer_state_.get(); |
169 } | 171 } |
170 | 172 |
| 173 void ReleaseJpegDecoder(int32 route_id); |
| 174 |
171 private: | 175 private: |
172 friend class GpuChannelMessageFilter; | 176 friend class GpuChannelMessageFilter; |
173 | 177 |
174 void OnDestroy(); | 178 void OnDestroy(); |
175 | 179 |
176 bool OnControlMessageReceived(const IPC::Message& msg); | 180 bool OnControlMessageReceived(const IPC::Message& msg); |
177 | 181 |
178 void HandleMessage(); | 182 void HandleMessage(); |
179 | 183 |
180 // Message handlers. | 184 // Message handlers. |
181 void OnCreateOffscreenCommandBuffer( | 185 void OnCreateOffscreenCommandBuffer( |
182 const gfx::Size& size, | 186 const gfx::Size& size, |
183 const GPUCreateCommandBufferConfig& init_params, | 187 const GPUCreateCommandBufferConfig& init_params, |
184 int32 route_id, | 188 int32 route_id, |
185 bool* succeeded); | 189 bool* succeeded); |
186 void OnDestroyCommandBuffer(int32 route_id); | 190 void OnDestroyCommandBuffer(int32 route_id); |
| 191 void OnCreateJpegDecoder(int32 route_id, bool* succeeded); |
187 | 192 |
188 // Decrement the count of unhandled IPC messages and defer preemption. | 193 // Decrement the count of unhandled IPC messages and defer preemption. |
189 void MessageProcessed(); | 194 void MessageProcessed(); |
190 | 195 |
191 // The lifetime of objects of this class is managed by a GpuChannelManager. | 196 // The lifetime of objects of this class is managed by a GpuChannelManager. |
192 // The GpuChannelManager destroy all the GpuChannels that they own when they | 197 // The GpuChannelManager destroy all the GpuChannels that they own when they |
193 // are destroyed. So a raw pointer is safe. | 198 // are destroyed. So a raw pointer is safe. |
194 GpuChannelManager* gpu_channel_manager_; | 199 GpuChannelManager* gpu_channel_manager_; |
195 | 200 |
196 scoped_ptr<IPC::SyncChannel> channel_; | 201 scoped_ptr<IPC::SyncChannel> channel_; |
(...skipping 25 matching lines...) Expand all Loading... |
222 | 227 |
223 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 228 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
224 | 229 |
225 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_; | 230 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_; |
226 | 231 |
227 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; | 232 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; |
228 | 233 |
229 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; | 234 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; |
230 StubMap stubs_; | 235 StubMap stubs_; |
231 | 236 |
| 237 // A map from route id to Jpeg decoder. |
| 238 base::ScopedPtrHashMap<int32, scoped_ptr<content::GpuJpegDecodeAccelerator>> |
| 239 jpeg_decoder_map_; |
| 240 |
232 bool log_messages_; // True if we should log sent and received messages. | 241 bool log_messages_; // True if we should log sent and received messages. |
233 gpu::gles2::DisallowedFeatures disallowed_features_; | 242 gpu::gles2::DisallowedFeatures disallowed_features_; |
234 GpuWatchdog* watchdog_; | 243 GpuWatchdog* watchdog_; |
235 bool software_; | 244 bool software_; |
236 bool handle_messages_scheduled_; | 245 bool handle_messages_scheduled_; |
237 IPC::Message* currently_processing_message_; | 246 IPC::Message* currently_processing_message_; |
238 | 247 |
239 scoped_refptr<GpuChannelMessageFilter> filter_; | 248 scoped_refptr<GpuChannelMessageFilter> filter_; |
240 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 249 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
241 | 250 |
242 size_t num_stubs_descheduled_; | 251 size_t num_stubs_descheduled_; |
243 | 252 |
244 bool allow_future_sync_points_; | 253 bool allow_future_sync_points_; |
245 | 254 |
246 // Member variables should appear before the WeakPtrFactory, to ensure | 255 // Member variables should appear before the WeakPtrFactory, to ensure |
247 // that any WeakPtrs to Controller are invalidated before its members | 256 // that any WeakPtrs to Controller are invalidated before its members |
248 // variable's destructors are executed, rendering them invalid. | 257 // variable's destructors are executed, rendering them invalid. |
249 base::WeakPtrFactory<GpuChannel> weak_factory_; | 258 base::WeakPtrFactory<GpuChannel> weak_factory_; |
250 | 259 |
251 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 260 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
252 }; | 261 }; |
253 | 262 |
254 } // namespace content | 263 } // namespace content |
255 | 264 |
256 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 265 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
OLD | NEW |