Skip to content

Commit

Permalink
Wayland: (cursor code) don't assume PixelSource::read() will execute …
Browse files Browse the repository at this point in the history
…the do_with_pixels functor.
  • Loading branch information
AlanGriffiths committed Jan 9, 2020
1 parent 6d43ad0 commit 2d7b97e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/server/frontend_wayland/wl_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ class BufferCursorImage : public mg::CursorImage
auto pixel_source = dynamic_cast<mrs::PixelSource*>(buffer.native_buffer_base());
if (pixel_source)
{
pixel_source->read([&](unsigned char const* buffer_pixels)
size_t const buffer_size_bytes = buffer_size.width.as_int() * buffer_size.height.as_int()
* MIR_BYTES_PER_PIXEL(buffer.pixel_format());
pixels = std::unique_ptr<unsigned char[]>(new unsigned char[buffer_size_bytes]);

pixel_source->read([this, buffer_size_bytes](unsigned char const* buffer_pixels)
{
size_t buffer_size_bytes = buffer_size.width.as_int() * buffer_size.height.as_int()
* MIR_BYTES_PER_PIXEL(buffer.pixel_format());
pixels = std::unique_ptr<unsigned char[]>(
new unsigned char[buffer_size_bytes]
);
memcpy(pixels.get(), buffer_pixels, buffer_size_bytes);
});
}
Expand Down Expand Up @@ -357,7 +356,12 @@ void WlSurfaceCursor::apply_latest_buffer()
auto const cursor_image = std::make_shared<BufferCursorImage>(
*stream->lock_compositor_buffer(this),
hotspot);
surface->set_cursor_image(cursor_image);
if (cursor_image->as_argb_8888())
surface->set_cursor_image(cursor_image);
else
{

}
}
else
{
Expand Down

0 comments on commit 2d7b97e

Please sign in to comment.