Mir

Merge lp:~kdub/mir/sort-out-surface-observers into lp:mir

Proposed by Kevin DuBois
Status: Work in progress
Proposed branch: lp:~kdub/mir/sort-out-surface-observers
Merge into: lp:mir
Diff against target: 989 lines (+376/-66)
31 files modified
include/server/mir/frontend/buffer_stream.h (+3/-3)
include/server/mir/scene/null_stream_observer.h (+36/-0)
include/server/mir/scene/null_surface_observer.h (+1/-1)
include/server/mir/scene/stream_observer.h (+45/-0)
include/server/mir/scene/surface.h (+2/-0)
include/server/mir/scene/surface_observer.h (+1/-1)
include/server/mir/shell/surface_ready_observer.h (+3/-2)
src/include/server/mir/scene/stream_observers.h (+43/-0)
src/include/server/mir/scene/surface_observers.h (+1/-1)
src/server/compositor/buffer_stream_surfaces.cpp (+2/-2)
src/server/compositor/buffer_stream_surfaces.h (+4/-4)
src/server/input/cursor_controller.cpp (+0/-4)
src/server/scene/CMakeLists.txt (+1/-0)
src/server/scene/basic_surface.cpp (+54/-15)
src/server/scene/basic_surface.h (+5/-0)
src/server/scene/legacy_scene_change_notification.cpp (+3/-2)
src/server/scene/legacy_stream_change_notification.cpp (+37/-0)
src/server/scene/legacy_stream_change_notification.h (+45/-0)
src/server/scene/legacy_surface_change_notification.cpp (+4/-6)
src/server/scene/legacy_surface_change_notification.h (+2/-5)
src/server/scene/null_surface_observer.cpp (+5/-1)
src/server/scene/stream_change_notification.h (+45/-0)
src/server/shell/surface_ready_observer.cpp (+4/-0)
src/server/symbols.map (+8/-2)
tests/include/mir_test_doubles/mock_buffer_stream.h (+2/-2)
tests/include/mir_test_doubles/mock_surface.h (+2/-0)
tests/include/mir_test_doubles/stub_buffer_stream.h (+2/-2)
tests/include/mir_test_doubles/stub_scene_surface.h (+2/-0)
tests/unit-tests/compositor/test_buffer_stream.cpp (+2/-3)
tests/unit-tests/scene/test_basic_surface.cpp (+1/-1)
tests/unit-tests/scene/test_legacy_scene_change_notification.cpp (+11/-9)
To merge this branch: bzr merge lp:~kdub/mir/sort-out-surface-observers
Reviewer Review Type Date Requested Status
Daniel van Vugt Abstain
Robert Carr (community) Approve
Alan Griffiths Needs Information
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+261553@code.launchpad.net

Commit message

