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 #include "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 } // anonymous namespace | 279 } // anonymous namespace |
280 | 280 |
281 // This class creates a GPU thread (instead of a GPU process), when running | 281 // This class creates a GPU thread (instead of a GPU process), when running |
282 // with --in-process-gpu or --single-process. | 282 // with --in-process-gpu or --single-process. |
283 class GpuMainThread : public base::Thread { | 283 class GpuMainThread : public base::Thread { |
284 public: | 284 public: |
285 explicit GpuMainThread(const std::string& channel_id) | 285 explicit GpuMainThread(const std::string& channel_id) |
286 : base::Thread("Chrome_InProcGpuThread"), | 286 : base::Thread("Chrome_InProcGpuThread"), |
287 channel_id_(channel_id), | 287 channel_id_(channel_id), |
288 gpu_process_(NULL), | 288 gpu_process_(NULL) { |
289 child_thread_(NULL) { | |
290 } | 289 } |
291 | 290 |
292 virtual ~GpuMainThread() { | 291 virtual ~GpuMainThread() { |
293 Stop(); | 292 Stop(); |
294 } | 293 } |
295 | 294 |
296 protected: | 295 protected: |
297 virtual void Init() OVERRIDE { | 296 virtual void Init() OVERRIDE { |
298 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { | 297 gpu_process_ = new GpuProcess(); |
299 child_thread_ = new GpuChildThread(channel_id_); | 298 // The process object takes ownership of the thread object, so do not |
300 } else { | 299 // save and delete the pointer. |
301 gpu_process_ = new GpuProcess(); | 300 gpu_process_->set_main_thread(new GpuChildThread(channel_id_)); |
302 // The process object takes ownership of the thread object, so do not | |
303 // save and delete the pointer. | |
304 gpu_process_->set_main_thread(new GpuChildThread(channel_id_)); | |
305 } | |
306 } | 301 } |
307 | 302 |
308 virtual void CleanUp() OVERRIDE { | 303 virtual void CleanUp() OVERRIDE { |
309 delete gpu_process_; | 304 delete gpu_process_; |
310 if (child_thread_) | |
311 delete child_thread_; | |
312 } | 305 } |
313 | 306 |
314 private: | 307 private: |
315 std::string channel_id_; | 308 std::string channel_id_; |
316 // Deleted in CleanUp() on the gpu thread, so don't use smart pointers. | 309 // Deleted in CleanUp() on the gpu thread, so don't use smart pointers. |
317 GpuProcess* gpu_process_; | 310 GpuProcess* gpu_process_; |
318 GpuChildThread* child_thread_; | |
319 | 311 |
320 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); | 312 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); |
321 }; | 313 }; |
322 | 314 |
323 // static | 315 // static |
324 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { | 316 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { |
325 if (!host) | 317 if (!host) |
326 return false; | 318 return false; |
327 | 319 |
328 // The Gpu process is invalid if it's not using SwiftShader, the card is | 320 // The Gpu process is invalid if it's not using SwiftShader, the card is |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1269 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1278 ClientIdToShaderCacheMap::iterator iter = | 1270 ClientIdToShaderCacheMap::iterator iter = |
1279 client_id_to_shader_cache_.find(client_id); | 1271 client_id_to_shader_cache_.find(client_id); |
1280 // If the cache doesn't exist then this is an off the record profile. | 1272 // If the cache doesn't exist then this is an off the record profile. |
1281 if (iter == client_id_to_shader_cache_.end()) | 1273 if (iter == client_id_to_shader_cache_.end()) |
1282 return; | 1274 return; |
1283 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1275 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1284 } | 1276 } |
1285 | 1277 |
1286 } // namespace content | 1278 } // namespace content |
OLD | NEW |