Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(EXPERIMENTAL) Provides a "transitional" boot from plymouth to mir #3033

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5ae949c
Providing a smooth_boot option to the compositor via mirAL
mattkae Aug 29, 2023
0c4fd06
Providing the display creation function with the buffer allocator and…
mattkae Aug 29, 2023
d41ab7e
Fix for a circular dependency that was unnecessary
mattkae Aug 30, 2023
8447a8b
A compiling and somewhat working buffer creation
mattkae Aug 30, 2023
59505eb
Required to provide the FD, my bad
mattkae Aug 30, 2023
f9fa2d5
Mapping the contents of the screen in a buffer-agnostic way
mattkae Aug 31, 2023
071f42b
Providing the Display with the initial buffer to create the correct b…
mattkae Aug 31, 2023
eed2ecd
We are not building, but we are on the verge of displaying
mattkae Aug 31, 2023
616e6c5
A bit of a tangled mess now, but the_initial_render is ready
mattkae Sep 1, 2023
9de256b
Needs a good refactor, but we are gathering the initial renderables
mattkae Sep 1, 2023
c1a588c
We can show the boot screen, but we need a ton of cleanup
mattkae Sep 1, 2023
5a80e07
Removing some unnecessary scene plumbing
mattkae Sep 1, 2023
63c6c73
First pass at removing unnecessaries
mattkae Sep 1, 2023
c403e9c
No longer holding the pointer to the InitialRender
mattkae Sep 1, 2023
651b1a2
Added a n initial render manager that will crush the buffer after its…
mattkae Sep 1, 2023
a93b6c9
Cleaing the initial renders after 5 seconds, woohoo!
mattkae Sep 1, 2023
e4c6278
Using the executor to schedule buffer add/removes
mattkae Sep 1, 2023
9dadc7b
Fixing a bad reference capture and null checking before we do risky t…
mattkae Sep 5, 2023
29e6ab7
Removing a poor console log
mattkae Sep 5, 2023
b4928f9
Intermediate commit for an overhaul of the initial render manager
mattkae Sep 6, 2023
d95549e
Fixing a few broken things with the implementation and robustifying t…
mattkae Sep 6, 2023
9016b3b
Merge branch 'flickerless-no-crtc' into flickerless-boot
mattkae Sep 6, 2023
3203d20
Merge branch 'flickerless-no-crtc' into flickerless-boot
mattkae Sep 6, 2023
d3d79e7
Merge branch 'flickerless-no-crtc' into flickerless-boot
mattkae Sep 7, 2023
347189f
Reverting bad commits in the throw paltform
mattkae Sep 7, 2023
3b274f0
Fix for something that I previously removed
mattkae Sep 7, 2023
1372f86
Updating symbols files
mattkae Sep 7, 2023
751330b
Highly experimental fading of the previous buffer
mattkae Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions debian/libmiral6.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,11 @@ libmiral.so.6 libmiral6 #MINVER#
(c++)"vtable for miral::MinimalWindowManager@MIRAL_4.0" 4.0.0
(c++)"vtable for miral::WindowManagementPolicy@MIRAL_4.0" 4.0.0
MIRAL_4.1@MIRAL_4.1 4.1.0
(c++)"miral::SmoothBootSupport::SmoothBootSupport()@MIRAL_4.1" 4.1.0
(c++)"miral::SmoothBootSupport::SmoothBootSupport(miral::SmoothBootSupport const&)@MIRAL_4.1" 4.1.0
(c++)"miral::SmoothBootSupport::SmoothBootSupport(unsigned int)@MIRAL_4.1" 4.1.0
(c++)"miral::SmoothBootSupport::operator()(mir::Server&) const@MIRAL_4.1" 4.1.0
(c++)"miral::SmoothBootSupport::operator=(miral::SmoothBootSupport const&)@MIRAL_4.1" 4.1.0
(c++)"miral::SmoothBootSupport::~SmoothBootSupport()@MIRAL_4.1" 4.1.0
(c++)"miral::WaylandExtensions::zwp_input_method_v1@MIRAL_4.1" 4.1.0
(c++)"miral::WaylandExtensions::zwp_input_panel_v1@MIRAL_4.1" 4.1.0
47 changes: 47 additions & 0 deletions include/miral/miral/smooth_boot_support.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

#ifndef MIRAL_SMOOTH_BOOT_SUPPORT_H
#define MIRAL_SMOOTH_BOOT_SUPPORT_H

#include <memory>

namespace mir { class Server; }

namespace miral
{

/// Provides a smooth boot transition from the prior screen (such as the plymouth
/// splash or any other DRM-based display) to the compositor.
class SmoothBootSupport
{
public:
void operator()(mir::Server& server) const;

explicit SmoothBootSupport();
explicit SmoothBootSupport(uint32_t behavior);
~SmoothBootSupport();
SmoothBootSupport(SmoothBootSupport const&);
auto operator=(SmoothBootSupport const&) -> SmoothBootSupport&;

private:
struct Self;
std::shared_ptr<Self> self;
};

}

