@@ -72,7 +72,7 @@ struct SmoothTransitionRenderable : public mg::Renderable
72
72
auto screen_position () const -> geom::Rectangle override
73
73
{
74
74
return {
75
- {-size. width . as_int () / 2 , -size. height . as_value () / 2 },
75
+ {0 , 0 },
76
76
{size.width .as_int (), size.height .as_int ()}
77
77
};
78
78
}
@@ -110,7 +110,7 @@ mgg::DisplayBuffer::DisplayBuffer(
110
110
std::vector<std::shared_ptr<KMSOutput>> const & outputs,
111
111
geom::Rectangle const & area,
112
112
glm::mat2 const & transformation,
113
- std::shared_ptr<graphics::GraphicBufferAllocator> const & buffer_allocator ,
113
+ std::shared_ptr<graphics::GraphicBufferAllocator> const & allocator ,
114
114
std::shared_ptr<input::Scene> const &,
115
115
bool smooth_transition)
116
116
: provider{std::move (provider)},
@@ -119,7 +119,9 @@ mgg::DisplayBuffer::DisplayBuffer(
119
119
area(area),
120
120
transform{transformation},
121
121
needs_set_crtc{false },
122
- page_flips_pending{false }
122
+ page_flips_pending{false },
123
+ allocator{allocator},
124
+ smooth_transition{smooth_transition}
123
125
{
124
126
listener->report_successful_setup_of_native_resources ();
125
127
@@ -138,22 +140,6 @@ mgg::DisplayBuffer::DisplayBuffer(
138
140
output->set_crtc (*visible_fb);
139
141
}
140
142
}
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
- }
157
143
158
144
listener->report_successful_drm_mode_set_crtc_on_construction ();
159
145
listener->report_successful_display_construction ();
@@ -391,9 +377,11 @@ void mir::graphics::gbm::DisplayBuffer::set_next_image(std::unique_ptr<Framebuff
391
377
}
392
378
}
393
379
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>
396
381
{
382
+ if (!smooth_transition)
383
+ return nullptr ;
384
+
397
385
if (outputs.empty ())
398
386
{
399
387
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
402
390
403
391
auto output = outputs[0 ];
404
392
auto mapping = output->map_content ();
393
+
405
394
if (!mapping)
406
395
return nullptr ;
407
396
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
+ }
0 commit comments