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
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_
8 #include <IOSurface/IOSurfaceAPI.h>
10 #include "base/containers/hash_tables.h"
11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/common/gpu/gpu_memory_buffer_factory.h"
14 #include "gpu/command_buffer/service/image_factory.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/gpu_memory_buffer.h"
24 class GpuMemoryBufferFactoryIOSurface
: public GpuMemoryBufferFactory
,
25 public gpu::ImageFactory
{
27 GpuMemoryBufferFactoryIOSurface();
28 ~GpuMemoryBufferFactoryIOSurface();
30 static bool IsGpuMemoryBufferConfigurationSupported(
31 gfx::GpuMemoryBuffer::Format format
,
32 gfx::GpuMemoryBuffer::Usage usage
);
34 // Overridden from GpuMemoryBufferFactory:
35 void GetSupportedGpuMemoryBufferConfigurations(
36 std::vector
<Configuration
>* configurations
) override
;
37 gfx::GpuMemoryBufferHandle
CreateGpuMemoryBuffer(
38 gfx::GpuMemoryBufferId id
,
39 const gfx::Size
& size
,
40 gfx::GpuMemoryBuffer::Format format
,
41 gfx::GpuMemoryBuffer::Usage usage
,
42 int client_id
) override
;
43 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id
,
44 int client_id
) override
;
45 gpu::ImageFactory
* AsImageFactory() override
;
47 // Overridden from gpu::ImageFactory:
48 scoped_refptr
<gfx::GLImage
> CreateImageForGpuMemoryBuffer(
49 const gfx::GpuMemoryBufferHandle
& handle
,
50 const gfx::Size
& size
,
51 gfx::GpuMemoryBuffer::Format format
,
52 unsigned internalformat
,
53 int client_id
) override
;
56 typedef std::pair
<int, int> IOSurfaceMapKey
;
57 typedef base::hash_map
<IOSurfaceMapKey
, base::ScopedCFTypeRef
<IOSurfaceRef
>>
59 IOSurfaceMap io_surfaces_
;
61 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactoryIOSurface
);
64 } // namespace content
66 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_