| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 94 | 94 | 
| 95 GpuInProcessThread::~GpuInProcessThread() { | 95 GpuInProcessThread::~GpuInProcessThread() { | 
| 96   Stop(); | 96   Stop(); | 
| 97 } | 97 } | 
| 98 | 98 | 
| 99 void GpuInProcessThread::ScheduleTask(const base::Closure& task) { | 99 void GpuInProcessThread::ScheduleTask(const base::Closure& task) { | 
| 100   message_loop()->PostTask(FROM_HERE, task); | 100   message_loop()->PostTask(FROM_HERE, task); | 
| 101 } | 101 } | 
| 102 | 102 | 
| 103 void GpuInProcessThread::ScheduleIdleWork(const base::Closure& callback) { | 103 void GpuInProcessThread::ScheduleIdleWork(const base::Closure& callback) { | 
|  | 104   // Match delay with GpuCommandBufferStub. | 
| 104   message_loop()->PostDelayedTask( | 105   message_loop()->PostDelayedTask( | 
| 105       FROM_HERE, callback, base::TimeDelta::FromMilliseconds(5)); | 106       FROM_HERE, callback, base::TimeDelta::FromMilliseconds(2)); | 
| 106 } | 107 } | 
| 107 | 108 | 
| 108 scoped_refptr<gles2::ShaderTranslatorCache> | 109 scoped_refptr<gles2::ShaderTranslatorCache> | 
| 109 GpuInProcessThread::shader_translator_cache() { | 110 GpuInProcessThread::shader_translator_cache() { | 
| 110   if (!shader_translator_cache_.get()) | 111   if (!shader_translator_cache_.get()) | 
| 111     shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; | 112     shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; | 
| 112   return shader_translator_cache_; | 113   return shader_translator_cache_; | 
| 113 } | 114 } | 
| 114 | 115 | 
| 115 struct GpuInProcessThreadHolder { | 116 struct GpuInProcessThreadHolder { | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 231       return gfx::GpuMemoryBufferHandle(); | 232       return gfx::GpuMemoryBufferHandle(); | 
| 232   } | 233   } | 
| 233 } | 234 } | 
| 234 | 235 | 
| 235 }  // anonyous namespace | 236 }  // anonyous namespace | 
| 236 | 237 | 
| 237 InProcessCommandBuffer::Service::Service() {} | 238 InProcessCommandBuffer::Service::Service() {} | 
| 238 | 239 | 
| 239 InProcessCommandBuffer::Service::~Service() {} | 240 InProcessCommandBuffer::Service::~Service() {} | 
| 240 | 241 | 
|  | 242 scoped_refptr<gfx::GLShareGroup> | 
|  | 243 InProcessCommandBuffer::Service::share_group() { | 
|  | 244   if (!share_group_.get()) | 
|  | 245     share_group_ = new gfx::GLShareGroup; | 
|  | 246   return share_group_; | 
|  | 247 } | 
|  | 248 | 
| 241 scoped_refptr<gles2::MailboxManager> | 249 scoped_refptr<gles2::MailboxManager> | 
| 242 InProcessCommandBuffer::Service::mailbox_manager() { | 250 InProcessCommandBuffer::Service::mailbox_manager() { | 
| 243   if (!mailbox_manager_.get()) { | 251   if (!mailbox_manager_.get()) { | 
| 244     if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 252     if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 
| 245             switches::kEnableThreadedTextureMailboxes)) { | 253             switches::kEnableThreadedTextureMailboxes)) { | 
| 246       mailbox_manager_ = new gles2::MailboxManagerSync(); | 254       mailbox_manager_ = new gles2::MailboxManagerSync(); | 
| 247     } else { | 255     } else { | 
| 248       mailbox_manager_ = new gles2::MailboxManagerImpl(); | 256       mailbox_manager_ = new gles2::MailboxManagerImpl(); | 
| 249     } | 257     } | 
| 250   } | 258   } | 
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 390   command_buffer->SetParseErrorCallback(base::Bind( | 398   command_buffer->SetParseErrorCallback(base::Bind( | 
| 391       &InProcessCommandBuffer::OnContextLost, gpu_thread_weak_ptr_)); | 399       &InProcessCommandBuffer::OnContextLost, gpu_thread_weak_ptr_)); | 
| 392 | 400 | 
| 393   if (!command_buffer->Initialize()) { | 401   if (!command_buffer->Initialize()) { | 
| 394     LOG(ERROR) << "Could not initialize command buffer."; | 402     LOG(ERROR) << "Could not initialize command buffer."; | 
| 395     DestroyOnGpuThread(); | 403     DestroyOnGpuThread(); | 
| 396     return false; | 404     return false; | 
| 397   } | 405   } | 
| 398 | 406 | 
| 399   gl_share_group_ = params.context_group | 407   gl_share_group_ = params.context_group | 
| 400                         ? params.context_group->gl_share_group_.get() | 408                         ? params.context_group->gl_share_group_ | 
| 401                         : new gfx::GLShareGroup; | 409                         : service_->share_group(); | 
| 402 | 410 | 
| 403 #if defined(OS_ANDROID) | 411 #if defined(OS_ANDROID) | 
| 404   stream_texture_manager_.reset(new StreamTextureManagerInProcess); | 412   stream_texture_manager_.reset(new StreamTextureManagerInProcess); | 
| 405 #endif | 413 #endif | 
| 406 | 414 | 
| 407   bool bind_generates_resource = false; | 415   bool bind_generates_resource = false; | 
| 408   decoder_.reset(gles2::GLES2Decoder::Create( | 416   decoder_.reset(gles2::GLES2Decoder::Create( | 
| 409       params.context_group | 417       params.context_group | 
| 410           ? params.context_group->decoder_->GetContextGroup() | 418           ? params.context_group->decoder_->GetContextGroup() | 
| 411           : new gles2::ContextGroup(service_->mailbox_manager(), | 419           : new gles2::ContextGroup(service_->mailbox_manager(), | 
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 949 | 957 | 
| 950 #if defined(OS_ANDROID) | 958 #if defined(OS_ANDROID) | 
| 951 scoped_refptr<gfx::SurfaceTexture> | 959 scoped_refptr<gfx::SurfaceTexture> | 
| 952 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 960 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 
| 953   DCHECK(stream_texture_manager_); | 961   DCHECK(stream_texture_manager_); | 
| 954   return stream_texture_manager_->GetSurfaceTexture(stream_id); | 962   return stream_texture_manager_->GetSurfaceTexture(stream_id); | 
| 955 } | 963 } | 
| 956 #endif | 964 #endif | 
| 957 | 965 | 
| 958 }  // namespace gpu | 966 }  // namespace gpu | 
| OLD | NEW | 
|---|