| 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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void CommandBufferDelegate::ContextLost() {} | 49 void CommandBufferDelegate::ContextLost() {} |
| 50 | 50 |
| 51 class CommandBufferClientImpl::SyncClientImpl | 51 class CommandBufferClientImpl::SyncClientImpl |
| 52 : public mus::mojom::CommandBufferSyncClient { | 52 : public mus::mojom::CommandBufferSyncClient { |
| 53 public: | 53 public: |
| 54 SyncClientImpl(mus::mojom::CommandBufferSyncClientPtr* ptr, | 54 SyncClientImpl(mus::mojom::CommandBufferSyncClientPtr* ptr, |
| 55 const MojoAsyncWaiter* async_waiter) | 55 const MojoAsyncWaiter* async_waiter) |
| 56 : initialized_successfully_(false), binding_(this, ptr, async_waiter) {} | 56 : initialized_successfully_(false), binding_(this, ptr, async_waiter) {} |
| 57 | 57 |
| 58 bool WaitForInitialization() { | 58 bool WaitForInitialization() { |
| 59 base::ThreadRestrictions::ScopedAllowWait wait; |
| 59 if (!binding_.WaitForIncomingMethodCall()) | 60 if (!binding_.WaitForIncomingMethodCall()) |
| 60 return false; | 61 return false; |
| 61 return initialized_successfully_; | 62 return initialized_successfully_; |
| 62 } | 63 } |
| 63 | 64 |
| 64 mus::mojom::CommandBufferStatePtr WaitForProgress() { | 65 mus::mojom::CommandBufferStatePtr WaitForProgress() { |
| 66 base::ThreadRestrictions::ScopedAllowWait wait; |
| 65 if (!binding_.WaitForIncomingMethodCall()) | 67 if (!binding_.WaitForIncomingMethodCall()) |
| 66 return mus::mojom::CommandBufferStatePtr(); | 68 return mus::mojom::CommandBufferStatePtr(); |
| 67 return command_buffer_state_.Pass(); | 69 return command_buffer_state_.Pass(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 gpu::Capabilities GetCapabilities() { | 72 gpu::Capabilities GetCapabilities() { |
| 71 if (capabilities_) | 73 if (capabilities_) |
| 72 return capabilities_.To<gpu::Capabilities>(); | 74 return capabilities_.To<gpu::Capabilities>(); |
| 73 return gpu::Capabilities(); | 75 return gpu::Capabilities(); |
| 74 } | 76 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 93 }; | 95 }; |
| 94 | 96 |
| 95 class CommandBufferClientImpl::SyncPointClientImpl | 97 class CommandBufferClientImpl::SyncPointClientImpl |
| 96 : public mus::mojom::CommandBufferSyncPointClient { | 98 : public mus::mojom::CommandBufferSyncPointClient { |
| 97 public: | 99 public: |
| 98 SyncPointClientImpl(mus::mojom::CommandBufferSyncPointClientPtr* ptr, | 100 SyncPointClientImpl(mus::mojom::CommandBufferSyncPointClientPtr* ptr, |
| 99 const MojoAsyncWaiter* async_waiter) | 101 const MojoAsyncWaiter* async_waiter) |
| 100 : sync_point_(0u), binding_(this, ptr, async_waiter) {} | 102 : sync_point_(0u), binding_(this, ptr, async_waiter) {} |
| 101 | 103 |
| 102 uint32_t WaitForInsertSyncPoint() { | 104 uint32_t WaitForInsertSyncPoint() { |
| 105 base::ThreadRestrictions::ScopedAllowWait wait; |
| 103 if (!binding_.WaitForIncomingMethodCall()) | 106 if (!binding_.WaitForIncomingMethodCall()) |
| 104 return 0u; | 107 return 0u; |
| 105 uint32_t result = sync_point_; | 108 uint32_t result = sync_point_; |
| 106 sync_point_ = 0u; | 109 sync_point_ = 0u; |
| 107 return result; | 110 return result; |
| 108 } | 111 } |
| 109 | 112 |
| 110 private: | 113 private: |
| 111 void DidInsertSyncPoint(uint32_t sync_point) override { | 114 void DidInsertSyncPoint(uint32_t sync_point) override { |
| 112 sync_point_ = sync_point; | 115 sync_point_ = sync_point; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 135 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( | 138 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( |
| 136 command_buffer_handle.Pass(), 0u), | 139 command_buffer_handle.Pass(), 0u), |
| 137 async_waiter); | 140 async_waiter); |
| 138 command_buffer_.set_connection_error_handler( | 141 command_buffer_.set_connection_error_handler( |
| 139 [this]() { DidLoseContext(gpu::error::kUnknown); }); | 142 [this]() { DidLoseContext(gpu::error::kUnknown); }); |
| 140 } | 143 } |
| 141 | 144 |
| 142 CommandBufferClientImpl::~CommandBufferClientImpl() {} | 145 CommandBufferClientImpl::~CommandBufferClientImpl() {} |
| 143 | 146 |
| 144 bool CommandBufferClientImpl::Initialize() { | 147 bool CommandBufferClientImpl::Initialize() { |
| 145 base::ThreadRestrictions::ScopedAllowWait wait; | |
| 146 | |
| 147 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 148 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
| 148 void* memory = NULL; | 149 void* memory = NULL; |
| 149 mojo::ScopedSharedBufferHandle duped; | 150 mojo::ScopedSharedBufferHandle duped; |
| 150 bool result = CreateMapAndDupSharedBuffer( | 151 bool result = CreateMapAndDupSharedBuffer( |
| 151 kSharedStateSize, &memory, &shared_state_handle_, &duped); | 152 kSharedStateSize, &memory, &shared_state_handle_, &duped); |
| 152 if (!result) | 153 if (!result) |
| 153 return false; | 154 return false; |
| 154 | 155 |
| 155 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); | 156 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); |
| 156 | 157 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 gfx::Size(static_cast<int>(width), static_cast<int>(height)), | 326 gfx::Size(static_cast<int>(width), static_cast<int>(height)), |
| 326 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), | 327 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), |
| 327 gfx::BufferUsage::SCANOUT)); | 328 gfx::BufferUsage::SCANOUT)); |
| 328 if (!buffer) | 329 if (!buffer) |
| 329 return -1; | 330 return -1; |
| 330 | 331 |
| 331 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 332 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); |
| 332 } | 333 } |
| 333 | 334 |
| 334 uint32_t CommandBufferClientImpl::InsertSyncPoint() { | 335 uint32_t CommandBufferClientImpl::InsertSyncPoint() { |
| 335 base::ThreadRestrictions::ScopedAllowWait wait; | |
| 336 command_buffer_->InsertSyncPoint(true); | 336 command_buffer_->InsertSyncPoint(true); |
| 337 return sync_point_client_impl_->WaitForInsertSyncPoint(); | 337 return sync_point_client_impl_->WaitForInsertSyncPoint(); |
| 338 } | 338 } |
| 339 | 339 |
| 340 uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { | 340 uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { |
| 341 command_buffer_->InsertSyncPoint(false); | 341 command_buffer_->InsertSyncPoint(false); |
| 342 return sync_point_client_impl_->WaitForInsertSyncPoint(); | 342 return sync_point_client_impl_->WaitForInsertSyncPoint(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void CommandBufferClientImpl::RetireSyncPoint(uint32_t sync_point) { | 345 void CommandBufferClientImpl::RetireSyncPoint(uint32_t sync_point) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // TODO(dyen) | 431 // TODO(dyen) |
| 432 } | 432 } |
| 433 | 433 |
| 434 bool CommandBufferClientImpl::CanWaitUnverifiedSyncToken( | 434 bool CommandBufferClientImpl::CanWaitUnverifiedSyncToken( |
| 435 const gpu::SyncToken* sync_token) { | 435 const gpu::SyncToken* sync_token) { |
| 436 // All sync tokens must be flushed before being waited on. | 436 // All sync tokens must be flushed before being waited on. |
| 437 return false; | 437 return false; |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace gles2 | 440 } // namespace gles2 |
| OLD | NEW |