Commit c4dee098 authored by abmyii's avatar abmyii
Browse files

Invert read pixels using an intermediate pixel buffer

parent 3400731e
Pipeline #215397479 passed with stage
in 3 minutes and 13 seconds
Mouse scroll wheel
Rotatation support
Tilde (~) appearing as grave (¬)
Tilde (~) appearing as grave (¬) - keysym -> scancode conversion needs to be fully refactored
......@@ -85,12 +85,22 @@ void shutdown(int)
running = 0;
}
void read_pixels(GLenum format, mir::geometry::Size const& size, void* buffer)
void read_pixels(GLenum format, mir::geometry::Size const& size, std::vector<char> *fb)
{
auto width = size.width.as_uint32_t();
auto height = size.height.as_uint32_t();
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, buffer);
// https://stackoverflow.com/a/60696921
std::vector<char> pixels(4 * width * height);
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels.data());
for(int line = 0; line != height/2; ++line) {
std::swap_ranges(
pixels.begin() + 4 * width * line,
pixels.begin() + 4 * width * (line+1),
pixels.begin() + 4 * width * (height-line-1));
}
fb->assign(pixels.begin(), pixels.end());
#ifdef DEBUG
unsigned int sum = 0;
unsigned int *pui = (unsigned int *) buffer;
......@@ -549,7 +559,7 @@ void do_screencast(EGLSetup const& egl_setup,
{
auto time_point = std::chrono::steady_clock::now() + capture_period;
read_pixels(format, size, frame_data.data());
read_pixels(format, size, &frame_data);
auto write_out_future = std::async(
std::launch::async,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment