{"id":"dpxswu","deleted":false,"future_paste":false,"expired":false,"language":"diff","created_at":"2022-05-02 13:42:00","expires_at":null,"content":"diff --git a\/hw\/kdrive\/ephyr\/ephyr.c b\/hw\/kdrive\/ephyr\/ephyr.c\r\nindex c503ad6a6..722122b66 100644\r\n--- a\/hw\/kdrive\/ephyr\/ephyr.c\r\n+++ b\/hw\/kdrive\/ephyr\/ephyr.c\r\n@@ -298,7 +298,7 @@ ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)\r\n      * pBuf->pDamage  regions\r\n      *\/\r\n     shadowUpdateRotatePacked(pScreen, pBuf);\r\n-    hostx_paint_rect(screen, 0, 0, 0, 0, screen->width, screen->height);\r\n+    hostx_paint_rect(screen, 0, 0, 0, 0, screen->width*SCALE, screen->height*SCALE);\r\n }\r\n \r\n static void\r\n@@ -918,8 +918,8 @@ ephyrProcessMouseMotion(xcb_generic_event_t *xev)\r\n         int x = 0, y = 0;\r\n \r\n         EPHYR_LOG(\"enqueuing mouse motion:%d\\n\", screen->pScreen->myNum);\r\n-        x = motion->event_x;\r\n-        y = motion->event_y;\r\n+        x = motion->event_x \/ SCALE;\r\n+        y = motion->event_y \/ SCALE;\r\n         EPHYR_LOG(\"initial (x,y):(%d,%d)\\n\", x, y);\r\n \r\n         \/* convert coords into desktop-wide coordinates.\r\ndiff --git a\/hw\/kdrive\/ephyr\/hostx.c b\/hw\/kdrive\/ephyr\/hostx.c\r\nindex a5b2e344e..07868a38f 100644\r\n--- a\/hw\/kdrive\/ephyr\/hostx.c\r\n+++ b\/hw\/kdrive\/ephyr\/hostx.c\r\n@@ -618,8 +618,8 @@ hostx_init(void)\r\n                               scrpriv->win,\r\n                               scrpriv->win_pre_existing,\r\n                               0,0,\r\n-                              scrpriv->win_width,\r\n-                              scrpriv->win_height,\r\n+                              scrpriv->win_width * SCALE,\r\n+                              scrpriv->win_height * SCALE,\r\n                               0,\r\n                               XCB_WINDOW_CLASS_COPY_FROM_PARENT,\r\n                               HostX.visual->visual_id,\r\n@@ -904,15 +904,15 @@ hostx_screen_init(KdScreenInfo *screen,\r\n \r\n     if (!ephyr_glamor && HostX.have_shm) {\r\n         scrpriv->ximg = xcb_image_create_native(HostX.conn,\r\n-                                                width,\r\n-                                                buffer_height,\r\n+                                                width * SCALE,\r\n+                                                buffer_height * SCALE,\r\n                                                 XCB_IMAGE_FORMAT_Z_PIXMAP,\r\n                                                 HostX.depth,\r\n                                                 NULL,\r\n                                                 ~0,\r\n                                                 NULL);\r\n \r\n-        scrpriv->shmsize = scrpriv->ximg->stride * buffer_height;\r\n+        scrpriv->shmsize = scrpriv->ximg->stride * buffer_height * SCALE;\r\n         if (!hostx_create_shm_segment(&scrpriv->shminfo,\r\n                                       scrpriv->shmsize)) {\r\n             EPHYR_DBG\r\n@@ -931,8 +931,8 @@ hostx_screen_init(KdScreenInfo *screen,\r\n         EPHYR_DBG(\"Creating image %dx%d for screen scrpriv=%p\\n\",\r\n                   width, buffer_height, scrpriv);\r\n         scrpriv->ximg = xcb_image_create_native(HostX.conn,\r\n-                                                    width,\r\n-                                                    buffer_height,\r\n+                                                    width * SCALE,\r\n+                                                    buffer_height * SCALE,\r\n                                                     XCB_IMAGE_FORMAT_Z_PIXMAP,\r\n                                                     HostX.depth,\r\n                                                     NULL,\r\n@@ -945,21 +945,21 @@ hostx_screen_init(KdScreenInfo *screen,\r\n             scrpriv->ximg->byte_order = IMAGE_BYTE_ORDER;\r\n \r\n         scrpriv->ximg->data =\r\n-            xallocarray(scrpriv->ximg->stride, buffer_height);\r\n+            xallocarray(scrpriv->ximg->stride, buffer_height * SCALE);\r\n     }\r\n \r\n     if (!HostX.size_set_from_configure)\r\n     {\r\n         uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;\r\n-        uint32_t values[2] = {width, height};\r\n+        uint32_t values[2] = {width * SCALE, height * SCALE};\r\n         xcb_configure_window(HostX.conn, scrpriv->win, mask, values);\r\n     }\r\n \r\n     if (scrpriv->win_pre_existing == None && !EphyrWantResize) {\r\n         \/* Ask the WM to keep our size static *\/\r\n         xcb_size_hints_t size_hints = {0};\r\n-        size_hints.max_width = size_hints.min_width = width;\r\n-        size_hints.max_height = size_hints.min_height = height;\r\n+        size_hints.max_width = size_hints.min_width = width * SCALE;\r\n+        size_hints.max_height = size_hints.min_height = height * SCALE;\r\n         size_hints.flags = (XCB_ICCCM_SIZE_HINT_P_MIN_SIZE |\r\n                             XCB_ICCCM_SIZE_HINT_P_MAX_SIZE);\r\n         xcb_icccm_set_wm_normal_hints(HostX.conn, scrpriv->win,\r\n@@ -991,6 +991,7 @@ hostx_screen_init(KdScreenInfo *screen,\r\n     scrpriv->win_x = x;\r\n     scrpriv->win_y = y;\r\n \r\n+    if (SCALE != 1) assert(scrpriv->ximg->bpp == 32);\r\n #ifdef GLAMOR\r\n     if (ephyr_glamor) {\r\n         *bytes_per_line = 0;\r\n@@ -999,7 +1000,7 @@ hostx_screen_init(KdScreenInfo *screen,\r\n         return NULL;\r\n     } else\r\n #endif\r\n-    if (host_depth_matches_server(scrpriv)) {\r\n+    if (SCALE == 1 && host_depth_matches_server(scrpriv)) {\r\n         *bytes_per_line = scrpriv->ximg->stride;\r\n         *bits_per_pixel = scrpriv->ximg->bpp;\r\n \r\n@@ -1007,11 +1008,12 @@ hostx_screen_init(KdScreenInfo *screen,\r\n         return scrpriv->ximg->data;\r\n     }\r\n     else {\r\n-        int bytes_per_pixel = scrpriv->server_depth >> 3;\r\n+        int server_depth = scrpriv->server_depth == 24 ? 32 : scrpriv->server_depth;\r\n+        int bytes_per_pixel = server_depth >> 3;\r\n         int stride = (width * bytes_per_pixel + 0x3) & ~0x3;\r\n \r\n         *bytes_per_line = stride;\r\n-        *bits_per_pixel = scrpriv->server_depth;\r\n+        *bits_per_pixel = server_depth;\r\n \r\n         EPHYR_DBG(\"server bpp %i\", bytes_per_pixel);\r\n         scrpriv->fb_data = xallocarray (stride, buffer_height);\r\n@@ -1091,34 +1093,52 @@ hostx_paint_rect(KdScreenInfo *screen,\r\n \r\n                     host_pixel = (r << 16) | (g << 8) | (b);\r\n \r\n-                    xcb_image_put_pixel(scrpriv->ximg, x, y, host_pixel);\r\n+                    for (int yp = 0; yp < SCALE; ++yp)\r\n+                        for (int xp = 0; xp < SCALE; ++xp)\r\n+                            xcb_image_put_pixel(scrpriv->ximg, x*SCALE+xp, y*SCALE+yp, host_pixel);\r\n                     break;\r\n                 }\r\n                 case 8:\r\n                 {\r\n                     unsigned char pixel =\r\n                         *(unsigned char *) (scrpriv->fb_data + idx);\r\n-                    xcb_image_put_pixel(scrpriv->ximg, x, y,\r\n-                                        scrpriv->cmap[pixel]);\r\n+                    host_pixel = scrpriv->cmap[pixel];\r\n+\r\n+                    for (int yp = 0; yp < SCALE; ++yp)\r\n+                        for (int xp = 0; xp < SCALE; ++xp)\r\n+                            xcb_image_put_pixel(scrpriv->ximg, x*SCALE+xp, y*SCALE+yp, host_pixel);\r\n                     break;\r\n                 }\r\n                 default:\r\n                     break;\r\n                 }\r\n             }\r\n+    } else if (SCALE != 1) {\r\n+        uint32_t* dst = (uint32_t*) scrpriv->ximg->data;\r\n+        uint32_t* src = (uint32_t*) scrpriv->fb_data;\r\n+        size_t src_stride = scrpriv->win_width;\r\n+        size_t dst_stride = scrpriv->ximg->stride\/4;\r\n+        for (int y = sy; y < sy + height; ++y)\r\n+            for (int x = sx; x < sx + width; ++x) {\r\n+                uint32_t val = src[y * src_stride + x];\r\n+                for (int yp = 0; yp < SCALE; ++yp)\r\n+                    for (int xp = 0; xp < SCALE; ++xp)\r\n+                        dst[(y*SCALE+yp) * dst_stride + (x*SCALE+xp)] = val;\r\n+            }\r\n     }\r\n \r\n     if (HostX.have_shm) {\r\n         xcb_image_shm_put(HostX.conn, scrpriv->win,\r\n                           HostX.gc, scrpriv->ximg,\r\n                           scrpriv->shminfo,\r\n-                          sx, sy, dx, dy, width, height, FALSE);\r\n+                          sx*SCALE, sy*SCALE, dx*SCALE, dy*SCALE,\r\n+                          width*SCALE, height*SCALE, FALSE);\r\n     }\r\n     else {\r\n-        xcb_image_t *subimg = xcb_image_subimage(scrpriv->ximg, sx, sy,\r\n-                                                 width, height, 0, 0, 0);\r\n+        xcb_image_t *subimg = xcb_image_subimage(scrpriv->ximg, sx*SCALE, sy*SCALE,\r\n+                                                 width*SCALE, height*SCALE, 0, 0, 0);\r\n         xcb_image_t *img = xcb_image_native(HostX.conn, subimg, 1);\r\n-        xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, img, dx, dy, 0);\r\n+        xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, img, dx*SCALE, dy*SCALE, 0);\r\n         if (subimg != img)\r\n             xcb_image_destroy(img);\r\n         xcb_image_destroy(subimg);\r\n@@ -1133,7 +1153,10 @@ hostx_paint_debug_rect(KdScreenInfo *screen,\r\n {\r\n     EphyrScrPriv *scrpriv = screen->driver;\r\n     struct timespec tspec;\r\n-    xcb_rectangle_t rect = { .x = x, .y = y, .width = width, .height = height };\r\n+    xcb_rectangle_t rect = {\r\n+        .x = x * SCALE, .y = y * SCALE,\r\n+        .width = width * SCALE, .height = height * SCALE\r\n+    };\r\n     xcb_void_cookie_t cookie;\r\n     xcb_generic_error_t *e;\r\n \r\n@@ -1471,7 +1494,7 @@ hostx_create_window(int a_screen_number,\r\n                       win,\r\n                       hostx_get_window (a_screen_number),\r\n                       a_geometry->x, a_geometry->y,\r\n-                      a_geometry->width, a_geometry->height, 0,\r\n+                      a_geometry->width * SCALE, a_geometry->height * SCALE, 0,\r\n                       XCB_WINDOW_CLASS_COPY_FROM_PARENT,\r\n                       a_visual_id, winmask, attrs);\r\n \r\n@@ -1514,8 +1537,8 @@ hostx_set_window_geometry(int a_win, EphyrBox * a_geo)\r\n \r\n     values[0] = a_geo->x;\r\n     values[1] = a_geo->y;\r\n-    values[2] = a_geo->width;\r\n-    values[3] = a_geo->height;\r\n+    values[2] = a_geo->width * SCALE;\r\n+    values[3] = a_geo->height * SCALE;\r\n     xcb_configure_window(HostX.conn, a_win, mask, values);\r\n \r\n     EPHYR_LOG(\"leave\\n\");\r\ndiff --git a\/hw\/kdrive\/ephyr\/hostx.h b\/hw\/kdrive\/ephyr\/hostx.h\r\nindex 4b2678e58..cfce75d30 100644\r\n--- a\/hw\/kdrive\/ephyr\/hostx.h\r\n+++ b\/hw\/kdrive\/ephyr\/hostx.h\r\n@@ -32,6 +32,8 @@\r\n #include <xcb\/render.h>\r\n #include \"ephyr.h\"\r\n \r\n+#define SCALE 2\r\n+\r\n #define EPHYR_WANT_DEBUG 0\r\n \r\n #if (EPHYR_WANT_DEBUG)\r\n"}