GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_buffer_factory.h
blob467944b63faff04f5a9c2be3cfb0923bddfe86ab
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_
8 #include <vector>
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"
17 namespace gfx {
18 class GLImage;
21 namespace gpu {
22 class ImageFactory;
25 namespace content {
27 class CONTENT_EXPORT GpuMemoryBufferFactory {
28 public:
29 struct Configuration {
30 gfx::GpuMemoryBuffer::Format format;
31 gfx::GpuMemoryBuffer::Usage usage;
34 GpuMemoryBufferFactory() {}
35 virtual ~GpuMemoryBufferFactory() {}
37 // Gets system supported GPU memory buffer factory types. Preferred type at
38 // the front of vector.
39 static void GetSupportedTypes(std::vector<gfx::GpuMemoryBufferType>* types);
41 // Creates a new factory instance for |type|.
42 static scoped_ptr<GpuMemoryBufferFactory> Create(
43 gfx::GpuMemoryBufferType type);
45 // Gets supported format/usage configurations.
46 virtual void GetSupportedGpuMemoryBufferConfigurations(
47 std::vector<Configuration>* configurations) = 0;
49 // Creates a new GPU memory buffer instance. A valid handle is returned on
50 // success.
51 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
52 gfx::GpuMemoryBufferId id,
53 const gfx::Size& size,
54 gfx::GpuMemoryBuffer::Format format,
55 gfx::GpuMemoryBuffer::Usage usage,
56 int client_id,
57 gfx::PluginWindowHandle surface_handle) = 0;
59 // Destroys GPU memory buffer identified by |id|.
60 virtual void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
61 int client_id) = 0;
63 // Type-checking downcast routine.
64 virtual gpu::ImageFactory* AsImageFactory() = 0;
66 private:
67 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory);
70 } // namespace content
72 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_