Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
session_mediator.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 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU 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 
20 #ifndef MIR_FRONTEND_SESSION_MEDIATOR_H_
21 #define MIR_FRONTEND_SESSION_MEDIATOR_H_
22 
23 #include "mir_protobuf.pb.h"
25 
26 #include <unordered_map>
27 #include <memory>
28 #include <mutex>
29 
30 namespace mir
31 {
32 namespace graphics
33 {
34 class Buffer;
35 class Platform;
36 class Display;
37 class GraphicBufferAllocator;
38 }
39 
40 
43 namespace frontend
44 {
45 class Shell;
46 class Session;
47 class ResourceCache;
48 class SessionMediatorReport;
49 class ClientBufferTracker;
50 class EventSink;
51 class DisplayChanger;
52 
53 // SessionMediator relays requests from the client process into the server.
54 class SessionMediator : public mir::protobuf::DisplayServer
55 {
56 public:
58  std::shared_ptr<Shell> const& shell,
59  std::shared_ptr<graphics::Platform> const& graphics_platform,
60  std::shared_ptr<frontend::DisplayChanger> const& display_changer,
61  std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
62  std::shared_ptr<SessionMediatorReport> const& report,
63  std::shared_ptr<EventSink> const& event_sink,
64  std::shared_ptr<ResourceCache> const& resource_cache);
65 
66  ~SessionMediator() noexcept;
67 
68  /* Platform independent requests */
69  void connect(::google::protobuf::RpcController* controller,
70  const ::mir::protobuf::ConnectParameters* request,
71  ::mir::protobuf::Connection* response,
72  ::google::protobuf::Closure* done) override;
73 
74  void create_surface(google::protobuf::RpcController* controller,
75  const mir::protobuf::SurfaceParameters* request,
76  mir::protobuf::Surface* response,
77  google::protobuf::Closure* done) override;
78 
79  void next_buffer(
80  google::protobuf::RpcController* controller,
81  mir::protobuf::SurfaceId const* request,
82  mir::protobuf::Buffer* response,
83  google::protobuf::Closure* done) override;
84 
85  void release_surface(google::protobuf::RpcController* controller,
87  mir::protobuf::Void*,
88  google::protobuf::Closure* done) override;
89 
90  void disconnect(google::protobuf::RpcController* controller,
91  const mir::protobuf::Void* request,
92  mir::protobuf::Void* response,
93  google::protobuf::Closure* done) override;
94 
95  void configure_surface(google::protobuf::RpcController* controller,
96  const mir::protobuf::SurfaceSetting*,
97  mir::protobuf::SurfaceSetting*,
98  google::protobuf::Closure* done) override;
99 
100  void configure_display(::google::protobuf::RpcController* controller,
101  const ::mir::protobuf::DisplayConfiguration* request,
102  ::mir::protobuf::DisplayConfiguration* response,
103  ::google::protobuf::Closure* done) override;
104 
105  /* Platform specific requests */
106  void drm_auth_magic(google::protobuf::RpcController* controller,
107  const mir::protobuf::DRMMagic* request,
108  mir::protobuf::DRMAuthMagicStatus* response,
109  google::protobuf::Closure* done) override;
110 
111 private:
112  void pack_protobuf_buffer(protobuf::Buffer& protobuf_buffer,
113  std::shared_ptr<graphics::Buffer> const& graphics_buffer,
114  bool need_full_ipc);
115 
116  std::shared_ptr<Shell> const shell;
117  std::shared_ptr<graphics::Platform> const graphics_platform;
118 
119  // TODO this is a dubious dependency - to get supported_pixel_formats
120  std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator;
121 
122  std::shared_ptr<frontend::DisplayChanger> const display_changer;
123  std::shared_ptr<SessionMediatorReport> const report;
124  std::shared_ptr<EventSink> const event_sink;
125  std::shared_ptr<ResourceCache> const resource_cache;
126 
127  std::unordered_map<SurfaceId,std::shared_ptr<graphics::Buffer>> client_buffer_resource;
128 
129  std::mutex session_mutex;
130  std::weak_ptr<Session> weak_session;
131 };
132 
133 }
134 }
135 
136 
137 #endif /* MIR_FRONTEND_SESSION_MEDIATOR_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013