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 scene
42 {
43 class SessionListener;
44 class Surface;
45 class SurfaceCoordinator;
46 class SnapshotStrategy;
47 class BufferStreamFactory;
48 class SurfaceFactory;
49 
51 {
52 public:
54  std::shared_ptr<SurfaceCoordinator> const& surface_coordinator,
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 
67  SurfaceCreationParameters const& params,
68  std::shared_ptr<frontend::EventSink> const& surface_sink) 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 
87  void set_lifecycle_state(MirLifecycleState state) override;
88 
89  void start_prompt_session() override;
90  void stop_prompt_session() override;
91  void suspend_prompt_session() override;
92  void resume_prompt_session() override;
93 
94  std::shared_ptr<frontend::BufferStream> get_buffer_stream(frontend::BufferStreamId stream) const override;
96  void destroy_buffer_stream(frontend::BufferStreamId stream) override;
97  void configure_streams(Surface& surface, std::vector<shell::StreamSpecification> const& config) override;
98 
99 protected:
100  ApplicationSession(ApplicationSession const&) = delete;
102 
103 private:
104  std::shared_ptr<SurfaceCoordinator> const surface_coordinator;
105  std::shared_ptr<SurfaceFactory> const surface_factory;
106  std::shared_ptr<BufferStreamFactory> const buffer_stream_factory;
107  pid_t const pid;
108  std::string const session_name;
109  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
110  std::shared_ptr<SessionListener> const session_listener;
111  std::shared_ptr<frontend::EventSink> const event_sink;
112 
113  frontend::SurfaceId next_id();
114 
115  std::atomic<int> next_surface_id;
116 
117  OutputPropertiesCache output_cache;
118 
119  typedef std::map<frontend::SurfaceId, std::shared_ptr<Surface>> Surfaces;
120  typedef std::map<frontend::BufferStreamId, std::shared_ptr<compositor::BufferStream>> Streams;
121  Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
122  Streams::const_iterator checked_find(frontend::BufferStreamId id) const;
123  std::mutex mutable surfaces_and_streams_mutex;
124  Surfaces surfaces;
125  Streams streams;
126 };
127 
128 }
129 } // namespace mir
130 
131 #endif // MIR_SCENE_APPLICATION_SESSION_H_
All things Mir.
Definition: atomic_callback.h:25
void destroy_surface(frontend::SurfaceId surface) override
Definition: application_session.cpp:242
std::shared_ptr< frontend::BufferStream > get_buffer_stream(frontend::BufferStreamId stream) const override
Definition: application_session.cpp:346
ApplicationSession(std::shared_ptr< SurfaceCoordinator > const &surface_coordinator, std::shared_ptr< SurfaceFactory > const &surface_factory, std::shared_ptr< BufferStreamFactory > const &buffer_stream_factory, pid_t pid, std::string const &session_name, std::shared_ptr< SnapshotStrategy > const &snapshot_strategy, std::shared_ptr< SessionListener > const &session_listener, graphics::DisplayConfiguration const &initial_config, std::shared_ptr< frontend::EventSink > const &sink)
void show() override
Definition: application_session.cpp:286
std::shared_ptr< Surface > default_surface() const override
Definition: application_session.cpp:232
void send_display_config(graphics::DisplayConfiguration const &info) override
Definition: application_session.cpp:295
pid_t process_id() const override
Definition: application_session.cpp:263
Definition: session.h:37
void destroy_buffer_stream(frontend::BufferStreamId stream) override
Definition: application_session.cpp:363
void suspend_prompt_session() override
Definition: application_session.cpp:336
std::function< void(Snapshot const &)> SnapshotCallback
Definition: snapshot.h:39
std::shared_ptr< Surface > surface(frontend::SurfaceId surface) const override
Definition: application_session.cpp:166
Definition: application_session.h:50
void set_lifecycle_state(MirLifecycleState state) override
Definition: application_session.cpp:320
void hide() override
Definition: application_session.cpp:277
ApplicationSession & operator=(ApplicationSession const &)=delete
std::shared_ptr< frontend::Surface > get_surface(frontend::SurfaceId surface) const override
Definition: application_session.cpp:161
void start_prompt_session() override
Definition: application_session.cpp:325
void configure_streams(Surface &surface, std::vector< shell::StreamSpecification > const &config) override
Definition: application_session.cpp:369
MirLifecycleState
Definition: common.h:94
Definition: int_wrapper.h:27
void take_snapshot(SnapshotCallback const &snapshot_taken) override
Definition: application_session.cpp:214
~ApplicationSession()
Definition: application_session.cpp:73
frontend::SurfaceId create_surface(SurfaceCreationParameters const &params, std::shared_ptr< frontend::EventSink > const &surface_sink) override
Definition: application_session.cpp:88
void resume_prompt_session() override
Definition: application_session.cpp:341
frontend::BufferStreamId create_buffer_stream(graphics::BufferProperties const &params) override
Definition: application_session.cpp:352
Definition: surface_creation_parameters.h:42
void stop_prompt_session() override
Definition: application_session.cpp:331
Buffer creation properties.
Definition: buffer_properties.h:48
void force_requests_to_complete() override
Definition: application_session.cpp:268
std::string name() const override
Definition: application_session.cpp:258
Definition: surface.h:47
Definition: output_properties_cache.h:46
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:166
std::shared_ptr< Surface > surface_after(std::shared_ptr< Surface > const &) const override
Definition: application_session.cpp:172

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015