Skip to content

Commit

Permalink
Extract rendering strategy for decorations (#3706)
Browse files Browse the repository at this point in the history
This extracts the generic rendering integration from the default
"strategy" for rendering
  • Loading branch information
AlanGriffiths authored Dec 20, 2024
2 parents 617948e + 7717e99 commit 304c5b4
Show file tree
Hide file tree
Showing 6 changed files with 911 additions and 728 deletions.
2 changes: 1 addition & 1 deletion src/server/shell/decoration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(
basic_decoration.h basic_decoration.cpp
window.h window.cpp
input.h input.cpp
renderer.h renderer.cpp
renderer.h renderer.cpp renderer_default.cpp
)

add_library(
Expand Down
14 changes: 8 additions & 6 deletions src/server/shell/decoration/basic_decoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class msd::BasicDecoration::BufferStreams
std::shared_ptr<scene::Session> const session;

public:
BufferStreams(std::shared_ptr<scene::Session> const& session);
BufferStreams(std::shared_ptr<scene::Session> const& session, MirPixelFormat buffer_format);
~BufferStreams();

auto create_buffer_stream() -> std::shared_ptr<mc::BufferStream>;
Expand All @@ -125,14 +125,16 @@ class msd::BasicDecoration::BufferStreams
BufferStreams(BufferStreams const&) = delete;
BufferStreams& operator=(BufferStreams const&) = delete;

MirPixelFormat const buffer_format;
};

msd::BasicDecoration::BufferStreams::BufferStreams(std::shared_ptr<scene::Session> const& session)
msd::BasicDecoration::BufferStreams::BufferStreams(std::shared_ptr<scene::Session> const& session, MirPixelFormat buffer_format)
: session{session},
titlebar{create_buffer_stream()},
left_border{create_buffer_stream()},
right_border{create_buffer_stream()},
bottom_border{create_buffer_stream()}
bottom_border{create_buffer_stream()},
buffer_format{buffer_format}
{
}

Expand Down Expand Up @@ -165,8 +167,8 @@ msd::BasicDecoration::BasicDecoration(
buffer_allocator{buffer_allocator},
cursor_images{cursor_images},
session{window_surface->session().lock()},
buffer_streams{std::make_unique<BufferStreams>(session)},
renderer{std::make_unique<Renderer>(buffer_allocator, static_geometry)},
buffer_streams{std::make_unique<BufferStreams>(session, static_geometry->buffer_format)},
renderer{std::make_unique<Renderer>(buffer_allocator, RendererStrategy::default_strategy(static_geometry))},
window_surface{window_surface},
decoration_surface{create_surface()},
window_state{new_window_state()},
Expand Down Expand Up @@ -293,7 +295,7 @@ auto msd::BasicDecoration::create_surface() const -> std::shared_ptr<scene::Surf
params.streams = {{
session->create_buffer_stream(mg::BufferProperties{
geom::Size{1, 1},
buffer_format,
static_geometry->buffer_format,
mg::BufferUsage::software}),
{},
}};
Expand Down
Loading

0 comments on commit 304c5b4

Please sign in to comment.