| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/gles2/command_buffer_client_impl.h" | 5 #include "mojo/gles2/command_buffer_client_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| 11 #include "base/threading/thread_restrictions.h" |
| 11 #include "components/mus/gles2/command_buffer_type_conversions.h" | 12 #include "components/mus/gles2/command_buffer_type_conversions.h" |
| 12 #include "components/mus/gles2/mojo_buffer_backing.h" | 13 #include "components/mus/gles2/mojo_buffer_backing.h" |
| 13 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" | 14 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" |
| 14 #include "gpu/command_buffer/service/image_factory.h" | 15 #include "gpu/command_buffer/service/image_factory.h" |
| 15 #include "mojo/platform_handle/platform_handle_functions.h" | 16 #include "mojo/platform_handle/platform_handle_functions.h" |
| 16 | 17 |
| 17 namespace gles2 { | 18 namespace gles2 { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( | 135 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( |
| 135 command_buffer_handle.Pass(), 0u), | 136 command_buffer_handle.Pass(), 0u), |
| 136 async_waiter); | 137 async_waiter); |
| 137 command_buffer_.set_connection_error_handler( | 138 command_buffer_.set_connection_error_handler( |
| 138 [this]() { DidLoseContext(gpu::error::kUnknown); }); | 139 [this]() { DidLoseContext(gpu::error::kUnknown); }); |
| 139 } | 140 } |
| 140 | 141 |
| 141 CommandBufferClientImpl::~CommandBufferClientImpl() {} | 142 CommandBufferClientImpl::~CommandBufferClientImpl() {} |
| 142 | 143 |
| 143 bool CommandBufferClientImpl::Initialize() { | 144 bool CommandBufferClientImpl::Initialize() { |
| 145 base::ThreadRestrictions::ScopedAllowWait wait; |
| 146 |
| 144 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 147 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
| 145 void* memory = NULL; | 148 void* memory = NULL; |
| 146 mojo::ScopedSharedBufferHandle duped; | 149 mojo::ScopedSharedBufferHandle duped; |
| 147 bool result = CreateMapAndDupSharedBuffer( | 150 bool result = CreateMapAndDupSharedBuffer( |
| 148 kSharedStateSize, &memory, &shared_state_handle_, &duped); | 151 kSharedStateSize, &memory, &shared_state_handle_, &duped); |
| 149 if (!result) | 152 if (!result) |
| 150 return false; | 153 return false; |
| 151 | 154 |
| 152 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); | 155 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); |
| 153 | 156 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 gfx::Size(static_cast<int>(width), static_cast<int>(height)), | 325 gfx::Size(static_cast<int>(width), static_cast<int>(height)), |
| 323 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), | 326 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), |
| 324 gfx::BufferUsage::SCANOUT)); | 327 gfx::BufferUsage::SCANOUT)); |
| 325 if (!buffer) | 328 if (!buffer) |
| 326 return -1; | 329 return -1; |
| 327 | 330 |
| 328 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 331 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); |
| 329 } | 332 } |
| 330 | 333 |
| 331 uint32_t CommandBufferClientImpl::InsertSyncPoint() { | 334 uint32_t CommandBufferClientImpl::InsertSyncPoint() { |
| 335 base::ThreadRestrictions::ScopedAllowWait wait; |
| 332 command_buffer_->InsertSyncPoint(true); | 336 command_buffer_->InsertSyncPoint(true); |
| 333 return sync_point_client_impl_->WaitForInsertSyncPoint(); | 337 return sync_point_client_impl_->WaitForInsertSyncPoint(); |
| 334 } | 338 } |
| 335 | 339 |
| 336 uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { | 340 uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { |
| 337 command_buffer_->InsertSyncPoint(false); | 341 command_buffer_->InsertSyncPoint(false); |
| 338 return sync_point_client_impl_->WaitForInsertSyncPoint(); | 342 return sync_point_client_impl_->WaitForInsertSyncPoint(); |
| 339 } | 343 } |
| 340 | 344 |
| 341 void CommandBufferClientImpl::RetireSyncPoint(uint32_t sync_point) { | 345 void CommandBufferClientImpl::RetireSyncPoint(uint32_t sync_point) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 // TODO(dyen) | 437 // TODO(dyen) |
| 434 } | 438 } |
| 435 | 439 |
| 436 bool CommandBufferClientImpl::CanWaitUnverifiedSyncToken( | 440 bool CommandBufferClientImpl::CanWaitUnverifiedSyncToken( |
| 437 const gpu::SyncToken* sync_token) { | 441 const gpu::SyncToken* sync_token) { |
| 438 // All sync tokens must be flushed before being waited on. | 442 // All sync tokens must be flushed before being waited on. |
| 439 return false; | 443 return false; |
| 440 } | 444 } |
| 441 | 445 |
| 442 } // namespace gles2 | 446 } // namespace gles2 |
| OLD | NEW |