From 7789335ad48349ddaeaf721995b6c3e4a402b3c5 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Thu, 2 May 2024 18:25:15 +1000 Subject: [PATCH 1/4] Drop the unnecessary indirection of `mc::BufferStreamFactory` We only create a `mc::Stream` in like 1 place, the implementation of `BufferStreamFactory` is trivial, and I'm about to remove *all* the parameters from the `mc::Stream` constructor anyway. There's no need to keep this indirection (and the tests that check that we correctly call through that indirection) --- .../server/mir}/compositor/stream.h | 3 +- .../server/mir/default_server_configuration.h | 3 - .../server/mir/scene/buffer_stream_factory.h | 48 -------- src/server/compositor/CMakeLists.txt | 2 +- .../compositor/buffer_stream_factory.cpp | 45 ------- src/server/compositor/buffer_stream_factory.h | 51 -------- .../compositor/default_configuration.cpp | 11 -- src/server/compositor/stream.cpp | 4 +- src/server/scene/application_session.cpp | 8 +- src/server/scene/application_session.h | 3 - src/server/scene/default_configuration.cpp | 1 - src/server/scene/session_manager.cpp | 3 - src/server/scene/session_manager.h | 3 - src/server/scene/surface_allocator.cpp | 2 - src/server/scene/surface_allocator.h | 1 - src/server/server.cpp | 1 - .../test/doubles/stub_buffer_stream_factory.h | 48 -------- .../test_surface_stack_with_compositor.cpp | 2 +- tests/unit-tests/compositor/test_stream.cpp | 2 +- .../unit-tests/scene/test_abstract_shell.cpp | 2 - .../scene/test_application_session.cpp | 111 ------------------ .../unit-tests/scene/test_session_manager.cpp | 5 - tests/unit-tests/scene/test_surface_stack.cpp | 1 - 23 files changed, 10 insertions(+), 350 deletions(-) rename src/{server => include/server/mir}/compositor/stream.h (98%) delete mode 100644 src/include/server/mir/scene/buffer_stream_factory.h delete mode 100644 src/server/compositor/buffer_stream_factory.cpp delete mode 100644 src/server/compositor/buffer_stream_factory.h delete mode 100644 tests/include/mir/test/doubles/stub_buffer_stream_factory.h diff --git a/src/server/compositor/stream.h b/src/include/server/mir/compositor/stream.h similarity index 98% rename from src/server/compositor/stream.h rename to src/include/server/mir/compositor/stream.h index 9d16e1bd628..74071186910 100644 --- a/src/server/compositor/stream.h +++ b/src/include/server/mir/compositor/stream.h @@ -20,7 +20,6 @@ #include "mir/compositor/buffer_stream.h" #include "mir/geometry/size.h" #include "mir/synchronised.h" -#include "multi_monitor_arbiter.h" #include #include @@ -31,6 +30,8 @@ namespace mir { namespace compositor { +class MultiMonitorArbiter; + class Stream : public BufferStream { public: diff --git a/src/include/server/mir/default_server_configuration.h b/src/include/server/mir/default_server_configuration.h index 878d285f1fa..20ca9a3c218 100644 --- a/src/include/server/mir/default_server_configuration.h +++ b/src/include/server/mir/default_server_configuration.h @@ -44,7 +44,6 @@ class MultiplexingDispatchable; } namespace compositor { -class BufferStreamFactory; class Scene; class DisplayBufferCompositorFactory; class Compositor; @@ -292,7 +291,6 @@ class DefaultServerConfiguration : public virtual ServerConfiguration /** @name scene configuration - dependencies * dependencies of scene on the rest of the Mir * @{ */ - virtual std::shared_ptr the_buffer_stream_factory(); virtual std::shared_ptr the_scene_report(); /** @} */ @@ -386,7 +384,6 @@ class DefaultServerConfiguration : public virtual ServerConfiguration CachedPtr session_authorizer; CachedPtr renderer_factory; - CachedPtr buffer_stream_factory; CachedPtr scene_surface_stack; CachedPtr surface_stack; CachedPtr scene_report; diff --git a/src/include/server/mir/scene/buffer_stream_factory.h b/src/include/server/mir/scene/buffer_stream_factory.h deleted file mode 100644 index b0d9769e51e..00000000000 --- a/src/include/server/mir/scene/buffer_stream_factory.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_SCENE_BUFFER_STREAM_FACTORY_H_ -#define MIR_SCENE_BUFFER_STREAM_FACTORY_H_ - -#include - -namespace mir -{ -namespace compositor { class BufferStream; } -namespace graphics { struct BufferProperties; } -namespace scene -{ -class BufferStreamFactory -{ -public: - virtual ~BufferStreamFactory() = default; - - virtual std::shared_ptr create_buffer_stream( - int nbuffers, - graphics::BufferProperties const& buffer_properties) = 0; - virtual std::shared_ptr create_buffer_stream( - graphics::BufferProperties const& buffer_properties) = 0; - -protected: - BufferStreamFactory() = default; - BufferStreamFactory(const BufferStreamFactory&) = delete; - BufferStreamFactory& operator=(const BufferStreamFactory&) = delete; -}; - -} -} - -#endif // MIR_SCENE_BUFFER_STREAM_FACTORY_H_ diff --git a/src/server/compositor/CMakeLists.txt b/src/server/compositor/CMakeLists.txt index 69e810137e1..967abcb046a 100644 --- a/src/server/compositor/CMakeLists.txt +++ b/src/server/compositor/CMakeLists.txt @@ -9,11 +9,11 @@ set( default_display_buffer_compositor.cpp default_display_buffer_compositor_factory.cpp - buffer_stream_factory.cpp multi_threaded_compositor.cpp occlusion.cpp default_configuration.cpp stream.cpp + ${PROJECT_SOURCE_DIR}/src/include/server/mir/compositor/stream.h multi_monitor_arbiter.cpp basic_screen_shooter.cpp null_screen_shooter.cpp diff --git a/src/server/compositor/buffer_stream_factory.cpp b/src/server/compositor/buffer_stream_factory.cpp deleted file mode 100644 index 53eeb48c27a..00000000000 --- a/src/server/compositor/buffer_stream_factory.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "buffer_stream_factory.h" -#include "mir/graphics/buffer_properties.h" -#include "stream.h" -#include "mir/graphics/buffer.h" - -#include - -namespace mc = mir::compositor; -namespace mg = mir::graphics; -namespace ms = mir::scene; -namespace mf = mir::frontend; - -mc::BufferStreamFactory::BufferStreamFactory() -{ -} - -std::shared_ptr mc::BufferStreamFactory::create_buffer_stream( - mg::BufferProperties const& buffer_properties) -{ - return create_buffer_stream(0, buffer_properties); -} - -std::shared_ptr mc::BufferStreamFactory::create_buffer_stream( - int, - mg::BufferProperties const& buffer_properties) -{ - return std::make_shared( - buffer_properties.size, buffer_properties.format); -} diff --git a/src/server/compositor/buffer_stream_factory.h b/src/server/compositor/buffer_stream_factory.h deleted file mode 100644 index 2df1498e575..00000000000 --- a/src/server/compositor/buffer_stream_factory.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ -#define MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ - -#include "mir/scene/buffer_stream_factory.h" - -#include - -namespace mir -{ -namespace graphics -{ -class GraphicBufferAllocator; -} -namespace compositor -{ - -class BufferStreamFactory : public scene::BufferStreamFactory -{ -public: - BufferStreamFactory(); - - virtual ~BufferStreamFactory() {} - - virtual std::shared_ptr create_buffer_stream( - int nbuffers, - graphics::BufferProperties const& buffer_properties) override; - virtual std::shared_ptr create_buffer_stream( - graphics::BufferProperties const&) override; -}; - -} -} - - -#endif /* MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ */ diff --git a/src/server/compositor/default_configuration.cpp b/src/server/compositor/default_configuration.cpp index 00a8a0f9a6d..3578f121ff1 100644 --- a/src/server/compositor/default_configuration.cpp +++ b/src/server/compositor/default_configuration.cpp @@ -18,7 +18,6 @@ #include "mir/log.h" #include "mir/shell/shell.h" -#include "buffer_stream_factory.h" #include "default_display_buffer_compositor_factory.h" #include "mir/executor.h" #include "multi_threaded_compositor.h" @@ -33,16 +32,6 @@ namespace mc = mir::compositor; namespace ms = mir::scene; namespace mg = mir::graphics; -std::shared_ptr -mir::DefaultServerConfiguration::the_buffer_stream_factory() -{ - return buffer_stream_factory( - []() - { - return std::make_shared(); - }); -} - std::shared_ptr mir::DefaultServerConfiguration::the_display_buffer_compositor_factory() { diff --git a/src/server/compositor/stream.cpp b/src/server/compositor/stream.cpp index 618178f0646..40f4e905645 100644 --- a/src/server/compositor/stream.cpp +++ b/src/server/compositor/stream.cpp @@ -14,7 +14,8 @@ * along with this program. If not, see . */ -#include "stream.h" +#include "mir/compositor/stream.h" +#include "multi_monitor_arbiter.h" #include "mir/graphics/buffer.h" #include #include @@ -22,7 +23,6 @@ #include namespace mc = mir::compositor; -namespace geom = mir::geometry; namespace mg = mir::graphics; namespace geom = mir::geometry; diff --git a/src/server/scene/application_session.cpp b/src/server/scene/application_session.cpp index 9a483d91e81..a261c458933 100644 --- a/src/server/scene/application_session.cpp +++ b/src/server/scene/application_session.cpp @@ -20,10 +20,9 @@ #include "mir/scene/session_container.h" #include "mir/scene/session_listener.h" #include "mir/scene/surface_factory.h" -#include "mir/scene/buffer_stream_factory.h" #include "mir/shell/surface_stack.h" #include "mir/shell/surface_specification.h" -#include "mir/compositor/buffer_stream.h" +#include "mir/compositor/stream.h" #include "mir/events/event_builders.h" #include "mir/frontend/event_sink.h" #include "mir/graphics/graphic_buffer_allocator.h" @@ -43,11 +42,11 @@ namespace msh = mir::shell; namespace mg = mir::graphics; namespace mev = mir::events; namespace mc = mir::compositor; +namespace geom = mir::geometry; ms::ApplicationSession::ApplicationSession( std::shared_ptr const& surface_stack, std::shared_ptr const& surface_factory, - std::shared_ptr const& buffer_stream_factory, pid_t pid, Fd socket_fd, std::string const& session_name, @@ -56,7 +55,6 @@ ms::ApplicationSession::ApplicationSession( std::shared_ptr const& gralloc) : surface_stack(surface_stack), surface_factory(surface_factory), - buffer_stream_factory(buffer_stream_factory), pid(pid), socket_fd_(socket_fd), session_name(session_name), @@ -292,7 +290,7 @@ void ms::ApplicationSession::resume_prompt_session() auto ms::ApplicationSession::create_buffer_stream(mg::BufferProperties const& props) -> std::shared_ptr { - auto stream = buffer_stream_factory->create_buffer_stream(props); + auto stream = std::make_shared(props.size, props.format); session_listener->buffer_stream_created(*this, stream); std::unique_lock lock(surfaces_and_streams_mutex); diff --git a/src/server/scene/application_session.h b/src/server/scene/application_session.h index 26471593d0c..22774458b4c 100644 --- a/src/server/scene/application_session.h +++ b/src/server/scene/application_session.h @@ -37,7 +37,6 @@ namespace scene { class SessionListener; class Surface; -class BufferStreamFactory; class SurfaceFactory; class ApplicationSession : public Session @@ -46,7 +45,6 @@ class ApplicationSession : public Session ApplicationSession( std::shared_ptr const& surface_stack, std::shared_ptr const& surface_factory, - std::shared_ptr const& buffer_stream_factory, pid_t pid, Fd socket_fd, std::string const& session_name, @@ -99,7 +97,6 @@ class ApplicationSession : public Session private: std::shared_ptr const surface_stack; std::shared_ptr const surface_factory; - std::shared_ptr const buffer_stream_factory; pid_t const pid; Fd socket_fd_; std::string const session_name; diff --git a/src/server/scene/default_configuration.cpp b/src/server/scene/default_configuration.cpp index 55689e280f5..961226b66b2 100644 --- a/src/server/scene/default_configuration.cpp +++ b/src/server/scene/default_configuration.cpp @@ -176,7 +176,6 @@ mir::DefaultServerConfiguration::the_session_coordinator() return std::make_shared( the_surface_stack(), the_surface_factory(), - the_buffer_stream_factory(), the_session_container(), the_session_event_sink(), the_session_listener(), diff --git a/src/server/scene/session_manager.cpp b/src/server/scene/session_manager.cpp index e10b33dc385..9f7f2221b4a 100644 --- a/src/server/scene/session_manager.cpp +++ b/src/server/scene/session_manager.cpp @@ -83,7 +83,6 @@ struct ms::SessionManager::SessionObservers : mir::ObserverMultiplexer const& surface_stack, std::shared_ptr const& surface_factory, - std::shared_ptr const& buffer_stream_factory, std::shared_ptr const& container, std::shared_ptr const& session_event_sink, std::shared_ptr const& session_listener, @@ -94,7 +93,6 @@ ms::SessionManager::SessionManager( observers(std::make_shared()), surface_stack(surface_stack), surface_factory(surface_factory), - buffer_stream_factory(buffer_stream_factory), app_container(container), session_event_sink(session_event_sink), session_listener(session_listener), @@ -135,7 +133,6 @@ std::shared_ptr ms::SessionManager::open_session( std::shared_ptr new_session = std::make_shared( surface_stack, surface_factory, - buffer_stream_factory, client_pid, socket_fd, name, diff --git a/src/server/scene/session_manager.h b/src/server/scene/session_manager.h index 887428c6868..2c4584051bd 100644 --- a/src/server/scene/session_manager.h +++ b/src/server/scene/session_manager.h @@ -44,7 +44,6 @@ class SessionEventSink; class SessionListener; class SurfaceStack; class PromptSessionManager; -class BufferStreamFactory; class SurfaceFactory; class ApplicationNotRespondingDetector; @@ -54,7 +53,6 @@ class SessionManager : public SessionCoordinator SessionManager( std::shared_ptr const& surface_stack, std::shared_ptr const& surface_factory, - std::shared_ptr const& buffer_stream_factory, std::shared_ptr const& app_container, std::shared_ptr const& session_event_sink, std::shared_ptr const& session_listener, @@ -91,7 +89,6 @@ class SessionManager : public SessionCoordinator std::shared_ptr const observers; std::shared_ptr const surface_stack; std::shared_ptr const surface_factory; - std::shared_ptr const buffer_stream_factory; std::shared_ptr const app_container; std::shared_ptr const session_event_sink; std::shared_ptr const session_listener; diff --git a/src/server/scene/surface_allocator.cpp b/src/server/scene/surface_allocator.cpp index 5b0c5426aac..84274c3f8cf 100644 --- a/src/server/scene/surface_allocator.cpp +++ b/src/server/scene/surface_allocator.cpp @@ -15,9 +15,7 @@ */ #include "surface_allocator.h" -#include "mir/scene/buffer_stream_factory.h" #include "mir/shell/surface_specification.h" -#include "mir/compositor/buffer_stream.h" #include "basic_surface.h" namespace geom=mir::geometry; diff --git a/src/server/scene/surface_allocator.h b/src/server/scene/surface_allocator.h index b53d51d610e..67e7c161234 100644 --- a/src/server/scene/surface_allocator.h +++ b/src/server/scene/surface_allocator.h @@ -27,7 +27,6 @@ namespace graphics class CursorImage; class DisplayConfigurationObserver; } -namespace compositor { class BufferStream; } namespace scene { class SceneReport; diff --git a/src/server/server.cpp b/src/server/server.cpp index 1b45c0d9304..8732d988d77 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -103,7 +103,6 @@ struct TemporaryCompositeEventFilter : public mi::CompositeEventFilter MACRO(renderer_factory) #define FOREACH_ACCESSOR(MACRO)\ - MACRO(the_buffer_stream_factory)\ MACRO(the_compositor)\ MACRO(the_compositor_report)\ MACRO(the_cursor_listener)\ diff --git a/tests/include/mir/test/doubles/stub_buffer_stream_factory.h b/tests/include/mir/test/doubles/stub_buffer_stream_factory.h deleted file mode 100644 index 07d68e664cd..00000000000 --- a/tests/include/mir/test/doubles/stub_buffer_stream_factory.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_TEST_DOUBLES_STUB_BUFFER_STREAM_FACTORY_H_ -#define MIR_TEST_DOUBLES_STUB_BUFFER_STREAM_FACTORY_H_ - -#include "mir/scene/buffer_stream_factory.h" -#include "stub_buffer_stream.h" - -namespace mir -{ -namespace test -{ -namespace doubles -{ - -struct StubBufferStreamFactory : public scene::BufferStreamFactory -{ - std::shared_ptr create_buffer_stream( - int, - graphics::BufferProperties const& p) - { - return create_buffer_stream(p); - } - std::shared_ptr create_buffer_stream( - graphics::BufferProperties const&) - { - return std::make_shared(); - } -}; -} -} -} - -#endif // MIR_TEST_DOUBLES_STUB_BUFFER_STREAM_FACTORY_H_ diff --git a/tests/integration-tests/test_surface_stack_with_compositor.cpp b/tests/integration-tests/test_surface_stack_with_compositor.cpp index 84e505c846a..ace28a9e7c8 100644 --- a/tests/integration-tests/test_surface_stack_with_compositor.cpp +++ b/tests/integration-tests/test_surface_stack_with_compositor.cpp @@ -22,7 +22,7 @@ #include "src/server/scene/basic_surface.h" #include "src/server/compositor/default_display_buffer_compositor_factory.h" #include "src/server/compositor/multi_threaded_compositor.h" -#include "src/server/compositor/stream.h" +#include "mir/compositor/stream.h" #include "mir/test/fake_shared.h" #include "mir/test/doubles/fake_display_configuration_observer_registrar.h" #include "mir/test/doubles/mock_buffer_stream.h" diff --git a/tests/unit-tests/compositor/test_stream.cpp b/tests/unit-tests/compositor/test_stream.cpp index 7cf2b957212..1283d09a825 100644 --- a/tests/unit-tests/compositor/test_stream.cpp +++ b/tests/unit-tests/compositor/test_stream.cpp @@ -16,7 +16,7 @@ #include "mir/test/doubles/stub_buffer.h" #include "mir/test/fake_shared.h" -#include "src/server/compositor/stream.h" +#include "mir/compositor/stream.h" #include #include diff --git a/tests/unit-tests/scene/test_abstract_shell.cpp b/tests/unit-tests/scene/test_abstract_shell.cpp index 60e893f0fdf..458206d456e 100644 --- a/tests/unit-tests/scene/test_abstract_shell.cpp +++ b/tests/unit-tests/scene/test_abstract_shell.cpp @@ -36,7 +36,6 @@ #include "mir/test/doubles/null_event_sink.h" #include "mir/test/doubles/null_prompt_session_manager.h" #include "mir/test/doubles/stub_input_targeter.h" -#include "mir/test/doubles/stub_buffer_stream_factory.h" #include "mir/test/doubles/stub_buffer_allocator.h" #include "mir/test/doubles/null_application_not_responding_detector.h" #include "mir/test/doubles/stub_display.h" @@ -103,7 +102,6 @@ struct MockSessionManager : ms::SessionManager : ms::SessionManager{ surface_stack, surface_factory, - std::make_shared(), app_container, session_event_sink, std::make_shared(), diff --git a/tests/unit-tests/scene/test_application_session.cpp b/tests/unit-tests/scene/test_application_session.cpp index f259fb2ce67..05ca20032b8 100644 --- a/tests/unit-tests/scene/test_application_session.cpp +++ b/tests/unit-tests/scene/test_application_session.cpp @@ -28,7 +28,6 @@ #include "mir/test/doubles/mock_session_listener.h" #include "mir/test/doubles/stub_display_configuration.h" #include "mir/test/doubles/stub_surface_factory.h" -#include "mir/test/doubles/stub_buffer_stream_factory.h" #include "mir/test/doubles/stub_buffer_stream.h" #include "mir/test/doubles/null_event_sink.h" #include "mir/test/doubles/mock_event_sink.h" @@ -61,15 +60,6 @@ static std::shared_ptr make_mock_surface() return surface; } -struct MockBufferStreamFactory : public ms::BufferStreamFactory -{ - MOCK_METHOD2(create_buffer_stream, std::shared_ptr( - int, mg::BufferProperties const&)); - MOCK_METHOD1(create_buffer_stream, std::shared_ptr( - mg::BufferProperties const&)); -}; - - MATCHER_P(EqPromptSessionEventState, state, "") { return arg.type() == mir_event_type_prompt_session_state_change && arg.to_prompt_session()->new_state() == state; } @@ -122,7 +112,6 @@ struct ApplicationSession : public testing::Test return std::make_shared( stub_surface_stack, stub_surface_factory, - stub_buffer_stream_factory, pid, mir::Fd{mir::Fd::invalid}, name, @@ -132,13 +121,11 @@ struct ApplicationSession : public testing::Test } std::shared_ptr make_application_session( - std::shared_ptr const& bstream_factory, std::shared_ptr const& surface_factory) { return std::make_shared( stub_surface_stack, surface_factory, - bstream_factory, pid, mir::Fd{mir::Fd::invalid}, name, @@ -154,7 +141,6 @@ struct ApplicationSession : public testing::Test return std::make_shared( surface_stack, surface_factory, - stub_buffer_stream_factory, pid, mir::Fd{mir::Fd::invalid}, name, @@ -168,7 +154,6 @@ struct ApplicationSession : public testing::Test return std::make_shared( surface_stack, stub_surface_factory, - stub_buffer_stream_factory, pid, mir::Fd{mir::Fd::invalid}, name, @@ -183,7 +168,6 @@ struct ApplicationSession : public testing::Test return std::make_shared( stub_surface_stack, stub_surface_factory, - stub_buffer_stream_factory, pid, mir::Fd{mir::Fd::invalid}, name, @@ -193,27 +177,10 @@ struct ApplicationSession : public testing::Test } - std::shared_ptr make_application_session_with_buffer_stream_factory( - std::shared_ptr const& buffer_stream_factory) - { - return std::make_shared( - stub_surface_stack, - stub_surface_factory, - buffer_stream_factory, - pid, - mir::Fd{mir::Fd::invalid}, - name, - stub_session_listener, - event_sink, - allocator); - } - std::shared_ptr const event_sink; std::shared_ptr const surface_observer; std::shared_ptr const stub_session_listener; std::shared_ptr const stub_surface_stack; - std::shared_ptr const stub_buffer_stream_factory = - std::make_shared(); std::shared_ptr const stub_surface_factory{std::make_shared()}; std::shared_ptr const stub_buffer_stream{std::make_shared()}; std::shared_ptr const allocator{ @@ -454,7 +421,6 @@ TEST_F(ApplicationSession, process_id) ms::ApplicationSession app_session( stub_surface_stack, stub_surface_factory, - stub_buffer_stream_factory, session_pid, mir::Fd{mir::Fd::invalid}, name, @@ -482,79 +448,6 @@ MATCHER(StreamEq, "") (std::get<0>(arg).displacement == std::get<1>(arg).displacement); } -TEST_F(ApplicationSession, sets_and_looks_up_surface_streams) -{ - using namespace testing; - NiceMock mock_bufferstream_factory; - NiceMock mock_surface_factory; - - auto mock_surface = make_mock_surface(); - EXPECT_CALL(mock_surface_factory, create_surface(_, _, _, _)) - .WillOnce(Return(mock_surface)); - - std::array,3> streams {{ - std::make_shared(), - std::make_shared(), - std::make_shared() - }}; - EXPECT_CALL(mock_bufferstream_factory, create_buffer_stream(_)) - .WillOnce(Return(streams[0])) - .WillOnce(Return(streams[1])) - .WillOnce(Return(streams[2])); - - auto stream_properties = mg::BufferProperties{{8,8}, mir_pixel_format_argb_8888, mg::BufferUsage::hardware}; - auto session = make_application_session( - mt::fake_shared(mock_bufferstream_factory), - mt::fake_shared(mock_surface_factory)); - - auto stream0 = session->create_buffer_stream(stream_properties); - auto stream1 = session->create_buffer_stream(stream_properties); - auto stream2 = session->create_buffer_stream(stream_properties); - - ASSERT_THAT(stream0, Eq(streams[0])) << "session->create_buffer_stream() did not create correct stream"; - ASSERT_THAT(stream1, Eq(streams[1])) << "session->create_buffer_stream() did not create correct stream"; - ASSERT_THAT(stream2, Eq(streams[2])) << "session->create_buffer_stream() did not create correct stream"; - - std::list info { - {streams[2], geom::Displacement{0,3}, {}}, - {streams[0], geom::Displacement{-1,1}, {}}, - {streams[1], geom::Displacement{0,2}, {}} - }; - - session->create_surface(nullptr, {}, mt::make_surface_spec(stream0), surface_observer, nullptr); - - EXPECT_CALL(*mock_surface, set_streams(Pointwise(StreamEq(), info))); - session->configure_streams(*mock_surface, { - {stream2, geom::Displacement{0,3}, {}}, - {stream0, geom::Displacement{-1,1}, {}}, - {stream1, geom::Displacement{0,2}, {}} - }); -} - -TEST_F(ApplicationSession, buffer_stream_constructed_with_requested_parameters) -{ - using namespace ::testing; - - geom::Size const buffer_size{geom::Width{1}, geom::Height{1}}; - - mtd::StubBufferStream stream; - MockBufferStreamFactory factory; - - mg::BufferProperties properties(buffer_size, mir_pixel_format_argb_8888, mg::BufferUsage::software); - - EXPECT_CALL(factory, create_buffer_stream(properties)).Times(1) - .WillOnce(Return(mt::fake_shared(stream))); - - auto session = make_application_session_with_buffer_stream_factory(mt::fake_shared(factory)); - auto buffer_stream = session->create_buffer_stream(properties); - - EXPECT_TRUE(session->has_buffer_stream(buffer_stream)); - - session->destroy_buffer_stream(buffer_stream); - - EXPECT_FALSE(session->has_buffer_stream(buffer_stream)); -} - MATCHER_P(HasSingleStream, value, "") { using namespace testing; @@ -568,7 +461,6 @@ TEST_F(ApplicationSession, surface_uses_prexisting_buffer_stream_if_set) { using namespace testing; - mtd::StubBufferStreamFactory bufferstream_factory; NiceMock mock_surface_factory; geom::Size const buffer_size{geom::Width{1}, geom::Height{1}}; @@ -576,7 +468,6 @@ TEST_F(ApplicationSession, surface_uses_prexisting_buffer_stream_if_set) mg::BufferProperties properties(buffer_size, mir_pixel_format_argb_8888, mg::BufferUsage::software); auto session = make_application_session( - mt::fake_shared(bufferstream_factory), mt::fake_shared(mock_surface_factory)); auto stream = session->create_buffer_stream(properties); @@ -599,7 +490,6 @@ struct ApplicationSessionSender : public ApplicationSession app_session( stub_surface_stack, stub_surface_factory, - stub_buffer_stream_factory, pid, mir::Fd{mir::Fd::invalid}, name, @@ -725,7 +615,6 @@ struct ApplicationSessionSurfaceOutput : public ApplicationSession app_session( stub_surface_stack, stub_surface_factory, - stub_buffer_stream_factory, pid, mir::Fd{mir::Fd::invalid}, name, diff --git a/tests/unit-tests/scene/test_session_manager.cpp b/tests/unit-tests/scene/test_session_manager.cpp index 4579c2ff4ce..64a7c221004 100644 --- a/tests/unit-tests/scene/test_session_manager.cpp +++ b/tests/unit-tests/scene/test_session_manager.cpp @@ -29,7 +29,6 @@ #include "mir/test/doubles/mock_surface_stack.h" #include "mir/test/doubles/mock_session_listener.h" #include "mir/test/doubles/stub_buffer_stream.h" -#include "mir/test/doubles/stub_buffer_stream_factory.h" #include "mir/test/doubles/null_session_event_sink.h" #include "mir/test/doubles/null_event_sink.h" #include "mir/test/doubles/stub_surface_factory.h" @@ -78,7 +77,6 @@ struct SessionManagerSetup : public testing::Test testing::NiceMock surface_stack; ms::SessionContainer container; ms::NullSessionListener session_listener; - mtd::StubBufferStreamFactory buffer_stream_factory; mtd::StubSurfaceFactory stub_surface_factory; mtd::StubDisplay display{2}; mtd::NullEventSink event_sink; @@ -87,7 +85,6 @@ struct SessionManagerSetup : public testing::Test ms::SessionManager session_manager{mt::fake_shared(surface_stack), mt::fake_shared(stub_surface_factory), - mt::fake_shared(buffer_stream_factory), mt::fake_shared(container), std::make_shared(), mt::fake_shared(session_listener), @@ -114,7 +111,6 @@ struct SessionManagerSessionListenerSetup : public testing::Test ms::SessionManager session_manager{ mt::fake_shared(surface_stack), mt::fake_shared(stub_surface_factory), - std::make_shared(), mt::fake_shared(container), std::make_shared(), mt::fake_shared(session_listener), @@ -195,7 +191,6 @@ struct SessionManagerSessionEventsSetup : public testing::Test ms::SessionManager session_manager{ mt::fake_shared(surface_stack), mt::fake_shared(stub_surface_factory), - std::make_shared(), mt::fake_shared(container), mt::fake_shared(session_event_sink), mt::fake_shared(session_listener), diff --git a/tests/unit-tests/scene/test_surface_stack.cpp b/tests/unit-tests/scene/test_surface_stack.cpp index c0c13b7529a..457cb2e57d1 100644 --- a/tests/unit-tests/scene/test_surface_stack.cpp +++ b/tests/unit-tests/scene/test_surface_stack.cpp @@ -21,7 +21,6 @@ #include "mir/compositor/scene_element.h" #include "src/server/report/null_report_factory.h" #include "src/server/scene/basic_surface.h" -#include "src/server/compositor/stream.h" #include "mir/test/fake_shared.h" #include "mir/test/doubles/fake_display_configuration_observer_registrar.h" #include "mir/test/doubles/stub_buffer_stream.h" From 783167d8861fcbe527526ca8aa30a65325189d45 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Fri, 3 May 2024 12:20:22 +1000 Subject: [PATCH 2/4] server/symbols.map: Drop removed symbols --- src/server/symbols.map | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/server/symbols.map b/src/server/symbols.map index f657f872bd3..73010c0b7ae 100644 --- a/src/server/symbols.map +++ b/src/server/symbols.map @@ -17,7 +17,6 @@ global: mir::DefaultServerConfiguration::set_wayland_extension_filter*; mir::DefaultServerConfiguration::the_application_not_responding_detector*; mir::DefaultServerConfiguration::the_buffer_allocator*; - mir::DefaultServerConfiguration::the_buffer_stream_factory*; mir::DefaultServerConfiguration::the_clock*; mir::DefaultServerConfiguration::the_composite_event_filter*; mir::DefaultServerConfiguration::the_compositor*; @@ -185,7 +184,6 @@ global: mir::Server::stop*; mir::Server::supported_pixel_formats*; mir::Server::the_application_not_responding_detector*; - mir::Server::the_buffer_stream_factory*; mir::Server::the_composite_event_filter*; mir::Server::the_compositor*; mir::Server::the_compositor_report*; @@ -667,7 +665,6 @@ global: non-virtual?thunk?to?mir::DefaultServerConfiguration::set_wayland_extension_filter*; non-virtual?thunk?to?mir::DefaultServerConfiguration::the_application_not_responding_detector*; non-virtual?thunk?to?mir::DefaultServerConfiguration::the_buffer_allocator*; - non-virtual?thunk?to?mir::DefaultServerConfiguration::the_buffer_stream_factory*; non-virtual?thunk?to?mir::DefaultServerConfiguration::the_clock*; non-virtual?thunk?to?mir::DefaultServerConfiguration::the_composite_event_filter*; non-virtual?thunk?to?mir::DefaultServerConfiguration::the_compositor*; From 43a188f26f7dfafe2ddb95485510bc387e13337e Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Fri, 3 May 2024 18:33:23 +1000 Subject: [PATCH 3/4] server/symbols.map: And also add new symbols! --- src/server/symbols.map | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/server/symbols.map b/src/server/symbols.map index 73010c0b7ae..57e42a59a62 100644 --- a/src/server/symbols.map +++ b/src/server/symbols.map @@ -256,6 +256,15 @@ global: mir::compositor::SceneElement::operator*; mir::compositor::ScreenShooter::?ScreenShooter*; mir::compositor::ScreenShooter::ScreenShooter*; + mir::compositor::Stream::?Stream*; + mir::compositor::Stream::Stream*; + mir::compositor::Stream::has_submitted_buffer*; + mir::compositor::Stream::lock_compositor_buffer*; + mir::compositor::Stream::pixel_format*; + mir::compositor::Stream::set_frame_posted_callback*; + mir::compositor::Stream::set_scale*; + mir::compositor::Stream::stream_size*; + mir::compositor::Stream::submit_buffer*; mir::detail::FdSources::?FdSources*; mir::detail::FdSources::FdSources*; mir::detail::FdSources::add*; @@ -783,6 +792,14 @@ global: non-virtual?thunk?to?mir::compositor::Scene::?Scene*; non-virtual?thunk?to?mir::compositor::SceneElement::?SceneElement*; non-virtual?thunk?to?mir::compositor::ScreenShooter::?ScreenShooter*; + non-virtual?thunk?to?mir::compositor::Stream::?Stream*; + non-virtual?thunk?to?mir::compositor::Stream::has_submitted_buffer*; + non-virtual?thunk?to?mir::compositor::Stream::lock_compositor_buffer*; + non-virtual?thunk?to?mir::compositor::Stream::pixel_format*; + non-virtual?thunk?to?mir::compositor::Stream::set_frame_posted_callback*; + non-virtual?thunk?to?mir::compositor::Stream::set_scale*; + non-virtual?thunk?to?mir::compositor::Stream::stream_size*; + non-virtual?thunk?to?mir::compositor::Stream::submit_buffer*; non-virtual?thunk?to?mir::frontend::BufferSink::?BufferSink*; non-virtual?thunk?to?mir::frontend::BufferStream::?BufferStream*; non-virtual?thunk?to?mir::frontend::Connector::?Connector*; @@ -1031,6 +1048,7 @@ global: typeinfo?for?mir::compositor::Scene; typeinfo?for?mir::compositor::SceneElement; typeinfo?for?mir::compositor::ScreenShooter; + typeinfo?for?mir::compositor::Stream; typeinfo?for?mir::detail::FdSources; typeinfo?for?mir::detail::GMainContextHandle; typeinfo?for?mir::detail::GSourceHandle; @@ -1230,6 +1248,7 @@ global: vtable?for?mir::compositor::Scene; vtable?for?mir::compositor::SceneElement; vtable?for?mir::compositor::ScreenShooter; + vtable?for?mir::compositor::Stream; vtable?for?mir::frontend::BufferSink; vtable?for?mir::frontend::BufferStream; vtable?for?mir::frontend::Connector; From 99dda3f47efe9e7df299fc21d3caa8bda2edd652 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Fri, 3 May 2024 17:22:25 -0400 Subject: [PATCH 4/4] bugfix: removing last remnants of the BufferStreamFactory --- src/include/server/mir/default_server_configuration.h | 1 - src/include/server/mir/server.h | 4 ---- src/server/symbols.map | 6 ------ 3 files changed, 11 deletions(-) diff --git a/src/include/server/mir/default_server_configuration.h b/src/include/server/mir/default_server_configuration.h index 20ca9a3c218..ce0c6ac267f 100644 --- a/src/include/server/mir/default_server_configuration.h +++ b/src/include/server/mir/default_server_configuration.h @@ -81,7 +81,6 @@ namespace scene { class SurfaceFactory; class BroadcastingSessionEventSink; -class BufferStreamFactory; class MediatingDisplayChanger; class SessionContainer; class SessionEventSink; diff --git a/src/include/server/mir/server.h b/src/include/server/mir/server.h index 2e3ef4c9044..789919094b7 100644 --- a/src/include/server/mir/server.h +++ b/src/include/server/mir/server.h @@ -54,7 +54,6 @@ class SurfaceStack; namespace scene { class ApplicationNotRespondingDetector; -class BufferStreamFactory; class PromptSessionListener; class PromptSessionManager; class SessionListener; @@ -395,9 +394,6 @@ class Server /// \return the display layout. auto the_shell_display_layout() const -> std::shared_ptr; - /// \return the buffer stream factory - auto the_buffer_stream_factory() const -> std::shared_ptr; - /// \return the surface factory auto the_surface_factory() const -> std::shared_ptr; diff --git a/src/server/symbols.map b/src/server/symbols.map index 57e42a59a62..d72821babb3 100644 --- a/src/server/symbols.map +++ b/src/server/symbols.map @@ -401,9 +401,6 @@ global: mir::scene::ApplicationNotRespondingDetectorWrapper::register_session*; mir::scene::ApplicationNotRespondingDetectorWrapper::unregister_observer*; mir::scene::ApplicationNotRespondingDetectorWrapper::unregister_session*; - mir::scene::BufferStreamFactory::?BufferStreamFactory*; - mir::scene::BufferStreamFactory::BufferStreamFactory*; - mir::scene::BufferStreamFactory::operator*; mir::scene::ClipboardObserver::?ClipboardObserver*; mir::scene::ClipboardObserver::ClipboardObserver*; mir::scene::DataExchangeSource::?DataExchangeSource*; @@ -851,7 +848,6 @@ global: non-virtual?thunk?to?mir::scene::ApplicationNotRespondingDetectorWrapper::register_session*; non-virtual?thunk?to?mir::scene::ApplicationNotRespondingDetectorWrapper::unregister_observer*; non-virtual?thunk?to?mir::scene::ApplicationNotRespondingDetectorWrapper::unregister_session*; - non-virtual?thunk?to?mir::scene::BufferStreamFactory::?BufferStreamFactory*; non-virtual?thunk?to?mir::scene::ClipboardObserver::?ClipboardObserver*; non-virtual?thunk?to?mir::scene::DataExchangeSource::?DataExchangeSource*; non-virtual?thunk?to?mir::scene::IdleHub::?IdleHub*; @@ -1093,7 +1089,6 @@ global: typeinfo?for?mir::scene::ApplicationNotRespondingDetector::Observer; typeinfo?for?mir::scene::ApplicationNotRespondingDetector; typeinfo?for?mir::scene::ApplicationNotRespondingDetectorWrapper; - typeinfo?for?mir::scene::BufferStreamFactory; typeinfo?for?mir::scene::Clipboard; typeinfo?for?mir::scene::ClipboardObserver; typeinfo?for?mir::scene::DataExchangeSource; @@ -1286,7 +1281,6 @@ global: vtable?for?mir::scene::ApplicationNotRespondingDetector::Observer; vtable?for?mir::scene::ApplicationNotRespondingDetector; vtable?for?mir::scene::ApplicationNotRespondingDetectorWrapper; - vtable?for?mir::scene::BufferStreamFactory; vtable?for?mir::scene::Clipboard; vtable?for?mir::scene::ClipboardObserver; vtable?for?mir::scene::DataExchangeSource;