Mir
buffer_allocator.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_MESA_BUFFER_ALLOCATOR_H_
20 #define MIR_GRAPHICS_MESA_BUFFER_ALLOCATOR_H_
21 
22 #include "platform_common.h"
24 #include "mir/graphics/buffer_id.h"
25 
26 #pragma GCC diagnostic push
27 #pragma GCC diagnostic warning "-Wall"
28 #include <gbm.h>
29 #pragma GCC diagnostic pop
30 
31 #include <memory>
32 
33 namespace mir
34 {
35 namespace graphics
36 {
37 struct EGLExtensions;
38 
39 namespace mesa
40 {
41 
43 {
45  dma_buf
46 };
47 
49 {
50 public:
51  BufferAllocator(gbm_device* device, BypassOption bypass_option, BufferImportMethod const buffer_import_method);
52 
53  virtual std::shared_ptr<Buffer> alloc_buffer(
54  graphics::BufferProperties const& buffer_properties);
55 
56  std::unique_ptr<Buffer> reconstruct_from(MirBufferPackage* package, MirPixelFormat format);
57 
58  std::vector<MirPixelFormat> supported_pixel_formats();
59 
60 private:
61  std::shared_ptr<Buffer> alloc_hardware_buffer(
62  graphics::BufferProperties const& buffer_properties);
63  std::shared_ptr<Buffer> alloc_software_buffer(
64  graphics::BufferProperties const& buffer_properties);
65 
66  gbm_device* const device;
67  std::shared_ptr<EGLExtensions> const egl_extensions;
68 
69  BypassOption const bypass_option;
70  BufferImportMethod const buffer_import_method;
71 };
72 
73 }
74 }
75 }
76 
77 #endif // MIR_GRAPHICS_MESA_BUFFER_ALLOCATOR_H_
std::unique_ptr< Buffer > reconstruct_from(MirBufferPackage *package, MirPixelFormat format)
Interface to graphic buffer allocation.
Definition: graphic_buffer_allocator.h:37
All things Mir.
Definition: atomic_callback.h:25
BufferImportMethod
Definition: buffer_allocator.h:42
Definition: buffer_allocator.h:48
Definition: mir_native_buffer.h:30
BufferAllocator(gbm_device *device, BypassOption bypass_option, BufferImportMethod const buffer_import_method)
std::vector< MirPixelFormat > supported_pixel_formats()
The supported buffer pixel formats.
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
virtual std::shared_ptr< Buffer > alloc_buffer(graphics::BufferProperties const &buffer_properties)
Allocates a buffer.
Buffer creation properties.
Definition: buffer_properties.h:48
BypassOption
Definition: platform_common.h:29

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015