Revision b4c85ddc ui/vnc.c

b/ui/vnc.c
442 442
       iteration.  otherwise, if (x % 16) != 0, the last iteration may span
443 443
       two 16-pixel blocks but we only mark the first as dirty
444 444
    */
445
    w += (x % 16);
446
    x -= (x % 16);
445
    w += (x % VNC_DIRTY_PIXELS_PER_BIT);
446
    x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
447 447

  
448 448
    x = MIN(x, width);
449 449
    y = MIN(y, height);
450 450
    w = MIN(x + w, width) - x;
451 451
    h = MIN(h, height);
452 452

  
453
    for (; y < h; y++)
454
        for (i = 0; i < w; i += 16)
455
            set_bit((x + i) / 16, s->dirty[y]);
453
    for (; y < h; y++) {
454
        for (i = 0; i < w; i += VNC_DIRTY_PIXELS_PER_BIT) {
455
            set_bit((x + i) / VNC_DIRTY_PIXELS_PER_BIT, s->dirty[y]);
456
        }
457
    }
456 458
}
457 459

  
458 460
void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
......
769 771
        y = dst_y + h - 1;
770 772
        inc = -1;
771 773
    }
772
    w_lim = w - (16 - (dst_x % 16));
773
    if (w_lim < 0)
774
    w_lim = w - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT));
775
    if (w_lim < 0) {
774 776
        w_lim = w;
775
    else
776
        w_lim = w - (w_lim % 16);
777
    } else {
778
        w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT);
779
    }
777 780
    for (i = 0; i < h; i++) {
778 781
        for (x = 0; x <= w_lim;
779 782
                x += s, src_row += cmp_bytes, dst_row += cmp_bytes) {
......
781 784
                if ((s = w - w_lim) == 0)
782 785
                    break;
783 786
            } else if (!x) {
784
                s = (16 - (dst_x % 16));
787
                s = (VNC_DIRTY_PIXELS_PER_BIT -
788
                    (dst_x % VNC_DIRTY_PIXELS_PER_BIT));
785 789
                s = MIN(s, w_lim);
786 790
            } else {
787
                s = 16;
791
                s = VNC_DIRTY_PIXELS_PER_BIT;
788 792
            }
789 793
            cmp_bytes = s * VNC_SERVER_FB_BYTES;
790 794
            if (memcmp(src_row, dst_row, cmp_bytes) == 0)
......
792 796
            memmove(dst_row, src_row, cmp_bytes);
793 797
            QTAILQ_FOREACH(vs, &vd->clients, next) {
794 798
                if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
795
                    set_bit(((x + dst_x) / 16), vs->dirty[y]);
799
                    set_bit(((x + dst_x) / VNC_DIRTY_PIXELS_PER_BIT),
800
                            vs->dirty[y]);
796 801
                }
797 802
            }
798 803
        }
......
904 909
        for (y = 0; y < height; y++) {
905 910
            int x;
906 911
            int last_x = -1;
907
            for (x = 0; x < width / 16; x++) {
912
            for (x = 0; x < width / VNC_DIRTY_PIXELS_PER_BIT; x++) {
908 913
                if (test_and_clear_bit(x, vs->dirty[y])) {
909 914
                    if (last_x == -1) {
910 915
                        last_x = x;
......
914 919
                        int h = find_and_clear_dirty_height(vs, y, last_x, x,
915 920
                                                            height);
916 921

  
917
                        n += vnc_job_add_rect(job, last_x * 16, y,
918
                                              (x - last_x) * 16, h);
922
                        n += vnc_job_add_rect(job,
923
                                              last_x * VNC_DIRTY_PIXELS_PER_BIT,
924
                                              y,
925
                                              (x - last_x) *
926
                                              VNC_DIRTY_PIXELS_PER_BIT,
927
                                              h);
919 928
                    }
920 929
                    last_x = -1;
921 930
                }
922 931
            }
923 932
            if (last_x != -1) {
924 933
                int h = find_and_clear_dirty_height(vs, y, last_x, x, height);
925
                n += vnc_job_add_rect(job, last_x * 16, y,
926
                                      (x - last_x) * 16, h);
934
                n += vnc_job_add_rect(job, last_x * VNC_DIRTY_PIXELS_PER_BIT,
935
                                      y,
936
                                      (x - last_x) * VNC_DIRTY_PIXELS_PER_BIT,
937
                                      h);
927 938
            }
928 939
        }
929 940

  
......
1841 1852
                                       int w, int h)
1842 1853
{
1843 1854
    int i;
1844
    const size_t width = surface_width(vs->vd->ds) / 16;
1855
    const size_t width = surface_width(vs->vd->ds) / VNC_DIRTY_PIXELS_PER_BIT;
1845 1856
    const size_t height = surface_height(vs->vd->ds);
1846 1857

  
1847 1858
    if (y_position > height) {
......
2543 2554

  
2544 2555
        vs->lossy_rect[sty][stx] = 0;
2545 2556
        for (j = 0; j < VNC_STAT_RECT; ++j) {
2546
            bitmap_set(vs->dirty[y + j], x / 16, VNC_STAT_RECT / 16);
2557
            bitmap_set(vs->dirty[y + j],
2558
                       x / VNC_DIRTY_PIXELS_PER_BIT,
2559
                       VNC_STAT_RECT / VNC_DIRTY_PIXELS_PER_BIT);
2547 2560
        }
2548 2561
        has_dirty++;
2549 2562
    }
......
2690 2703
            }
2691 2704
            server_ptr = server_row;
2692 2705

  
2693
            for (x = 0; x + 15 < width;
2694
                    x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
2695
                if (!test_and_clear_bit((x / 16), vd->guest.dirty[y]))
2706
            for (x = 0; x + VNC_DIRTY_PIXELS_PER_BIT - 1 < width;
2707
                 x += VNC_DIRTY_PIXELS_PER_BIT, guest_ptr += cmp_bytes,
2708
                 server_ptr += cmp_bytes) {
2709
                if (!test_and_clear_bit((x / VNC_DIRTY_PIXELS_PER_BIT),
2710
                    vd->guest.dirty[y])) {
2696 2711
                    continue;
2697
                if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0)
2712
                }
2713
                if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0) {
2698 2714
                    continue;
2715
                }
2699 2716
                memcpy(server_ptr, guest_ptr, cmp_bytes);
2700 2717
                if (!vd->non_adaptive)
2701 2718
                    vnc_rect_updated(vd, x, y, &tv);
2702 2719
                QTAILQ_FOREACH(vs, &vd->clients, next) {
2703
                    set_bit((x / 16), vs->dirty[y]);
2720
                    set_bit((x / VNC_DIRTY_PIXELS_PER_BIT), vs->dirty[y]);
2704 2721
                }
2705 2722
                has_dirty++;
2706 2723
            }

Also available in: Unified diff