| 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 "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 9 #include "ui/gl/gl_image.h" | 9 #include "ui/gl/gl_image.h" |
| 10 #include "ui/gl/gl_image_shared_memory.h" | 10 #include "ui/gl/gl_image_shared_memory.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 gfx::GpuMemoryBufferHandle | 32 gfx::GpuMemoryBufferHandle |
| 33 GpuMemoryBufferFactorySharedMemory::CreateGpuMemoryBuffer( | 33 GpuMemoryBufferFactorySharedMemory::CreateGpuMemoryBuffer( |
| 34 gfx::GpuMemoryBufferId id, | 34 gfx::GpuMemoryBufferId id, |
| 35 const gfx::Size& size, | 35 const gfx::Size& size, |
| 36 gfx::GpuMemoryBuffer::Format format, | 36 gfx::GpuMemoryBuffer::Format format, |
| 37 gfx::GpuMemoryBuffer::Usage usage, | 37 gfx::GpuMemoryBuffer::Usage usage, |
| 38 int client_id, | 38 int client_id, |
| 39 gfx::PluginWindowHandle surface_handle) { | 39 gfx::PluginWindowHandle surface_handle) { |
| 40 base::SharedMemory shared_memory; | 40 base::SharedMemory shared_memory; |
| 41 if (!shared_memory.CreateAnonymous( | 41 if (!shared_memory.CreateAnonymous( |
| 42 size.GetArea() * GpuMemoryBufferImpl::BytesPerPixel(format))) | 42 size.GetArea() * GpuMemoryBufferImpl::BitsPerPixel(format) / 8)) |
| 43 return gfx::GpuMemoryBufferHandle(); | 43 return gfx::GpuMemoryBufferHandle(); |
| 44 | 44 |
| 45 gfx::GpuMemoryBufferHandle handle; | 45 gfx::GpuMemoryBufferHandle handle; |
| 46 handle.type = gfx::SHARED_MEMORY_BUFFER; | 46 handle.type = gfx::SHARED_MEMORY_BUFFER; |
| 47 handle.id = id; | 47 handle.id = id; |
| 48 shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), &handle.handle); | 48 shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), &handle.handle); |
| 49 return handle; | 49 return handle; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void GpuMemoryBufferFactorySharedMemory::DestroyGpuMemoryBuffer( | 52 void GpuMemoryBufferFactorySharedMemory::DestroyGpuMemoryBuffer( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 int client_id) { | 67 int client_id) { |
| 68 scoped_refptr<gfx::GLImageSharedMemory> image( | 68 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 69 new gfx::GLImageSharedMemory(size, internalformat)); | 69 new gfx::GLImageSharedMemory(size, internalformat)); |
| 70 if (!image->Initialize(handle, format)) | 70 if (!image->Initialize(handle, format)) |
| 71 return scoped_refptr<gfx::GLImage>(); | 71 return scoped_refptr<gfx::GLImage>(); |
| 72 | 72 |
| 73 return image; | 73 return image; |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace content | 76 } // namespace content |
| OLD | NEW |