Skip to content

Commit c1a588c

Browse files
committed
We can show the boot screen, but we need a ton of cleanup
1 parent 9de256b commit c1a588c

File tree

9 files changed

+69
-50
lines changed

9 files changed

+69
-50
lines changed

src/platform/graphics/cpu_buffers.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ auto mrs::alloc_buffer_with_content(
192192
MirPixelFormat src_format) -> std::shared_ptr<graphics::Buffer>
193193
{
194194
auto const buffer = allocator.alloc_software_buffer(size, src_format);
195-
196195
auto mapping = as_write_mappable_buffer(buffer)->map_writeable();
197196
if (mapping->stride() == src_stride)
198197
{

src/platforms/common/server/shm_buffer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ mgc::ShmBuffer::ShmBuffer(
9999
pixel_format_{format},
100100
egl_delegate{std::move(egl_delegate)}
101101
{
102+
mir::log_info("Constructed A");
102103
}
103104

104105
mgc::MemoryBackedShmBuffer::MemoryBackedShmBuffer(
@@ -109,6 +110,7 @@ mgc::MemoryBackedShmBuffer::MemoryBackedShmBuffer(
109110
stride_{MIR_BYTES_PER_PIXEL(pixel_format) * size.width.as_uint32_t()},
110111
pixels{new unsigned char[stride_.as_int() * size.height.as_int()]}
111112
{
113+
mir::log_info("Constructed B");
112114
}
113115

114116
mgc::ShmBuffer::~ShmBuffer() noexcept

src/platforms/gbm-kms/server/buffer_allocator.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@ mgg::BufferAllocator::BufferAllocator(EGLDisplay dpy, EGLContext share_with)
160160
std::shared_ptr<mg::Buffer> mgg::BufferAllocator::alloc_software_buffer(
161161
geom::Size size, MirPixelFormat format)
162162
{
163+
mir::log_info("Before format");
163164
if (!mgc::MemoryBackedShmBuffer::supports(format))
164165
{
165166
BOOST_THROW_EXCEPTION(
166167
std::runtime_error(
167168
"Trying to create SHM buffer with unsupported pixel format"));
168169
}
169170

171+
mir::log_info("After format");
170172
return std::make_shared<mgc::MemoryBackedShmBuffer>(size, format, egl_delegate);
171173
}
172174

src/platforms/gbm-kms/server/kms/display.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,33 @@ auto mgg::Display::create_hardware_cursor() -> std::shared_ptr<graphics::Cursor>
313313

314314
std::shared_ptr<mg::InitialRender> mgg::Display::create_initial_render()
315315
{
316-
return nullptr;
316+
class GbmKmsInitialRender : public mg::InitialRender
317+
{
318+
public:
319+
void add_renderable(std::shared_ptr<Renderable> renderable)
320+
{
321+
if (renderable == nullptr)
322+
return;
323+
324+
renderables.push_back(renderable);
325+
}
326+
327+
auto get_renderables() const -> std::vector<std::shared_ptr<Renderable>> override
328+
{
329+
return renderables;
330+
}
331+
332+
private:
333+
std::vector<std::shared_ptr<Renderable>> renderables;
334+
};
335+
336+
auto initial_render = std::make_shared<GbmKmsInitialRender>();
337+
for (auto const& buffer : display_buffers)
338+
{
339+
initial_render->add_renderable(buffer->copy_to_buffer());
340+
}
341+
342+
return initial_render;
317343
}
318344

319345
void mgg::Display::clear_connected_unused_outputs()

src/platforms/gbm-kms/server/kms/display_buffer.cpp

+24-29
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct SmoothTransitionRenderable : public mg::Renderable
7272
auto screen_position() const -> geom::Rectangle override
7373
{
7474
return {
75-
{-size.width.as_int() / 2, -size.height.as_value() / 2},
75+
{0, 0},
7676
{size.width.as_int(), size.height.as_int()}
7777
};
7878
}
@@ -110,7 +110,7 @@ mgg::DisplayBuffer::DisplayBuffer(
110110
std::vector<std::shared_ptr<KMSOutput>> const& outputs,
111111
geom::Rectangle const& area,
112112
glm::mat2 const& transformation,
113-
std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
113+
std::shared_ptr<graphics::GraphicBufferAllocator> const& allocator,
114114
std::shared_ptr<input::Scene> const&,
115115
bool smooth_transition)
116116
: provider{std::move(provider)},
@@ -119,7 +119,9 @@ mgg::DisplayBuffer::DisplayBuffer(
119119
area(area),
120120
transform{transformation},
121121
needs_set_crtc{false},
122-
page_flips_pending{false}
122+
page_flips_pending{false},
123+
allocator{allocator},
124+
smooth_transition{smooth_transition}
123125
{
124126
listener->report_successful_setup_of_native_resources();
125127

@@ -138,22 +140,6 @@ mgg::DisplayBuffer::DisplayBuffer(
138140
output->set_crtc(*visible_fb);
139141
}
140142
}
141-
else
142-
{
143-
auto output = outputs[0];
144-
auto mapping = output->map_content();
145-
146-
if (mapping)
147-
{
148-
auto pixel_format = mapping->get_pixel_format().as_mir_format();
149-
auto buffer = mir::renderer::software::alloc_buffer_with_content(
150-
*buffer_allocator,
151-
reinterpret_cast<const unsigned char *>(mapping->get_data()),
152-
mapping->get_size(),
153-
mapping->get_stride(),
154-
pixel_format.value());
155-
}
156-
}
157143

158144
listener->report_successful_drm_mode_set_crtc_on_construction();
159145
listener->report_successful_display_construction();
@@ -391,9 +377,11 @@ void mir::graphics::gbm::DisplayBuffer::set_next_image(std::unique_ptr<Framebuff
391377
}
392378
}
393379

394-
auto mgg::DisplayBuffer::copy_to_buffer(std::shared_ptr<graphics::common::EGLContextExecutor>& egl_delegate) const
395-
-> std::unique_ptr<common::MemoryBackedShmBuffer>
380+
auto mgg::DisplayBuffer::copy_to_buffer() const -> std::unique_ptr<mg::Renderable>
396381
{
382+
if (!smooth_transition)
383+
return nullptr;
384+
397385
if (outputs.empty())
398386
{
399387
mir::log_error("Unable to copy the contents of the buffer: No outputs available");
@@ -402,14 +390,21 @@ auto mgg::DisplayBuffer::copy_to_buffer(std::shared_ptr<graphics::common::EGLCon
402390

403391
auto output = outputs[0];
404392
auto mapping = output->map_content();
393+
405394
if (!mapping)
406395
return nullptr;
407396

408-
auto const pixel_format = mapping->get_pixel_format().as_mir_format();
409-
auto buffer = new common::MemoryBackedShmBuffer(
410-
mapping->get_size(),
411-
pixel_format.value(),
412-
egl_delegate);
413-
(void)buffer;
414-
return nullptr;
415-
}
397+
auto pixel_format = mapping->get_pixel_format().as_mir_format();
398+
auto data = mapping->get_data();
399+
auto size = mapping->get_size();
400+
auto stride = mapping->get_stride();
401+
auto format = pixel_format.value();
402+
403+
auto buffer = mir::renderer::software::alloc_buffer_with_content(
404+
*allocator,
405+
data,
406+
size,
407+
stride,
408+
format);
409+
return std::make_unique<SmoothTransitionRenderable>(buffer, mapping->get_size());
410+
}

src/platforms/gbm-kms/server/kms/display_buffer.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ class DisplayBuffer : public graphics::DisplayBuffer,
9797
/// Creates a Buffer from the current contents of the first output.
9898
/// TODO: What do we do about the other outputs?
9999
/// \returns A buffer
100-
auto copy_to_buffer(std::shared_ptr<graphics::common::EGLContextExecutor>&) const
101-
-> std::unique_ptr<common::MemoryBackedShmBuffer>;
100+
auto copy_to_buffer() const -> std::unique_ptr<graphics::Renderable>;
102101
private:
103102
bool schedule_page_flip(FBHandle const& bufobj);
104103
void set_crtc(FBHandle const&);
@@ -122,6 +121,8 @@ class DisplayBuffer : public graphics::DisplayBuffer,
122121
std::atomic<bool> needs_set_crtc;
123122
std::chrono::milliseconds recommend_sleep{0};
124123
bool page_flips_pending;
124+
std::shared_ptr<graphics::GraphicBufferAllocator> const allocator;
125+
bool smooth_transition;
125126
};
126127

127128
}

src/platforms/gbm-kms/server/kms/kms_output.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class KMSOutputContentMap
4848
virtual auto get_size() -> mir::geometry::Size const& = 0;
4949
virtual auto get_stride() -> mir::geometry::Stride const& = 0;
5050
virtual auto get_pixel_format() -> mir::graphics::DRMFormat const& = 0;
51-
virtual auto get_data() -> const char* = 0;
51+
virtual auto get_data() -> const unsigned char* = 0;
5252
};
5353

5454
class KMSOutput

src/platforms/gbm-kms/server/kms/real_kms_output.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class RealKMSOutputContentMap : public mgg::KMSOutputContentMap
4646
mir::geometry::Size size,
4747
mir::geometry::Stride stride,
4848
uint32_t pixel_format,
49-
char* data)
49+
unsigned char* data)
5050
: mapping_size{mapping_size},
5151
size{size},
5252
stride{stride},
@@ -76,7 +76,7 @@ class RealKMSOutputContentMap : public mgg::KMSOutputContentMap
7676
return pixel_format;
7777
}
7878

