Skip to content

Commit

Permalink
platform/graphics: Use interface Option type in interfaces.
Browse files Browse the repository at this point in the history
There's no particular reason these interfaces need the concrete `ProgramOption`,
and it's simpler if we don't need to wildly `dynamic_cast<ProgramOption>` everywhere.
  • Loading branch information
RAOF committed Aug 20, 2024
1 parent b57e4cf commit 13c01c6
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 35 deletions.
9 changes: 4 additions & 5 deletions include/platform/mir/graphics/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class Surface;
namespace options
{
class Option;
class ProgramOption;
}
namespace renderer::software
{
Expand Down Expand Up @@ -564,13 +563,13 @@ typedef void(*AddPlatformOptions)(
typedef std::vector<mir::graphics::SupportedDevice>(*PlatformProbe)(
std::shared_ptr<mir::ConsoleServices> const&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const& options);
mir::options::Option const& options);

typedef std::vector<mir::graphics::SupportedDevice>(*RenderProbe)(
std::span<std::shared_ptr<mir::graphics::DisplayPlatform>> const&,
mir::ConsoleServices&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const&);
mir::options::Option const&);

typedef mir::ModuleProperties const*(*DescribeModule)();
}
Expand Down Expand Up @@ -628,13 +627,13 @@ void add_graphics_platform_options(
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const& console,
std::shared_ptr<mir::udev::Context> const& udev,
mir::options::ProgramOption const& options) -> std::vector<mir::graphics::SupportedDevice>;
mir::options::Option const& options) -> std::vector<mir::graphics::SupportedDevice>;

auto probe_rendering_platform(
std::span<std::shared_ptr<mir::graphics::DisplayPlatform>> const& targets,
mir::ConsoleServices& console,
std::shared_ptr<mir::udev::Context> const& udev,
mir::options::ProgramOption const& options) -> std::vector<mir::graphics::SupportedDevice>;
mir::options::Option const& options) -> std::vector<mir::graphics::SupportedDevice>;

mir::ModuleProperties const* describe_graphics_module();

Expand Down
4 changes: 2 additions & 2 deletions src/platforms/eglstream-kms/server/platform_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ auto probe_rendering_platform(
std::span<std::shared_ptr<mg::DisplayPlatform>> const& displays,
mir::ConsoleServices& /*console*/,
std::shared_ptr<mir::udev::Context> const& udev,
mo::ProgramOption const& /*options*/) -> std::vector<mg::SupportedDevice>
mo::Option const& /*options*/) -> std::vector<mg::SupportedDevice>
{
mir::assert_entry_point_signature<mg::RenderProbe>(&probe_rendering_platform);

Expand Down Expand Up @@ -312,7 +312,7 @@ mir::UniqueModulePtr<mg::DisplayPlatform> create_display_platform(
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const& console,
std::shared_ptr<mir::udev::Context> const& udev,
mo::ProgramOption const&) -> std::vector<mg::SupportedDevice>
mo::Option const&) -> std::vector<mg::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);

Expand Down
4 changes: 2 additions & 2 deletions src/platforms/gbm-kms/server/kms/platform_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MinimalGLConfig : public mir::graphics::GLConfig
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const& console,
std::shared_ptr<mir::udev::Context> const& udev,
mir::options::ProgramOption const& options) -> std::vector<mir::graphics::SupportedDevice>
mir::options::Option const& options) -> std::vector<mir::graphics::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);

