Revert of Roll Clang 218707:220284 (+cherry-picks of 220340, 220403 and 220407) ...
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_buffer_factory_io_surface.h
blob1ee16ef582f818275fad44aa799ddd89c561a7d0
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"
16 namespace gfx {
17 class GLImage;
20 namespace content {
22 class GpuMemoryBufferFactoryIOSurface {
23 public:
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,
33 int client_id);
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,
43 int client_id);
45 private:
46 typedef std::pair<int, int> IOSurfaceMapKey;
47 typedef base::hash_map<IOSurfaceMapKey, base::ScopedCFTypeRef<IOSurfaceRef>>
48 IOSurfaceMap;
49 IOSurfaceMap io_surfaces_;
52 } // namespace content
54 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_