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 common
36 {
37 class BufferTextureBinder;
38 }
39 
40 namespace mesa
41 {
42 
44 {
45  struct gbm_bo *bo;
46 };
47 
50 enum : uint32_t { invalid_gbm_format = std::numeric_limits<uint32_t>::max() };
51 
52 class GBMBuffer: public BufferBasic, public NativeBufferBase,
54 {
55 public:
56  GBMBuffer(std::shared_ptr<gbm_bo> const& handle,
57  uint32_t bo_flags,
58  std::unique_ptr<common::BufferTextureBinder> texture_binder);
59  GBMBuffer(const GBMBuffer&) = delete;
60  ~GBMBuffer();
61 
62  GBMBuffer& operator=(const GBMBuffer&) = delete;
63 
64  virtual geometry::Size size() const override;
65 
66  virtual geometry::Stride stride() const override;
67 
68  virtual MirPixelFormat pixel_format() const override;
69 
70  virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;
71 
72  virtual void gl_bind_to_texture() override;
73  virtual void bind() override;
74  virtual void secure_for_render() override;
75 
76  void write(unsigned char const* pixels, size_t size) override;
77  void read(std::function<void(unsigned char const*)> const& do_with_pixels) override;
78 
79  NativeBufferBase* native_buffer_base() override;
80 
81 private:
82  std::shared_ptr<gbm_bo> const gbm_handle;
83  uint32_t bo_flags;
84  std::unique_ptr<common::BufferTextureBinder> const texture_binder;
85  int prime_fd;
86 };
87 
88 }
89 }
90 }
91 
92 
93 #endif // MIR_GRAPHICS_MESA_GBM_BUFFER_H_
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: gbm_buffer.h:52
Definition: texture_source.h:31
struct gbm_bo * bo
Definition: gbm_buffer.h:45
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:50
Definition: mir_native_buffer.h:30
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:43
Definition: buffer_basic.h:29
Definition: dimensions.h:36
int const size
Definition: make_socket_rpc_channel.cpp:51

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016