Skip to content

Commit

Permalink
Drop the unnecessary indirection of mc::BufferStreamFactory (#3368)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
AlanGriffiths authored Jun 7, 2024
2 parents b25b49d + 99dda3f commit acd0b55
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 364 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <atomic>
#include <mutex>
Expand All @@ -31,6 +30,8 @@ namespace mir
{
namespace compositor
{
class MultiMonitorArbiter;

class Stream : public BufferStream
{
public:
Expand Down
4 changes: 0 additions & 4 deletions src/include/server/mir/default_server_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class MultiplexingDispatchable;
}
namespace compositor
{
class BufferStreamFactory;
class Scene;
class DisplayBufferCompositorFactory;
class Compositor;
Expand Down Expand Up @@ -81,7 +80,6 @@ namespace scene
{
class SurfaceFactory;
class BroadcastingSessionEventSink;
class BufferStreamFactory;
class MediatingDisplayChanger;
class SessionContainer;
class SessionEventSink;
Expand Down Expand Up @@ -291,7 +289,6 @@ class DefaultServerConfiguration : public virtual ServerConfiguration
/** @name scene configuration - dependencies
* dependencies of scene on the rest of the Mir
* @{ */
virtual std::shared_ptr<scene::BufferStreamFactory> the_buffer_stream_factory();
virtual std::shared_ptr<scene::SceneReport> the_scene_report();
/** @} */

Expand Down Expand Up @@ -385,7 +382,6 @@ class DefaultServerConfiguration : public virtual ServerConfiguration

CachedPtr<frontend::SessionAuthorizer> session_authorizer;
CachedPtr<renderer::RendererFactory> renderer_factory;
CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;
CachedPtr<scene::SurfaceStack> scene_surface_stack;
CachedPtr<shell::SurfaceStack> surface_stack;
CachedPtr<scene::SceneReport> scene_report;
Expand Down
48 changes: 0 additions & 48 deletions src/include/server/mir/scene/buffer_stream_factory.h

This file was deleted.

4 changes: 0 additions & 4 deletions src/include/server/mir/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class SurfaceStack;
namespace scene
{
class ApplicationNotRespondingDetector;
class BufferStreamFactory;
class PromptSessionListener;
class PromptSessionManager;
class SessionListener;
Expand Down Expand Up @@ -395,9 +394,6 @@ class Server
/// \return the display layout.
auto the_shell_display_layout() const -> std::shared_ptr<shell::DisplayLayout>;

/// \return the buffer stream factory
auto the_buffer_stream_factory() const -> std::shared_ptr<scene::BufferStreamFactory>;

/// \return the surface factory
auto the_surface_factory() const -> std::shared_ptr<scene::SurfaceFactory>;

Expand Down
2 changes: 1 addition & 1 deletion src/server/compositor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 0 additions & 45 deletions src/server/compositor/buffer_stream_factory.cpp

This file was deleted.

51 changes: 0 additions & 51 deletions src/server/compositor/buffer_stream_factory.h

This file was deleted.

11 changes: 0 additions & 11 deletions src/server/compositor/default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -33,16 +32,6 @@ namespace mc = mir::compositor;
namespace ms = mir::scene;
namespace mg = mir::graphics;

std::shared_ptr<ms::BufferStreamFactory>
mir::DefaultServerConfiguration::the_buffer_stream_factory()
{
return buffer_stream_factory(
[]()
{
return std::make_shared<mc::BufferStreamFactory>();
});
}

std::shared_ptr<mc::DisplayBufferCompositorFactory>
mir::DefaultServerConfiguration::the_display_buffer_compositor_factory()
{
Expand Down
4 changes: 2 additions & 2 deletions src/server/compositor/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "stream.h"
#include "mir/compositor/stream.h"
#include "multi_monitor_arbiter.h"
#include "mir/graphics/buffer.h"
#include <boost/throw_exception.hpp>
#include <math.h>

#include <cmath>

namespace mc = mir::compositor;
namespace geom = mir::geometry;
namespace mg = mir::graphics;
namespace geom = mir::geometry;

Expand Down
8 changes: 3 additions & 5 deletions src/server/scene/application_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<msh::SurfaceStack> const& surface_stack,
std::shared_ptr<SurfaceFactory> const& surface_factory,
std::shared_ptr<ms::BufferStreamFactory> const& buffer_stream_factory,
pid_t pid,
Fd socket_fd,
std::string const& session_name,
Expand All @@ -56,7 +55,6 @@ ms::ApplicationSession::ApplicationSession(
std::shared_ptr<graphics::GraphicBufferAllocator> 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),
Expand Down Expand Up @@ -292,7 +290,7 @@ void ms::ApplicationSession::resume_prompt_session()
auto ms::ApplicationSession::create_buffer_stream(mg::BufferProperties const& props)
-> std::shared_ptr<compositor::BufferStream>
{
auto stream = buffer_stream_factory->create_buffer_stream(props);
auto stream = std::make_shared<mc::Stream>(props.size, props.format);
session_listener->buffer_stream_created(*this, stream);

std::unique_lock lock(surfaces_and_streams_mutex);
Expand Down
3 changes: 0 additions & 3 deletions src/server/scene/application_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace scene
{
class SessionListener;
class Surface;
class BufferStreamFactory;
class SurfaceFactory;

class ApplicationSession : public Session
Expand All @@ -46,7 +45,6 @@ class ApplicationSession : public Session
ApplicationSession(
std::shared_ptr<shell::SurfaceStack> const& surface_stack,
std::shared_ptr<SurfaceFactory> const& surface_factory,
std::shared_ptr<BufferStreamFactory> const& buffer_stream_factory,
pid_t pid,
Fd socket_fd,
std::string const& session_name,
Expand Down Expand Up @@ -99,7 +97,6 @@ class ApplicationSession : public Session
private:
std::shared_ptr<shell::SurfaceStack> const surface_stack;
std::shared_ptr<SurfaceFactory> const surface_factory;
std::shared_ptr<BufferStreamFactory> const buffer_stream_factory;
pid_t const pid;
Fd socket_fd_;
std::string const session_name;
Expand Down
1 change: 0 additions & 1 deletion src/server/scene/default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ mir::DefaultServerConfiguration::the_session_coordinator()
return std::make_shared<ms::SessionManager>(
the_surface_stack(),
the_surface_factory(),
the_buffer_stream_factory(),
the_session_container(),
the_session_event_sink(),
the_session_listener(),
Expand Down
3 changes: 0 additions & 3 deletions src/server/scene/session_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ struct ms::SessionManager::SessionObservers : mir::ObserverMultiplexer<ms::Sessi
ms::SessionManager::SessionManager(
std::shared_ptr<shell::SurfaceStack> const& surface_stack,
std::shared_ptr<SurfaceFactory> const& surface_factory,
std::shared_ptr<BufferStreamFactory> const& buffer_stream_factory,
std::shared_ptr<SessionContainer> const& container,
std::shared_ptr<SessionEventSink> const& session_event_sink,
std::shared_ptr<SessionListener> const& session_listener,
Expand All @@ -94,7 +93,6 @@ ms::SessionManager::SessionManager(
observers(std::make_shared<SessionObservers>()),
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),
Expand Down Expand Up @@ -135,7 +133,6 @@ std::shared_ptr<ms::Session> ms::SessionManager::open_session(
std::shared_ptr<Session> new_session = std::make_shared<ApplicationSession>(
surface_stack,
surface_factory,
buffer_stream_factory,
client_pid,
socket_fd,
name,
Expand Down
3 changes: 0 additions & 3 deletions src/server/scene/session_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class SessionEventSink;
class SessionListener;
class SurfaceStack;
class PromptSessionManager;
class BufferStreamFactory;
class SurfaceFactory;
class ApplicationNotRespondingDetector;

Expand All @@ -54,7 +53,6 @@ class SessionManager : public SessionCoordinator
SessionManager(
std::shared_ptr<shell::SurfaceStack> const& surface_stack,
std::shared_ptr<SurfaceFactory> const& surface_factory,
std::shared_ptr<BufferStreamFactory> const& buffer_stream_factory,
std::shared_ptr<SessionContainer> const& app_container,
std::shared_ptr<SessionEventSink> const& session_event_sink,
std::shared_ptr<SessionListener> const& session_listener,
Expand Down Expand Up @@ -91,7 +89,6 @@ class SessionManager : public SessionCoordinator
std::shared_ptr<SessionObservers> const observers;
std::shared_ptr<shell::SurfaceStack> const surface_stack;
std::shared_ptr<SurfaceFactory> const surface_factory;
std::shared_ptr<BufferStreamFactory> const buffer_stream_factory;
std::shared_ptr<SessionContainer> const app_container;
std::shared_ptr<SessionEventSink> const session_event_sink;
std::shared_ptr<SessionListener> const session_listener;
Expand Down
Loading

0 comments on commit acd0b55

Please sign in to comment.