static void vnc_dpy_copy(DisplayChangeListener *dcl,

                         DisplayState *ds,

                         int src_x, int src_y,

                         int dst_x, int dst_y, int w, int h)

{

    VncDisplay *vd = ds->opaque;

    VncState *vs, *vn;

    uint8_t *src_row;

    uint8_t *dst_row;

    int i, x, y, pitch, inc, w_lim, s;

    int cmp_bytes;



    vnc_refresh_server_surface(vd);

    QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

            vs->force_update = 1;

            vnc_update_client_sync(vs, 1);

            /* vs might be free()ed here */

        }

    }



    /* do bitblit op on the local surface too */

    pitch = vnc_server_fb_stride(vd);

    src_row = vnc_server_fb_ptr(vd, src_x, src_y);

    dst_row = vnc_server_fb_ptr(vd, dst_x, dst_y);

    y = dst_y;

    inc = 1;

    if (dst_y > src_y) {

        /* copy backwards */

        src_row += pitch * (h-1);

        dst_row += pitch * (h-1);

        pitch = -pitch;

        y = dst_y + h - 1;

        inc = -1;

    }

    w_lim = w - (16 - (dst_x % 16));

    if (w_lim < 0)

        w_lim = w;

    else

        w_lim = w - (w_lim % 16);

    for (i = 0; i < h; i++) {

        for (x = 0; x <= w_lim;

                x += s, src_row += cmp_bytes, dst_row += cmp_bytes) {

            if (x == w_lim) {

                if ((s = w - w_lim) == 0)

                    break;

            } else if (!x) {

                s = (16 - (dst_x % 16));

                s = MIN(s, w_lim);

            } else {

                s = 16;

            }

            cmp_bytes = s * VNC_SERVER_FB_BYTES;

            if (memcmp(src_row, dst_row, cmp_bytes) == 0)

                continue;

            memmove(dst_row, src_row, cmp_bytes);

            QTAILQ_FOREACH(vs, &vd->clients, next) {

                if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

                    set_bit(((x + dst_x) / 16), vs->dirty[y]);

                }

            }

        }

        src_row += pitch - w * VNC_SERVER_FB_BYTES;

        dst_row += pitch - w * VNC_SERVER_FB_BYTES;

        y += inc;

    }



    QTAILQ_FOREACH(vs, &vd->clients, next) {

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

            vnc_copy(vs, src_x, src_y, dst_x, dst_y, w, h);

        }

    }

}

static void vnc_dpy_copy(DisplayChangeListener *dcl,

                         DisplayState *ds,

                         int src_x, int src_y,

                         int dst_x, int dst_y, int w, int h)

{

    VncDisplay *vd = ds->opaque;

    VncState *vs, *vn;

    uint8_t *src_row;

    uint8_t *dst_row;

    int i, x, y, pitch, inc, w_lim, s;

    int cmp_bytes;



    vnc_refresh_server_surface(vd);

    QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

            vs->force_update = 1;

            vnc_update_client_sync(vs, 1);

            

        }

    }



    

    pitch = vnc_server_fb_stride(vd);

    src_row = vnc_server_fb_ptr(vd, src_x, src_y);

    dst_row = vnc_server_fb_ptr(vd, dst_x, dst_y);

    y = dst_y;

    inc = 1;

    if (dst_y > src_y) {

        

        src_row += pitch * (h-1);

        dst_row += pitch * (h-1);

        pitch = -pitch;

        y = dst_y + h - 1;

        inc = -1;

    }

    w_lim = w - (16 - (dst_x % 16));

    if (w_lim < 0)

        w_lim = w;

    else

        w_lim = w - (w_lim % 16);

    for (i = 0; i < h; i++) {

        for (x = 0; x <= w_lim;

                x += s, src_row += cmp_bytes, dst_row += cmp_bytes) {

            if (x == w_lim) {

                if ((s = w - w_lim) == 0)

                    break;

            } else if (!x) {

                s = (16 - (dst_x % 16));

                s = MIN(s, w_lim);

            } else {

                s = 16;

            }

            cmp_bytes = s * VNC_SERVER_FB_BYTES;

            if (memcmp(src_row, dst_row, cmp_bytes) == 0)

                continue;

            memmove(dst_row, src_row, cmp_bytes);

            QTAILQ_FOREACH(vs, &vd->clients, next) {

                if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

                    set_bit(((x + dst_x) / 16), vs->dirty[y]);

                }

            }

        }

        src_row += pitch - w * VNC_SERVER_FB_BYTES;

        dst_row += pitch - w * VNC_SERVER_FB_BYTES;

        y += inc;

    }



    QTAILQ_FOREACH(vs, &vd->clients, next) {

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

            vnc_copy(vs, src_x, src_y, dst_x, dst_y, w, h);

        }

    }

}

    VncDisplay *vd = ds->opaque;     VncDisplay *vd = ds->opaque;     VncDisplay *vd = ds->opaque;     VncDisplay *vd = ds->opaque;
