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 { | 29 struct Configuration { |
30 gfx::GpuMemoryBuffer::Format format; | 30 gfx::BufferFormat format; |
31 gfx::GpuMemoryBuffer::Usage usage; | 31 gfx::BufferUsage usage; |
32 }; | 32 }; |
33 | 33 |
34 virtual ~GpuMemoryBufferFactory() {} | 34 virtual ~GpuMemoryBufferFactory() {} |
35 | 35 |
36 // Gets system supported GPU memory buffer factory types. Preferred type at | 36 // Gets system supported GPU memory buffer factory types. Preferred type at |
37 // the front of vector. | 37 // the front of vector. |
38 static void GetSupportedTypes(std::vector<gfx::GpuMemoryBufferType>* types); | 38 static void GetSupportedTypes(std::vector<gfx::GpuMemoryBufferType>* types); |
39 | 39 |
40 // Creates a new factory instance for |type|. | 40 // Creates a new factory instance for |type|. |
41 static scoped_ptr<GpuMemoryBufferFactory> Create( | 41 static scoped_ptr<GpuMemoryBufferFactory> Create( |
42 gfx::GpuMemoryBufferType type); | 42 gfx::GpuMemoryBufferType type); |
43 | 43 |
44 // Gets supported format/usage configurations. | 44 // Gets supported format/usage configurations. |
45 virtual void GetSupportedGpuMemoryBufferConfigurations( | 45 virtual void GetSupportedGpuMemoryBufferConfigurations( |
46 std::vector<Configuration>* configurations) = 0; | 46 std::vector<Configuration>* configurations) = 0; |
47 | 47 |
48 // Creates a new GPU memory buffer instance. A valid handle is returned on | 48 // Creates a new GPU memory buffer instance. A valid handle is returned on |
49 // success. It can be called on any thread. | 49 // success. It can be called on any thread. |
50 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 50 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
51 gfx::GpuMemoryBufferId id, | 51 gfx::GpuMemoryBufferId id, |
52 const gfx::Size& size, | 52 const gfx::Size& size, |
53 gfx::GpuMemoryBuffer::Format format, | 53 gfx::BufferFormat format, |
54 gfx::GpuMemoryBuffer::Usage usage, | 54 gfx::BufferUsage usage, |
55 int client_id, | 55 int client_id, |
56 gfx::PluginWindowHandle surface_handle) = 0; | 56 gfx::PluginWindowHandle surface_handle) = 0; |
57 | 57 |
58 // Destroys GPU memory buffer identified by |id|. | 58 // Destroys GPU memory buffer identified by |id|. |
59 // It can be called on any thread. | 59 // It can be called on any thread. |
60 virtual void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 60 virtual void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
61 int client_id) = 0; | 61 int client_id) = 0; |
62 | 62 |
63 // Type-checking downcast routine. | 63 // Type-checking downcast routine. |
64 virtual gpu::ImageFactory* AsImageFactory() = 0; | 64 virtual gpu::ImageFactory* AsImageFactory() = 0; |
65 | 65 |
66 protected: | 66 protected: |
67 GpuMemoryBufferFactory() {} | 67 GpuMemoryBufferFactory() {} |
68 | 68 |
69 private: | 69 private: |
70 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory); | 70 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory); |
71 }; | 71 }; |
72 | 72 |
73 } // namespace content | 73 } // namespace content |
74 | 74 |
75 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 75 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
OLD | NEW |