Expand Down Expand Up @@ -310,7 +310,7 @@ auto probe_rendering_platform(
std::span<std::shared_ptr<mg::DisplayPlatform>> const& platforms,
mir::ConsoleServices&,
std::shared_ptr<mir::udev::Context> const& udev,
mir::options::ProgramOption const& options) -> std::vector<mir::graphics::SupportedDevice>
mir::options::Option const& options) -> std::vector<mir::graphics::SupportedDevice>
{
mir::assert_entry_point_signature<mg::RenderProbe>(&probe_rendering_platform);

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/renderer-generic-egl/platform_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ auto probe_rendering_platform(
std::span<std::shared_ptr<mg::DisplayPlatform>> const& displays,
mir::ConsoleServices&,
std::shared_ptr<mir::udev::Context> const&,
mo::ProgramOption const&) -> std::vector<mg::SupportedDevice>
mo::Option const&) -> std::vector<mg::SupportedDevice>
{
mir::assert_entry_point_signature<mg::RenderProbe>(&probe_rendering_platform);

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/virtual/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void add_graphics_platform_options(boost::program_options::options_description&
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const&,
std::shared_ptr<mir::udev::Context> const&,
mo::ProgramOption const& options) -> std::vector<mg::SupportedDevice>
mo::Option const& options) -> std::vector<mg::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);
std::vector<mg::SupportedDevice> result;
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/wayland/platform_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void add_graphics_platform_options(boost::program_options::options_description&
}

auto probe_graphics_platform(
mo::ProgramOption const& options) -> std::optional<mg::SupportedDevice>
mo::Option const& options) -> std::optional<mg::SupportedDevice>
{
if (mpw::connection_options_supplied(options))
{
Expand All @@ -75,7 +75,7 @@ auto probe_graphics_platform(
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const&,
std::shared_ptr<mir::udev::Context> const&,
mo::ProgramOption const& options) -> std::vector<mg::SupportedDevice>
mo::Option const& options) -> std::vector<mg::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);
if (auto probe = probe_graphics_platform(options))
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/x11/graphics/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ auto probe_graphics_platform() -> std::optional<mg::SupportedDevice>
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const&) -> std::vector<mg::SupportedDevice>
mir::options::Option const&) -> std::vector<mg::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);
if (auto probe = probe_graphics_platform())
Expand Down
4 changes: 2 additions & 2 deletions src/server/graphics/default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() ->
graphics::probe_rendering_module(
display_targets,
*platform,
dynamic_cast<mir::options::ProgramOption&>(*the_options()),
*the_options(),
the_console_services());

bool found_supported_device{false};
Expand All @@ -261,7 +261,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() ->
}
else
{
platform_modules = mir::graphics::rendering_modules_for_device(platforms, display_targets, dynamic_cast<mir::options::ProgramOption&>(*the_options()), the_console_services());
platform_modules = mir::graphics::rendering_modules_for_device(platforms, display_targets, *the_options(), the_console_services());
}