static void FUNC_0(DisplayChangeListener *VAR_0,

                         DisplayState *VAR_1,

                         int VAR_2, int VAR_3,

                         int VAR_4, int VAR_5, int VAR_6, int VAR_7)

{

    VncDisplay *vd = VAR_1->opaque;

    VncState *vs, *vn;

    uint8_t *src_row;

    uint8_t *dst_row;

    int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;

    int VAR_15;



    vnc_refresh_server_surface(vd);

    QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

            vs->force_update = 1;

            vnc_update_client_sync(vs, 1);

            

        }

    }



    

    VAR_11 = vnc_server_fb_stride(vd);

    src_row = vnc_server_fb_ptr(vd, VAR_2, VAR_3);

    dst_row = vnc_server_fb_ptr(vd, VAR_4, VAR_5);

    VAR_10 = VAR_5;

    VAR_12 = 1;

    if (VAR_5 > VAR_3) {

        

        src_row += VAR_11 * (VAR_7-1);

        dst_row += VAR_11 * (VAR_7-1);

        VAR_11 = -VAR_11;

        VAR_10 = VAR_5 + VAR_7 - 1;

        VAR_12 = -1;

    }

    VAR_13 = VAR_6 - (16 - (VAR_4 % 16));

    if (VAR_13 < 0)

        VAR_13 = VAR_6;

    else

        VAR_13 = VAR_6 - (VAR_13 % 16);

    for (VAR_8 = 0; VAR_8 < VAR_7; VAR_8++) {

        for (VAR_9 = 0; VAR_9 <= VAR_13;

                VAR_9 += VAR_14, src_row += VAR_15, dst_row += VAR_15) {

            if (VAR_9 == VAR_13) {

                if ((VAR_14 = VAR_6 - VAR_13) == 0)

                    break;

            } else if (!VAR_9) {

                VAR_14 = (16 - (VAR_4 % 16));

                VAR_14 = MIN(VAR_14, VAR_13);

            } else {

                VAR_14 = 16;

            }

            VAR_15 = VAR_14 * VNC_SERVER_FB_BYTES;

            if (memcmp(src_row, dst_row, VAR_15) == 0)

                continue;

            memmove(dst_row, src_row, VAR_15);

            QTAILQ_FOREACH(vs, &vd->clients, next) {

                if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

                    set_bit(((VAR_9 + VAR_4) / 16), vs->dirty[VAR_10]);

                }

            }

        }

        src_row += VAR_11 - VAR_6 * VNC_SERVER_FB_BYTES;

        dst_row += VAR_11 - VAR_6 * VNC_SERVER_FB_BYTES;

        VAR_10 += VAR_12;

    }



    QTAILQ_FOREACH(vs, &vd->clients, next) {

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

            vnc_copy(vs, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7);

        }

    }

}

static void FUNC_0(DisplayChangeListener *VAR_0,
DisplayState *VAR_1,
int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{ VncDisplay *vd = VAR_1->opaque; VncState *vs, *vn; uint8_t *src_row; uint8_t *dst_row; int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14; int VAR_15; vnc_refresh_server_surface(vd); QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) { if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) { vs->force_update = 1; vnc_update_client_sync(vs, 1); } } VAR_11 = vnc_server_fb_stride(vd); src_row = vnc_server_fb_ptr(vd, VAR_2, VAR_3); dst_row = vnc_server_fb_ptr(vd, VAR_4, VAR_5); VAR_10 = VAR_5; VAR_12 = 1; if (VAR_5 > VAR_3) { src_row += VAR_11 * (VAR_7-1); dst_row += VAR_11 * (VAR_7-1); VAR_11 = -VAR_11; VAR_10 = VAR_5 + VAR_7 - 1; VAR_12 = -1; } VAR_13 = VAR_6 - (16 - (VAR_4 % 16)); if (VAR_13 < 0)
VAR_13 = VAR_6; else
VAR_13 = VAR_6 - (VAR_13 % 16); for (VAR_8 = 0; VAR_8 < VAR_7; VAR_8++) { for (VAR_9 = 0; VAR_9 <= VAR_13; VAR_9 += VAR_14, src_row += VAR_15, dst_row += VAR_15) { if (VAR_9 == VAR_13) { if ((VAR_14 = VAR_6 - VAR_13) == 0)
break; } else if (!VAR_9) { VAR_14 = (16 - (VAR_4 % 16)); VAR_14 = MIN(VAR_14, VAR_13); } else { VAR_14 = 16; } VAR_15 = VAR_14 * VNC_SERVER_FB_BYTES; if (memcmp(src_row, dst_row, VAR_15) == 0)
continue; memmove(dst_row, src_row, VAR_15); QTAILQ_FOREACH(vs, &vd->clients, next) { if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) { set_bit(((VAR_9 + VAR_4) / 16), vs->dirty[VAR_10]); } } } src_row += VAR_11 - VAR_6 * VNC_SERVER_FB_BYTES; dst_row += VAR_11 - VAR_6 * VNC_SERVER_FB_BYTES; VAR_10 += VAR_12; } QTAILQ_FOREACH(vs, &vd->clients, next) { if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) { vnc_copy(vs, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7); } } }