| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "components/mus/gles2/command_buffer_type_conversions.h" | 16 #include "components/mus/gles2/command_buffer_type_conversions.h" |
| 17 #include "components/mus/gles2/mojo_buffer_backing.h" | 17 #include "components/mus/gles2/mojo_buffer_backing.h" |
| 18 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" | 18 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" |
| 19 #include "gpu/command_buffer/common/command_buffer_id.h" |
| 19 #include "gpu/command_buffer/common/sync_token.h" | 20 #include "gpu/command_buffer/common/sync_token.h" |
| 20 #include "gpu/command_buffer/service/image_factory.h" | 21 #include "gpu/command_buffer/service/image_factory.h" |
| 21 #include "mojo/platform_handle/platform_handle_functions.h" | 22 #include "mojo/platform_handle/platform_handle_functions.h" |
| 22 | 23 |
| 23 namespace gles2 { | 24 namespace gles2 { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 bool CreateMapAndDupSharedBuffer(size_t size, | 28 bool CreateMapAndDupSharedBuffer(size_t size, |
| 28 void** memory, | 29 void** memory, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void CommandBufferDelegate::ContextLost() {} | 66 void CommandBufferDelegate::ContextLost() {} |
| 66 | 67 |
| 67 CommandBufferClientImpl::CommandBufferClientImpl( | 68 CommandBufferClientImpl::CommandBufferClientImpl( |
| 68 CommandBufferDelegate* delegate, | 69 CommandBufferDelegate* delegate, |
| 69 const std::vector<int32_t>& attribs, | 70 const std::vector<int32_t>& attribs, |
| 70 const MojoAsyncWaiter* async_waiter, | 71 const MojoAsyncWaiter* async_waiter, |
| 71 mojo::ScopedMessagePipeHandle command_buffer_handle) | 72 mojo::ScopedMessagePipeHandle command_buffer_handle) |
| 72 : delegate_(delegate), | 73 : delegate_(delegate), |
| 73 attribs_(attribs), | 74 attribs_(attribs), |
| 74 client_binding_(this), | 75 client_binding_(this), |
| 75 command_buffer_id_(0), | 76 command_buffer_id_(), |
| 76 shared_state_(NULL), | 77 shared_state_(NULL), |
| 77 last_put_offset_(-1), | 78 last_put_offset_(-1), |
| 78 next_transfer_buffer_id_(0), | 79 next_transfer_buffer_id_(0), |
| 79 next_image_id_(0), | 80 next_image_id_(0), |
| 80 next_fence_sync_release_(1), | 81 next_fence_sync_release_(1), |
| 81 flushed_fence_sync_release_(0), | 82 flushed_fence_sync_release_(0), |
| 82 async_waiter_(async_waiter) { | 83 async_waiter_(async_waiter) { |
| 83 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( | 84 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( |
| 84 std::move(command_buffer_handle), 0u), | 85 std::move(command_buffer_handle), 0u), |
| 85 async_waiter); | 86 async_waiter); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return false; | 118 return false; |
| 118 } | 119 } |
| 119 | 120 |
| 120 if (!initialize_result) { | 121 if (!initialize_result) { |
| 121 VLOG(1) << "Command buffer cannot be initialized successfully."; | 122 VLOG(1) << "Command buffer cannot be initialized successfully."; |
| 122 return false; | 123 return false; |
| 123 } | 124 } |
| 124 | 125 |
| 125 DCHECK_EQ(gpu::CommandBufferNamespace::MOJO, | 126 DCHECK_EQ(gpu::CommandBufferNamespace::MOJO, |
| 126 initialize_result->command_buffer_namespace); | 127 initialize_result->command_buffer_namespace); |
| 127 command_buffer_id_ = initialize_result->command_buffer_id; | 128 command_buffer_id_ = gpu::CommandBufferId::FromUnsafeValue( |
| 129 initialize_result->command_buffer_id); |
| 128 capabilities_ = initialize_result->capabilities; | 130 capabilities_ = initialize_result->capabilities; |
| 129 return true; | 131 return true; |
| 130 } | 132 } |
| 131 | 133 |
| 132 gpu::CommandBuffer::State CommandBufferClientImpl::GetLastState() { | 134 gpu::CommandBuffer::State CommandBufferClientImpl::GetLastState() { |
| 133 return last_state_; | 135 return last_state_; |
| 134 } | 136 } |
| 135 | 137 |
| 136 int32_t CommandBufferClientImpl::GetLastToken() { | 138 int32_t CommandBufferClientImpl::GetLastToken() { |
| 137 TryUpdateState(); | 139 TryUpdateState(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 340 } |
| 339 | 341 |
| 340 void CommandBufferClientImpl::EnsureWorkVisible() { | 342 void CommandBufferClientImpl::EnsureWorkVisible() { |
| 341 // This is only relevant for out-of-process command buffers. | 343 // This is only relevant for out-of-process command buffers. |
| 342 } | 344 } |
| 343 | 345 |
| 344 gpu::CommandBufferNamespace CommandBufferClientImpl::GetNamespaceID() const { | 346 gpu::CommandBufferNamespace CommandBufferClientImpl::GetNamespaceID() const { |
| 345 return gpu::CommandBufferNamespace::MOJO; | 347 return gpu::CommandBufferNamespace::MOJO; |
| 346 } | 348 } |
| 347 | 349 |
| 348 uint64_t CommandBufferClientImpl::GetCommandBufferID() const { | 350 gpu::CommandBufferId CommandBufferClientImpl::GetCommandBufferID() const { |
| 349 return command_buffer_id_; | 351 return command_buffer_id_; |
| 350 } | 352 } |
| 351 | 353 |
| 352 int32_t CommandBufferClientImpl::GetExtraCommandBufferData() const { | 354 int32_t CommandBufferClientImpl::GetExtraCommandBufferData() const { |
| 353 return 0; | 355 return 0; |
| 354 } | 356 } |
| 355 | 357 |
| 356 uint64_t CommandBufferClientImpl::GenerateFenceSyncRelease() { | 358 uint64_t CommandBufferClientImpl::GenerateFenceSyncRelease() { |
| 357 return next_fence_sync_release_++; | 359 return next_fence_sync_release_++; |
| 358 } | 360 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 384 | 386 |
| 385 // It is also safe to wait on the same context. | 387 // It is also safe to wait on the same context. |
| 386 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && | 388 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && |
| 387 sync_token->command_buffer_id() == GetCommandBufferID()) | 389 sync_token->command_buffer_id() == GetCommandBufferID()) |
| 388 return true; | 390 return true; |
| 389 | 391 |
| 390 return false; | 392 return false; |
| 391 } | 393 } |
| 392 | 394 |
| 393 } // namespace gles2 | 395 } // namespace gles2 |
| OLD | NEW |