#endif
9 changes: 8 additions & 1 deletion include/platform/mir/graphics/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define MIR_GRAPHICS_DISPLAY_H_

#include "mir/graphics/frame.h"
#include "mir/renderer/gl/context_source.h"
#include <memory>
#include <functional>
#include <chrono>
Expand All @@ -33,6 +32,7 @@ class DisplayBuffer;
class DisplayConfiguration;
class Cursor;
class EventHandlerRegister;
class InitialRender;

typedef std::function<bool()> DisplayPauseHandler;
typedef std::function<bool()> DisplayResumeHandler;
Expand Down Expand Up @@ -165,6 +165,13 @@ class Display
*/
virtual std::shared_ptr<Cursor> create_hardware_cursor() = 0;

/**
* Creates an initial render for this Display. Used in instances where it is desirable to capture the
* previous buffer (e.g. for smooth transitions between plymouth and the compositor).
* @return the initial render
*/
virtual std::shared_ptr<InitialRender> create_initial_render() = 0;

Display() = default;
virtual ~Display() = default;
private:
Expand Down
63 changes: 63 additions & 0 deletions include/platform/mir/graphics/initial_render.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright © Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MIR_GRAPHICS_INITIAL_RENDER_H
#define MIR_GRAPHICS_INITIAL_RENDER_H

#include <vector>
#include <memory>
#include <functional>

namespace mir
{
namespace graphics
{

class Renderable;

enum class SmoothSupportBehavior : uint32_t
{
none,
fade,
count
};

/// A Display is able to specify an initial render that it wants to show to the user
/// (such as the plymouth buffer for a fade-in effect from startup splash to compostior).
class InitialRender
{
public:
virtual ~InitialRender() = default;
virtual void for_each_renderable(std::function<void(std::shared_ptr<Renderable> const&)>) const = 0;

protected:
InitialRender() = default;
InitialRender(InitialRender const&) = delete;
InitialRender& operator=(InitialRender const&) = delete;
};

/// Manages the lifetime of InitialRender objects
class InitialRenderManager
{
public:
virtual ~InitialRenderManager() = default;
virtual void add_initial_render(std::shared_ptr<InitialRender> const&) = 0;
};

}
}

#endif
7 changes: 5 additions & 2 deletions include/platform/mir/graphics/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <gbm.h>

#include "mir/graphics/drm_formats.h"
#include "mir/graphics/initial_render.h"
#include "mir/module_properties.h"
#include "mir/module_deleter.h"
#include "mir/udev/wrapper.h"
Expand Down Expand Up @@ -173,7 +174,7 @@ class RenderingPlatform
/**
* Creates the buffer allocator subsystem.
*/
virtual UniqueModulePtr<GraphicBufferAllocator> create_buffer_allocator(Display const& output) = 0;
virtual UniqueModulePtr<GraphicBufferAllocator> create_buffer_allocator() = 0;

/**
* Attempt to acquire a platform-specific interface from this RenderingPlatform
Expand Down Expand Up @@ -457,7 +458,9 @@ class DisplayPlatform : public std::enable_shared_from_this<DisplayPlatform>
*/
virtual UniqueModulePtr<Display> create_display(
std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
std::shared_ptr<GLConfig> const& gl_config) = 0;
std::shared_ptr<GLConfig> const& gl_config,
std::shared_ptr<mir::options::Option> const& options,
std::shared_ptr<GraphicBufferAllocator> const& allocator) = 0;

static auto interface_for(std::shared_ptr<DisplayPlatform> platform)
-> std::shared_ptr<DisplayInterfaceProvider>
Expand Down
1 change: 1 addition & 0 deletions include/platform/mir/options/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ extern char const* const null_console;
extern char const* const auto_console;

extern char const* const vt_option_name;
extern char const* const smooth_boot_opt;

