Commit f08bb558 authored by abmyii's avatar abmyii
Browse files

Implement landscape mode completely

parent 03be5f8d
Pipeline #216294783 passed with stage
in 2 minutes and 58 seconds
......@@ -73,6 +73,8 @@ thread_local int dummy_tls[2];
struct libevdev *dev;
struct libevdev_uinput *uidev;
int maxx, maxy;
bool landscape = false;
float scale_factor;
bool lmb;
......@@ -91,18 +93,26 @@ void read_pixels(int bpp, GLenum format, mir::geometry::Size const& size, std::v
auto height = size.height.as_uint32_t();
std::vector<char> pixels(bpp * width * height);
std::vector<char> rotated(bpp * height * width);
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels.data());
for (int x = width*bpp; x > 0; x -= bpp) {
for (int y = 0; y < height; y++) {
int offset = (width * bpp * y) + x;
std::vector<char> pixel(pixels.begin()+offset-bpp, pixels.begin()+offset);
rotated.insert(rotated.end(), pixel.begin(), pixel.end());
}
}
// Rotate to landscape
if (landscape) {
/** Starts from the last column and moves back reading each vertically and writing it horizontally **/
int i = 0;
for (int x = width*bpp; x > 0; x -= bpp) {
for (int y = 0; y < height; y++) {
int offset = (width * bpp * y) + x;
fb = pixels;
// Set each of <bpp> pixels (i.e. <offset-3>, <offset-2>, <offset-1> <offset>)
for (int p = 0; p < bpp; p++)
fb[i+p] = pixels[offset-bpp+p];
i += bpp;
}
}
}
else
fb = pixels;
#ifdef DEBUG
unsigned int sum = 0;
unsigned int *pui = (unsigned int *) buffer;
......@@ -482,11 +492,11 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
int left_down = buttonMask & 0x1;
int right_down = buttonMask & 0x4;
int middle_down = buttonMask & 0x2;
/* printf("%d %d %d %d\n", buttonMask, left_down, right_down, right_down >> 2); */
/* libevdev_uinput_write_event(uidev, EV_ABS, ABS_X, x*scale_factor); */
/* libevdev_uinput_write_event(uidev, EV_ABS, ABS_Y, y*scale_factor); */
/* libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); */
if (landscape) {
y = maxy - y;
std::swap(x, y);
}
if (left_down) {
libevdev_uinput_write_event(uidev, EV_KEY, BTN_LEFT, 1);
......@@ -543,8 +553,11 @@ void do_screencast(EGLSetup const& egl_setup,
// vnc server
int bpp=4;
int maxx = size.width.as_uint32_t();
int maxy = size.height.as_uint32_t();
maxx = size.width.as_uint32_t();
maxy = size.height.as_uint32_t();
if (landscape)
std::swap(maxx, maxy);
rfbScreenInfoPtr rfbScreen = rfbGetScreen(NULL,NULL,maxx,maxy,8,3,bpp);
rfbScreen->desktopName = "MIR Screen";
......@@ -651,6 +664,7 @@ try
po::value<std::string>(&socket_filename), "mir server socket filename")
("file,f",
po::value<std::string>(&output_filename), "output filename (default is /tmp/mir_screencast_<w>x<h>.<rgba|bgra>")
("landscape", po::value<bool>(&landscape)->zero_tokens(), "landscape mode - note width and height are automatically swapped")
("size,s",
po::value<std::vector<int>>(&requested_size)->multitoken(),
"screencast size [width height]")
......
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