Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
surface_stack.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_SCENE_SURFACE_STACK_H_
20 #define MIR_SCENE_SURFACE_STACK_H_
21 
22 #include "surface_stack_model.h"
23 
24 #include "mir/compositor/scene.h"
25 #include "mir/scene/depth_id.h"
26 #include "mir/scene/observer.h"
27 #include "mir/input/scene.h"
28 
29 #include "mir/basic_observers.h"
30 
31 #include <memory>
32 #include <vector>
33 #include <mutex>
34 #include <map>
35 #include <set>
36 
37 namespace mir
38 {
39 namespace graphics
40 {
41 class Renderable;
42 }
45 namespace scene
46 {
47 class InputRegistrar;
48 class BasicSurface;
49 class SceneReport;
50 class RenderingTracker;
51 
52 class Observers : public Observer, BasicObservers<Observer>
53 {
54 public:
55  // ms::Observer
56  void surface_added(Surface* surface) override;
57  void surface_removed(Surface* surface) override;
58  void surfaces_reordered() override;
59  void scene_changed() override;
60  void surface_exists(Surface* surface) override;
61  void end_observation();
62 
65 };
66 
68 {
69 public:
70  explicit SurfaceStack(
71  std::shared_ptr<SceneReport> const& report);
72  virtual ~SurfaceStack() noexcept(true) {}
73 
74  // From Scene
78 
79  // From Scene
80  void for_each(std::function<void(std::shared_ptr<input::Surface> const&)> const& callback);
81 
82  virtual void remove_surface(std::weak_ptr<Surface> const& surface) override;
83 
84  virtual void raise(std::weak_ptr<Surface> const& surface) override;
85 
86  void add_surface(
87  std::shared_ptr<Surface> const& surface,
88  DepthId depth,
89  input::InputReceptionMode input_mode) override;
90 
91  void add_observer(std::shared_ptr<Observer> const& observer) override;
92  void remove_observer(std::weak_ptr<Observer> const& observer) override;
93 
94  // Intended for input overlays, as described in mir::input::Scene documentation.
95  void add_input_visualization(std::shared_ptr<graphics::Renderable> const& overlay);
96  void remove_input_visualization(std::weak_ptr<graphics::Renderable> const& overlay);
97 
98  void emit_scene_changed() override;
99 
100 private:
101  SurfaceStack(const SurfaceStack&) = delete;
102  SurfaceStack& operator=(const SurfaceStack&) = delete;
103  void create_rendering_tracker_for(std::shared_ptr<Surface> const&);
104  void update_rendering_tracker_compositors();
105 
106  std::mutex mutable guard;
107 
108  std::shared_ptr<InputRegistrar> const input_registrar;
109  std::shared_ptr<SceneReport> const report;
110 
111  typedef std::vector<std::shared_ptr<Surface>> Layer;
112  std::map<DepthId, Layer> layers_by_depth;
113  std::map<Surface*,std::shared_ptr<RenderingTracker>> rendering_trackers;
114  std::set<compositor::CompositorID> registered_compositors;
115 
116  std::vector<std::shared_ptr<graphics::Renderable>> overlays;
117 
118  Observers observers;
119 };
120 
121 }
122 }
123 
124 #endif /* MIR_SCENE_SURFACE_STACK_H_ */
Definition: scene.h:42
All things Mir.
Definition: aging_buffer.h:24
Definition: surface_stack_model.h:34
void for_each(std::function< void(std::shared_ptr< input::Surface > const &)> const &callback)
Definition: surface_stack.cpp:239
void surface_added(Surface *surface) override
Definition: surface_stack.cpp:321
Definition: hwc_layers.h:45
Definition: surface_stack.h:67
void remove_input_visualization(std::weak_ptr< graphics::Renderable > const &overlay)
Definition: surface_stack.cpp:169
void surface_removed(Surface *surface) override
Definition: surface_stack.cpp:327
An observer for top level notifications of scene changes. In order to receive more granular change no...
Definition: observer.h:33
void emit_scene_changed() override
Definition: surface_stack.cpp:186
void add_observer(std::shared_ptr< Observer > const &observer) override
Definition: surface_stack.cpp:295
std::vector< std::shared_ptr< SceneElement >> SceneElementSequence
Definition: scene.h:38
Definition: scene.h:40
virtual void remove_surface(std::weak_ptr< Surface > const &surface) override
Definition: surface_stack.cpp:207
true
Definition: display_configuration.cpp:30
SurfaceStack(std::shared_ptr< SceneReport > const &report)
Definition: surface_stack.cpp:114
compositor::SceneElementSequence scene_elements_for(compositor::CompositorID id) override
Generate a valid sequence of scene elements based on the current state of the Scene.
Definition: surface_stack.cpp:120
void unregister_compositor(compositor::CompositorID id) override
Definition: surface_stack.cpp:150
Definition: surface_stack.h:52
virtual ~SurfaceStack() noexcept(true)
Definition: surface_stack.h:72
void end_observation()
Definition: surface_stack.cpp:351
void remove_observer(std::weak_ptr< Observer > const &observer) override
Definition: surface_stack.cpp:310
void const * CompositorID
Definition: compositor_id.h:27
Definition: basic_observers.h:30
void surface_exists(Surface *surface) override
Definition: surface_stack.cpp:345
void surfaces_reordered() override
Definition: surface_stack.cpp:333
void add_input_visualization(std::shared_ptr< graphics::Renderable > const &overlay)
Definition: surface_stack.cpp:159
void add_surface(std::shared_ptr< Surface > const &surface, DepthId depth, input::InputReceptionMode input_mode) override
Definition: surface_stack.cpp:191
InputReceptionMode
Definition: input_reception_mode.h:27
void register_compositor(compositor::CompositorID id) override
Definition: surface_stack.cpp:141
Definition: surface.h:40
void scene_changed() override
Definition: surface_stack.cpp:339

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014