Sort out the observers structure by introducing a StreamObserver. The BufferStreamObserver can notify of frame posting and resize of a buffer stream. The surface observer no longer notifies of a new frame (as it doesn't know what the streams are doing), but it can notify that the stacking of the streams has changed.

Description of the change

Sort out the observers structure by introducing a StreamObserver. The BufferStreamObserver can notify of frame posting and resize of a buffer stream. The surface observer no longer notifies of a new frame (as it doesn't know what the streams are doing), but it can notify that the stacking of the streams has changed.

In the review of ~kdub/mir/surface-has-a-bufferstream, Alexandros pointed in this comment (https://code.launchpad.net/~kdub/mir/surface-has-a-bufferstream/+merge/257559/comments/642904)
that the SurfaceObservers keeping track of the streams was a bit strange, and this MP corrects this.

I also considered having
ms::SurfaceObserver : public ms::BufferStreamObserver
but it seems to me that these are two different operations, so they are separate in this MP.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

*Needs Discussion*

397 +void ms::BasicSurface::add_observer(std::shared_ptr<StreamObserver> const& observer)

I'm not convinced that the Surface (and not the SurfaceObserver) is responsible for adding StreamObservers.

My instinct would be for LegacySurfaceChangeNotification::stream_added() to register a stream observer.

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote :

I'm not totally sure this is an improvement. It seems to solve the problem of having to use the implement complete surface observer interface when only a stream observer is needed but this is pretty easy to manager with null observers and isn't so much a safety issue as a wart (as far as I see it)...I think this branch comes with a few warts:

+class SurfaceReadyObserver : public scene::NullStreamObserver,

We've fixed one name mismatch but introduced another as far as I can see...the other wart I notice being the increased complexity in BasicSurface.

It's possible Alan's suggestion about making the Surface Observer responsible for adding the StreamObserver would resolve some of my concerns, this way you would have SurfaceReadyObserver be a SurfaceObserver right?

Anyway though...it seems a reasonable and runtime correct step and I assume you find it useful if you've proposed it so I'll approve!

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

Will see if I can root out the requirement on Surface tomorrow.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think our Surface-related classes are quite overcomplicated for the limited functionality they have. So from a high level I feel there's no justifiable reason to grow the code, we should be shrinking it.

But I won't block progress in wishing we were doing better...

review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

The rework should not complicate the Surface class anymore. This is somewhat on the backburner, will re-propose at a later time.

Unmerged revisions

2642. By Kevin DuBois

remove a dup symbol from the table

2641. By Kevin DuBois

merge in mir

2640. By Kevin DuBois

round of cleanups

2639. By Kevin DuBois

shift around files

2638. By Kevin DuBois

sort out observers with resetting the streams

2637. By Kevin DuBois

merge in mir

2636. By Kevin DuBois

tests to pass

2635. By Kevin DuBois

merge in mir

2634. By Kevin DuBois

transition most things to having a separate stream and surface notification path

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/server/mir/frontend/buffer_stream.h'
--- include/server/mir/frontend/buffer_stream.h 2015-06-02 13:41:40 +0000
+++ include/server/mir/frontend/buffer_stream.h 2015-06-10 12:39:17 +0000
@@ -32,7 +32,7 @@
32}32}
33namespace scene33namespace scene
34{34{
35class SurfaceObserver;35class StreamObserver;
36}36}
3737
38namespace frontend38namespace frontend
@@ -45,8 +45,8 @@
45 45
46 virtual void swap_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) = 0;46 virtual void swap_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) = 0;
4747
48 virtual void add_observer(std::shared_ptr<scene::SurfaceObserver> const& observer) = 0;48 virtual void add_observer(std::shared_ptr<scene::StreamObserver> const& observer) = 0;
49 virtual void remove_observer(std::weak_ptr<scene::SurfaceObserver> const& observer) = 0;49 virtual void remove_observer(std::weak_ptr<scene::StreamObserver> const& observer) = 0;
50 50
51 virtual void with_most_recent_buffer_do(51 virtual void with_most_recent_buffer_do(
52 std::function<void(graphics::Buffer&)> const& exec) = 0;52 std::function<void(graphics::Buffer&)> const& exec) = 0;
5353
=== added file 'include/server/mir/scene/null_stream_observer.h'
--- include/server/mir/scene/null_stream_observer.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/null_stream_observer.h 2015-06-10 12:39:17 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_SCENE_NULL_STREAM_OBSERVER_H_
20#define MIR_SCENE_NULL_STREAM_OBSERVER_H_
21
22#include "mir/scene/stream_observer.h"
23
24namespace mir
25{
26namespace scene
27{
28class NullStreamObserver : public StreamObserver
29{
30 void frame_posted(int frames_available) override;
31 void resized_to(geometry::Size const& size) override;
32};
33}
34}
35
36#endif // MIR_SCENE_NULL_STREAM_OBSERVER_H_
037
=== modified file 'include/server/mir/scene/null_surface_observer.h'
--- include/server/mir/scene/null_surface_observer.h 2015-04-09 08:57:24 +0000
+++ include/server/mir/scene/null_surface_observer.h 2015-06-10 12:39:17 +0000
@@ -35,7 +35,6 @@
35 void resized_to(geometry::Size const& size) override;35 void resized_to(geometry::Size const& size) override;
36 void moved_to(geometry::Point const& top_left) override;36 void moved_to(geometry::Point const& top_left) override;
37 void hidden_set_to(bool hide) override;37 void hidden_set_to(bool hide) override;
38 void frame_posted(int frames_available) override;
39 void alpha_set_to(float alpha) override;38 void alpha_set_to(float alpha) override;
40 void orientation_set_to(MirOrientation orientation) override;39 void orientation_set_to(MirOrientation orientation) override;
41 void transformation_set_to(glm::mat4 const& t) override;40 void transformation_set_to(glm::mat4 const& t) override;
@@ -44,6 +43,7 @@
44 void client_surface_close_requested() override;43 void client_surface_close_requested() override;
45 void keymap_changed(xkb_rule_names const& names) override;44 void keymap_changed(xkb_rule_names const& names) override;
46 void renamed(char const* name) override;45 void renamed(char const* name) override;
46 void streams_repositioned() override;
4747
48protected:48protected:
49 NullSurfaceObserver(NullSurfaceObserver const&) = delete;49 NullSurfaceObserver(NullSurfaceObserver const&) = delete;
5050
=== added file 'include/server/mir/scene/stream_observer.h'
--- include/server/mir/scene/stream_observer.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/stream_observer.h 2015-06-10 12:39:17 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_SCENE_STREAM_OBSERVER_H_
20#define MIR_SCENE_STREAM_OBSERVER_H_
21
22namespace mir
23{
24namespace geometry
25{
26struct Size;
27}
28namespace scene
29{
30class StreamObserver
31{
32public:
33 virtual void resized_to(geometry::Size const& size) = 0;
34 virtual void frame_posted(int frames_available) = 0;
35
36protected:
37 StreamObserver() = default;
38 virtual ~StreamObserver() = default;
39 StreamObserver(StreamObserver const&) = delete;
40 StreamObserver& operator=(StreamObserver const&) = delete;
41};
42}
43}
44
45#endif // MIR_SCENE_SURFACE_OBSERVER_H_
046
=== modified file 'include/server/mir/scene/surface.h'
--- include/server/mir/scene/surface.h 2015-06-02 13:41:40 +0000
+++ include/server/mir/scene/surface.h 2015-06-10 12:39:17 +0000
@@ -93,6 +93,8 @@
93 virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) override = 0;93 virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) override = 0;
94 virtual std::shared_ptr<graphics::CursorImage> cursor_image() const override = 0;94 virtual std::shared_ptr<graphics::CursorImage> cursor_image() const override = 0;
9595
96 virtual void add_observer(std::shared_ptr<StreamObserver> const& observer) = 0;
97 virtual void remove_observer(std::weak_ptr<StreamObserver> const& observer) = 0;
96 virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;98 virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
97 virtual void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) = 0;99 virtual void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) = 0;
98100
99101
=== modified file 'include/server/mir/scene/surface_observer.h'
--- include/server/mir/scene/surface_observer.h 2015-04-09 08:57:24 +0000
+++ include/server/mir/scene/surface_observer.h 2015-06-10 12:39:17 +0000
@@ -47,7 +47,6 @@
47 virtual void resized_to(geometry::Size const& size) = 0;47 virtual void resized_to(geometry::Size const& size) = 0;
48 virtual void moved_to(geometry::Point const& top_left) = 0;48 virtual void moved_to(geometry::Point const& top_left) = 0;
49 virtual void hidden_set_to(bool hide) = 0;49 virtual void hidden_set_to(bool hide) = 0;
50 virtual void frame_posted(int frames_available) = 0;
51 virtual void alpha_set_to(float alpha) = 0;50 virtual void alpha_set_to(float alpha) = 0;
52 virtual void orientation_set_to(MirOrientation orientation) = 0;51 virtual void orientation_set_to(MirOrientation orientation) = 0;
53 virtual void transformation_set_to(glm::mat4 const& t) = 0;52 virtual void transformation_set_to(glm::mat4 const& t) = 0;
@@ -56,6 +55,7 @@
56 virtual void client_surface_close_requested() = 0;55 virtual void client_surface_close_requested() = 0;
57 virtual void keymap_changed(xkb_rule_names const& names) = 0;56 virtual void keymap_changed(xkb_rule_names const& names) = 0;
58 virtual void renamed(char const* name) = 0;57 virtual void renamed(char const* name) = 0;
58 virtual void streams_repositioned() = 0;
5959
60protected:60protected:
61 SurfaceObserver() = default;61 SurfaceObserver() = default;
6262
=== modified file 'include/server/mir/shell/surface_ready_observer.h'
--- include/server/mir/shell/surface_ready_observer.h 2015-05-18 19:58:07 +0000
+++ include/server/mir/shell/surface_ready_observer.h 2015-06-10 12:39:17 +0000
@@ -19,7 +19,7 @@
19#ifndef MIR_SHELL_SURFACE_READY_OBSERVER_H_19#ifndef MIR_SHELL_SURFACE_READY_OBSERVER_H_
20#define MIR_SHELL_SURFACE_READY_OBSERVER_H_20#define MIR_SHELL_SURFACE_READY_OBSERVER_H_
2121
22#include "mir/scene/null_surface_observer.h"22#include "mir/scene/null_stream_observer.h"
2323
24#include <functional>24#include <functional>
25#include <memory>25#include <memory>
@@ -30,7 +30,7 @@
3030
31namespace shell31namespace shell
32{32{
33class SurfaceReadyObserver : public scene::NullSurfaceObserver,33class SurfaceReadyObserver : public scene::NullStreamObserver,
34 public std::enable_shared_from_this<SurfaceReadyObserver>34 public std::enable_shared_from_this<SurfaceReadyObserver>
35{35{
36public:36public:
@@ -47,6 +47,7 @@
4747
48private:48private:
49 void frame_posted(int) override;49 void frame_posted(int) override;
50 void resized_to(geometry::Size const&) override;
5051
51 ActivateFunction const activate;52 ActivateFunction const activate;
52 std::weak_ptr<scene::Session> const session;53 std::weak_ptr<scene::Session> const session;
5354
=== added file 'src/include/server/mir/scene/stream_observers.h'
--- src/include/server/mir/scene/stream_observers.h 1970-01-01 00:00:00 +0000
+++ src/include/server/mir/scene/stream_observers.h 2015-06-10 12:39:17 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_SCENE_STREAM_OBSERVERS_H_
20#define MIR_SCENE_STREAM_OBSERVERS_H_
21
22#include "mir/basic_observers.h"
23#include "mir/scene/stream_observer.h"
24
25namespace mir
26{
27namespace scene
28{
29
30class StreamObservers : public StreamObserver, BasicObservers<StreamObserver>
31{
32public:
33 using BasicObservers<StreamObserver>::add;
34 using BasicObservers<StreamObserver>::remove;
35 using BasicObservers<StreamObserver>::for_each;
36 void frame_posted(int frames_available) override;
37 void resized_to(geometry::Size const& size) override;
38};
39
40}
41}
42
43#endif /* MIR_SCENE_STREAM_OBSERVERS_H_ */
044
=== modified file 'src/include/server/mir/scene/surface_observers.h'
--- src/include/server/mir/scene/surface_observers.h 2015-05-19 21:34:34 +0000
+++ src/include/server/mir/scene/surface_observers.h 2015-06-10 12:39:17 +0000
@@ -37,7 +37,6 @@
37 void resized_to(geometry::Size const& size) override;37 void resized_to(geometry::Size const& size) override;
38 void moved_to(geometry::Point const& top_left) override;38 void moved_to(geometry::Point const& top_left) override;
39 void hidden_set_to(bool hide) override;39 void hidden_set_to(bool hide) override;
40 void frame_posted(int frames_available) override;
41 void alpha_set_to(float alpha) override;40 void alpha_set_to(float alpha) override;
42 void orientation_set_to(MirOrientation orientation) override;41 void orientation_set_to(MirOrientation orientation) override;
43 void transformation_set_to(glm::mat4 const& t) override;42 void transformation_set_to(glm::mat4 const& t) override;
@@ -46,6 +45,7 @@
46 void client_surface_close_requested() override;45 void client_surface_close_requested() override;
47 void keymap_changed(xkb_rule_names const& names) override;46 void keymap_changed(xkb_rule_names const& names) override;
48 void renamed(char const*) override;47 void renamed(char const*) override;
48 void streams_repositioned() override;
49};49};
5050
51}51}
5252
=== modified file 'src/server/compositor/buffer_stream_surfaces.cpp'
--- src/server/compositor/buffer_stream_surfaces.cpp 2015-05-19 21:34:34 +0000
+++ src/server/compositor/buffer_stream_surfaces.cpp 2015-06-10 12:39:17 +0000
@@ -125,12 +125,12 @@
125 return buffer_bundle->properties().format;125 return buffer_bundle->properties().format;
126}126}
127127
128void mc::BufferStreamSurfaces::add_observer(std::shared_ptr<scene::SurfaceObserver> const& observer)128void mc::BufferStreamSurfaces::add_observer(std::shared_ptr<scene::StreamObserver> const& observer)
129{129{
130 observers.add(observer);130 observers.add(observer);
131}131}
132132
133void mc::BufferStreamSurfaces::remove_observer(std::weak_ptr<scene::SurfaceObserver> const& observer)133void mc::BufferStreamSurfaces::remove_observer(std::weak_ptr<scene::StreamObserver> const& observer)
134{134{
135 if (auto o = observer.lock())135 if (auto o = observer.lock())
136 observers.remove(o);136 observers.remove(o);
137137
=== modified file 'src/server/compositor/buffer_stream_surfaces.h'
--- src/server/compositor/buffer_stream_surfaces.h 2015-05-19 21:34:34 +0000
+++ src/server/compositor/buffer_stream_surfaces.h 2015-06-10 12:39:17 +0000
@@ -21,7 +21,7 @@
21#define MIR_COMPOSITOR_BUFFER_STREAM_SCENE_H_21#define MIR_COMPOSITOR_BUFFER_STREAM_SCENE_H_
2222
23#include "mir/compositor/buffer_stream.h"23#include "mir/compositor/buffer_stream.h"
24#include "mir/scene/surface_observers.h"24#include "mir/scene/stream_observers.h"
2525
26#include <mutex>26#include <mutex>
2727
@@ -45,8 +45,8 @@
45 graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override;45 graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override;
46 void with_most_recent_buffer_do(std::function<void(graphics::Buffer&)> const& exec) override;46 void with_most_recent_buffer_do(std::function<void(graphics::Buffer&)> const& exec) override;
47 MirPixelFormat pixel_format() const override;47 MirPixelFormat pixel_format() const override;
48 void add_observer(std::shared_ptr<scene::SurfaceObserver> const& observer) override;48 void add_observer(std::shared_ptr<scene::StreamObserver> const& observer) override;
49 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const& observer) override;49 void remove_observer(std::weak_ptr<scene::StreamObserver> const& observer) override;
5050
51 //from mc::BufferStream51 //from mc::BufferStream
52 void acquire_client_buffer(std::function<void(graphics::Buffer* buffer)> complete);52 void acquire_client_buffer(std::function<void(graphics::Buffer* buffer)> complete);
@@ -70,7 +70,7 @@
70private:70private:
71 std::mutex mutable mutex;71 std::mutex mutable mutex;
72 std::shared_ptr<BufferBundle> const buffer_bundle;72 std::shared_ptr<BufferBundle> const buffer_bundle;
73 scene::SurfaceObservers observers;73 scene::StreamObservers observers;
74 bool first_frame_posted;74 bool first_frame_posted;
75};75};
7676
7777
=== modified file 'src/server/input/cursor_controller.cpp'
--- src/server/input/cursor_controller.cpp 2015-05-12 06:58:52 +0000
+++ src/server/input/cursor_controller.cpp 2015-06-10 12:39:17 +0000
@@ -62,10 +62,6 @@
62 {62 {
63 cursor_controller->update_cursor_image();63 cursor_controller->update_cursor_image();
64 }64 }
65 void frame_posted(int) override
66 {
67 // Frame posting wont trigger a cursor update
68 }
69 void alpha_set_to(float) override65 void alpha_set_to(float) override
70 {66 {
71 cursor_controller->update_cursor_image();67 cursor_controller->update_cursor_image();
7268
=== modified file 'src/server/scene/CMakeLists.txt'
--- src/server/scene/CMakeLists.txt 2015-05-19 17:17:57 +0000
+++ src/server/scene/CMakeLists.txt 2015-06-10 12:39:17 +0000
@@ -20,6 +20,7 @@
20 threaded_snapshot_strategy.cpp20 threaded_snapshot_strategy.cpp
21 legacy_scene_change_notification.cpp21 legacy_scene_change_notification.cpp
22 legacy_surface_change_notification.cpp22 legacy_surface_change_notification.cpp
23 legacy_stream_change_notification.cpp
23 prompt_session_container.cpp24 prompt_session_container.cpp
24 prompt_session_impl.cpp25 prompt_session_impl.cpp
25 prompt_session_manager_impl.cpp26 prompt_session_manager_impl.cpp
2627
=== modified file 'src/server/scene/basic_surface.cpp'
--- src/server/scene/basic_surface.cpp 2015-06-04 11:32:52 +0000
+++ src/server/scene/basic_surface.cpp 2015-06-10 12:39:17 +0000
@@ -29,7 +29,7 @@
29#include "mir/geometry/displacement.h"29#include "mir/geometry/displacement.h"
3030
31#include "mir/scene/scene_report.h"31#include "mir/scene/scene_report.h"
32#include "mir/scene/null_surface_observer.h"32#include "mir/scene/null_stream_observer.h"
3333
34#include <boost/throw_exception.hpp>34#include <boost/throw_exception.hpp>
3535
@@ -70,12 +70,23 @@
70 { observer->hidden_set_to(hide); });70 { observer->hidden_set_to(hide); });
71}71}
7272
73void ms::SurfaceObservers::frame_posted(int frames_available)73void ms::StreamObservers::frame_posted(int frames_available)
74{74{
75 for_each([&](std::shared_ptr<SurfaceObserver> const& observer)75 for_each([&](std::shared_ptr<StreamObserver> const& observer)
76 { observer->frame_posted(frames_available); });76 { observer->frame_posted(frames_available); });
77}77}
7878
79void ms::StreamObservers::resized_to(geom::Size const& size)
80{
81 for_each([&](std::shared_ptr<StreamObserver> const& observer)
82 { observer->resized_to(size); });
83}
84
85void ms::SurfaceObservers::streams_repositioned()
86{
87 for_each([&](std::shared_ptr<SurfaceObserver> const& observer)
88 { observer->streams_repositioned(); });
89}
79void ms::SurfaceObservers::alpha_set_to(float alpha)90void ms::SurfaceObservers::alpha_set_to(float alpha)
80{91{
81 for_each([&](std::shared_ptr<SurfaceObserver> const& observer)92 for_each([&](std::shared_ptr<SurfaceObserver> const& observer)
@@ -557,7 +568,7 @@
557568
558namespace569namespace
559{570{
560struct FramePostObserver : public ms::NullSurfaceObserver571struct FramePostObserver : public ms::NullStreamObserver
561{572{
562 FramePostObserver(std::function<void()> const& exec)573 FramePostObserver(std::function<void()> const& exec)
563 : exec(exec)574 : exec(exec)
@@ -729,11 +740,28 @@
729 return new_visibility;740 return new_visibility;
730}741}
731742
743void ms::BasicSurface::add_observer(std::shared_ptr<StreamObserver> const& observer)
744{
745 stream_observers.add(observer);
746 std::lock_guard<std::mutex> lg(guard);
747 for (auto& info : layers)
748 info.stream->add_observer(observer);
749}
750
751void ms::BasicSurface::remove_observer(std::weak_ptr<StreamObserver> const& observer)
752{
753 auto o = observer.lock();
754 if (!o)
755 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid observer (previously destroyed)"));
756 std::lock_guard<std::mutex> lg(guard);
757 for (auto& info : layers)
758 info.stream->remove_observer(observer);
759 stream_observers.remove(o);
760}
761
732void ms::BasicSurface::add_observer(std::shared_ptr<SurfaceObserver> const& observer)762void ms::BasicSurface::add_observer(std::shared_ptr<SurfaceObserver> const& observer)
733{763{
734 observers.add(observer);764 observers.add(observer);
735 for (auto& info : layers)
736 info.stream->add_observer(observer);
737}765}
738766
739void ms::BasicSurface::remove_observer(std::weak_ptr<SurfaceObserver> const& observer)767void ms::BasicSurface::remove_observer(std::weak_ptr<SurfaceObserver> const& observer)
@@ -742,8 +770,6 @@
742 if (!o)770 if (!o)
743 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid observer (previously destroyed)"));771 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid observer (previously destroyed)"));
744 observers.remove(o);772 observers.remove(o);
745 for (auto& info : layers)
746 info.stream->remove_observer(observer);
747}773}
748774
749std::shared_ptr<ms::Surface> ms::BasicSurface::parent() const775std::shared_ptr<ms::Surface> ms::BasicSurface::parent() const
@@ -844,15 +870,28 @@
844870
845void ms::BasicSurface::set_streams(std::list<scene::StreamInfo> const& s)871void ms::BasicSurface::set_streams(std::list<scene::StreamInfo> const& s)
846{872{
847 std::unique_lock<std::mutex> lk(guard);
848
849 if (s.end() == std::find_if(s.begin(), s.end(),
850 [this] (ms::StreamInfo const& info) { return info.stream == surface_buffer_stream; }))
851 {873 {
852 BOOST_THROW_EXCEPTION(std::logic_error("cannot remove the created-with buffer stream yet"));874 std::unique_lock<std::mutex> lk(guard);
875
876 if (s.end() == std::find_if(s.begin(), s.end(),
877 [this] (ms::StreamInfo const& info) { return info.stream == surface_buffer_stream; }))
878 {
879 BOOST_THROW_EXCEPTION(std::logic_error("cannot remove the created-with buffer stream yet"));
880 }
881
882 stream_observers.for_each([this](std::shared_ptr<StreamObserver> const& observer) {
883 for(auto& layer : layers)
884 layer.stream->remove_observer(observer);
885 });
886
887 layers = s;
888
889 stream_observers.for_each([this](std::shared_ptr<StreamObserver> const& observer) {
890 for(auto& layer : layers)
891 layer.stream->add_observer(observer);
892 });
853 }893 }
854894 observers.streams_repositioned();
855 layers = s;
856}895}
857896
858mg::RenderableList ms::BasicSurface::generate_renderables(mc::CompositorID id) const897mg::RenderableList ms::BasicSurface::generate_renderables(mc::CompositorID id) const
859898
=== modified file 'src/server/scene/basic_surface.h'
--- src/server/scene/basic_surface.h 2015-06-04 11:32:52 +0000
+++ src/server/scene/basic_surface.h 2015-06-10 12:39:17 +0000
@@ -22,6 +22,7 @@
22#include "mir/scene/surface.h"22#include "mir/scene/surface.h"
23#include "mir/basic_observers.h"23#include "mir/basic_observers.h"
24#include "mir/scene/surface_observers.h"24#include "mir/scene/surface_observers.h"
25#include "mir/scene/stream_observers.h"
2526
26#include "mir/geometry/rectangle.h"27#include "mir/geometry/rectangle.h"
2728
@@ -139,6 +140,8 @@
139140
140 void add_observer(std::shared_ptr<SurfaceObserver> const& observer) override;141 void add_observer(std::shared_ptr<SurfaceObserver> const& observer) override;
141 void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) override;142 void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) override;
143 void add_observer(std::shared_ptr<StreamObserver> const& observer) override;
144 void remove_observer(std::weak_ptr<StreamObserver> const& observer) override;
142145
143 int dpi() const;146 int dpi() const;
144147
@@ -157,6 +160,8 @@
157 MirOrientationMode set_preferred_orientation(MirOrientationMode mode);160 MirOrientationMode set_preferred_orientation(MirOrientationMode mode);
158161
159 SurfaceObservers observers;162 SurfaceObservers observers;
163 StreamObservers stream_observers;
164
160 std::mutex mutable guard;165 std::mutex mutable guard;
161 std::string surface_name;166 std::string surface_name;
162 geometry::Rectangle surface_rect;167 geometry::Rectangle surface_rect;
163168
=== modified file 'src/server/scene/legacy_scene_change_notification.cpp'
--- src/server/scene/legacy_scene_change_notification.cpp 2015-06-01 16:19:11 +0000
+++ src/server/scene/legacy_scene_change_notification.cpp 2015-06-10 12:39:17 +0000
@@ -19,6 +19,7 @@
19#include "legacy_surface_change_notification.h"19#include "legacy_surface_change_notification.h"
2020
21#include "mir/scene/legacy_scene_change_notification.h"21#include "mir/scene/legacy_scene_change_notification.h"
22#include "legacy_stream_change_notification.h"
22#include "mir/scene/surface.h"23#include "mir/scene/surface.h"
2324
24#include <boost/throw_exception.hpp>25#include <boost/throw_exception.hpp>
@@ -48,9 +49,9 @@
48 was_visible = surface->visible();49 was_visible = surface->visible();
49 };50 };
5051
51 auto observer = std::make_shared<ms::LegacySurfaceChangeNotification>(52 auto observer = std::make_shared<ms::LegacySurfaceChangeNotification>(notifier);
52 notifier, buffer_notify_change);
53 surface->add_observer(observer);53 surface->add_observer(observer);
54 surface->add_observer(std::make_shared<ms::LegacyStreamChangeNotification>(buffer_notify_change));
54 55
55 {56 {
56 std::unique_lock<decltype(surface_observers_guard)> lg(surface_observers_guard);57 std::unique_lock<decltype(surface_observers_guard)> lg(surface_observers_guard);
5758
=== added file 'src/server/scene/legacy_stream_change_notification.cpp'
--- src/server/scene/legacy_stream_change_notification.cpp 1970-01-01 00:00:00 +0000
+++ src/server/scene/legacy_stream_change_notification.cpp 2015-06-10 12:39:17 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "legacy_stream_change_notification.h"
20
21namespace ms = mir::scene;
22namespace geom = mir::geometry;
23
24ms::LegacyStreamChangeNotification::LegacyStreamChangeNotification(
25 std::function<void(int)> const& notify_buffer_change) :
26 notify_buffer_change(notify_buffer_change)
27{
28}
29
30void ms::LegacyStreamChangeNotification::frame_posted(int frames_available)
31{
32 notify_buffer_change(frames_available);
33}
34
35void ms::LegacyStreamChangeNotification::resized_to(geom::Size const&)
36{
37}
038
=== added file 'src/server/scene/legacy_stream_change_notification.h'
--- src/server/scene/legacy_stream_change_notification.h 1970-01-01 00:00:00 +0000
+++ src/server/scene/legacy_stream_change_notification.h 2015-06-10 12:39:17 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_SCENE_LEGACY_STREAM_CHANGE_NOTIFICATION_H_
20#define MIR_SCENE_LEGACY_STREAM_CHANGE_NOTIFICATION_H_
21
22#include "mir/scene/stream_observer.h"
23
24#include <functional>
25
26namespace ms = mir::scene;
27namespace geom = mir::geometry;
28
29namespace mir
30{
31namespace scene
32{
33class LegacyStreamChangeNotification : public ms::StreamObserver
34{
35public:
36 LegacyStreamChangeNotification(std::function<void(int)> const& stream_change);
37 void frame_posted(int frames_available) override;
38 void resized_to(geometry::Size const& size) override;
39private:
40 std::function<void(int)> const notify_buffer_change;
41};
42}
43}
44
45#endif // MIR_SCENE_LEGACY_STREAM_CHANGE_NOTIFICATION_H_
046
=== modified file 'src/server/scene/legacy_surface_change_notification.cpp'
--- src/server/scene/legacy_surface_change_notification.cpp 2015-04-09 08:57:24 +0000
+++ src/server/scene/legacy_surface_change_notification.cpp 2015-06-10 12:39:17 +0000
@@ -24,10 +24,8 @@
24namespace geom = mir::geometry;24namespace geom = mir::geometry;
2525
26ms::LegacySurfaceChangeNotification::LegacySurfaceChangeNotification(26ms::LegacySurfaceChangeNotification::LegacySurfaceChangeNotification(
27 std::function<void()> const& notify_scene_change,27 std::function<void()> const& notify_scene_change) :
28 std::function<void(int)> const& notify_buffer_change) :28 notify_scene_change(notify_scene_change)
29 notify_scene_change(notify_scene_change),
30 notify_buffer_change(notify_buffer_change)
31{29{
32}30}
3331
@@ -46,9 +44,9 @@
46 notify_scene_change();44 notify_scene_change();
47}45}
4846
49void ms::LegacySurfaceChangeNotification::frame_posted(int frames_available)47void ms::LegacySurfaceChangeNotification::streams_repositioned()
50{48{
51 notify_buffer_change(frames_available);49 notify_scene_change();
52}50}
5351
54void ms::LegacySurfaceChangeNotification::alpha_set_to(float /*alpha*/)52void ms::LegacySurfaceChangeNotification::alpha_set_to(float /*alpha*/)
5553
=== modified file 'src/server/scene/legacy_surface_change_notification.h'
--- src/server/scene/legacy_surface_change_notification.h 2015-04-09 08:57:24 +0000
+++ src/server/scene/legacy_surface_change_notification.h 2015-06-10 12:39:17 +0000
@@ -33,14 +33,11 @@
33class LegacySurfaceChangeNotification : public ms::SurfaceObserver33class LegacySurfaceChangeNotification : public ms::SurfaceObserver
34{34{
35public:35public:
36 LegacySurfaceChangeNotification(36 LegacySurfaceChangeNotification(std::function<void()> const& notify_scene_change);
37 std::function<void()> const& notify_scene_change,
38 std::function<void(int)> const& notify_buffer_change);
3937
40 void resized_to(geometry::Size const& /*size*/) override;38 void resized_to(geometry::Size const& /*size*/) override;
41 void moved_to(geometry::Point const& /*top_left*/) override;39 void moved_to(geometry::Point const& /*top_left*/) override;
42 void hidden_set_to(bool /*hide*/) override;40 void hidden_set_to(bool /*hide*/) override;
43 void frame_posted(int frames_available) override;
44 void alpha_set_to(float /*alpha*/) override;41 void alpha_set_to(float /*alpha*/) override;
45 void orientation_set_to(MirOrientation orientation) override;42 void orientation_set_to(MirOrientation orientation) override;
46 void transformation_set_to(glm::mat4 const& /*t*/) override;43 void transformation_set_to(glm::mat4 const& /*t*/) override;
@@ -50,10 +47,10 @@
50 void client_surface_close_requested() override;47 void client_surface_close_requested() override;
51 void keymap_changed(xkb_rule_names const& names) override;48 void keymap_changed(xkb_rule_names const& names) override;
52 void renamed(char const*) override;49 void renamed(char const*) override;
50 void streams_repositioned() override;
5351
54private:52private:
55 std::function<void()> const notify_scene_change;53 std::function<void()> const notify_scene_change;
56 std::function<void(int)> const notify_buffer_change;
57};54};
58}55}
59}56}
6057
=== modified file 'src/server/scene/null_surface_observer.cpp'
--- src/server/scene/null_surface_observer.cpp 2015-04-09 08:57:24 +0000
+++ src/server/scene/null_surface_observer.cpp 2015-06-10 12:39:17 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "mir/scene/null_surface_observer.h"19#include "mir/scene/null_surface_observer.h"
20#include "mir/scene/null_stream_observer.h"
2021
21namespace ms = mir::scene;22namespace ms = mir::scene;
22namespace mg = mir::graphics;23namespace mg = mir::graphics;
@@ -25,7 +26,6 @@
25void ms::NullSurfaceObserver::resized_to(geometry::Size const& /*size*/) {}26void ms::NullSurfaceObserver::resized_to(geometry::Size const& /*size*/) {}
26void ms::NullSurfaceObserver::moved_to(geometry::Point const& /*top_left*/) {}27void ms::NullSurfaceObserver::moved_to(geometry::Point const& /*top_left*/) {}
27void ms::NullSurfaceObserver::hidden_set_to(bool /*hide*/) {}28void ms::NullSurfaceObserver::hidden_set_to(bool /*hide*/) {}
28void ms::NullSurfaceObserver::frame_posted(int /*frames_available*/) {}
29void ms::NullSurfaceObserver::alpha_set_to(float /*alpha*/) {}29void ms::NullSurfaceObserver::alpha_set_to(float /*alpha*/) {}
30void ms::NullSurfaceObserver::orientation_set_to(MirOrientation /*orientation*/) {}30void ms::NullSurfaceObserver::orientation_set_to(MirOrientation /*orientation*/) {}
31void ms::NullSurfaceObserver::transformation_set_to(glm::mat4 const& /*t*/) {}31void ms::NullSurfaceObserver::transformation_set_to(glm::mat4 const& /*t*/) {}
@@ -34,3 +34,7 @@
34void ms::NullSurfaceObserver::client_surface_close_requested() {}34void ms::NullSurfaceObserver::client_surface_close_requested() {}
35void ms::NullSurfaceObserver::keymap_changed(xkb_rule_names const& /* names */) {}35void ms::NullSurfaceObserver::keymap_changed(xkb_rule_names const& /* names */) {}
36void ms::NullSurfaceObserver::renamed(char const*) {}36void ms::NullSurfaceObserver::renamed(char const*) {}
37void ms::NullSurfaceObserver::streams_repositioned() {}
38
39void ms::NullStreamObserver::frame_posted(int /*frames_available*/) {}
40void ms::NullStreamObserver::resized_to(geometry::Size const& /*size*/) {}
3741
=== added file 'src/server/scene/stream_change_notification.h'
--- src/server/scene/stream_change_notification.h 1970-01-01 00:00:00 +0000
+++ src/server/scene/stream_change_notification.h 2015-06-10 12:39:17 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_SCENE_STREAM_CHANGE_NOTIFICATION_H_
20#define MIR_SCENE_STREAM_CHANGE_NOTIFICATION_H_
21
22#include "mir/scene/surface_observer.h"
23
24#include <functional>
25
26namespace ms = mir::scene;
27namespace geom = mir::geometry;
28
29namespace mir
30{
31namespace scene
32{
33class LegacySurfaceChangeNotification : public ms::SurfaceObserver
34{
35public:
36 LegacySurfaceChangeNotification(std::function<void(int)> const& notify_buffer_change);
37 void resized_to(geometry::Size const& /*size*/) override;
38 void frame_posted(int frames_available) override;
39private:
40 std::function<void()> const notify_scene_change;
41};
42}
43}
44
45#endif // MIR_SCENE_STREAM_CHANGE_NOTIFICATION_H_
046
=== modified file 'src/server/shell/surface_ready_observer.cpp'
--- src/server/shell/surface_ready_observer.cpp 2015-05-18 19:58:07 +0000
+++ src/server/shell/surface_ready_observer.cpp 2015-06-10 12:39:17 +0000
@@ -43,3 +43,7 @@
43 s->remove_observer(shared_from_this());43 s->remove_observer(shared_from_this());
44 }44 }
45}45}
46
47void msh::SurfaceReadyObserver::resized_to(mir::geometry::Size const&)
48{
49}
4650
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2015-06-09 07:20:56 +0000
+++ src/server/symbols.map 2015-06-10 12:39:17 +0000
@@ -71,11 +71,12 @@
71 mir::scene::NullSessionListener::?NullSessionListener*;71 mir::scene::NullSessionListener::?NullSessionListener*;
72 mir::scene::NullSessionListener::NullSessionListener*;72 mir::scene::NullSessionListener::NullSessionListener*;
73 mir::scene::NullSessionListener::operator*;73 mir::scene::NullSessionListener::operator*;
74 mir::scene::NullStreamObserver::frame_posted*;
75 mir::scene::NullStreamObserver::resized_to*;
74 mir::scene::NullSurfaceObserver::alpha_set_to*;76 mir::scene::NullSurfaceObserver::alpha_set_to*;
75 mir::scene::NullSurfaceObserver::attrib_changed*;77 mir::scene::NullSurfaceObserver::attrib_changed*;
76 mir::scene::NullSurfaceObserver::client_surface_close_requested*;78 mir::scene::NullSurfaceObserver::client_surface_close_requested*;
77 mir::scene::NullSurfaceObserver::cursor_image_set_to*;79 mir::scene::NullSurfaceObserver::cursor_image_set_to*;
78 mir::scene::NullSurfaceObserver::frame_posted*;
79 mir::scene::NullSurfaceObserver::hidden_set_to*;80 mir::scene::NullSurfaceObserver::hidden_set_to*;
80 mir::scene::NullSurfaceObserver::keymap_changed*;81 mir::scene::NullSurfaceObserver::keymap_changed*;
81 mir::scene::NullSurfaceObserver::moved_to*;82 mir::scene::NullSurfaceObserver::moved_to*;
@@ -87,6 +88,7 @@
87 mir::scene::NullSurfaceObserver::resized_to*;88 mir::scene::NullSurfaceObserver::resized_to*;
88 mir::scene::NullSurfaceObserver::transformation_set_to*;89 mir::scene::NullSurfaceObserver::transformation_set_to*;
89 mir::scene::NullSurfaceObserver::renamed*;90 mir::scene::NullSurfaceObserver::renamed*;
91 mir::scene::NullSurfaceObserver::streams_repositioned*;
90 mir::scene::Observer::?Observer*;92 mir::scene::Observer::?Observer*;
91 mir::scene::Observer::Observer*;93 mir::scene::Observer::Observer*;
92 mir::scene::Observer::operator*;94 mir::scene::Observer::operator*;
@@ -280,11 +282,12 @@
280 non-virtual?thunk?to?mir::LockableCallback::?LockableCallback*;282 non-virtual?thunk?to?mir::LockableCallback::?LockableCallback*;
281 non-virtual?thunk?to?mir::scene::CoordinateTranslator::?CoordinateTranslator*;283 non-virtual?thunk?to?mir::scene::CoordinateTranslator::?CoordinateTranslator*;
282 non-virtual?thunk?to?mir::scene::NullSessionListener::?NullSessionListener*;284 non-virtual?thunk?to?mir::scene::NullSessionListener::?NullSessionListener*;
285 non-virtual?thunk?to?mir::scene::NullStreamObserver::frame_posted*;
286 non-virtual?thunk?to?mir::scene::NullStreamObserver::resized_to*;
283 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::alpha_set_to*;287 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::alpha_set_to*;
284 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::attrib_changed*;288 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::attrib_changed*;
285 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::client_surface_close_requested*;289 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::client_surface_close_requested*;
286 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::cursor_image_set_to*;290 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::cursor_image_set_to*;
287 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::frame_posted*;
288 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::hidden_set_to*;291 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::hidden_set_to*;
289 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::keymap_changed*;292 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::keymap_changed*;
290 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::moved_to*;293 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::moved_to*;
@@ -292,6 +295,7 @@
292 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::orientation_set_to*;295 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::orientation_set_to*;
293 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::reception_mode_set_to*;296 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::reception_mode_set_to*;
294 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::resized_to*;297 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::resized_to*;
298 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::streams_repositioned*;
295 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::transformation_set_to*;299 non-virtual?thunk?to?mir::scene::NullSurfaceObserver::transformation_set_to*;
296 non-virtual?thunk?to?mir::scene::Observer::?Observer*;300 non-virtual?thunk?to?mir::scene::Observer::?Observer*;
297 non-virtual?thunk?to?mir::scene::PlacementStrategy::?PlacementStrategy*;301 non-virtual?thunk?to?mir::scene::PlacementStrategy::?PlacementStrategy*;
@@ -375,6 +379,7 @@
375 typeinfo?for?mir::MainLoop;379 typeinfo?for?mir::MainLoop;
376 typeinfo?for?mir::scene::CoordinateTranslator;380 typeinfo?for?mir::scene::CoordinateTranslator;
377 typeinfo?for?mir::scene::NullSessionListener;381 typeinfo?for?mir::scene::NullSessionListener;
382 typeinfo?for?mir::scene::NullStreamObserver;
378 typeinfo?for?mir::scene::NullSurfaceObserver;383 typeinfo?for?mir::scene::NullSurfaceObserver;
379 typeinfo?for?mir::scene::Observer;384 typeinfo?for?mir::scene::Observer;
380 typeinfo?for?mir::scene::PlacementStrategy;385 typeinfo?for?mir::scene::PlacementStrategy;
@@ -432,6 +437,7 @@
432 vtable?for?mir::MainLoop;437 vtable?for?mir::MainLoop;
433 vtable?for?mir::scene::CoordinateTranslator;438 vtable?for?mir::scene::CoordinateTranslator;
434 vtable?for?mir::scene::NullSessionListener;439 vtable?for?mir::scene::NullSessionListener;
440 vtable?for?mir::scene::NullStreamObserver;
435 vtable?for?mir::scene::NullSurfaceObserver;441 vtable?for?mir::scene::NullSurfaceObserver;
436 vtable?for?mir::scene::Observer;442 vtable?for?mir::scene::Observer;
437 vtable?for?mir::scene::PlacementStrategy;443 vtable?for?mir::scene::PlacementStrategy;
438444
=== modified file 'tests/include/mir_test_doubles/mock_buffer_stream.h'
--- tests/include/mir_test_doubles/mock_buffer_stream.h 2015-05-29 13:48:13 +0000
+++ tests/include/mir_test_doubles/mock_buffer_stream.h 2015-06-10 12:39:17 +0000
@@ -58,8 +58,8 @@
58 MOCK_METHOD1(release_client_buffer, void(graphics::Buffer*));58 MOCK_METHOD1(release_client_buffer, void(graphics::Buffer*));
59 MOCK_METHOD1(lock_compositor_buffer,59 MOCK_METHOD1(lock_compositor_buffer,
60 std::shared_ptr<graphics::Buffer>(void const*));60 std::shared_ptr<graphics::Buffer>(void const*));
61 MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::SurfaceObserver> const&));61 MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::StreamObserver> const&));
62 MOCK_METHOD1(remove_observer, void(std::weak_ptr<scene::SurfaceObserver> const&));62 MOCK_METHOD1(remove_observer, void(std::weak_ptr<scene::StreamObserver> const&));
6363
64 MOCK_METHOD0(get_stream_pixel_format, MirPixelFormat());64 MOCK_METHOD0(get_stream_pixel_format, MirPixelFormat());
65 MOCK_METHOD0(stream_size, geometry::Size());65 MOCK_METHOD0(stream_size, geometry::Size());
6666
=== modified file 'tests/include/mir_test_doubles/mock_surface.h'
--- tests/include/mir_test_doubles/mock_surface.h 2015-05-19 21:34:34 +0000
+++ tests/include/mir_test_doubles/mock_surface.h 2015-06-10 12:39:17 +0000
@@ -68,6 +68,8 @@
68 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));68 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
69 MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::SurfaceObserver> const&));69 MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::SurfaceObserver> const&));
70 MOCK_METHOD1(remove_observer, void(std::weak_ptr<scene::SurfaceObserver> const&));70 MOCK_METHOD1(remove_observer, void(std::weak_ptr<scene::SurfaceObserver> const&));
71 MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::StreamObserver> const&));
72 MOCK_METHOD1(remove_observer, void(std::weak_ptr<scene::StreamObserver> const&));
71 MOCK_CONST_METHOD0(primary_buffer_stream, std::shared_ptr<frontend::BufferStream>());73 MOCK_CONST_METHOD0(primary_buffer_stream, std::shared_ptr<frontend::BufferStream>());
72};74};
7375
7476
=== modified file 'tests/include/mir_test_doubles/stub_buffer_stream.h'
--- tests/include/mir_test_doubles/stub_buffer_stream.h 2015-05-19 21:34:34 +0000
+++ tests/include/mir_test_doubles/stub_buffer_stream.h 2015-06-10 12:39:17 +0000
@@ -76,8 +76,8 @@
76 fn(*stub_compositor_buffer);76 fn(*stub_compositor_buffer);
77 }77 }
78 MirPixelFormat pixel_format() const { return mir_pixel_format_abgr_8888; }78 MirPixelFormat pixel_format() const { return mir_pixel_format_abgr_8888; }
79 void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) {}79 void add_observer(std::shared_ptr<scene::StreamObserver> const&) {}
80 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) {}80 void remove_observer(std::weak_ptr<scene::StreamObserver> const&) {}
81 bool has_submitted_buffer() const { return true; }81 bool has_submitted_buffer() const { return true; }
8282
83 StubBuffer stub_client_buffer;83 StubBuffer stub_client_buffer;
8484
=== modified file 'tests/include/mir_test_doubles/stub_scene_surface.h'
--- tests/include/mir_test_doubles/stub_scene_surface.h 2015-05-29 13:48:13 +0000
+++ tests/include/mir_test_doubles/stub_scene_surface.h 2015-06-10 12:39:17 +0000
@@ -80,6 +80,8 @@
80 void set_alpha(float) override {}80 void set_alpha(float) override {}
81 void set_orientation(MirOrientation) {}81 void set_orientation(MirOrientation) {}
8282
83 void add_observer(std::shared_ptr<scene::StreamObserver> const&) override {}
84 void remove_observer(std::weak_ptr<scene::StreamObserver> const&) override {}
83 void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override {}85 void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override {}
84 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}86 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}
8587
8688
=== modified file 'tests/unit-tests/compositor/test_buffer_stream.cpp'
--- tests/unit-tests/compositor/test_buffer_stream.cpp 2015-05-19 21:34:34 +0000
+++ tests/unit-tests/compositor/test_buffer_stream.cpp 2015-06-10 12:39:17 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "src/server/compositor/buffer_stream_surfaces.h"19#include "src/server/compositor/buffer_stream_surfaces.h"
20#include "src/server/scene/legacy_surface_change_notification.h"20#include "src/server/scene/legacy_stream_change_notification.h"
2121
22#include "mir_test_doubles/stub_buffer.h"22#include "mir_test_doubles/stub_buffer.h"
23#include "mir_test_doubles/mock_buffer_bundle.h"23#include "mir_test_doubles/mock_buffer_bundle.h"
@@ -222,8 +222,7 @@
222 };222 };
223 NiceMock<MockCallback> mock_cb;223 NiceMock<MockCallback> mock_cb;
224 EXPECT_CALL(mock_cb, call()).Times(3);224 EXPECT_CALL(mock_cb, call()).Times(3);
225 auto observer = std::make_shared<mir::scene::LegacySurfaceChangeNotification>(225 auto observer = std::make_shared<mir::scene::LegacyStreamChangeNotification>(
226 []{ FAIL() << "buffer stream shouldnt notify of scene changes.";},
227 std::bind(&MockCallback::call, &mock_cb));226 std::bind(&MockCallback::call, &mock_cb));
228227
229 mc::BufferStreamSurfaces buffer_stream(mock_bundle);228 mc::BufferStreamSurfaces buffer_stream(mock_bundle);
230229
=== modified file 'tests/unit-tests/scene/test_basic_surface.cpp'
--- tests/unit-tests/scene/test_basic_surface.cpp 2015-06-04 11:24:07 +0000
+++ tests/unit-tests/scene/test_basic_surface.cpp 2015-06-10 12:39:17 +0000
@@ -93,7 +93,7 @@
93 std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report();93 std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report();
94 void const* compositor_id{nullptr};94 void const* compositor_id{nullptr};
95 std::shared_ptr<ms::LegacySurfaceChangeNotification> observer =95 std::shared_ptr<ms::LegacySurfaceChangeNotification> observer =
96 std::make_shared<ms::LegacySurfaceChangeNotification>(mock_change_cb, [this](int){mock_change_cb();});96 std::make_shared<ms::LegacySurfaceChangeNotification>(mock_change_cb);
97 std::shared_ptr<mi::InputSender> const stub_input_sender = std::make_shared<mtd::StubInputSender>();97 std::shared_ptr<mi::InputSender> const stub_input_sender = std::make_shared<mtd::StubInputSender>();
98 testing::NiceMock<mtd::MockInputSender> mock_sender;98 testing::NiceMock<mtd::MockInputSender> mock_sender;
9999
100100
=== modified file 'tests/unit-tests/scene/test_legacy_scene_change_notification.cpp'
--- tests/unit-tests/scene/test_legacy_scene_change_notification.cpp 2015-06-01 16:19:11 +0000
+++ tests/unit-tests/scene/test_legacy_scene_change_notification.cpp 2015-06-10 12:39:17 +0000
@@ -66,7 +66,8 @@
6666
67TEST_F(LegacySceneChangeNotificationTest, registers_observer_with_surfaces)67TEST_F(LegacySceneChangeNotificationTest, registers_observer_with_surfaces)
68{68{
69 EXPECT_CALL(surface, add_observer(testing::_))69 using namespace testing;
70 EXPECT_CALL(surface, add_observer(Matcher<std::shared_ptr<ms::SurfaceObserver> const&>(_)))
70 .Times(1);71 .Times(1);
7172
72 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);73 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);
@@ -75,7 +76,8 @@
7576
76TEST_F(LegacySceneChangeNotificationTest, registers_observer_with_existing_surfaces)77TEST_F(LegacySceneChangeNotificationTest, registers_observer_with_existing_surfaces)
77{78{
78 EXPECT_CALL(surface, add_observer(testing::_))79 using namespace testing;
80 EXPECT_CALL(surface, add_observer(Matcher<std::shared_ptr<ms::SurfaceObserver> const&>(_)))
79 .Times(1);81 .Times(1);
8082
81 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);83 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);
@@ -85,8 +87,8 @@
85TEST_F(LegacySceneChangeNotificationTest, observes_surface_changes)87TEST_F(LegacySceneChangeNotificationTest, observes_surface_changes)
86{88{
87 using namespace ::testing;89 using namespace ::testing;
88 std::shared_ptr<ms::SurfaceObserver> surface_observer;90 std::shared_ptr<ms::StreamObserver> surface_observer;
89 EXPECT_CALL(surface, add_observer(_)).Times(1)91 EXPECT_CALL(surface, add_observer(Matcher<std::shared_ptr<ms::StreamObserver> const&>(_)))
90 .WillOnce(SaveArg<0>(&surface_observer));92 .WillOnce(SaveArg<0>(&surface_observer));
91 93
92 int buffer_num{3}; 94 int buffer_num{3};
@@ -104,7 +106,7 @@
104106
105 std::shared_ptr<ms::SurfaceObserver> surface_observer;107 std::shared_ptr<ms::SurfaceObserver> surface_observer;
106108
107 EXPECT_CALL(surface, add_observer(_)).Times(1)109 EXPECT_CALL(surface, add_observer(Matcher<std::shared_ptr<ms::SurfaceObserver> const&>(_)))
108 .WillOnce(SaveArg<0>(&surface_observer));110 .WillOnce(SaveArg<0>(&surface_observer));
109 EXPECT_CALL(scene_callback, invoke()).Times(1);111 EXPECT_CALL(scene_callback, invoke()).Times(1);
110112
@@ -118,9 +120,9 @@
118{120{
119 using namespace ::testing;121 using namespace ::testing;
120 122
121 EXPECT_CALL(surface, add_observer(_))123 EXPECT_CALL(surface, add_observer(Matcher<std::shared_ptr<ms::SurfaceObserver> const&>(_)))
122 .Times(1);124 .Times(1);
123 EXPECT_CALL(surface, remove_observer(_))125 EXPECT_CALL(surface, remove_observer(Matcher<std::weak_ptr<ms::SurfaceObserver> const&>(_)))
124 .Times(1);126 .Times(1);
125 {127 {
126 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);128 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);
@@ -131,9 +133,9 @@
131TEST_F(LegacySceneChangeNotificationTest, ending_observation_unregisters_observers)133TEST_F(LegacySceneChangeNotificationTest, ending_observation_unregisters_observers)
132{134{
133 using namespace ::testing;135 using namespace ::testing;
134 EXPECT_CALL(surface, add_observer(_))136 EXPECT_CALL(surface, add_observer(Matcher<std::shared_ptr<ms::SurfaceObserver> const&>(_)))
135 .Times(1);137 .Times(1);
136 EXPECT_CALL(surface, remove_observer(_))138 EXPECT_CALL(surface, remove_observer(Matcher<std::weak_ptr<ms::SurfaceObserver> const&>(_)))
137 .Times(1);139 .Times(1);
138140
139 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);141 ms::LegacySceneChangeNotification observer(scene_change_callback, buffer_change_callback);

Subscribers

People subscribed via source and target branches