79-
virtual auto get_data() -> const char* override
79+
virtual auto get_data() -> const unsigned char* override
8080
{
8181
return data;
8282
}
@@ -107,7 +107,7 @@ class RealKMSOutputContentMap : public mgg::KMSOutputContentMap
107107

108108
// Establish a memory map.
109109
uint32_t size = height * stride;
110-
auto map = static_cast<char *>(mmap(
110+
auto map = static_cast<unsigned char *>(mmap(
111111
0,
112112
size,
113113
PROT_READ,
@@ -133,7 +133,7 @@ class RealKMSOutputContentMap : public mgg::KMSOutputContentMap
133133
mir::geometry::Size size;
134134
mir::geometry::Stride stride;
135135
mir::graphics::DRMFormat pixel_format;
136-
char* data = nullptr;
136+
unsigned char* data = nullptr;
137137
};
138138
}
139139

@@ -732,6 +732,7 @@ std::shared_ptr<mgg::KMSOutputContentMap> mgg::RealKMSOutput::map_content() cons
732732
if (!map)
733733
continue;
734734

735+
mir::log_info("Got one!");
735736
return map;
736737
}
737738

src/server/graphics/default_configuration.cpp

+5-12
Original file line numberDiff line numberDiff line change
@@ -507,23 +507,16 @@ mir::DefaultServerConfiguration::the_initial_render(std::shared_ptr<mg::Display>
507507
return initial_render(
508508
[display = in_display, input_scene = the_input_scene()]
509509
{
510-
class NoInitialRender : public mg::InitialRender
510+
auto initial = display->create_initial_render();
511+
if (initial)
511512
{
512-
virtual auto get_renderables() const -> std::vector<std::shared_ptr<mg::Renderable>> override
513+
for (auto const& renderable : initial->get_renderables())
513514
{
514-
return {};
515+
input_scene->add_input_visualization(renderable);
515516
}
516-
};
517-
518-
auto initial = display->create_initial_render();
519-
if (!initial)
520-
initial = std::make_shared<NoInitialRender>();
521-
522-
for (auto const& renderable : initial->get_renderables())
523-
{
524-
input_scene->add_input_visualization(renderable);
525517
}
526518

519+
527520
return initial;
528521
});
529522
}

0 commit comments

Comments
 (0)