Mir
shm_buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 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  * Alexandros Frantzis <alexandros.frantzis@canonical.com>
18  */
19 
20 #ifndef MIR_GRAPHICS_MESA_SHM_BUFFER_H_
21 #define MIR_GRAPHICS_MESA_SHM_BUFFER_H_
22 
25 #include "mir/geometry/size.h"
26 #include "mir_toolkit/common.h"
28 
29 namespace mir
30 {
31 namespace graphics
32 {
33 namespace mesa
34 {
35 
36 class ShmFile;
37 
38 class ShmBuffer : public BufferBasic, public NativeBufferBase,
40 {
41 public:
42  static bool supports(MirPixelFormat);
43 
44  ShmBuffer(std::shared_ptr<ShmFile> const& shm_file,
45  geometry::Size const& size,
47  ~ShmBuffer() noexcept;
48 
49  geometry::Size size() const override;
50  geometry::Stride stride() const override;
51  MirPixelFormat pixel_format() const override;
52  std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;
53  void gl_bind_to_texture() override;
54  void bind() override;
55  void secure_for_render() override;
56  void write(unsigned char const* data, size_t size) override;
57  void read(std::function<void(unsigned char const*)> const& do_with_pixels) override;
59 
60 private:
61  ShmBuffer(ShmBuffer const&) = delete;
62  ShmBuffer& operator=(ShmBuffer const&) = delete;
63 
64  std::shared_ptr<ShmFile> const shm_file;
65  geometry::Size const size_;
66  MirPixelFormat const pixel_format_;
67  geometry::Stride const stride_;
68  void* const pixels;
69 };
70 
71 }
72 }
73 }
74 
75 #endif /* MIR_GRAPHICS_MESA_SHM_BUFFER_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: texture_source.h:31
NativeBufferBase * native_buffer_base() override
void read(std::function< void(unsigned char const *)> const &do_with_pixels) override
void gl_bind_to_texture() override
std::shared_ptr< MirNativeBuffer > native_buffer_handle() const override
void secure_for_render() override
Definition: buffer.h:35
Definition: shm_buffer.h:38
geometry::Stride stride() const override
MirPixelFormat pixel_format() const override
ShmBuffer(std::shared_ptr< ShmFile > const &shm_file, geometry::Size const &size, MirPixelFormat const &pixel_format)
void write(unsigned char const *data, size_t size) override
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
geometry::Size size() const override
Definition: buffer_basic.h:29
Definition: dimensions.h:36
static bool supports(MirPixelFormat)

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016