| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "gpu/command_buffer/service/query_manager.h" | 40 #include "gpu/command_buffer/service/query_manager.h" |
| 41 #include "gpu/command_buffer/service/sync_point_manager.h" | 41 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 42 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 42 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 43 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 43 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 44 #include "ui/gfx/geometry/size.h" | 44 #include "ui/gfx/geometry/size.h" |
| 45 #include "ui/gl/gl_context.h" | 45 #include "ui/gl/gl_context.h" |
| 46 #include "ui/gl/gl_image.h" | 46 #include "ui/gl/gl_image.h" |
| 47 #include "ui/gl/gl_image_shared_memory.h" | 47 #include "ui/gl/gl_image_shared_memory.h" |
| 48 #include "ui/gl/gl_share_group.h" | 48 #include "ui/gl/gl_share_group.h" |
| 49 | 49 |
| 50 #if defined(OS_ANDROID) | |
| 51 #include "gpu/command_buffer/service/stream_texture_manager_in_process_android.h
" | |
| 52 #include "ui/gl/android/surface_texture.h" | |
| 53 #endif | |
| 54 | |
| 55 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 56 #include <windows.h> | 51 #include <windows.h> |
| 57 #include "base/process/process_handle.h" | 52 #include "base/process/process_handle.h" |
| 58 #endif | 53 #endif |
| 59 | 54 |
| 60 namespace gpu { | 55 namespace gpu { |
| 61 | 56 |
| 62 namespace { | 57 namespace { |
| 63 | 58 |
| 64 base::StaticAtomicSequenceNumber g_next_command_buffer_id; | 59 base::StaticAtomicSequenceNumber g_next_command_buffer_id; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (!command_buffer->Initialize()) { | 330 if (!command_buffer->Initialize()) { |
| 336 LOG(ERROR) << "Could not initialize command buffer."; | 331 LOG(ERROR) << "Could not initialize command buffer."; |
| 337 DestroyOnGpuThread(); | 332 DestroyOnGpuThread(); |
| 338 return false; | 333 return false; |
| 339 } | 334 } |
| 340 | 335 |
| 341 gl_share_group_ = params.context_group | 336 gl_share_group_ = params.context_group |
| 342 ? params.context_group->gl_share_group_ | 337 ? params.context_group->gl_share_group_ |
| 343 : service_->share_group(); | 338 : service_->share_group(); |
| 344 | 339 |
| 345 #if defined(OS_ANDROID) | |
| 346 stream_texture_manager_.reset(new StreamTextureManagerInProcess); | |
| 347 #endif | |
| 348 | |
| 349 bool bind_generates_resource = false; | 340 bool bind_generates_resource = false; |
| 350 decoder_.reset(gles2::GLES2Decoder::Create( | 341 decoder_.reset(gles2::GLES2Decoder::Create( |
| 351 params.context_group | 342 params.context_group |
| 352 ? params.context_group->decoder_->GetContextGroup() | 343 ? params.context_group->decoder_->GetContextGroup() |
| 353 : new gles2::ContextGroup(service_->gpu_preferences(), | 344 : new gles2::ContextGroup(service_->gpu_preferences(), |
| 354 service_->mailbox_manager(), NULL, | 345 service_->mailbox_manager(), NULL, |
| 355 service_->shader_translator_cache(), | 346 service_->shader_translator_cache(), |
| 356 service_->framebuffer_completeness_cache(), | 347 service_->framebuffer_completeness_cache(), |
| 357 NULL, service_->subscription_ref_set(), | 348 NULL, service_->subscription_ref_set(), |
| 358 service_->pending_valuebuffer_state(), | 349 service_->pending_valuebuffer_state(), |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 decoder_.reset(); | 468 decoder_.reset(); |
| 478 } | 469 } |
| 479 context_ = nullptr; | 470 context_ = nullptr; |
| 480 surface_ = nullptr; | 471 surface_ = nullptr; |
| 481 sync_point_client_ = nullptr; | 472 sync_point_client_ = nullptr; |
| 482 if (sync_point_order_data_) { | 473 if (sync_point_order_data_) { |
| 483 sync_point_order_data_->Destroy(); | 474 sync_point_order_data_->Destroy(); |
| 484 sync_point_order_data_ = nullptr; | 475 sync_point_order_data_ = nullptr; |
| 485 } | 476 } |
| 486 gl_share_group_ = nullptr; | 477 gl_share_group_ = nullptr; |
| 487 #if defined(OS_ANDROID) | |
| 488 stream_texture_manager_.reset(); | |
| 489 #endif | |
| 490 | 478 |
| 491 return true; | 479 return true; |
| 492 } | 480 } |
| 493 | 481 |
| 494 void InProcessCommandBuffer::CheckSequencedThread() { | 482 void InProcessCommandBuffer::CheckSequencedThread() { |
| 495 DCHECK(!sequence_checker_ || | 483 DCHECK(!sequence_checker_ || |
| 496 sequence_checker_->CalledOnValidSequencedThread()); | 484 sequence_checker_->CalledOnValidSequencedThread()); |
| 497 } | 485 } |
| 498 | 486 |
| 499 void InProcessCommandBuffer::OnContextLostOnGpuThread() { | 487 void InProcessCommandBuffer::OnContextLostOnGpuThread() { |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 base::Unretained(this), | 974 base::Unretained(this), |
| 987 sync_token, | 975 sync_token, |
| 988 WrapCallback(callback))); | 976 WrapCallback(callback))); |
| 989 } | 977 } |
| 990 | 978 |
| 991 bool InProcessCommandBuffer::CanWaitUnverifiedSyncToken( | 979 bool InProcessCommandBuffer::CanWaitUnverifiedSyncToken( |
| 992 const SyncToken* sync_token) { | 980 const SyncToken* sync_token) { |
| 993 return sync_token->namespace_id() == GetNamespaceID(); | 981 return sync_token->namespace_id() == GetNamespaceID(); |
| 994 } | 982 } |
| 995 | 983 |
| 996 uint32_t InProcessCommandBuffer::CreateStreamTextureOnGpuThread( | |
| 997 uint32_t client_texture_id) { | |
| 998 #if defined(OS_ANDROID) | |
| 999 return stream_texture_manager_->CreateStreamTexture( | |
| 1000 client_texture_id, decoder_->GetContextGroup()->texture_manager()); | |
| 1001 #else | |
| 1002 return 0; | |
| 1003 #endif | |
| 1004 } | |
| 1005 | |
| 1006 gpu::error::Error InProcessCommandBuffer::GetLastError() { | 984 gpu::error::Error InProcessCommandBuffer::GetLastError() { |
| 1007 CheckSequencedThread(); | 985 CheckSequencedThread(); |
| 1008 return last_state_.error; | 986 return last_state_.error; |
| 1009 } | 987 } |
| 1010 | 988 |
| 1011 bool InProcessCommandBuffer::Initialize() { | 989 bool InProcessCommandBuffer::Initialize() { |
| 1012 NOTREACHED(); | 990 NOTREACHED(); |
| 1013 return false; | 991 return false; |
| 1014 } | 992 } |
| 1015 | 993 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1042 base::Closure callback_on_client_thread = | 1020 base::Closure callback_on_client_thread = |
| 1043 base::Bind(&RunOnTargetThread, base::Passed(&scoped_callback)); | 1021 base::Bind(&RunOnTargetThread, base::Passed(&scoped_callback)); |
| 1044 base::Closure wrapped_callback = | 1022 base::Closure wrapped_callback = |
| 1045 base::Bind(&PostCallback, base::ThreadTaskRunnerHandle::IsSet() | 1023 base::Bind(&PostCallback, base::ThreadTaskRunnerHandle::IsSet() |
| 1046 ? base::ThreadTaskRunnerHandle::Get() | 1024 ? base::ThreadTaskRunnerHandle::Get() |
| 1047 : nullptr, | 1025 : nullptr, |
| 1048 callback_on_client_thread); | 1026 callback_on_client_thread); |
| 1049 return wrapped_callback; | 1027 return wrapped_callback; |
| 1050 } | 1028 } |
| 1051 | 1029 |
| 1052 #if defined(OS_ANDROID) | |
| 1053 scoped_refptr<gfx::SurfaceTexture> InProcessCommandBuffer::GetSurfaceTexture( | |
| 1054 uint32_t stream_id) { | |
| 1055 DCHECK(stream_texture_manager_); | |
| 1056 return stream_texture_manager_->GetSurfaceTexture(stream_id); | |
| 1057 } | |
| 1058 | |
| 1059 uint32_t InProcessCommandBuffer::CreateStreamTexture(uint32_t texture_id) { | |
| 1060 base::WaitableEvent completion(true, false); | |
| 1061 uint32_t stream_id = 0; | |
| 1062 base::Callback<uint32_t(void)> task = | |
| 1063 base::Bind(&InProcessCommandBuffer::CreateStreamTextureOnGpuThread, | |
| 1064 base::Unretained(this), texture_id); | |
| 1065 QueueTask( | |
| 1066 base::Bind(&RunTaskWithResult<uint32_t>, task, &stream_id, &completion)); | |
| 1067 completion.Wait(); | |
| 1068 return stream_id; | |
| 1069 } | |
| 1070 #endif | |
| 1071 | |
| 1072 GpuInProcessThread::GpuInProcessThread(SyncPointManager* sync_point_manager) | 1030 GpuInProcessThread::GpuInProcessThread(SyncPointManager* sync_point_manager) |
| 1073 : base::Thread("GpuThread"), sync_point_manager_(sync_point_manager) { | 1031 : base::Thread("GpuThread"), sync_point_manager_(sync_point_manager) { |
| 1074 Start(); | 1032 Start(); |
| 1075 } | 1033 } |
| 1076 | 1034 |
| 1077 GpuInProcessThread::~GpuInProcessThread() { | 1035 GpuInProcessThread::~GpuInProcessThread() { |
| 1078 Stop(); | 1036 Stop(); |
| 1079 } | 1037 } |
| 1080 | 1038 |
| 1081 void GpuInProcessThread::AddRef() const { | 1039 void GpuInProcessThread::AddRef() const { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 framebuffer_completeness_cache_ = | 1072 framebuffer_completeness_cache_ = |
| 1115 new gpu::gles2::FramebufferCompletenessCache; | 1073 new gpu::gles2::FramebufferCompletenessCache; |
| 1116 return framebuffer_completeness_cache_; | 1074 return framebuffer_completeness_cache_; |
| 1117 } | 1075 } |
| 1118 | 1076 |
| 1119 SyncPointManager* GpuInProcessThread::sync_point_manager() { | 1077 SyncPointManager* GpuInProcessThread::sync_point_manager() { |
| 1120 return sync_point_manager_; | 1078 return sync_point_manager_; |
| 1121 } | 1079 } |
| 1122 | 1080 |
| 1123 } // namespace gpu | 1081 } // namespace gpu |
| OLD | NEW |