Mir
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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_GRAPHICS_BUFFER_H_
20 #define MIR_GRAPHICS_BUFFER_H_
21 
23 #include "mir/graphics/buffer_id.h"
24 #include "mir/geometry/size.h"
25 #include "mir_toolkit/common.h"
26 
27 #include <memory>
28 #include <functional>
29 
30 namespace mir
31 {
32 namespace graphics
33 {
34 
36 {
37 protected:
38  NativeBufferBase() = default;
39  virtual ~NativeBufferBase() = default;
40  NativeBufferBase(NativeBuffer const&) = delete;
41  NativeBufferBase operator=(NativeBuffer const&) = delete;
42 };
43 
44 class Buffer
45 {
46 public:
47  virtual ~Buffer() {}
48 
49  virtual std::shared_ptr<NativeBuffer> native_buffer_handle() const = 0;
50  virtual BufferID id() const = 0;
51  virtual geometry::Size size() const = 0;
52  virtual geometry::Stride stride() const = 0;
53  virtual MirPixelFormat pixel_format() const = 0;
54  //FIXME: correct mg::Buffer::write, it requires that the user does too much to use it correctly,
55  // (ie, it forces them to figure out what size is proper, alloc a buffer, fill it, and then
56  // copy the data into the buffer)
57  virtual void write(unsigned char const* pixels, size_t size) = 0;
58  virtual void read(std::function<void(unsigned char const*)> const& do_with_pixels) = 0;
59 
60  virtual NativeBufferBase* native_buffer_base() = 0;
61 
62 protected:
63  Buffer() = default;
64 };
65 
66 }
67 }
68 #endif // MIR_GRAPHICS_BUFFER_H_
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: buffer.h:35
Definition: native_buffer.h:44
NativeBufferBase operator=(NativeBuffer const &)=delete
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
virtual ~NativeBufferBase()=default
Definition: buffer.h:44
virtual ~Buffer()
Definition: buffer.h:47
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