base/threading: remove ScopedTracker placed for experiments
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_buffer_factory_io_surface.h
blobf505a62f6ffeb55be0671df9e668c4f0564d7b38
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/IOSurface.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(gfx::BufferFormat format,
32 gfx::BufferUsage 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::BufferFormat format,
41 gfx::BufferUsage usage,
42 int client_id,
43 gfx::PluginWindowHandle surface_handle) override;
44 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
45 int client_id) override;
46 gpu::ImageFactory* AsImageFactory() override;
48 // Overridden from gpu::ImageFactory:
49 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
50 const gfx::GpuMemoryBufferHandle& handle,
51 const gfx::Size& size,
52 gfx::BufferFormat format,
53 unsigned internalformat,
54 int client_id) override;
56 private:
57 typedef std::pair<int, int> IOSurfaceMapKey;
58 typedef base::hash_map<IOSurfaceMapKey, base::ScopedCFTypeRef<IOSurfaceRef>>
59 IOSurfaceMap;
60 IOSurfaceMap io_surfaces_;
61 base::Lock io_surfaces_lock_;
63 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactoryIOSurface);
66 } // namespace content
68 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_IO_SURFACE_H_