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 #include <utility> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
11 #include "services/gles2/command_buffer_type_conversions.h" | 12 #include "services/gles2/command_buffer_type_conversions.h" |
12 #include "services/gles2/mojo_buffer_backing.h" | 13 #include "services/gles2/mojo_buffer_backing.h" |
13 | 14 |
14 namespace gles2 { | 15 namespace gles2 { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
(...skipping 22 matching lines...) Expand all Loading... |
40 | 41 |
41 } // namespace | 42 } // namespace |
42 | 43 |
43 CommandBufferDelegate::~CommandBufferDelegate() {} | 44 CommandBufferDelegate::~CommandBufferDelegate() {} |
44 | 45 |
45 void CommandBufferDelegate::ContextLost() {} | 46 void CommandBufferDelegate::ContextLost() {} |
46 | 47 |
47 class CommandBufferClientImpl::SyncClientImpl | 48 class CommandBufferClientImpl::SyncClientImpl |
48 : public mojo::CommandBufferSyncClient { | 49 : public mojo::CommandBufferSyncClient { |
49 public: | 50 public: |
50 SyncClientImpl(mojo::CommandBufferSyncClientPtr* ptr, | 51 SyncClientImpl(mojo::InterfaceHandle<mojo::CommandBufferSyncClient>* ptr, |
51 const MojoAsyncWaiter* async_waiter) | 52 const MojoAsyncWaiter* async_waiter) |
52 : initialized_successfully_(false), binding_(this, ptr, async_waiter) {} | 53 : initialized_successfully_(false), binding_(this, ptr, async_waiter) {} |
53 | 54 |
54 bool WaitForInitialization() { | 55 bool WaitForInitialization() { |
55 if (!binding_.WaitForIncomingMethodCall()) | 56 if (!binding_.WaitForIncomingMethodCall()) |
56 return false; | 57 return false; |
57 return initialized_successfully_; | 58 return initialized_successfully_; |
58 } | 59 } |
59 | 60 |
60 mojo::CommandBufferStatePtr WaitForProgress() { | 61 mojo::CommandBufferStatePtr WaitForProgress() { |
(...skipping 21 matching lines...) Expand all Loading... |
82 mojo::GpuCapabilitiesPtr capabilities_; | 83 mojo::GpuCapabilitiesPtr capabilities_; |
83 mojo::CommandBufferStatePtr command_buffer_state_; | 84 mojo::CommandBufferStatePtr command_buffer_state_; |
84 mojo::Binding<mojo::CommandBufferSyncClient> binding_; | 85 mojo::Binding<mojo::CommandBufferSyncClient> binding_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(SyncClientImpl); | 87 DISALLOW_COPY_AND_ASSIGN(SyncClientImpl); |
87 }; | 88 }; |
88 | 89 |
89 class CommandBufferClientImpl::SyncPointClientImpl | 90 class CommandBufferClientImpl::SyncPointClientImpl |
90 : public mojo::CommandBufferSyncPointClient { | 91 : public mojo::CommandBufferSyncPointClient { |
91 public: | 92 public: |
92 SyncPointClientImpl(mojo::CommandBufferSyncPointClientPtr* ptr, | 93 SyncPointClientImpl( |
93 const MojoAsyncWaiter* async_waiter) | 94 mojo::InterfaceHandle<mojo::CommandBufferSyncPointClient>* ptr, |
| 95 const MojoAsyncWaiter* async_waiter) |
94 : sync_point_(0u), binding_(this, ptr, async_waiter) {} | 96 : sync_point_(0u), binding_(this, ptr, async_waiter) {} |
95 | 97 |
96 uint32_t WaitForInsertSyncPoint() { | 98 uint32_t WaitForInsertSyncPoint() { |
97 if (!binding_.WaitForIncomingMethodCall()) | 99 if (!binding_.WaitForIncomingMethodCall()) |
98 return 0u; | 100 return 0u; |
99 uint32_t result = sync_point_; | 101 uint32_t result = sync_point_; |
100 sync_point_ = 0u; | 102 sync_point_ = 0u; |
101 return result; | 103 return result; |
102 } | 104 } |
103 | 105 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 mojo::ScopedSharedBufferHandle duped; | 138 mojo::ScopedSharedBufferHandle duped; |
137 bool result = CreateMapAndDupSharedBuffer( | 139 bool result = CreateMapAndDupSharedBuffer( |
138 kSharedStateSize, &memory, &shared_state_handle_, &duped); | 140 kSharedStateSize, &memory, &shared_state_handle_, &duped); |
139 if (!result) | 141 if (!result) |
140 return false; | 142 return false; |
141 | 143 |
142 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); | 144 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); |
143 | 145 |
144 shared_state()->Initialize(); | 146 shared_state()->Initialize(); |
145 | 147 |
146 mojo::CommandBufferSyncClientPtr sync_client; | 148 mojo::InterfaceHandle<mojo::CommandBufferSyncClient> sync_client; |
147 sync_client_impl_.reset(new SyncClientImpl(&sync_client, async_waiter_)); | 149 sync_client_impl_.reset(new SyncClientImpl(&sync_client, async_waiter_)); |
148 | 150 |
149 mojo::CommandBufferSyncPointClientPtr sync_point_client; | 151 mojo::InterfaceHandle<mojo::CommandBufferSyncPointClient> sync_point_client; |
150 sync_point_client_impl_.reset( | 152 sync_point_client_impl_.reset( |
151 new SyncPointClientImpl(&sync_point_client, async_waiter_)); | 153 new SyncPointClientImpl(&sync_point_client, async_waiter_)); |
152 | 154 |
153 mojo::CommandBufferLostContextObserverPtr observer_ptr; | 155 mojo::InterfaceHandle<mojo::CommandBufferLostContextObserver> observer_ptr; |
154 observer_binding_.Bind(GetProxy(&observer_ptr), async_waiter_); | 156 observer_binding_.Bind(GetProxy(&observer_ptr), async_waiter_); |
155 command_buffer_->Initialize(sync_client.Pass(), | 157 command_buffer_->Initialize(std::move(sync_client), |
156 sync_point_client.Pass(), | 158 std::move(sync_point_client), |
157 observer_ptr.Pass(), | 159 std::move(observer_ptr), duped.Pass()); |
158 duped.Pass()); | |
159 | 160 |
160 // Wait for DidInitialize to come on the sync client pipe. | 161 // Wait for DidInitialize to come on the sync client pipe. |
161 if (!sync_client_impl_->WaitForInitialization()) { | 162 if (!sync_client_impl_->WaitForInitialization()) { |
162 VLOG(1) << "Channel encountered error while creating command buffer"; | 163 VLOG(1) << "Channel encountered error while creating command buffer"; |
163 return false; | 164 return false; |
164 } | 165 } |
165 capabilities_ = sync_client_impl_->GetCapabilities(); | 166 capabilities_ = sync_client_impl_->GetCapabilities(); |
166 return true; | 167 return true; |
167 } | 168 } |
168 | 169 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 } | 327 } |
327 | 328 |
328 if (state->generation - last_state_.generation < 0x80000000U) | 329 if (state->generation - last_state_.generation < 0x80000000U) |
329 last_state_ = state.To<State>(); | 330 last_state_ = state.To<State>(); |
330 } | 331 } |
331 | 332 |
332 void CommandBufferClientImpl::SetLock(base::Lock* lock) { | 333 void CommandBufferClientImpl::SetLock(base::Lock* lock) { |
333 } | 334 } |
334 | 335 |
335 } // namespace gles2 | 336 } // namespace gles2 |
OLD | NEW |