class Configuration
{
Expand Down
3 changes: 3 additions & 0 deletions src/include/server/mir/default_server_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class GraphicBufferAllocator;
class Cursor;
class CursorImage;
class GLConfig;
class InitialRenderManager;
}
namespace input
{
Expand Down Expand Up @@ -347,6 +348,7 @@ class DefaultServerConfiguration : public virtual ServerConfiguration
std::shared_ptr<input::DefaultInputDeviceHub> the_default_input_device_hub();
std::shared_ptr<graphics::DisplayConfigurationObserver> the_display_configuration_observer();
std::shared_ptr<input::SeatObserver> the_seat_observer();
std::shared_ptr<graphics::InitialRenderManager> the_initial_render_manager();

virtual std::shared_ptr<scene::MediatingDisplayChanger> the_mediating_display_changer();

Expand Down Expand Up @@ -429,6 +431,7 @@ class DefaultServerConfiguration : public virtual ServerConfiguration
CachedPtr<cookie::Authority> cookie_authority;
CachedPtr<input::KeyMapper> key_mapper;
std::shared_ptr<ConsoleServices> console_services;
CachedPtr<graphics::InitialRenderManager> initial_render_manager;

private:
std::shared_ptr<options::Configuration> const configuration_options;
Expand Down
75 changes: 75 additions & 0 deletions src/include/server/mir/graphics/default_initial_render_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

#ifndef MIR_DEFAULT_INITIAL_RENDER_MANAGER_H
#define MIR_DEFAULT_INITIAL_RENDER_MANAGER_H

#include "mir/graphics/initial_render.h"

#include <memory>

namespace mir
{
class Executor;

namespace options
{
class Option;
}

namespace time
{
class Clock;
class Alarm;
class AlarmFactory;
}

namespace input
{
class Scene;
}

namespace graphics
{

class DefaultInitialRenderManager : public InitialRenderManager
{
public:
DefaultInitialRenderManager(
std::shared_ptr<options::Option> const& options,
std::shared_ptr<Executor> const& scene_executor,
std::shared_ptr<time::Clock> const& clock,
std::shared_ptr<time::AlarmFactory> const& alarm_factory,
std::shared_ptr<input::Scene> const& scene);
~DefaultInitialRenderManager();
void add_initial_render(std::shared_ptr<InitialRender> const&) override;

private:
void remove_renderables();
SmoothSupportBehavior behavior;
std::shared_ptr<Executor> const scene_executor;
std::shared_ptr<time::Clock> const clock;
std::shared_ptr<input::Scene> const scene;
std::vector<std::shared_ptr<Renderable>> renderable_list;
std::shared_ptr<time::AlarmFactory> const alarm_factory;
std::unique_ptr<time::Alarm> const alarm;
};

}
}


#endif //MIR_DEFAULT_INITIAL_RENDER_MANAGER_H
1 change: 1 addition & 0 deletions src/miral/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ add_library(miral SHARED
${miral_include}/miral/lambda_as_function.h
x11_support.cpp ${miral_include}/miral/x11_support.h
zone.cpp ${miral_include}/miral/zone.h
smooth_boot_support.cpp ${miral_include}/miral/smooth_boot_support.h
)

#include <mir/udev/wrapper.h>
Expand Down
79 changes: 79 additions & 0 deletions src/miral/smooth_boot_support.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

#include "miral/smooth_boot_support.h"

#include <mir/server.h>
#include <mir/options/configuration.h>
#include <mir/graphics/display.h>
#include <mir/graphics/display_buffer.h>
#include <mir/graphics/initial_render.h>
#include <stdexcept>

namespace mg = mir::graphics;
namespace mo = mir::options;

namespace
{
const char* to_option(mg::SmoothSupportBehavior behavior)
{
switch (behavior)
{
case mg::SmoothSupportBehavior::none:
return "none";
case mg::SmoothSupportBehavior::fade:
return "fade";
default:
return nullptr;
}
}
}

struct miral::SmoothBootSupport::Self
{
mg::SmoothSupportBehavior behavior = mg::SmoothSupportBehavior::fade;
};

miral::SmoothBootSupport::SmoothBootSupport(uint32_t behavior)
: self{std::make_shared<Self>()}
{
if (behavior >= static_cast<uint32_t>(mg::SmoothSupportBehavior::count))
BOOST_THROW_EXCEPTION(std::invalid_argument("Unsupported smooth boot behavior"));

self->behavior = static_cast<mg::SmoothSupportBehavior>(behavior);
}

miral::SmoothBootSupport::SmoothBootSupport()
: self{std::make_shared<Self>()}
{
}

miral::SmoothBootSupport::~SmoothBootSupport() = default;
miral::SmoothBootSupport::SmoothBootSupport(SmoothBootSupport const& other) = default;
auto miral::SmoothBootSupport::operator=(miral::SmoothBootSupport const& other) -> SmoothBootSupport& = default;

void miral::SmoothBootSupport::operator()(mir::Server &server) const
{
auto option = to_option(self->behavior);
if (!option)
BOOST_THROW_EXCEPTION(std::logic_error("Undefined smooth boot behavior option"));

server.add_configuration_option(
mo::smooth_boot_opt,
"When set, provides a transition from the previous screen to the compositor",
option
);
}
5 changes: 5 additions & 0 deletions src/miral/symbols.map
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ global:
extern "C++" {
miral::WaylandExtensions::zwp_input_method_v1*;
miral::WaylandExtensions::zwp_input_panel_v1*;
miral::SmoothBootSupport::?SmoothBootSupport*;
miral::SmoothBootSupport::SmoothBootSupport*;
miral::SmoothBootSupport::operator*;
typeinfo?for?miral::SmoothBootSupport;
vtable?for?miral::SmoothBootSupport;
};

} MIRAL_4.0;
Expand Down
1 change: 0 additions & 1 deletion src/platform/graphics/cpu_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ auto mrs::alloc_buffer_with_content(
MirPixelFormat src_format) -> std::shared_ptr<graphics::Buffer>
{
auto const buffer = allocator.alloc_software_buffer(size, src_format);

auto mapping = as_write_mappable_buffer(buffer)->map_writeable();
if (mapping->stride() == src_stride)
{
Expand Down
Loading
Loading