Add P2PDatagramSocket and P2PStreamSocket interfaces.
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_buffer_factory_io_surface.h
blobeac05adb58a37e96011373fa49563e5ec9dbe204
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 "base/synchronization/lock.h"
14 #include "content/common/gpu/gpu_memory_buffer_factory.h"
15 #include "gpu/command_buffer/service/image_factory.h"
16 #include "ui/gfx/geometry/size.h"
17 #include "ui/gfx/gpu_memory_buffer.h"
19 namespace gfx {
20 class GLImage;
23 namespace content {
25 class GpuMemoryBufferFactoryIOSurface : public GpuMemoryBufferFactory,
26 public gpu::ImageFactory {
27 public:
28 GpuMemoryBufferFactoryIOSurface();
29 ~GpuMemoryBufferFactoryIOSurface() override;
31 static bool IsGpuMemoryBufferConfigurationSupported(
32 gfx::GpuMemoryBuffer::Format format,
33 gfx::GpuMemoryBuffer::Usage usage);
35 // Overridden from GpuMemoryBufferFactory:
36 void GetSupportedGpuMemoryBufferConfigurations(
37 std::vector<Configuration>* configurations) override;
38 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
39 gfx::GpuMemoryBufferId id,
40 const gfx::Size& size,
41 gfx::GpuMemoryBuffer::Format format,
42 gfx::GpuMemoryBuffer::Usage usage,
43 int client_id,
44 gfx::PluginWindowHandle surface_handle) override;
45 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
46 int client_id) override;
47 gpu::ImageFactory* AsImageFactory() override;
49 // Overridden from gpu::ImageFactory:
50 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
51 const gfx::GpuMemoryBufferHandle& handle,
52 const gfx::Size& size,
53 gfx::GpuMemoryBuffer::Format format,
54 unsigned internalformat,
55 int client_id) override;
57 private:
58 typedef std::pair<int, int> IOSurfaceMapKey;
59 typedef base::hash_map<IOSurfaceMapKey, base::ScopedCFTypeRef<IOSurfaceRef>>
60 IOSurfaceMap;
61 IOSurfaceMap io_surfaces_;
62 base::Lock io_surfaces_lock_;
64 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactoryIOSurface);
67 } // namespace content
69 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_