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_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/gpu_memory_buffer.h"
15 #include "ui/gfx/native_widget_types.h"
27 class CONTENT_EXPORT GpuMemoryBufferFactory
{
29 struct Configuration
{
30 gfx::GpuMemoryBuffer::Format format
;
31 gfx::GpuMemoryBuffer::Usage usage
;
34 virtual ~GpuMemoryBufferFactory() {}
36 // Gets system supported GPU memory buffer factory types. Preferred type at
37 // the front of vector.
38 static void GetSupportedTypes(std::vector
<gfx::GpuMemoryBufferType
>* types
);
40 // Creates a new factory instance for |type|.
41 static scoped_ptr
<GpuMemoryBufferFactory
> Create(
42 gfx::GpuMemoryBufferType type
);
44 // Gets supported format/usage configurations.
45 virtual void GetSupportedGpuMemoryBufferConfigurations(
46 std::vector
<Configuration
>* configurations
) = 0;
48 // Creates a new GPU memory buffer instance. A valid handle is returned on
49 // success. It can be called on any thread.
50 virtual gfx::GpuMemoryBufferHandle
CreateGpuMemoryBuffer(
51 gfx::GpuMemoryBufferId id
,
52 const gfx::Size
& size
,
53 gfx::GpuMemoryBuffer::Format format
,
54 gfx::GpuMemoryBuffer::Usage usage
,
56 gfx::PluginWindowHandle surface_handle
) = 0;
58 // Destroys GPU memory buffer identified by |id|.
59 // It can be called on any thread.
60 virtual void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id
,
63 // Type-checking downcast routine.
64 virtual gpu::ImageFactory
* AsImageFactory() = 0;
67 GpuMemoryBufferFactory() {}
70 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory
);
73 } // namespace content
75 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_