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> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 CommandBufferDelegate::~CommandBufferDelegate() {} | 64 CommandBufferDelegate::~CommandBufferDelegate() {} |
65 | 65 |
66 void CommandBufferDelegate::ContextLost() {} | 66 void CommandBufferDelegate::ContextLost() {} |
67 | 67 |
68 CommandBufferClientImpl::CommandBufferClientImpl( | 68 CommandBufferClientImpl::CommandBufferClientImpl( |
69 CommandBufferDelegate* delegate, | 69 CommandBufferDelegate* delegate, |
70 const std::vector<int32_t>& attribs, | 70 const std::vector<int32_t>& attribs, |
71 const MojoAsyncWaiter* async_waiter, | |
72 mojo::ScopedMessagePipeHandle command_buffer_handle) | 71 mojo::ScopedMessagePipeHandle command_buffer_handle) |
73 : delegate_(delegate), | 72 : delegate_(delegate), |
74 attribs_(attribs), | 73 attribs_(attribs), |
75 client_binding_(this), | 74 client_binding_(this), |
76 command_buffer_id_(), | 75 command_buffer_id_(), |
77 shared_state_(NULL), | 76 shared_state_(NULL), |
78 last_put_offset_(-1), | 77 last_put_offset_(-1), |
79 next_transfer_buffer_id_(0), | 78 next_transfer_buffer_id_(0), |
80 next_image_id_(0), | 79 next_image_id_(0), |
81 next_fence_sync_release_(1), | 80 next_fence_sync_release_(1), |
82 flushed_fence_sync_release_(0), | 81 flushed_fence_sync_release_(0) { |
83 async_waiter_(async_waiter) { | |
84 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( | 82 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( |
85 std::move(command_buffer_handle), 0u), | 83 std::move(command_buffer_handle), 0u)); |
86 async_waiter); | |
87 command_buffer_.set_connection_error_handler( | 84 command_buffer_.set_connection_error_handler( |
88 [this]() { Destroyed(gpu::error::kUnknown, gpu::error::kLostContext); }); | 85 [this]() { Destroyed(gpu::error::kUnknown, gpu::error::kLostContext); }); |
89 } | 86 } |
90 | 87 |
91 CommandBufferClientImpl::~CommandBufferClientImpl() {} | 88 CommandBufferClientImpl::~CommandBufferClientImpl() {} |
92 | 89 |
93 bool CommandBufferClientImpl::Initialize() { | 90 bool CommandBufferClientImpl::Initialize() { |
94 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 91 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
95 void* memory = NULL; | 92 void* memory = NULL; |
96 mojo::ScopedSharedBufferHandle duped; | 93 mojo::ScopedSharedBufferHandle duped; |
97 bool result = CreateMapAndDupSharedBuffer( | 94 bool result = CreateMapAndDupSharedBuffer( |
98 kSharedStateSize, &memory, &shared_state_handle_, &duped); | 95 kSharedStateSize, &memory, &shared_state_handle_, &duped); |
99 if (!result) | 96 if (!result) |
100 return false; | 97 return false; |
101 | 98 |
102 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); | 99 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); |
103 | 100 |
104 shared_state()->Initialize(); | 101 shared_state()->Initialize(); |
105 | 102 |
106 mus::mojom::CommandBufferClientPtr client_ptr; | 103 mus::mojom::CommandBufferClientPtr client_ptr; |
107 client_binding_.Bind(GetProxy(&client_ptr), async_waiter_); | 104 client_binding_.Bind(GetProxy(&client_ptr)); |
108 | 105 |
109 mus::mojom::CommandBufferInitializeResultPtr initialize_result; | 106 mus::mojom::CommandBufferInitializeResultPtr initialize_result; |
110 command_buffer_->Initialize( | 107 command_buffer_->Initialize( |
111 std::move(client_ptr), std::move(duped), | 108 std::move(client_ptr), std::move(duped), |
112 mojo::Array<int32_t>::From(attribs_), | 109 mojo::Array<int32_t>::From(attribs_), |
113 base::Bind(&InitializeCallback, &initialize_result)); | 110 base::Bind(&InitializeCallback, &initialize_result)); |
114 | 111 |
115 base::ThreadRestrictions::ScopedAllowWait wait; | 112 base::ThreadRestrictions::ScopedAllowWait wait; |
116 if (!command_buffer_.WaitForIncomingResponse()) { | 113 if (!command_buffer_.WaitForIncomingResponse()) { |
117 VLOG(1) << "Channel encountered error while creating command buffer."; | 114 VLOG(1) << "Channel encountered error while creating command buffer."; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 383 |
387 // It is also safe to wait on the same context. | 384 // It is also safe to wait on the same context. |
388 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && | 385 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && |
389 sync_token->command_buffer_id() == GetCommandBufferID()) | 386 sync_token->command_buffer_id() == GetCommandBufferID()) |
390 return true; | 387 return true; |
391 | 388 |
392 return false; | 389 return false; |
393 } | 390 } |
394 | 391 |
395 } // namespace gles2 | 392 } // namespace gles2 |
OLD | NEW |