Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.cc

Issue 217813004: Make ShaderTranslatorCache thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: protect ShFinalize Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "gpu/command_buffer/service/in_process_command_buffer.h" 5 #include "gpu/command_buffer/service/in_process_command_buffer.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 virtual void AddRef() const OVERRIDE { 66 virtual void AddRef() const OVERRIDE {
67 base::RefCountedThreadSafe<GpuInProcessThread>::AddRef(); 67 base::RefCountedThreadSafe<GpuInProcessThread>::AddRef();
68 } 68 }
69 virtual void Release() const OVERRIDE { 69 virtual void Release() const OVERRIDE {
70 base::RefCountedThreadSafe<GpuInProcessThread>::Release(); 70 base::RefCountedThreadSafe<GpuInProcessThread>::Release();
71 } 71 }
72 72
73 virtual void ScheduleTask(const base::Closure& task) OVERRIDE; 73 virtual void ScheduleTask(const base::Closure& task) OVERRIDE;
74 virtual void ScheduleIdleWork(const base::Closure& callback) OVERRIDE; 74 virtual void ScheduleIdleWork(const base::Closure& callback) OVERRIDE;
75 virtual bool UseVirtualizedGLContexts() OVERRIDE { return false; } 75 virtual bool UseVirtualizedGLContexts() OVERRIDE { return false; }
76 virtual gles2::ShaderTranslatorCache* shader_translator_cache() OVERRIDE;
76 77
77 private: 78 private:
78 virtual ~GpuInProcessThread(); 79 virtual ~GpuInProcessThread();
79 friend class base::RefCountedThreadSafe<GpuInProcessThread>; 80 friend class base::RefCountedThreadSafe<GpuInProcessThread>;
80 81
82 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_;
81 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); 83 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread);
82 }; 84 };
83 85
84 GpuInProcessThread::GpuInProcessThread() : base::Thread("GpuThread") { 86 GpuInProcessThread::GpuInProcessThread() : base::Thread("GpuThread") {
85 Start(); 87 Start();
86 } 88 }
87 89
88 GpuInProcessThread::~GpuInProcessThread() { 90 GpuInProcessThread::~GpuInProcessThread() {
89 Stop(); 91 Stop();
90 } 92 }
91 93
92 void GpuInProcessThread::ScheduleTask(const base::Closure& task) { 94 void GpuInProcessThread::ScheduleTask(const base::Closure& task) {
93 message_loop()->PostTask(FROM_HERE, task); 95 message_loop()->PostTask(FROM_HERE, task);
94 } 96 }
95 97
96 void GpuInProcessThread::ScheduleIdleWork(const base::Closure& callback) { 98 void GpuInProcessThread::ScheduleIdleWork(const base::Closure& callback) {
97 message_loop()->PostDelayedTask( 99 message_loop()->PostDelayedTask(
98 FROM_HERE, callback, base::TimeDelta::FromMilliseconds(5)); 100 FROM_HERE, callback, base::TimeDelta::FromMilliseconds(5));
99 } 101 }
100 102
103 gles2::ShaderTranslatorCache* GpuInProcessThread::shader_translator_cache() {
104 if (!shader_translator_cache_.get())
105 shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache;
106 return shader_translator_cache_.get();
107 }
108
101 base::LazyInstance<std::set<InProcessCommandBuffer*> > default_thread_clients_ = 109 base::LazyInstance<std::set<InProcessCommandBuffer*> > default_thread_clients_ =
102 LAZY_INSTANCE_INITIALIZER; 110 LAZY_INSTANCE_INITIALIZER;
103 base::LazyInstance<base::Lock> default_thread_clients_lock_ = 111 base::LazyInstance<base::Lock> default_thread_clients_lock_ =
104 LAZY_INSTANCE_INITIALIZER; 112 LAZY_INSTANCE_INITIALIZER;
105 113
106 class ScopedEvent { 114 class ScopedEvent {
107 public: 115 public:
108 ScopedEvent(base::WaitableEvent* event) : event_(event) {} 116 ScopedEvent(base::WaitableEvent* event) : event_(event) {}
109 ~ScopedEvent() { event_->Signal(); } 117 ~ScopedEvent() { event_->Signal(); }
110 118
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if (!context_->MakeCurrent(surface_.get())) { 390 if (!context_->MakeCurrent(surface_.get())) {
383 LOG(ERROR) << "Could not make context current."; 391 LOG(ERROR) << "Could not make context current.";
384 DestroyOnGpuThread(); 392 DestroyOnGpuThread();
385 return false; 393 return false;
386 } 394 }
387 395
388 gles2::DisallowedFeatures disallowed_features; 396 gles2::DisallowedFeatures disallowed_features;
389 disallowed_features.gpu_memory_manager = true; 397 disallowed_features.gpu_memory_manager = true;
390 if (!decoder_->Initialize(surface_, 398 if (!decoder_->Initialize(surface_,
391 context_, 399 context_,
400 service_->shader_translator_cache(),
392 params.is_offscreen, 401 params.is_offscreen,
393 params.size, 402 params.size,
394 disallowed_features, 403 disallowed_features,
395 params.attribs)) { 404 params.attribs)) {
396 LOG(ERROR) << "Could not initialize decoder."; 405 LOG(ERROR) << "Could not initialize decoder.";
397 DestroyOnGpuThread(); 406 DestroyOnGpuThread();
398 return false; 407 return false;
399 } 408 }
400 409
401 gpu_control_.reset( 410 gpu_control_.reset(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } 751 }
743 #endif 752 #endif
744 753
745 // static 754 // static
746 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( 755 void InProcessCommandBuffer::SetGpuMemoryBufferFactory(
747 GpuMemoryBufferFactory* factory) { 756 GpuMemoryBufferFactory* factory) {
748 g_gpu_memory_buffer_factory = factory; 757 g_gpu_memory_buffer_factory = factory;
749 } 758 }
750 759
751 } // namespace gpu 760 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698