Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
23 #include "mir/graphics/buffer_id.h"
24 
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic warning "-Wall"
27 #include <gbm.h>
28 #pragma GCC diagnostic pop
29 
30 #include <memory>
31 
32 namespace mir
33 {
34 namespace graphics
35 {
36 class BufferInitializer;
37 struct EGLExtensions;
38 
39 namespace mesa
40 {
42 {
43 public:
44  BufferAllocator(gbm_device* device,
45  std::shared_ptr<BufferInitializer> const& buffer_initializer);
46 
47  virtual std::shared_ptr<Buffer> alloc_buffer(
48  graphics::BufferProperties const& buffer_properties);
49 
50  std::vector<MirPixelFormat> supported_pixel_formats();
51 
52 private:
53  bool is_pixel_format_supported(MirPixelFormat format);
54  std::shared_ptr<Buffer> alloc_hardware_buffer(
55  graphics::BufferProperties const& buffer_properties);
56  std::shared_ptr<Buffer> alloc_software_buffer(
57  graphics::BufferProperties const& buffer_properties);
58 
59  gbm_device* const device;
60  std::shared_ptr<graphics::BufferInitializer> buffer_initializer;
61  std::shared_ptr<EGLExtensions> const egl_extensions;
62 
63  bool bypass_env;
64 };
65 
66 }
67 }
68 }
69 
70 #endif // MIR_GRAPHICS_MESA_BUFFER_ALLOCATOR_H_
Interface to graphic buffer allocation.
Definition: graphic_buffer_allocator.h:37
BufferAllocator(gbm_device *device, std::shared_ptr< BufferInitializer > const &buffer_initializer)
Definition: buffer_allocator.cpp:111
Definition: buffer_allocator.h:41
std::vector< MirPixelFormat > supported_pixel_formats()
The supported buffer pixel formats.
Definition: buffer_allocator.cpp:221
MirPixelFormat
The order of components in a format enum matches the order of the components as they would be written...
Definition: common.h:99
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:124

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014