| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ |
| 7 | 7 |
| 8 #include <IOSurface/IOSurfaceAPI.h> | 8 #include <IOSurface/IOSurfaceAPI.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| 11 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 11 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // Implementation of GPU memory buffer based on IO surfaces. | 15 // Implementation of GPU memory buffer based on IO surfaces. |
| 16 class GpuMemoryBufferImplIOSurface : public GpuMemoryBufferImpl { | 16 class GpuMemoryBufferImplIOSurface : public GpuMemoryBufferImpl { |
| 17 public: | 17 public: |
| 18 static void Create(const gfx::Size& size, | 18 static void Create(const gfx::Size& size, |
| 19 unsigned internalformat, | 19 Format format, |
| 20 unsigned usage, | |
| 21 int client_id, | 20 int client_id, |
| 22 const CreationCallback& callback); | 21 const CreationCallback& callback); |
| 23 | 22 |
| 24 static void AllocateForChildProcess(const gfx::Size& size, | 23 static void AllocateForChildProcess(const gfx::Size& size, |
| 25 unsigned internalformat, | 24 Format format, |
| 26 unsigned usage, | |
| 27 int child_client_id, | 25 int child_client_id, |
| 28 const AllocationCallback& callback); | 26 const AllocationCallback& callback); |
| 29 | 27 |
| 30 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 28 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
| 31 const gfx::GpuMemoryBufferHandle& handle, | 29 const gfx::GpuMemoryBufferHandle& handle, |
| 32 const gfx::Size& size, | 30 const gfx::Size& size, |
| 33 unsigned internalformat, | 31 Format format, |
| 34 const DestructionCallback& callback); | 32 const DestructionCallback& callback); |
| 35 | 33 |
| 36 static bool IsFormatSupported(unsigned internalformat); | 34 static bool IsFormatSupported(Format format); |
| 37 static bool IsUsageSupported(unsigned usage); | 35 static bool IsUsageSupported(Usage usage); |
| 38 static bool IsConfigurationSupported(unsigned internalformat, unsigned usage); | 36 static bool IsConfigurationSupported(Format format, Usage usage); |
| 39 static uint32 PixelFormat(unsigned internalformat); | 37 static uint32 PixelFormat(Format format); |
| 40 | 38 |
| 41 // Overridden from gfx::GpuMemoryBuffer: | 39 // Overridden from gfx::GpuMemoryBuffer: |
| 42 virtual void* Map() override; | 40 virtual void* Map() override; |
| 43 virtual void Unmap() override; | 41 virtual void Unmap() override; |
| 44 virtual uint32 GetStride() const override; | 42 virtual uint32 GetStride() const override; |
| 45 virtual gfx::GpuMemoryBufferHandle GetHandle() const override; | 43 virtual gfx::GpuMemoryBufferHandle GetHandle() const override; |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 GpuMemoryBufferImplIOSurface(const gfx::Size& size, | 46 GpuMemoryBufferImplIOSurface(const gfx::Size& size, |
| 49 unsigned internalformat, | 47 Format format, |
| 50 const DestructionCallback& callback, | 48 const DestructionCallback& callback, |
| 51 IOSurfaceRef io_surface); | 49 IOSurfaceRef io_surface); |
| 52 virtual ~GpuMemoryBufferImplIOSurface(); | 50 virtual ~GpuMemoryBufferImplIOSurface(); |
| 53 | 51 |
| 54 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; | 52 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; |
| 55 | 53 |
| 56 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplIOSurface); | 54 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplIOSurface); |
| 57 }; | 55 }; |
| 58 | 56 |
| 59 } // namespace content | 57 } // namespace content |
| 60 | 58 |
| 61 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ | 59 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ |
| OLD | NEW |