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> |
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/client/gpu_control_client.h" | 19 #include "gpu/command_buffer/client/gpu_control_client.h" |
20 #include "gpu/command_buffer/common/command_buffer_id.h" | 20 #include "gpu/command_buffer/common/command_buffer_id.h" |
21 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" | 21 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
22 #include "gpu/command_buffer/common/sync_token.h" | 22 #include "gpu/command_buffer/common/sync_token.h" |
23 #include "mojo/platform_handle/platform_handle_functions.h" | 23 #include "mojo/public/cpp/system/platform_handle.h" |
24 | 24 |
25 namespace gles2 { | 25 namespace gles2 { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 bool CreateMapAndDupSharedBuffer(size_t size, | 29 bool CreateMapAndDupSharedBuffer(size_t size, |
30 void** memory, | 30 void** memory, |
31 mojo::ScopedSharedBufferHandle* handle, | 31 mojo::ScopedSharedBufferHandle* handle, |
32 mojo::ScopedSharedBufferHandle* duped) { | 32 mojo::ScopedSharedBufferHandle* duped) { |
33 MojoResult result = mojo::CreateSharedBuffer(NULL, size, handle); | 33 MojoResult result = mojo::CreateSharedBuffer(NULL, size, handle); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 230 } |
231 | 231 |
232 base::SharedMemoryHandle dupd_handle = | 232 base::SharedMemoryHandle dupd_handle = |
233 base::SharedMemory::DuplicateHandle(handle.handle); | 233 base::SharedMemory::DuplicateHandle(handle.handle); |
234 #if defined(OS_WIN) | 234 #if defined(OS_WIN) |
235 HANDLE platform_handle = dupd_handle.GetHandle(); | 235 HANDLE platform_handle = dupd_handle.GetHandle(); |
236 #else | 236 #else |
237 int platform_handle = dupd_handle.fd; | 237 int platform_handle = dupd_handle.fd; |
238 #endif | 238 #endif |
239 | 239 |
240 MojoHandle mojo_handle = MOJO_HANDLE_INVALID; | 240 mojo::ScopedHandle scoped_handle = mojo::WrapPlatformFile(platform_handle); |
241 MojoResult create_result = MojoCreatePlatformHandleWrapper( | |
242 platform_handle, &mojo_handle); | |
243 if (create_result != MOJO_RESULT_OK) { | |
244 NOTIMPLEMENTED(); | |
245 return -1; | |
246 } | |
247 mojo::ScopedHandle scoped_handle; | |
248 scoped_handle.reset(mojo::Handle(mojo_handle)); | |
249 command_buffer_->CreateImage( | 241 command_buffer_->CreateImage( |
250 new_id, std::move(scoped_handle), handle.type, std::move(size), | 242 new_id, std::move(scoped_handle), handle.type, std::move(size), |
251 static_cast<int32_t>(gpu_memory_buffer->GetFormat()), internalformat); | 243 static_cast<int32_t>(gpu_memory_buffer->GetFormat()), internalformat); |
252 if (requires_sync_point) { | 244 if (requires_sync_point) { |
253 NOTIMPLEMENTED(); | 245 NOTIMPLEMENTED(); |
254 // TODO(jam): need to support this if we support types other than | 246 // TODO(jam): need to support this if we support types other than |
255 // SHARED_MEMORY_BUFFER. | 247 // SHARED_MEMORY_BUFFER. |
256 //gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, | 248 //gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, |
257 // InsertSyncPoint()); | 249 // InsertSyncPoint()); |
258 } | 250 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 376 |
385 // It is also safe to wait on the same context. | 377 // It is also safe to wait on the same context. |
386 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && | 378 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && |
387 sync_token->command_buffer_id() == GetCommandBufferID()) | 379 sync_token->command_buffer_id() == GetCommandBufferID()) |
388 return true; | 380 return true; |
389 | 381 |
390 return false; | 382 return false; |
391 } | 383 } |
392 | 384 |
393 } // namespace gles2 | 385 } // namespace gles2 |
OLD | NEW |