OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
14 #include "ui/gfx/gpu_memory_buffer.h" | 14 #include "ui/gfx/gpu_memory_buffer.h" |
15 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 class GLImage; | 18 class GLImage; |
19 } | 19 } |
20 | 20 |
21 namespace gpu { | 21 namespace gpu { |
22 class ImageFactory; | 22 class ImageFactory; |
23 } | 23 } |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 | 26 |
27 class CONTENT_EXPORT GpuMemoryBufferFactory { | 27 class CONTENT_EXPORT GpuMemoryBufferFactory { |
28 public: | 28 public: |
29 struct Configuration { | |
30 gfx::BufferFormat format; | |
31 gfx::BufferUsage usage; | |
32 }; | |
33 | |
34 virtual ~GpuMemoryBufferFactory() {} | 29 virtual ~GpuMemoryBufferFactory() {} |
35 | 30 |
36 // Gets system supported GPU memory buffer factory types. Preferred type at | 31 // Returns the native GPU memory buffer factory type. Returns EMPTY_BUFFER |
37 // the front of vector. | 32 // type if native buffers are not supported. |
38 static void GetSupportedTypes(std::vector<gfx::GpuMemoryBufferType>* types); | 33 static gfx::GpuMemoryBufferType GetNativeType(); |
39 | 34 |
40 // Creates a new factory instance for |type|. | 35 // Creates a new factory instance for native GPU memory buffers. |
41 static scoped_ptr<GpuMemoryBufferFactory> Create( | 36 static scoped_ptr<GpuMemoryBufferFactory> CreateNativeType(); |
42 gfx::GpuMemoryBufferType type); | |
43 | |
44 // Gets supported format/usage configurations. | |
45 virtual void GetSupportedGpuMemoryBufferConfigurations( | |
46 std::vector<Configuration>* configurations) = 0; | |
47 | 37 |
48 // Creates a new GPU memory buffer instance. A valid handle is returned on | 38 // Creates a new GPU memory buffer instance. A valid handle is returned on |
49 // success. It can be called on any thread. | 39 // success. It can be called on any thread. |
50 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 40 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
51 gfx::GpuMemoryBufferId id, | 41 gfx::GpuMemoryBufferId id, |
52 const gfx::Size& size, | 42 const gfx::Size& size, |
53 gfx::BufferFormat format, | 43 gfx::BufferFormat format, |
54 gfx::BufferUsage usage, | 44 gfx::BufferUsage usage, |
55 int client_id, | 45 int client_id, |
56 gfx::PluginWindowHandle surface_handle) = 0; | 46 gfx::PluginWindowHandle surface_handle) = 0; |
57 | 47 |
58 // Destroys GPU memory buffer identified by |id|. | 48 // Destroys GPU memory buffer identified by |id|. |
59 // It can be called on any thread. | 49 // It can be called on any thread. |
60 virtual void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 50 virtual void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
61 int client_id) = 0; | 51 int client_id) = 0; |
62 | 52 |
63 // Type-checking downcast routine. | 53 // Type-checking downcast routine. |
64 virtual gpu::ImageFactory* AsImageFactory() = 0; | 54 virtual gpu::ImageFactory* AsImageFactory() = 0; |
65 | 55 |
66 protected: | 56 protected: |
67 GpuMemoryBufferFactory() {} | 57 GpuMemoryBufferFactory() {} |
68 | 58 |
69 private: | 59 private: |
70 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory); | 60 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory); |
71 }; | 61 }; |
72 | 62 |
73 } // namespace content | 63 } // namespace content |
74 | 64 |
75 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 65 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
OLD | NEW |