OLD | NEW |
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 Loading... |
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 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache() |
| 77 OVERRIDE; |
76 | 78 |
77 private: | 79 private: |
78 virtual ~GpuInProcessThread(); | 80 virtual ~GpuInProcessThread(); |
79 friend class base::RefCountedThreadSafe<GpuInProcessThread>; | 81 friend class base::RefCountedThreadSafe<GpuInProcessThread>; |
80 | 82 |
| 83 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
81 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); | 84 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); |
82 }; | 85 }; |
83 | 86 |
84 GpuInProcessThread::GpuInProcessThread() : base::Thread("GpuThread") { | 87 GpuInProcessThread::GpuInProcessThread() : base::Thread("GpuThread") { |
85 Start(); | 88 Start(); |
86 } | 89 } |
87 | 90 |
88 GpuInProcessThread::~GpuInProcessThread() { | 91 GpuInProcessThread::~GpuInProcessThread() { |
89 Stop(); | 92 Stop(); |
90 } | 93 } |
91 | 94 |
92 void GpuInProcessThread::ScheduleTask(const base::Closure& task) { | 95 void GpuInProcessThread::ScheduleTask(const base::Closure& task) { |
93 message_loop()->PostTask(FROM_HERE, task); | 96 message_loop()->PostTask(FROM_HERE, task); |
94 } | 97 } |
95 | 98 |
96 void GpuInProcessThread::ScheduleIdleWork(const base::Closure& callback) { | 99 void GpuInProcessThread::ScheduleIdleWork(const base::Closure& callback) { |
97 message_loop()->PostDelayedTask( | 100 message_loop()->PostDelayedTask( |
98 FROM_HERE, callback, base::TimeDelta::FromMilliseconds(5)); | 101 FROM_HERE, callback, base::TimeDelta::FromMilliseconds(5)); |
99 } | 102 } |
100 | 103 |
| 104 scoped_refptr<gles2::ShaderTranslatorCache> |
| 105 GpuInProcessThread::shader_translator_cache() { |
| 106 if (!shader_translator_cache_.get()) |
| 107 shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; |
| 108 return shader_translator_cache_; |
| 109 } |
| 110 |
101 base::LazyInstance<std::set<InProcessCommandBuffer*> > default_thread_clients_ = | 111 base::LazyInstance<std::set<InProcessCommandBuffer*> > default_thread_clients_ = |
102 LAZY_INSTANCE_INITIALIZER; | 112 LAZY_INSTANCE_INITIALIZER; |
103 base::LazyInstance<base::Lock> default_thread_clients_lock_ = | 113 base::LazyInstance<base::Lock> default_thread_clients_lock_ = |
104 LAZY_INSTANCE_INITIALIZER; | 114 LAZY_INSTANCE_INITIALIZER; |
105 | 115 |
106 class ScopedEvent { | 116 class ScopedEvent { |
107 public: | 117 public: |
108 ScopedEvent(base::WaitableEvent* event) : event_(event) {} | 118 ScopedEvent(base::WaitableEvent* event) : event_(event) {} |
109 ~ScopedEvent() { event_->Signal(); } | 119 ~ScopedEvent() { event_->Signal(); } |
110 | 120 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 gl_share_group_ = params.context_group | 328 gl_share_group_ = params.context_group |
319 ? params.context_group->gl_share_group_.get() | 329 ? params.context_group->gl_share_group_.get() |
320 : new gfx::GLShareGroup; | 330 : new gfx::GLShareGroup; |
321 | 331 |
322 #if defined(OS_ANDROID) | 332 #if defined(OS_ANDROID) |
323 stream_texture_manager_.reset(new StreamTextureManagerInProcess); | 333 stream_texture_manager_.reset(new StreamTextureManagerInProcess); |
324 #endif | 334 #endif |
325 | 335 |
326 bool bind_generates_resource = false; | 336 bool bind_generates_resource = false; |
327 decoder_.reset(gles2::GLES2Decoder::Create( | 337 decoder_.reset(gles2::GLES2Decoder::Create( |
328 params.context_group ? params.context_group->decoder_->GetContextGroup() | 338 params.context_group |
329 : new gles2::ContextGroup(NULL, | 339 ? params.context_group->decoder_->GetContextGroup() |
330 NULL, | 340 : new gles2::ContextGroup(NULL, |
331 NULL, | 341 NULL, |
332 NULL, | 342 NULL, |
333 bind_generates_resource))); | 343 service_->shader_translator_cache(), |
| 344 NULL, |
| 345 bind_generates_resource))); |
334 | 346 |
335 gpu_scheduler_.reset( | 347 gpu_scheduler_.reset( |
336 new GpuScheduler(command_buffer.get(), decoder_.get(), decoder_.get())); | 348 new GpuScheduler(command_buffer.get(), decoder_.get(), decoder_.get())); |
337 command_buffer->SetGetBufferChangeCallback(base::Bind( | 349 command_buffer->SetGetBufferChangeCallback(base::Bind( |
338 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); | 350 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); |
339 command_buffer_ = command_buffer.Pass(); | 351 command_buffer_ = command_buffer.Pass(); |
340 | 352 |
341 decoder_->set_engine(gpu_scheduler_.get()); | 353 decoder_->set_engine(gpu_scheduler_.get()); |
342 | 354 |
343 if (!surface_) { | 355 if (!surface_) { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 } | 754 } |
743 #endif | 755 #endif |
744 | 756 |
745 // static | 757 // static |
746 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( | 758 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( |
747 GpuMemoryBufferFactory* factory) { | 759 GpuMemoryBufferFactory* factory) { |
748 g_gpu_memory_buffer_factory = factory; | 760 g_gpu_memory_buffer_factory = factory; |
749 } | 761 } |
750 | 762 |
751 } // namespace gpu | 763 } // namespace gpu |
OLD | NEW |