Mir
gbm_buffer.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:
17  * Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
18  */
19 
20 #ifndef MIR_GRAPHICS_MESA_GBM_BUFFER_H_
21 #define MIR_GRAPHICS_MESA_GBM_BUFFER_H_
22 
25 
26 #include <gbm.h>
27 
28 #include <memory>
29 #include <limits>
30 
31 namespace mir
32 {
33 namespace graphics
34 {
35 namespace mesa
36 {
37 
39 {
40  struct gbm_bo *bo;
41 };
42 
45 enum : uint32_t { invalid_gbm_format = std::numeric_limits<uint32_t>::max() };
46 
47 class BufferTextureBinder;
48 
49 class GBMBuffer: public BufferBasic, public NativeBufferBase,
51 {
52 public:
53  GBMBuffer(std::shared_ptr<gbm_bo> const& handle,
54  uint32_t bo_flags,
55  std::unique_ptr<BufferTextureBinder> texture_binder);
56  GBMBuffer(const GBMBuffer&) = delete;
57  ~GBMBuffer();
58 
59  GBMBuffer& operator=(const GBMBuffer&) = delete;
60 
61  virtual geometry::Size size() const override;
62 
63  virtual geometry::Stride stride() const override;
64 
65  virtual MirPixelFormat pixel_format() const override;
66 
67  virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;
68 
69  virtual void gl_bind_to_texture() override;
70 
71  void write(unsigned char const* pixels, size_t size) override;
72  void read(std::function<void(unsigned char const*)> const& do_with_pixels) override;
73 
75 
76 private:
77  std::shared_ptr<gbm_bo> const gbm_handle;
78  uint32_t bo_flags;
79  std::unique_ptr<BufferTextureBinder> const texture_binder;
80  int prime_fd;
81 };
82 
83 }
84 }
85 }
86 
87 
88 #endif // MIR_GRAPHICS_MESA_GBM_BUFFER_H_
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: gbm_buffer.h:49
Definition: texture_source.h:29
virtual void gl_bind_to_texture() override
void read(std::function< void(unsigned char const *)> const &do_with_pixels) override
virtual std::shared_ptr< MirNativeBuffer > native_buffer_handle() const override
struct gbm_bo * bo
Definition: gbm_buffer.h:40
NativeBufferBase * native_buffer_base() override
uint32_t mir_format_to_gbm_format(MirPixelFormat format)
Definition: buffer.h:35
MirPixelFormat gbm_format_to_mir_format(uint32_t format)
Definition: gbm_buffer.h:45
GBMBuffer(std::shared_ptr< gbm_bo > const &handle, uint32_t bo_flags, std::unique_ptr< BufferTextureBinder > texture_binder)
Definition: mir_native_buffer.h:30
GBMBuffer & operator=(const GBMBuffer &)=delete
virtual geometry::Size size() const override
virtual geometry::Stride stride() const override
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
Definition: gbm_buffer.h:38
Definition: buffer_basic.h:29
virtual MirPixelFormat pixel_format() const override
Definition: dimensions.h:36
void write(unsigned char const *pixels, size_t size) override

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