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

Unified Diff: services/ui/ws/gpu_service_proxy.cc

Issue 2496783002: gpu: Reuse existing code for shared memory allocation. (Closed)
Patch Set: . Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: services/ui/ws/gpu_service_proxy.cc
diff --git a/services/ui/ws/gpu_service_proxy.cc b/services/ui/ws/gpu_service_proxy.cc
index 6d3b126bafbd28dae0334a4e66a9f1bd56544e55..0f851cc6dd50da01b0a483281e06fbf0b3d5047c 100644
--- a/services/ui/ws/gpu_service_proxy.cc
+++ b/services/ui/ws/gpu_service_proxy.cc
@@ -110,41 +110,8 @@ void GpuServiceProxy::CreateGpuMemoryBuffer(
callback.Run(gfx::GpuMemoryBufferHandle());
return;
}
-
- size_t bytes = 0;
- if (!gfx::BufferSizeForBufferFormatChecked(size, format, &bytes)) {
- callback.Run(gfx::GpuMemoryBufferHandle());
- return;
- }
-
- mojo::ScopedSharedBufferHandle mojo_handle =
- mojo::SharedBufferHandle::Create(bytes);
- if (!mojo_handle.is_valid()) {
- callback.Run(gfx::GpuMemoryBufferHandle());
- return;
- }
-
- base::SharedMemoryHandle shm_handle;
- size_t shm_size;
- bool readonly;
- MojoResult result = mojo::UnwrapSharedMemoryHandle(
- std::move(mojo_handle), &shm_handle, &shm_size, &readonly);
- if (result != MOJO_RESULT_OK) {
- callback.Run(gfx::GpuMemoryBufferHandle());
- return;
- }
- DCHECK_EQ(shm_size, bytes);
- DCHECK(!readonly);
- const int stride = base::checked_cast<int>(
- gfx::RowSizeForBufferFormat(size.width(), format, 0));
-
- gfx::GpuMemoryBufferHandle gmb_handle;
- gmb_handle.type = gfx::SHARED_MEMORY_BUFFER;
- gmb_handle.id = id;
- gmb_handle.handle = shm_handle;
- gmb_handle.offset = 0;
- gmb_handle.stride = stride;
- callback.Run(gmb_handle);
+ callback.Run(gpu::GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
+ id, size, format));
}
void GpuServiceProxy::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
« base/memory/shared_memory.h ('K') | « gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698