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

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

Issue 1548443002: Introducing gpu::CommandBufferId as a distinct, IdType<...>-based type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-save-package-id-self-contained
Patch Set: Rebasing (i.e. had to add GetSize to IPC traits). Created 4 years, 10 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 "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
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698