Mir
application_session.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-2014 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: Robert Carr <racarr@canonical.com>
17  */
18 
19 #ifndef MIR_SCENE_APPLICATION_SESSION_H_
20 #define MIR_SCENE_APPLICATION_SESSION_H_
21 
22 #include "mir/scene/session.h"
23 
25 
26 #include <atomic>
27 #include <map>
28 #include <mutex>
29 
30 namespace mir
31 {
32 namespace frontend
33 {
34 class EventSink;
35 }
36 namespace compositor { class BufferStream; }
37 namespace graphics
38 {
39 class DisplayConfiguration;
40 }
41 namespace shell { class SurfaceStack; }
42 namespace scene
43 {
44 class SessionListener;
45 class Surface;
46 class SnapshotStrategy;
47 class BufferStreamFactory;
48 class SurfaceFactory;
49 
51 {
52 public:
54  std::shared_ptr<shell::SurfaceStack> const& surface_stack,
55  std::shared_ptr<SurfaceFactory> const& surface_factory,
56  std::shared_ptr<BufferStreamFactory> const& buffer_stream_factory,
57  pid_t pid,
58  std::string const& session_name,
59  std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
60  std::shared_ptr<SessionListener> const& session_listener,
61  graphics::DisplayConfiguration const& initial_config,
62  std::shared_ptr<frontend::EventSink> const& sink);
63 
65 
66  frontend::SurfaceId create_surface(
67  SurfaceCreationParameters const& params,
68  std::shared_ptr<frontend::EventSink> const& surface_sink) override;
69  void destroy_surface(frontend::SurfaceId surface) override;
70  std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const override;
71  std::shared_ptr<Surface> surface(frontend::SurfaceId surface) const override;
72  std::shared_ptr<Surface> surface_after(std::shared_ptr<Surface> const&) const override;
73 
74  void take_snapshot(SnapshotCallback const& snapshot_taken) override;
75  std::shared_ptr<Surface> default_surface() const override;
76 
77  std::string name() const override;
78  pid_t process_id() const override;
79 
80  void force_requests_to_complete() override;
81 
82  void hide() override;
83  void show() override;
84 
85  void send_display_config(graphics::DisplayConfiguration const& info) override;
86  void send_input_device_change(std::vector<std::shared_ptr<input::Device>> const& devices) override;
87 
88  void set_lifecycle_state(MirLifecycleState state) override;
89 
90  void start_prompt_session() override;
91  void stop_prompt_session() override;
92  void suspend_prompt_session() override;
93  void resume_prompt_session() override;
94 
95  std::shared_ptr<frontend::BufferStream> get_buffer_stream(frontend::BufferStreamId stream) const override;
96  frontend::BufferStreamId create_buffer_stream(graphics::BufferProperties const& params) override;
97  void destroy_buffer_stream(frontend::BufferStreamId stream) override;
98  void configure_streams(Surface& surface, std::vector<shell::StreamSpecification> const& config) override;
99  void destroy_surface(std::weak_ptr<Surface> const& surface) override;
100 
101 protected:
102  ApplicationSession(ApplicationSession const&) = delete;
103  ApplicationSession& operator=(ApplicationSession const&) = delete;
104 
105 private:
106  std::shared_ptr<shell::SurfaceStack> const surface_stack;
107  std::shared_ptr<SurfaceFactory> const surface_factory;
108  std::shared_ptr<BufferStreamFactory> const buffer_stream_factory;
109  pid_t const pid;
110  std::string const session_name;
111  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
112  std::shared_ptr<SessionListener> const session_listener;
113  std::shared_ptr<frontend::EventSink> const event_sink;
114 
115  frontend::SurfaceId next_id();
116 
117  std::atomic<int> next_surface_id;
118 
119  OutputPropertiesCache output_cache;
120 
121  typedef std::map<frontend::SurfaceId, std::shared_ptr<Surface>> Surfaces;
122  typedef std::map<frontend::BufferStreamId, std::shared_ptr<compositor::BufferStream>> Streams;
123  Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
124  Streams::const_iterator checked_find(frontend::BufferStreamId id) const;
125  std::mutex mutable surfaces_and_streams_mutex;
126  Surfaces surfaces;
127  Streams streams;
128 
129  void destroy_surface(std::unique_lock<std::mutex>& lock, Surfaces::const_iterator in_surfaces);
130 };
131 
132 }
133 } // namespace mir
134 
135 #endif // MIR_SCENE_APPLICATION_SESSION_H_
All things Mir.
Definition: atomic_callback.h:25
Definition: session.h:38
std::function< void(Snapshot const &)> SnapshotCallback
Definition: snapshot.h:39
Definition: application_session.h:50
MirLifecycleState
Definition: common.h:94
Definition: int_wrapper.h:27
Definition: surface_creation_parameters.h:41
Buffer creation properties.
Definition: buffer_properties.h:48
Definition: surface.h:47
Definition: output_properties_cache.h:44
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:167

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