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

Side by Side Diff: services/ui/public/cpp/lib/command_buffer_client_impl.cc

Issue 2096293002: Eliminate usage of InterfacePtr::WaitForIncomingResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybots failure Created 4 years, 5 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
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 "services/ui/public/cpp/lib/command_buffer_client_impl.h" 5 #include "services/ui/public/cpp/lib/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 22 matching lines...) Expand all
33 if (!handle->is_valid()) 33 if (!handle->is_valid())
34 return false; 34 return false;
35 35
36 *mapping = (*handle)->Map(size); 36 *mapping = (*handle)->Map(size);
37 if (!*mapping) 37 if (!*mapping)
38 return false; 38 return false;
39 39
40 return true; 40 return true;
41 } 41 }
42 42
43 void MakeProgressCallback(gpu::CommandBuffer::State* output,
44 const gpu::CommandBuffer::State& input) {
45 *output = input;
46 }
47
48 void InitializeCallback(ui::mojom::CommandBufferInitializeResultPtr* output,
49 ui::mojom::CommandBufferInitializeResultPtr input) {
50 *output = std::move(input);
51 }
52
53 } // namespace 43 } // namespace
54 44
55 CommandBufferClientImpl::CommandBufferClientImpl( 45 CommandBufferClientImpl::CommandBufferClientImpl(
56 const std::vector<int32_t>& attribs, 46 const std::vector<int32_t>& attribs,
57 ui::mojom::CommandBufferPtr command_buffer_ptr) 47 ui::mojom::CommandBufferPtr command_buffer_ptr)
58 : gpu_control_client_(nullptr), 48 : gpu_control_client_(nullptr),
59 destroyed_(false), 49 destroyed_(false),
60 attribs_(attribs), 50 attribs_(attribs),
61 client_binding_(this), 51 client_binding_(this),
62 command_buffer_(std::move(command_buffer_ptr)), 52 command_buffer_(std::move(command_buffer_ptr)),
(...skipping 17 matching lines...) Expand all
80 CreateAndMapSharedBuffer(kSharedStateSize, &shared_state_, &handle); 70 CreateAndMapSharedBuffer(kSharedStateSize, &shared_state_, &handle);
81 if (!result) 71 if (!result)
82 return false; 72 return false;
83 73
84 shared_state()->Initialize(); 74 shared_state()->Initialize();
85 75
86 ui::mojom::CommandBufferClientPtr client_ptr; 76 ui::mojom::CommandBufferClientPtr client_ptr;
87 client_binding_.Bind(GetProxy(&client_ptr)); 77 client_binding_.Bind(GetProxy(&client_ptr));
88 78
89 ui::mojom::CommandBufferInitializeResultPtr initialize_result; 79 ui::mojom::CommandBufferInitializeResultPtr initialize_result;
90 command_buffer_->Initialize( 80 result = command_buffer_->Initialize(std::move(client_ptr), std::move(handle),
91 std::move(client_ptr), std::move(handle), 81 mojo::Array<int32_t>::From(attribs_),
92 mojo::Array<int32_t>::From(attribs_), 82 &initialize_result);
93 base::Bind(&InitializeCallback, &initialize_result));
94 83
95 base::ThreadRestrictions::ScopedAllowWait wait; 84 if (!result) {
96 if (!command_buffer_.WaitForIncomingResponse()) {
97 VLOG(1) << "Channel encountered error while creating command buffer."; 85 VLOG(1) << "Channel encountered error while creating command buffer.";
98 return false; 86 return false;
99 } 87 }
100 88
101 if (!initialize_result) { 89 if (!initialize_result) {
102 VLOG(1) << "Command buffer cannot be initialized successfully."; 90 VLOG(1) << "Command buffer cannot be initialized successfully.";
103 return false; 91 return false;
104 } 92 }
105 93
106 DCHECK_EQ(gpu::CommandBufferNamespace::MOJO, 94 DCHECK_EQ(gpu::CommandBufferNamespace::MOJO,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void CommandBufferClientImpl::UpdateVSyncParameters(int64_t timebase, 278 void CommandBufferClientImpl::UpdateVSyncParameters(int64_t timebase,
291 int64_t interval) {} 279 int64_t interval) {}
292 280
293 void CommandBufferClientImpl::TryUpdateState() { 281 void CommandBufferClientImpl::TryUpdateState() {
294 if (last_state_.error == gpu::error::kNoError) 282 if (last_state_.error == gpu::error::kNoError)
295 shared_state()->Read(&last_state_); 283 shared_state()->Read(&last_state_);
296 } 284 }
297 285
298 void CommandBufferClientImpl::MakeProgressAndUpdateState() { 286 void CommandBufferClientImpl::MakeProgressAndUpdateState() {
299 gpu::CommandBuffer::State state; 287 gpu::CommandBuffer::State state;
300 command_buffer_->MakeProgress(last_state_.get_offset, 288 bool result = command_buffer_->MakeProgress(last_state_.get_offset, &state);
301 base::Bind(&MakeProgressCallback, &state));
302 289
303 base::ThreadRestrictions::ScopedAllowWait wait; 290 if (!result) {
304 if (!command_buffer_.WaitForIncomingResponse()) {
305 VLOG(1) << "Channel encountered error while waiting for command buffer."; 291 VLOG(1) << "Channel encountered error while waiting for command buffer.";
306 // TODO(piman): is it ok for this to re-enter? 292 // TODO(piman): is it ok for this to re-enter?
307 Destroyed(gpu::error::kUnknown, gpu::error::kLostContext); 293 Destroyed(gpu::error::kUnknown, gpu::error::kLostContext);
308 return; 294 return;
309 } 295 }
310 296
311 if (state.generation - last_state_.generation < 0x80000000U) 297 if (state.generation - last_state_.generation < 0x80000000U)
312 last_state_ = state; 298 last_state_ = state;
313 } 299 }
314 300
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 347
362 // It is also safe to wait on the same context. 348 // It is also safe to wait on the same context.
363 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && 349 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO &&
364 sync_token->command_buffer_id() == GetCommandBufferID()) 350 sync_token->command_buffer_id() == GetCommandBufferID())
365 return true; 351 return true;
366 352
367 return false; 353 return false;
368 } 354 }
369 355
370 } // namespace ui 356 } // namespace ui
OLDNEW
« no previous file with comments | « services/catalog/public/interfaces/catalog.mojom ('k') | services/ui/public/interfaces/command_buffer.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698