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 GpuMemoryBufferImplIOSurface(const gfx::Size& size, unsigned internalformat); | 18 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
19 virtual ~GpuMemoryBufferImplIOSurface(); | 19 const gfx::GpuMemoryBufferHandle& handle, |
| 20 const gfx::Size& size, |
| 21 unsigned internalformat, |
| 22 const DestructionCallback& callback); |
20 | 23 |
21 static bool IsFormatSupported(unsigned internalformat); | 24 static bool IsFormatSupported(unsigned internalformat); |
22 static bool IsUsageSupported(unsigned usage); | 25 static bool IsUsageSupported(unsigned usage); |
23 static bool IsConfigurationSupported(unsigned internalformat, unsigned usage); | 26 static bool IsConfigurationSupported(unsigned internalformat, unsigned usage); |
24 static uint32 PixelFormat(unsigned internalformat); | 27 static uint32 PixelFormat(unsigned internalformat); |
25 | 28 |
26 bool InitializeFromHandle(const gfx::GpuMemoryBufferHandle& handle); | |
27 | |
28 // Overridden from gfx::GpuMemoryBuffer: | 29 // Overridden from gfx::GpuMemoryBuffer: |
29 virtual void* Map() OVERRIDE; | 30 virtual void* Map() OVERRIDE; |
30 virtual void Unmap() OVERRIDE; | 31 virtual void Unmap() OVERRIDE; |
31 virtual uint32 GetStride() const OVERRIDE; | 32 virtual uint32 GetStride() const OVERRIDE; |
32 virtual gfx::GpuMemoryBufferHandle GetHandle() const OVERRIDE; | 33 virtual gfx::GpuMemoryBufferHandle GetHandle() const OVERRIDE; |
33 | 34 |
34 private: | 35 private: |
| 36 GpuMemoryBufferImplIOSurface(const gfx::Size& size, |
| 37 unsigned internalformat, |
| 38 const DestructionCallback& callback, |
| 39 IOSurfaceRef io_surface); |
| 40 virtual ~GpuMemoryBufferImplIOSurface(); |
| 41 |
35 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; | 42 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; |
36 | 43 |
37 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplIOSurface); | 44 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplIOSurface); |
38 }; | 45 }; |
39 | 46 |
40 } // namespace content | 47 } // namespace content |
41 | 48 |
42 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ | 49 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_IO_SURFACE_H_ |
OLD | NEW |