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 "ui/gfx/geometry/size.h"
14 #include "ui/gfx/gpu_memory_buffer.h"
22 class GpuMemoryBufferFactoryIOSurface
{
24 GpuMemoryBufferFactoryIOSurface();
25 ~GpuMemoryBufferFactoryIOSurface();
27 // Creates a IOSurface backed GPU memory buffer with |size| and
28 // |internalformat|. A valid handle is returned on success.
29 gfx::GpuMemoryBufferHandle
CreateGpuMemoryBuffer(
30 gfx::GpuMemoryBufferId id
,
31 const gfx::Size
& size
,
32 gfx::GpuMemoryBuffer::Format format
,
35 // Destroy a previously created GPU memory buffer.
36 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id
, int client_id
);
38 // Creates a GLImage instance for a GPU memory buffer.
39 scoped_refptr
<gfx::GLImage
> CreateImageForGpuMemoryBuffer(
40 gfx::GpuMemoryBufferId id
,
41 const gfx::Size
& size
,
42 gfx::GpuMemoryBuffer::Format format
,
46 typedef std::pair
<int, int> IOSurfaceMapKey
;
47 typedef base::hash_map
<IOSurfaceMapKey
, base::ScopedCFTypeRef
<IOSurfaceRef
>>
49 IOSurfaceMap io_surfaces_
;
52 } // namespace content
54 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_