for (auto const& [device, platform]: platform_modules)
Expand Down
14 changes: 7 additions & 7 deletions src/server/graphics/platform_probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ auto probe_module(

auto mir::graphics::probe_display_module(
SharedLibrary const& module,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console) -> std::vector<SupportedDevice>
{
return probe_module(
Expand All @@ -102,7 +102,7 @@ auto mir::graphics::probe_display_module(
auto mir::graphics::probe_rendering_module(
std::span<std::shared_ptr<mg::DisplayPlatform>> const& platforms,
SharedLibrary const& module,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console) -> std::vector<SupportedDevice>
{
return probe_module(
Expand Down Expand Up @@ -269,7 +269,7 @@ auto mg::modules_for_device(

auto mir::graphics::display_modules_for_device(
std::vector<std::shared_ptr<SharedLibrary>> const& modules,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console) -> std::vector<std::pair<SupportedDevice, std::shared_ptr<SharedLibrary>>>
{
return modules_for_device(
Expand All @@ -284,7 +284,7 @@ auto mir::graphics::display_modules_for_device(
auto mir::graphics::rendering_modules_for_device(
std::vector<std::shared_ptr<SharedLibrary>> const& modules,
std::span<std::shared_ptr<DisplayPlatform>> const& platforms,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console) -> std::vector<std::pair<SupportedDevice, std::shared_ptr<SharedLibrary>>>
{
return modules_for_device(
Expand Down Expand Up @@ -467,7 +467,7 @@ auto mg::select_display_modules(
auto supported_devices =
graphics::probe_display_module(
*platform,
dynamic_cast<mir::options::ProgramOption const&>(options),
options,
console);

bool found_supported_device{false};
Expand Down Expand Up @@ -513,13 +513,13 @@ auto mg::select_display_modules(
// We don't need to probe the virtual platform; that is done separately below.
platforms.erase(virtual_platform_pos);
}
platform_modules = display_modules_for_device(platforms, dynamic_cast<mir::options::ProgramOption const&>(options), console);
platform_modules = display_modules_for_device(platforms, options, console);
}

if (virtual_platform)
{
auto virtual_probe = probe_display_module(
*virtual_platform, dynamic_cast<mo::ProgramOption const&>(options), console);
*virtual_platform, options, console);
if (virtual_probe.size() && virtual_probe.front().support_level >= mg::probe::supported)
{
platform_modules.emplace_back(std::move(virtual_probe.front()), std::move(virtual_platform));
Expand Down
8 changes: 4 additions & 4 deletions src/server/graphics/platform_probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ auto modules_for_device(

auto probe_display_module(
SharedLibrary const& module,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console) -> std::vector<SupportedDevice>;

auto probe_rendering_module(
std::span<std::shared_ptr<DisplayPlatform>> const& platforms,
SharedLibrary const& module,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console) -> std::vector<SupportedDevice>;

auto display_modules_for_device(
std::vector<std::shared_ptr<SharedLibrary>> const& modules,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console)
-> std::vector<std::pair<SupportedDevice, std::shared_ptr<SharedLibrary>>>;

auto rendering_modules_for_device(
std::vector<std::shared_ptr<SharedLibrary>> const& modules,
std::span<std::shared_ptr<DisplayPlatform>> const& platforms,
options::ProgramOption const& options,
options::Option const& options,
std::shared_ptr<ConsoleServices> const& console)
-> std::vector<std::pair<SupportedDevice, std::shared_ptr<SharedLibrary>>>;

Expand Down
8 changes: 2 additions & 6 deletions tests/mir_test_framework/platform_graphics_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ namespace mg = mir::graphics;

namespace mir
{
namespace options
{
class ProgramOption;
}
}

auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const&) -> std::vector<mir::graphics::SupportedDevice>
mir::options::Option const&) -> std::vector<mir::graphics::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);
std::vector<mg::SupportedDevice> result;
Expand All @@ -49,7 +45,7 @@ auto probe_rendering_platform(
std::span<std::shared_ptr<mg::DisplayPlatform>> const&,
mir::ConsoleServices&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const&) -> std::vector<mir::graphics::SupportedDevice>
mir::options::Option const&) -> std::vector<mir::graphics::SupportedDevice>
{
mir::assert_entry_point_signature<mg::RenderProbe>(&probe_rendering_platform);
std::vector<mg::SupportedDevice> result;
Expand Down
4 changes: 2 additions & 2 deletions tests/mir_test_framework/platform_graphics_throw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ExceptionThrowingPlatform : public mg::DisplayPlatform, public mg::Renderi
auto probe_display_platform(
std::shared_ptr<mir::ConsoleServices> const&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const&) -> std::vector<mir::graphics::SupportedDevice>
mir::options::Option const&) -> std::vector<mir::graphics::SupportedDevice>
{
mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_display_platform);
std::vector<mg::SupportedDevice> result;
Expand All @@ -149,7 +149,7 @@ auto probe_rendering_platform(
std::span<std::shared_ptr<mg::DisplayPlatform>> const&,
mir::ConsoleServices&,
std::shared_ptr<mir::udev::Context> const&,
mir::options::ProgramOption const&) -> std::vector<mir::graphics::SupportedDevice>
mir::options::Option const&) -> std::vector<mir::graphics::SupportedDevice>
{
mir::assert_entry_point_signature<mg::RenderProbe>(&probe_rendering_platform);
std::vector<mg::SupportedDevice> result;
Expand Down

0 comments on commit 13c01c6

Please sign in to comment.