Mir
buffer_factory.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_CLIENT_MIR_BUFFER_FACTORY_H
20 #define MIR_CLIENT_MIR_BUFFER_FACTORY_H
21 
22 #include "mir/geometry/size.h"
23 #include "mir_protobuf.pb.h"
24 #include "buffer.h"
25 #include <mutex>
26 #include <memory>
27 
28 namespace mir
29 {
30 namespace client
31 {
32 class ClientBufferFactory;
34 {
35 public:
36  virtual ~AsyncBufferFactory() = default;
37  AsyncBufferFactory() = default;
38 
39  virtual std::unique_ptr<MirBuffer> generate_buffer(mir::protobuf::Buffer const& buffer) = 0;
40  virtual void expect_buffer(
41  std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
42  MirConnection* connection,
44  MirPixelFormat format,
45  MirBufferUsage usage,
47  void* cb_context) = 0;
48  virtual void cancel_requests_with_context(void*) = 0;
49 
50 private:
51  AsyncBufferFactory(AsyncBufferFactory const&) = delete;
52  AsyncBufferFactory& operator=(AsyncBufferFactory const&) = delete;
53 };
54 
56 {
57 public:
58  std::unique_ptr<MirBuffer> generate_buffer(mir::protobuf::Buffer const& buffer) override;
59  void expect_buffer(
60  std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
61  MirConnection* connection,
63  MirPixelFormat format,
64  MirBufferUsage usage,
66  void* cb_context) override;
67  void cancel_requests_with_context(void*) override;
68 
69 private:
70  std::mutex mutex;
71  int error_id { -1 };
72  struct AllocationRequest
73  {
74  AllocationRequest(
75  std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
76  MirConnection* connection,
77  geometry::Size size,
78  MirPixelFormat format,
79  MirBufferUsage usage,
81  void* cb_context);
82 
83  std::shared_ptr<ClientBufferFactory> const native_buffer_factory;
84  MirConnection* connection;
86  MirPixelFormat format;
87  MirBufferUsage usage;
89  void* cb_context;
90  };
91  std::vector<std::unique_ptr<AllocationRequest>> allocation_requests;
92 };
93 }
94 }
95 #endif /* MIR_CLIENT_MIR_BUFFER_FACTORY_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
virtual void expect_buffer(std::shared_ptr< ClientBufferFactory > const &native_buffer_factory, MirConnection *connection, geometry::Size size, MirPixelFormat format, MirBufferUsage usage, mir_buffer_callback cb, void *cb_context)=0
Definition: buffer_factory.h:55
virtual ~AsyncBufferFactory()=default
MirBufferUsage
MirBufferUsage specifies how a surface can and will be used.
Definition: client_types.h:159
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
Definition: mir_connection.h:96
Definition: buffer_factory.h:33
void(* mir_buffer_callback)(MirBuffer *, void *context)
Definition: client_types_nbs.h:36
virtual void cancel_requests_with_context(void *)=0
virtual std::unique_ptr< MirBuffer > generate_buffer(mir::protobuf::Buffer const &buffer)=0
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