| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/gles2/command_buffer_local.h" | 5 #include "components/mus/gles2/command_buffer_local.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "components/mus/gles2/command_buffer_driver.h" | 12 #include "components/mus/gles2/command_buffer_driver.h" |
| 13 #include "components/mus/gles2/command_buffer_local_client.h" | 13 #include "components/mus/gles2/command_buffer_local_client.h" |
| 14 #include "components/mus/gles2/command_buffer_type_conversions.h" | 14 #include "components/mus/gles2/command_buffer_type_conversions.h" |
| 15 #include "components/mus/gles2/gpu_memory_tracker.h" | 15 #include "components/mus/gles2/gpu_memory_tracker.h" |
| 16 #include "components/mus/gles2/gpu_state.h" | 16 #include "components/mus/gles2/gpu_state.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/gpu_memory_buffer_support.h" | 20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
| 21 #include "gpu/command_buffer/common/sync_token.h" | 21 #include "gpu/command_buffer/common/sync_token.h" |
| 22 #include "gpu/command_buffer/service/command_buffer_service.h" | 22 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 23 #include "gpu/command_buffer/service/context_group.h" | 23 #include "gpu/command_buffer/service/context_group.h" |
| 24 #include "gpu/command_buffer/service/image_manager.h" | 24 #include "gpu/command_buffer/service/image_manager.h" |
| 25 #include "gpu/command_buffer/service/memory_tracking.h" | 25 #include "gpu/command_buffer/service/memory_tracking.h" |
| 26 #include "gpu/command_buffer/service/shader_translator_cache.h" | 26 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 28 #include "mojo/platform_handle/platform_handle_functions.h" | 28 #include "mojo/public/cpp/system/platform_handle.h" |
| 29 #include "ui/gfx/buffer_format_util.h" | 29 #include "ui/gfx/buffer_format_util.h" |
| 30 #include "ui/gfx/vsync_provider.h" | 30 #include "ui/gfx/vsync_provider.h" |
| 31 #include "ui/gl/gl_context.h" | 31 #include "ui/gl/gl_context.h" |
| 32 #include "ui/gl/gl_image_shared_memory.h" | 32 #include "ui/gl/gl_image_shared_memory.h" |
| 33 #include "ui/gl/gl_surface.h" | 33 #include "ui/gl/gl_surface.h" |
| 34 | 34 |
| 35 namespace mus { | 35 namespace mus { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 mus::MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); | 241 mus::MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); |
| 242 | 242 |
| 243 bool requires_sync_point = false; | 243 bool requires_sync_point = false; |
| 244 | 244 |
| 245 if (gpu_memory_buffer->GetBufferType() == gfx::SHARED_MEMORY_BUFFER) { | 245 if (gpu_memory_buffer->GetBufferType() == gfx::SHARED_MEMORY_BUFFER) { |
| 246 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); | 246 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); |
| 247 // TODO(rjkroege): Verify that this is required and update appropriately. | 247 // TODO(rjkroege): Verify that this is required and update appropriately. |
| 248 base::SharedMemoryHandle dupd_handle = | 248 base::SharedMemoryHandle dupd_handle = |
| 249 base::SharedMemory::DuplicateHandle(handle.handle); | 249 base::SharedMemory::DuplicateHandle(handle.handle); |
| 250 #if defined(OS_WIN) | 250 #if defined(OS_WIN) |
| 251 HANDLE platform_handle = dupd_handle.GetHandle(); | 251 HANDLE platform_file = dupd_handle.GetHandle(); |
| 252 #else | 252 #else |
| 253 int platform_handle = dupd_handle.fd; | 253 int platform_file = dupd_handle.fd; |
| 254 #endif | 254 #endif |
| 255 | 255 |
| 256 MojoHandle mojo_handle = MOJO_HANDLE_INVALID; | 256 mojo::ScopedHandle scoped_handle = mojo::WrapPlatformFile(platform_file); |
| 257 MojoResult create_result = | |
| 258 MojoCreatePlatformHandleWrapper(platform_handle, &mojo_handle); | |
| 259 // |MojoCreatePlatformHandleWrapper()| always takes the ownership of the | |
| 260 // |platform_handle|, so we don't need to close |platform_handle|. | |
| 261 if (create_result != MOJO_RESULT_OK) { | |
| 262 NOTIMPLEMENTED(); | |
| 263 return -1; | |
| 264 } | |
| 265 mojo::ScopedHandle scoped_handle; | |
| 266 scoped_handle.reset(mojo::Handle(mojo_handle)); | |
| 267 | |
| 268 const int32_t format = static_cast<int32_t>(gpu_memory_buffer->GetFormat()); | 257 const int32_t format = static_cast<int32_t>(gpu_memory_buffer->GetFormat()); |
| 269 gpu_state_->command_buffer_task_runner()->PostTask( | 258 gpu_state_->command_buffer_task_runner()->PostTask( |
| 270 driver_.get(), | 259 driver_.get(), |
| 271 base::Bind(&CommandBufferLocal::CreateImageOnGpuThread, | 260 base::Bind(&CommandBufferLocal::CreateImageOnGpuThread, |
| 272 base::Unretained(this), new_id, base::Passed(&scoped_handle), | 261 base::Unretained(this), new_id, base::Passed(&scoped_handle), |
| 273 handle.type, base::Passed(&size), format, internal_format)); | 262 handle.type, base::Passed(&size), format, internal_format)); |
| 274 #if defined(USE_OZONE) | 263 #if defined(USE_OZONE) |
| 275 } else if (gpu_memory_buffer->GetBufferType() == gfx::OZONE_NATIVE_PIXMAP) { | 264 } else if (gpu_memory_buffer->GetBufferType() == gfx::OZONE_NATIVE_PIXMAP) { |
| 276 gpu_state_->command_buffer_task_runner()->PostTask( | 265 gpu_state_->command_buffer_task_runner()->PostTask( |
| 277 driver_.get(), | 266 driver_.get(), |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 client_->UpdateVSyncParameters(timebase, interval); | 567 client_->UpdateVSyncParameters(timebase, interval); |
| 579 } | 568 } |
| 580 | 569 |
| 581 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( | 570 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( |
| 582 gfx::SwapResult result) { | 571 gfx::SwapResult result) { |
| 583 if (client_) | 572 if (client_) |
| 584 client_->GpuCompletedSwapBuffers(result); | 573 client_->GpuCompletedSwapBuffers(result); |
| 585 } | 574 } |
| 586 | 575 |
| 587 } // namespace mus | 576 } // namespace mus |
| OLD | NEW |