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.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 {
42 {
43 public:
44  BufferAllocator(gbm_device* device, BypassOption bypass_option);
45 
46  virtual std::shared_ptr<Buffer> alloc_buffer(
47  graphics::BufferProperties const& buffer_properties);
48 
49  std::vector<MirPixelFormat> supported_pixel_formats();
50 
51 private:
52  bool is_pixel_format_supported(MirPixelFormat format);
53  std::shared_ptr<Buffer> alloc_hardware_buffer(
54  graphics::BufferProperties const& buffer_properties);
55  std::shared_ptr<Buffer> alloc_software_buffer(
56  graphics::BufferProperties const& buffer_properties);
57 
58  gbm_device* const device;
59  std::shared_ptr<EGLExtensions> const egl_extensions;
60 
61  BypassOption const bypass_option;
62 };
63 
64 }
65 }
66 }
67 
68 #endif // MIR_GRAPHICS_MESA_BUFFER_ALLOCATOR_H_
Interface to graphic buffer allocation.
Definition: graphic_buffer_allocator.h:37
All things Mir.
Definition: buffer_stream.h:37
Definition: buffer_allocator.h:41
std::vector< MirPixelFormat > supported_pixel_formats()
The supported buffer pixel formats.
Definition: buffer_allocator.cpp:213
MirPixelFormat
The order of components in a format enum matches the order of the components as they would be written...
Definition: common.h:127
BufferAllocator(gbm_device *device, BypassOption bypass_option)
Definition: buffer_allocator.cpp:110
Buffer creation properties.
Definition: buffer_properties.h:48
virtual std::shared_ptr< Buffer > alloc_buffer(graphics::BufferProperties const &buffer_properties)
Allocates a buffer.
Definition: buffer_allocator.cpp:120
BypassOption
Definition: platform.h:32

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015