vnc.c (453f842bc4cab49f10c267cff9ad3cf657265d49) vnc.c (f7b3d68c95bc4f8915a3d084360aa07c7f4e4717)
1/*
2 * QEMU VNC display driver
3 *
4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
5 * Copyright (C) 2006 Fabrice Bellard
6 * Copyright (C) 2009 Red Hat, Inc
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy

--- 614 unchanged lines hidden (view full) ---

623
624static int vnc_height(VncDisplay *vd)
625{
626 return MIN(VNC_MAX_HEIGHT, surface_height(vd->ds));
627}
628
629static void vnc_set_area_dirty(DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT],
630 VNC_MAX_WIDTH / VNC_DIRTY_PIXELS_PER_BIT),
1/*
2 * QEMU VNC display driver
3 *
4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
5 * Copyright (C) 2006 Fabrice Bellard
6 * Copyright (C) 2009 Red Hat, Inc
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy

--- 614 unchanged lines hidden (view full) ---

623
624static int vnc_height(VncDisplay *vd)
625{
626 return MIN(VNC_MAX_HEIGHT, surface_height(vd->ds));
627}
628
629static void vnc_set_area_dirty(DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT],
630 VNC_MAX_WIDTH / VNC_DIRTY_PIXELS_PER_BIT),
631 int width, int height,
632 int x, int y, int w, int h) {
631 VncDisplay *vd,
632 int x, int y, int w, int h)
633{
634 int width = vnc_width(vd);
635 int height = vnc_height(vd);
636
633 /* this is needed this to ensure we updated all affected
634 * blocks if x % VNC_DIRTY_PIXELS_PER_BIT != 0 */
635 w += (x % VNC_DIRTY_PIXELS_PER_BIT);
636 x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
637
638 x = MIN(x, width);
639 y = MIN(y, height);
640 w = MIN(x + w, width) - x;

--- 5 unchanged lines hidden (view full) ---

646 }
647}
648
649static void vnc_dpy_update(DisplayChangeListener *dcl,
650 int x, int y, int w, int h)
651{
652 VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
653 struct VncSurface *s = &vd->guest;
637 /* this is needed this to ensure we updated all affected
638 * blocks if x % VNC_DIRTY_PIXELS_PER_BIT != 0 */
639 w += (x % VNC_DIRTY_PIXELS_PER_BIT);
640 x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
641
642 x = MIN(x, width);
643 y = MIN(y, height);
644 w = MIN(x + w, width) - x;

--- 5 unchanged lines hidden (view full) ---

650 }
651}
652
653static void vnc_dpy_update(DisplayChangeListener *dcl,
654 int x, int y, int w, int h)
655{
656 VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
657 struct VncSurface *s = &vd->guest;
654 int width = pixman_image_get_width(vd->server);
655 int height = pixman_image_get_height(vd->server);
656
658
657 vnc_set_area_dirty(s->dirty, width, height, x, y, w, h);
659 vnc_set_area_dirty(s->dirty, vd, x, y, w, h);
658}
659
660void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
661 int32_t encoding)
662{
663 vnc_write_u16(vs, x);
664 vnc_write_u16(vs, y);
665 vnc_write_u16(vs, w);

--- 84 unchanged lines hidden (view full) ---

750
751 /* guest surface */
752 qemu_pixman_image_unref(vd->guest.fb);
753 vd->guest.fb = pixman_image_ref(surface->image);
754 vd->guest.format = surface->format;
755 width = vnc_width(vd);
756 height = vnc_height(vd);
757 memset(vd->guest.dirty, 0x00, sizeof(vd->guest.dirty));
660}
661
662void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
663 int32_t encoding)
664{
665 vnc_write_u16(vs, x);
666 vnc_write_u16(vs, y);
667 vnc_write_u16(vs, w);

--- 84 unchanged lines hidden (view full) ---

752
753 /* guest surface */
754 qemu_pixman_image_unref(vd->guest.fb);
755 vd->guest.fb = pixman_image_ref(surface->image);
756 vd->guest.format = surface->format;
757 width = vnc_width(vd);
758 height = vnc_height(vd);
759 memset(vd->guest.dirty, 0x00, sizeof(vd->guest.dirty));
758 vnc_set_area_dirty(vd->guest.dirty, width, height, 0, 0,
760 vnc_set_area_dirty(vd->guest.dirty, vd, 0, 0,
759 width, height);
760
761 QTAILQ_FOREACH(vs, &vd->clients, next) {
762 vnc_colordepth(vs);
763 vnc_desktop_resize(vs);
764 if (vs->vd->cursor) {
765 vnc_cursor_define(vs);
766 }
767 memset(vs->dirty, 0x00, sizeof(vs->dirty));
761 width, height);
762
763 QTAILQ_FOREACH(vs, &vd->clients, next) {
764 vnc_colordepth(vs);
765 vnc_desktop_resize(vs);
766 if (vs->vd->cursor) {
767 vnc_cursor_define(vs);
768 }
769 memset(vs->dirty, 0x00, sizeof(vs->dirty));
768 vnc_set_area_dirty(vs->dirty, width, height, 0, 0,
770 vnc_set_area_dirty(vs->dirty, vd, 0, 0,
769 width, height);
770 }
771}
772
773/* fastest code */
774static void vnc_write_pixels_copy(VncState *vs,
775 void *pixels, int size)
776{

--- 1239 unchanged lines hidden (view full) ---

2016 trace_vnc_key_event_ext(down, sym, keycode, code2name(keycode));
2017 do_key_event(vs, down, keycode, sym);
2018 }
2019}
2020
2021static void framebuffer_update_request(VncState *vs, int incremental,
2022 int x, int y, int w, int h)
2023{
771 width, height);
772 }
773}
774
775/* fastest code */
776static void vnc_write_pixels_copy(VncState *vs,
777 void *pixels, int size)
778{

--- 1239 unchanged lines hidden (view full) ---

2018 trace_vnc_key_event_ext(down, sym, keycode, code2name(keycode));
2019 do_key_event(vs, down, keycode, sym);
2020 }
2021}
2022
2023static void framebuffer_update_request(VncState *vs, int incremental,
2024 int x, int y, int w, int h)
2025{
2024 int width = pixman_image_get_width(vs->vd->server);
2025 int height = pixman_image_get_height(vs->vd->server);
2026
2027 vs->need_update = 1;
2028
2029 if (incremental) {
2030 return;
2031 }
2032
2033 vs->force_update = 1;
2026 vs->need_update = 1;
2027
2028 if (incremental) {
2029 return;
2030 }
2031
2032 vs->force_update = 1;
2034 vnc_set_area_dirty(vs->dirty, width, height, x, y, w, h);
2033 vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h);
2035}
2036
2037static void send_ext_key_event_ack(VncState *vs)
2038{
2039 vnc_lock_output(vs);
2040 vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
2041 vnc_write_u8(vs, 0);
2042 vnc_write_u16(vs, 1);

--- 1884 unchanged lines hidden ---
2034}
2035
2036static void send_ext_key_event_ack(VncState *vs)
2037{
2038 vnc_lock_output(vs);
2039 vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
2040 vnc_write_u8(vs, 0);
2041 vnc_write_u16(vs, 1);

--- 1884 unchanged lines hidden ---