Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: mojo/gles2/command_buffer_client_impl.cc

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.h ('k') | ui/views/mus/surface_binding.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 return true; 41 return true;
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 CommandBufferDelegate::~CommandBufferDelegate() {} 46 CommandBufferDelegate::~CommandBufferDelegate() {}
47 47
48 void CommandBufferDelegate::ContextLost() {} 48 void CommandBufferDelegate::ContextLost() {}
49 49
50 class CommandBufferClientImpl::SyncClientImpl 50 class CommandBufferClientImpl::SyncClientImpl
51 : public mojo::CommandBufferSyncClient { 51 : public mus::mojom::CommandBufferSyncClient {
52 public: 52 public:
53 SyncClientImpl(mojo::CommandBufferSyncClientPtr* ptr, 53 SyncClientImpl(mus::mojom::CommandBufferSyncClientPtr* ptr,
54 const MojoAsyncWaiter* async_waiter) 54 const MojoAsyncWaiter* async_waiter)
55 : initialized_successfully_(false), binding_(this, ptr, async_waiter) {} 55 : initialized_successfully_(false), binding_(this, ptr, async_waiter) {}
56 56
57 bool WaitForInitialization() { 57 bool WaitForInitialization() {
58 if (!binding_.WaitForIncomingMethodCall()) 58 if (!binding_.WaitForIncomingMethodCall())
59 return false; 59 return false;
60 return initialized_successfully_; 60 return initialized_successfully_;
61 } 61 }
62 62
63 mojo::CommandBufferStatePtr WaitForProgress() { 63 mus::mojom::CommandBufferStatePtr WaitForProgress() {
64 if (!binding_.WaitForIncomingMethodCall()) 64 if (!binding_.WaitForIncomingMethodCall())
65 return mojo::CommandBufferStatePtr(); 65 return mus::mojom::CommandBufferStatePtr();
66 return command_buffer_state_.Pass(); 66 return command_buffer_state_.Pass();
67 } 67 }
68 68
69 gpu::Capabilities GetCapabilities() { 69 gpu::Capabilities GetCapabilities() {
70 if (capabilities_) 70 if (capabilities_)
71 return capabilities_.To<gpu::Capabilities>(); 71 return capabilities_.To<gpu::Capabilities>();
72 return gpu::Capabilities(); 72 return gpu::Capabilities();
73 } 73 }
74 74
75 private: 75 private:
76 // CommandBufferSyncClient methods: 76 // CommandBufferSyncClient methods:
77 void DidInitialize(bool success, 77 void DidInitialize(bool success,
78 mojo::GpuCapabilitiesPtr capabilities) override { 78 mus::mojom::GpuCapabilitiesPtr capabilities) override {
79 initialized_successfully_ = success; 79 initialized_successfully_ = success;
80 capabilities_ = capabilities.Pass(); 80 capabilities_ = capabilities.Pass();
81 } 81 }
82 void DidMakeProgress(mojo::CommandBufferStatePtr state) override { 82 void DidMakeProgress(mus::mojom::CommandBufferStatePtr state) override {
83 command_buffer_state_ = state.Pass(); 83 command_buffer_state_ = state.Pass();
84 } 84 }
85 85
86 bool initialized_successfully_; 86 bool initialized_successfully_;
87 mojo::GpuCapabilitiesPtr capabilities_; 87 mus::mojom::GpuCapabilitiesPtr capabilities_;
88 mojo::CommandBufferStatePtr command_buffer_state_; 88 mus::mojom::CommandBufferStatePtr command_buffer_state_;
89 mojo::Binding<mojo::CommandBufferSyncClient> binding_; 89 mojo::Binding<mus::mojom::CommandBufferSyncClient> binding_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(SyncClientImpl); 91 DISALLOW_COPY_AND_ASSIGN(SyncClientImpl);
92 }; 92 };
93 93
94 class CommandBufferClientImpl::SyncPointClientImpl 94 class CommandBufferClientImpl::SyncPointClientImpl
95 : public mojo::CommandBufferSyncPointClient { 95 : public mus::mojom::CommandBufferSyncPointClient {
96 public: 96 public:
97 SyncPointClientImpl(mojo::CommandBufferSyncPointClientPtr* ptr, 97 SyncPointClientImpl(mus::mojom::CommandBufferSyncPointClientPtr* ptr,
98 const MojoAsyncWaiter* async_waiter) 98 const MojoAsyncWaiter* async_waiter)
99 : sync_point_(0u), binding_(this, ptr, async_waiter) {} 99 : sync_point_(0u), binding_(this, ptr, async_waiter) {}
100 100
101 uint32_t WaitForInsertSyncPoint() { 101 uint32_t WaitForInsertSyncPoint() {
102 if (!binding_.WaitForIncomingMethodCall()) 102 if (!binding_.WaitForIncomingMethodCall())
103 return 0u; 103 return 0u;
104 uint32_t result = sync_point_; 104 uint32_t result = sync_point_;
105 sync_point_ = 0u; 105 sync_point_ = 0u;
106 return result; 106 return result;
107 } 107 }
108 108
109 private: 109 private:
110 void DidInsertSyncPoint(uint32_t sync_point) override { 110 void DidInsertSyncPoint(uint32_t sync_point) override {
111 sync_point_ = sync_point; 111 sync_point_ = sync_point;
112 } 112 }
113 113
114 uint32_t sync_point_; 114 uint32_t sync_point_;
115 115
116 mojo::Binding<mojo::CommandBufferSyncPointClient> binding_; 116 mojo::Binding<mus::mojom::CommandBufferSyncPointClient> binding_;
117 }; 117 };
118 118
119 CommandBufferClientImpl::CommandBufferClientImpl( 119 CommandBufferClientImpl::CommandBufferClientImpl(
120 CommandBufferDelegate* delegate, 120 CommandBufferDelegate* delegate,
121 const std::vector<int32_t>& attribs, 121 const std::vector<int32_t>& attribs,
122 const MojoAsyncWaiter* async_waiter, 122 const MojoAsyncWaiter* async_waiter,
123 mojo::ScopedMessagePipeHandle command_buffer_handle) 123 mojo::ScopedMessagePipeHandle command_buffer_handle)
124 : delegate_(delegate), 124 : delegate_(delegate),
125 attribs_(attribs), 125 attribs_(attribs),
126 observer_binding_(this), 126 observer_binding_(this),
127 shared_state_(NULL), 127 shared_state_(NULL),
128 last_put_offset_(-1), 128 last_put_offset_(-1),
129 next_transfer_buffer_id_(0), 129 next_transfer_buffer_id_(0),
130 next_image_id_(0), 130 next_image_id_(0),
131 next_fence_sync_release_(1), 131 next_fence_sync_release_(1),
132 flushed_fence_sync_release_(0), 132 flushed_fence_sync_release_(0),
133 async_waiter_(async_waiter) { 133 async_waiter_(async_waiter) {
134 command_buffer_.Bind(mojo::InterfacePtrInfo<mojo::CommandBuffer>( 134 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>(
135 command_buffer_handle.Pass(), 0u), 135 command_buffer_handle.Pass(), 0u),
136 async_waiter); 136 async_waiter);
137 command_buffer_.set_connection_error_handler( 137 command_buffer_.set_connection_error_handler(
138 [this]() { DidLoseContext(gpu::error::kUnknown); }); 138 [this]() { DidLoseContext(gpu::error::kUnknown); });
139 } 139 }
140 140
141 CommandBufferClientImpl::~CommandBufferClientImpl() {} 141 CommandBufferClientImpl::~CommandBufferClientImpl() {}
142 142
143 bool CommandBufferClientImpl::Initialize() { 143 bool CommandBufferClientImpl::Initialize() {
144 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); 144 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState);
145 void* memory = NULL; 145 void* memory = NULL;
146 mojo::ScopedSharedBufferHandle duped; 146 mojo::ScopedSharedBufferHandle duped;
147 bool result = CreateMapAndDupSharedBuffer( 147 bool result = CreateMapAndDupSharedBuffer(
148 kSharedStateSize, &memory, &shared_state_handle_, &duped); 148 kSharedStateSize, &memory, &shared_state_handle_, &duped);
149 if (!result) 149 if (!result)
150 return false; 150 return false;
151 151
152 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory); 152 shared_state_ = static_cast<gpu::CommandBufferSharedState*>(memory);
153 153
154 shared_state()->Initialize(); 154 shared_state()->Initialize();
155 155
156 mojo::CommandBufferSyncClientPtr sync_client; 156 mus::mojom::CommandBufferSyncClientPtr sync_client;
157 sync_client_impl_.reset(new SyncClientImpl(&sync_client, async_waiter_)); 157 sync_client_impl_.reset(new SyncClientImpl(&sync_client, async_waiter_));
158 158
159 mojo::CommandBufferSyncPointClientPtr sync_point_client; 159 mus::mojom::CommandBufferSyncPointClientPtr sync_point_client;
160 sync_point_client_impl_.reset( 160 sync_point_client_impl_.reset(
161 new SyncPointClientImpl(&sync_point_client, async_waiter_)); 161 new SyncPointClientImpl(&sync_point_client, async_waiter_));
162 162
163 mojo::CommandBufferLostContextObserverPtr observer_ptr; 163 mus::mojom::CommandBufferLostContextObserverPtr observer_ptr;
164 observer_binding_.Bind(GetProxy(&observer_ptr), async_waiter_); 164 observer_binding_.Bind(GetProxy(&observer_ptr), async_waiter_);
165 command_buffer_->Initialize(sync_client.Pass(), 165 command_buffer_->Initialize(sync_client.Pass(),
166 sync_point_client.Pass(), 166 sync_point_client.Pass(),
167 observer_ptr.Pass(), 167 observer_ptr.Pass(),
168 duped.Pass(), 168 duped.Pass(),
169 mojo::Array<int32_t>::From(attribs_)); 169 mojo::Array<int32_t>::From(attribs_));
170 170
171 // Wait for DidInitialize to come on the sync client pipe. 171 // Wait for DidInitialize to come on the sync client pipe.
172 if (!sync_client_impl_->WaitForInitialization()) { 172 if (!sync_client_impl_->WaitForInitialization()) {
173 VLOG(1) << "Channel encountered error while creating command buffer"; 173 VLOG(1) << "Channel encountered error while creating command buffer";
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 372 }
373 373
374 void CommandBufferClientImpl::TryUpdateState() { 374 void CommandBufferClientImpl::TryUpdateState() {
375 if (last_state_.error == gpu::error::kNoError) 375 if (last_state_.error == gpu::error::kNoError)
376 shared_state()->Read(&last_state_); 376 shared_state()->Read(&last_state_);
377 } 377 }
378 378
379 void CommandBufferClientImpl::MakeProgressAndUpdateState() { 379 void CommandBufferClientImpl::MakeProgressAndUpdateState() {
380 command_buffer_->MakeProgress(last_state_.get_offset); 380 command_buffer_->MakeProgress(last_state_.get_offset);
381 381
382 mojo::CommandBufferStatePtr state = sync_client_impl_->WaitForProgress(); 382 mus::mojom::CommandBufferStatePtr state =
383 sync_client_impl_->WaitForProgress();
383 if (!state) { 384 if (!state) {
384 VLOG(1) << "Channel encountered error while waiting for command buffer"; 385 VLOG(1) << "Channel encountered error while waiting for command buffer";
385 // TODO(piman): is it ok for this to re-enter? 386 // TODO(piman): is it ok for this to re-enter?
386 DidLoseContext(gpu::error::kUnknown); 387 DidLoseContext(gpu::error::kUnknown);
387 return; 388 return;
388 } 389 }
389 390
390 if (state->generation - last_state_.generation < 0x80000000U) 391 if (state->generation - last_state_.generation < 0x80000000U)
391 last_state_ = state.To<State>(); 392 last_state_ = state.To<State>();
392 } 393 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return IsFenceSyncFlushed(release); 428 return IsFenceSyncFlushed(release);
428 } 429 }
429 430
430 bool CommandBufferClientImpl::CanWaitUnverifiedSyncToken( 431 bool CommandBufferClientImpl::CanWaitUnverifiedSyncToken(
431 const gpu::SyncToken* sync_token) { 432 const gpu::SyncToken* sync_token) {
432 // All sync tokens must be flushed before being waited on. 433 // All sync tokens must be flushed before being waited on.
433 return false; 434 return false;
434 } 435 }
435 436
436 } // namespace gles2 437 } // namespace gles2
OLDNEW
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.h ('k') | ui/views/mus/surface_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698