Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
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 class BufferInitializer;
38 struct EGLExtensions;
39 
40 namespace mesa
41 {
43 {
44 public:
45  BufferAllocator(gbm_device* device,
46  std::shared_ptr<BufferInitializer> const& buffer_initializer,
47  BypassOption bypass_option);
48 
49  virtual std::shared_ptr<Buffer> alloc_buffer(
50  graphics::BufferProperties const& buffer_properties);
51 
52  std::vector<MirPixelFormat> supported_pixel_formats();
53 
54 private:
55  bool is_pixel_format_supported(MirPixelFormat format);
56  std::shared_ptr<Buffer> alloc_hardware_buffer(
57  graphics::BufferProperties const& buffer_properties);
58  std::shared_ptr<Buffer> alloc_software_buffer(
59  graphics::BufferProperties const& buffer_properties);
60 
61  gbm_device* const device;
62  std::shared_ptr<graphics::BufferInitializer> buffer_initializer;
63  std::shared_ptr<EGLExtensions> const egl_extensions;
64 
65  BypassOption const bypass_option;
66 };
67 
68 }
69 }
70 }
71 
72 #endif // MIR_GRAPHICS_MESA_BUFFER_ALLOCATOR_H_
Interface to graphic buffer allocation.
Definition: graphic_buffer_allocator.h:37
All things Mir.
Definition: aging_buffer.h:24
Definition: buffer_allocator.h:42
BufferAllocator(gbm_device *device, std::shared_ptr< BufferInitializer > const &buffer_initializer, BypassOption bypass_option)
Definition: buffer_allocator.cpp:111
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:119
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
BypassOption
Definition: platform.h:35

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014