static void vnc_dpy_copy(DisplayChangeListener *dcl,

                         int src_x, int src_y,

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

{

    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);

    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(vs, 1, true);

            /* 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 - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT));

    if (w_lim < 0) {

        w_lim = w;

    } else {

        w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT);


    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 = (VNC_DIRTY_PIXELS_PER_BIT -

                    (dst_x % VNC_DIRTY_PIXELS_PER_BIT));

                s = MIN(s, w_lim);

            } else {

                s = VNC_DIRTY_PIXELS_PER_BIT;


            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) / VNC_DIRTY_PIXELS_PER_BIT),

                            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,

                         int src_x, int src_y,

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

{

    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);

    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(vs, 1, true);

            









    

    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 - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT));

    if (w_lim < 0) {

        w_lim = w;

    } else {

        w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT);


    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 = (VNC_DIRTY_PIXELS_PER_BIT -

                    (dst_x % VNC_DIRTY_PIXELS_PER_BIT));

                s = MIN(s, w_lim);

            } else {

                s = VNC_DIRTY_PIXELS_PER_BIT;


            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) / VNC_DIRTY_PIXELS_PER_BIT),

                            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 FUNC_0(DisplayChangeListener *VAR_0,

                         int VAR_1, int VAR_2,

                         int VAR_3, int VAR_4, int VAR_5, int VAR_6)

{

    VncDisplay *vd = container_of(VAR_0, VncDisplay, VAR_0);

    VncState *vs, *vn;

    uint8_t *src_row;

    uint8_t *dst_row;

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

    int VAR_14;









    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(vs, 1, true);

            









    

    VAR_10 = vnc_server_fb_stride(vd);

    src_row = vnc_server_fb_ptr(vd, VAR_1, VAR_2);

    dst_row = vnc_server_fb_ptr(vd, VAR_3, VAR_4);

    VAR_9 = VAR_4;

    VAR_11 = 1;

    if (VAR_4 > VAR_2) {

        

        src_row += VAR_10 * (VAR_6-1);

        dst_row += VAR_10 * (VAR_6-1);

        VAR_10 = -VAR_10;

        VAR_9 = VAR_4 + VAR_6 - 1;

        VAR_11 = -1;


    VAR_12 = VAR_5 - (VNC_DIRTY_PIXELS_PER_BIT - (VAR_3 % VNC_DIRTY_PIXELS_PER_BIT));

    if (VAR_12 < 0) {

        VAR_12 = VAR_5;

    } else {

        VAR_12 = VAR_5 - (VAR_12 % VNC_DIRTY_PIXELS_PER_BIT);


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

        for (VAR_8 = 0; VAR_8 <= VAR_12;

                VAR_8 += VAR_13, src_row += VAR_14, dst_row += VAR_14) {

            if (VAR_8 == VAR_12) {

                if ((VAR_13 = VAR_5 - VAR_12) == 0)

                    break;

            } else if (!VAR_8) {

                VAR_13 = (VNC_DIRTY_PIXELS_PER_BIT -

                    (VAR_3 % VNC_DIRTY_PIXELS_PER_BIT));

                VAR_13 = MIN(VAR_13, VAR_12);

            } else {

                VAR_13 = VNC_DIRTY_PIXELS_PER_BIT;


            VAR_14 = VAR_13 * VNC_SERVER_FB_BYTES;

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

                continue;

            memmove(dst_row, src_row, VAR_14);

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

                if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

                    set_bit(((VAR_8 + VAR_3) / VNC_DIRTY_PIXELS_PER_BIT),

                            vs->dirty[VAR_9]);




        src_row += VAR_10 - VAR_5 * VNC_SERVER_FB_BYTES;

        dst_row += VAR_10 - VAR_5 * VNC_SERVER_FB_BYTES;

        VAR_9 += VAR_11;




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

        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {

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



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