cocoa_resize
------------------------------------------------------
*/
-static void cocoa_resize(DisplayState *ds, int w, int h, int linesize)
+static void cocoa_resize(DisplayState *ds, int w, int h)
{
const int device_bpp = 32;
static void *screen_pixels;
{
if (width != s->cols || height != s->rows) {
if (pl110_enabled(s)) {
- dpy_resize(s->ds, width, height, width * 4);
+ dpy_resize(s->ds, width, height);
}
}
s->cols = width;
s->cr = val;
s->bpp = (val >> 1) & 7;
if (pl110_enabled(s)) {
- dpy_resize(s->ds, s->cols, s->rows, s->cols * 4);
+ dpy_resize(s->ds, s->cols, s->rows);
}
break;
case 10: /* LCDICR */
register_savevm("tcx", addr, 1, tcx_save, tcx_load, s);
qemu_register_reset(tcx_reset, s);
tcx_reset(s);
- dpy_resize(s->ds, width, height, width * 1);
+ dpy_resize(s->ds, width, height);
}
static void tcx_screen_dump(void *opaque, const char *filename)
static rgb_to_pixel_dup_func *rgb_to_pixel_dup_table[NB_DEPTHS];
+static int old_depth = 0;
+
/*
* Text mode update
* Missing:
/* Disable dirty bit tracking */
xc_hvm_track_dirty_vram(xc_handle, domid, 0, 0, NULL);
- if (s->ds->dpy_colourdepth != NULL && s->ds->depth != 0)
- s->ds->dpy_colourdepth(s->ds, 0);
+ /* total width & height */
+ cheight = (s->cr[9] & 0x1f) + 1;
+ cw = 8;
+ if (!(s->sr[1] & 0x01))
+ cw = 9;
+ if (s->sr[1] & 0x08)
+ cw = 16; /* NOTE: no 18 pixel wide */
+ width = (s->cr[0x01] + 1);
+ if (s->cr[0x06] == 100) {
+ /* ugly hack for CGA 160x100x16 - explain me the logic */
+ height = 100;
+ } else {
+ height = s->cr[0x12] |
+ ((s->cr[0x07] & 0x02) << 7) |
+ ((s->cr[0x07] & 0x40) << 3);
+ height = (height + 1) / cheight;
+ }
+ if ((height * width) > CH_ATTR_SIZE) {
+ /* better than nothing: exit if transient size is too big */
+ return;
+ }
+
+ s->last_scr_width = width * cw;
+ s->last_scr_height = height * cheight;
+ if (s->ds->dpy_resize_shared && old_depth) {
+ dpy_resize_shared(s->ds, s->last_scr_width, s->last_scr_height, 0, s->last_scr_width * (s->ds->depth / 8), NULL);
+ old_depth = 0;
+ full_update = 1;
+ } else if (width != s->last_width || height != s->last_height ||
+ cw != s->last_cw || cheight != s->last_ch) {
+ dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
+ full_update = 1;
+ }
+ s->last_width = width;
+ s->last_height = height;
+ s->last_ch = cheight;
+ s->last_cw = cw;
+
s->rgb_to_pixel =
rgb_to_pixel_dup_table[get_depth_index(s->ds)];
full_update |= update_palette16(s);
palette = s->last_palette;
+ x_incr = cw * ((s->ds->depth + 7) >> 3);
/* compute font data address (in plane 2) */
v = s->sr[3];
offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2;
line_offset = s->line_offset;
s1 = s->vram_ptr + (s->start_addr * 4);
- /* total width & height */
- cheight = (s->cr[9] & 0x1f) + 1;
- cw = 8;
- if (!(s->sr[1] & 0x01))
- cw = 9;
- if (s->sr[1] & 0x08)
- cw = 16; /* NOTE: no 18 pixel wide */
- x_incr = cw * ((s->ds->depth + 7) >> 3);
- width = (s->cr[0x01] + 1);
- if (s->cr[0x06] == 100) {
- /* ugly hack for CGA 160x100x16 - explain me the logic */
- height = 100;
- } else {
- height = s->cr[0x12] |
- ((s->cr[0x07] & 0x02) << 7) |
- ((s->cr[0x07] & 0x40) << 3);
- height = (height + 1) / cheight;
- }
- if ((height * width) > CH_ATTR_SIZE) {
- /* better than nothing: exit if transient size is too big */
- return;
- }
-
- if (width != s->last_width || height != s->last_height ||
- cw != s->last_cw || cheight != s->last_ch) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
- dpy_resize(s->ds, s->last_scr_width, s->last_scr_height, s->last_scr_width * (s->ds->depth / 8));
- s->last_width = width;
- s->last_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
- }
cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
if (cursor_offset != s->cursor_offset ||
s->cr[0xa] != s->cursor_start ||
s->get_resolution(s, &width, &height);
disp_width = width;
- ds_depth = s->ds->depth;
- depth = s->get_bpp(s);
- if (s->ds->dpy_colourdepth != NULL &&
- (ds_depth != depth || !s->ds->shared_buf))
- s->ds->dpy_colourdepth(s->ds, depth);
- if (ds_depth != s->ds->depth) full_update = 1;
-
- s->rgb_to_pixel =
- rgb_to_pixel_dup_table[get_depth_index(s->ds)];
-
shift_control = (s->gr[0x05] >> 5) & 3;
double_scan = (s->cr[0x09] >> 7);
if (shift_control != 1) {
s->shift_control = shift_control;
s->double_scan = double_scan;
}
-
+ if (shift_control == 1 && (s->sr[0x01] & 8)) {
+ disp_width <<= 1;
+ }
+
+ ds_depth = s->ds->depth;
+ depth = s->get_bpp(s);
+ if (s->ds->dpy_resize_shared) {
+ if (s->line_offset != s->last_line_offset ||
+ disp_width != s->last_width ||
+ height != s->last_height ||
+ old_depth != depth) {
+ dpy_resize_shared(s->ds, disp_width, height, depth, s->line_offset, s->vram_ptr + (s->start_addr * 4));
+ s->last_scr_width = disp_width;
+ s->last_scr_height = height;
+ s->last_width = disp_width;
+ s->last_height = height;
+ s->last_line_offset = s->line_offset;
+ old_depth = depth;
+ full_update = 1;
+ } else if (s->ds->shared_buf && (full_update || s->ds->data != s->vram_ptr + (s->start_addr * 4)))
+ s->ds->dpy_setdata(s->ds, s->vram_ptr + (s->start_addr * 4));
+ } else if (disp_width != s->last_width ||
+ height != s->last_height) {
+ dpy_resize(s->ds, disp_width, height);
+ s->last_scr_width = disp_width;
+ s->last_scr_height = height;
+ s->last_width = disp_width;
+ s->last_height = height;
+ full_update = 1;
+ }
+
+ s->rgb_to_pixel =
+ rgb_to_pixel_dup_table[get_depth_index(s->ds)];
+
if (shift_control == 0) {
full_update |= update_palette16(s);
if (s->sr[0x01] & 8) {
v = VGA_DRAW_LINE4D2;
- disp_width <<= 1;
} else {
v = VGA_DRAW_LINE4;
}
full_update |= update_palette16(s);
if (s->sr[0x01] & 8) {
v = VGA_DRAW_LINE2D2;
- disp_width <<= 1;
} else {
v = VGA_DRAW_LINE2;
}
}
vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
- if (s->line_offset != s->last_line_offset ||
- disp_width != s->last_width ||
- height != s->last_height) {
- dpy_resize(s->ds, disp_width, height, s->line_offset);
- s->last_scr_width = disp_width;
- s->last_scr_height = height;
- s->last_width = disp_width;
- s->last_height = height;
- s->last_line_offset = s->line_offset;
- full_update = 1;
- }
- if (s->ds->shared_buf && (full_update || s->ds->data != s->vram_ptr + (s->start_addr * 4)))
- s->ds->dpy_setdata(s->ds, s->vram_ptr + (s->start_addr * 4));
if (!s->ds->shared_buf && s->cursor_invalidate)
s->cursor_invalidate(s);
{
}
-static void vga_save_dpy_resize(DisplayState *s, int w, int h, int linesize)
+static void vga_save_dpy_resize(DisplayState *s, int w, int h)
{
s->linesize = w * 4;
s->data = qemu_malloc(h * s->linesize);
event->resize.offset,
event->resize.stride) < 0)
break;
- dpy_colourdepth(xenfb->ds, xenfb->depth);
- dpy_resize(xenfb->ds, xenfb->width, xenfb->height, xenfb->row_stride);
- if (xenfb->ds->shared_buf)
- dpy_setdata(xenfb->ds, xenfb->pixels + xenfb->offset);
+ if (xenfb->ds->dpy_resize_shared)
+ dpy_resize_shared(xenfb->ds, xenfb->width, xenfb->height, xenfb->depth, xenfb->row_stride, xenfb->pixels + xenfb->offset);
+ else
+ dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
xenfb_invalidate(xenfb);
break;
}
xenfb_invalidate,
xenfb_screen_dump,
xenfb);
- dpy_colourdepth(xenfb->ds, xenfb->depth);
- dpy_resize(xenfb->ds, xenfb->width, xenfb->height, xenfb->row_stride);
- if (xenfb->ds->shared_buf)
- dpy_setdata(xenfb->ds, xenfb->pixels);
+ if (xenfb->ds->dpy_resize_shared)
+ dpy_resize_shared(xenfb->ds, xenfb->width, xenfb->height, xenfb->depth, xenfb->row_stride, xenfb->pixels + xenfb->offset);
+ else
+ dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
if (qemu_set_fd_handler2(xc_evtchn_fd(xenfb->evt_xch), NULL, xenfb_dispatch_channel, NULL, xenfb) < 0)
return -1;
static unsigned char linux2scancode[KEY_MAX + 1];
+static void xenfb_pv_colourdepth(DisplayState *ds, int depth);
+
int xenfb_connect_vkbd(const char *path)
{
kbd_path = strdup(path);
fbfront_update(fb_dev, x, y, w, h);
}
-static void xenfb_pv_resize(DisplayState *ds, int w, int h, int linesize)
+static void xenfb_pv_resize_shared(DisplayState *ds, int w, int h, int depth, int linesize, void *pixels)
{
XenFBState *xs = ds->opaque;
struct fbfront_dev *fb_dev = xs->fb_dev;
+ int offset;
fprintf(stderr,"resize to %dx%d, %d required\n", w, h, linesize);
+ xenfb_pv_colourdepth(ds, depth);
ds->width = w;
ds->height = h;
if (!linesize)
if (!fb_dev)
return;
if (ds->shared_buf) {
- ds->data = NULL;
+ offset = pixels - xs->vga_vram;
+ ds->data = pixels;
+ fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, offset);
} else {
ds->data = xs->nonshared_vram;
fbfront_resize(fb_dev, w, h, linesize, ds->depth, VGA_RAM_SIZE);
}
}
+static void xenfb_pv_resize(DisplayState *ds, int w, int h)
+{
+ xenfb_pv_resize_shared(ds, w, h, 0, 0, NULL);
+}
+
static void xenfb_pv_colourdepth(DisplayState *ds, int depth)
{
XenFBState *xs = ds->opaque;
ds->data = NULL;
} else {
ds->data = xs->nonshared_vram;
- fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, VGA_RAM_SIZE);
}
}
ds->linesize = 640 * 4;
ds->dpy_update = xenfb_pv_update;
ds->dpy_resize = xenfb_pv_resize;
- ds->dpy_colourdepth = xenfb_pv_colourdepth;
+ ds->dpy_resize_shared = xenfb_pv_resize_shared;
ds->dpy_setdata = xenfb_pv_setdata;
ds->dpy_refresh = xenfb_pv_refresh;
return 0;
static int absolute_enabled = 0;
static int opengl_enabled;
+static void sdl_colourdepth(DisplayState *ds, int depth);
+
#ifdef CONFIG_OPENGL
static GLint tex_format;
static GLint tex_type;
ds->data = pixels;
}
-static void sdl_resize(DisplayState *ds, int w, int h, int linesize)
+static void sdl_resize_shared(DisplayState *ds, int w, int h, int depth, int linesize, void *pixels)
{
int flags;
// printf("resizing to %d %d\n", w, h);
+ sdl_colourdepth(ds, depth);
+
#ifdef CONFIG_OPENGL
if (ds->shared_buf && opengl_enabled)
flags = SDL_OPENGL|SDL_RESIZABLE;
opengl_enabled = 0;
ds->dpy_update = sdl_update;
ds->dpy_setdata = sdl_setdata;
- sdl_resize(ds, w, h, linesize);
+ ds->dpy_resize_shared = sdl_resize_shared;
+ sdl_resize_shared(ds, w, h, depth, linesize, pixels);
return;
}
exit(1);
} else {
ds->bgr = 0;
}
+ shared = NULL;
ds->data = screen->pixels;
ds->linesize = screen->pitch;
} else {
};
#endif
}
+ if (ds->shared_buf) ds->dpy_setdata(ds, pixels);
+}
+
+static void sdl_resize(DisplayState *ds, int w, int h)
+{
+ sdl_resize_shared(ds, w, h, 0, w * (ds->depth / 8), NULL);
}
static void sdl_colourdepth(DisplayState *ds, int depth)
{
if (!depth || !ds->depth) {
ds->shared_buf = 0;
+ ds->dpy_update = sdl_update;
return;
}
ds->shared_buf = 1;
ds->depth = depth;
- ds->linesize = width * depth / 8;
#ifdef CONFIG_OPENGL
if (opengl_enabled) {
ds->dpy_update = opengl_update;
- ds->dpy_setdata = opengl_setdata;
}
#endif
}
static void toggle_full_screen(DisplayState *ds)
{
gui_fullscreen = !gui_fullscreen;
- sdl_resize(ds, ds->width, ds->height, ds->linesize);
- ds->dpy_setdata(ds, ds->data);
+ sdl_resize_shared(ds, ds->width, ds->height, ds->depth, ds->linesize, ds->data);
if (gui_fullscreen) {
gui_saved_grab = gui_grab;
sdl_grab_start();
ds->dpy_update = sdl_update;
ds->dpy_resize = sdl_resize;
+ ds->dpy_resize_shared = sdl_resize_shared;
ds->dpy_refresh = sdl_refresh;
- ds->dpy_colourdepth = sdl_colourdepth;
- ds->dpy_setdata = sdl_setdata;
+#ifdef CONFIG_OPENGL
+ if (opengl_enabled)
+ ds->dpy_setdata = opengl_setdata;
+ else
+ ds->dpy_setdata = sdl_setdata;
+#endif
- sdl_resize(ds, 640, 400, 640 * 4);
+ sdl_resize(ds, 640, 400);
sdl_update_caption();
SDL_EnableKeyRepeat(250, 50);
SDL_EnableUNICODE(1);
ds->depth = 0;
ds->dpy_update = dumb_update;
ds->dpy_resize = dumb_resize;
- ds->dpy_colourdepth = NULL;
ds->dpy_refresh = dumb_refresh;
ds->gui_timer_interval = 500;
ds->idle = 1;
int shared_buf;
void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
- void (*dpy_resize)(struct DisplayState *s, int w, int h, int linesize);
- void (*dpy_colourdepth)(struct DisplayState *s, int depth);
+ void (*dpy_resize)(struct DisplayState *s, int w, int h);
void (*dpy_setdata)(DisplayState *s, void *pixels);
+ void (*dpy_resize_shared)(DisplayState *s, int w, int h, int depth, int linesize, void *pixels);
void (*dpy_refresh)(struct DisplayState *s);
void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h);
};
s->dpy_update(s, x, y, w, h);
}
-static inline void dpy_resize(DisplayState *s, int w, int h, int linesize)
+static inline void dpy_resize(DisplayState *s, int w, int h)
{
- s->dpy_resize(s, w, h, linesize);
+ s->dpy_resize(s, w, h);
}
-static inline void dpy_colourdepth(struct DisplayState *s, int depth)
+static inline void dpy_resize_shared(DisplayState *s, int w, int h, int depth, int linesize, void *pixels)
{
- s->dpy_colourdepth(s, depth);
+ s->dpy_resize_shared(s, w, h, depth, linesize, pixels);
}
static inline void dpy_setdata(DisplayState *s, void *pixels)
static void dequeue_framebuffer_update(VncState *vs);
static int is_empty_queue(VncState *vs);
static void free_queue(VncState *vs);
+static void vnc_colourdepth(DisplayState *ds, int depth);
#if 0
static inline void vnc_set_bit(uint32_t *d, int k)
vnc_write_s32(vs, encoding);
}
-static void vnc_dpy_resize(DisplayState *ds, int w, int h, int linesize)
+static void vnc_dpy_resize_shared(DisplayState *ds, int w, int h, int depth, int linesize, void *pixels)
{
static int allocated;
int size_changed;
VncState *vs = ds->opaque;
int o;
+ vnc_colourdepth(ds, depth);
if (!ds->shared_buf) {
ds->linesize = w * vs->depth;
if (allocated)
for (o = DIRTY_PIXEL_BITS; o < ds->width; o *= 2)
vs->dirty_pixel_shift++;
framebuffer_set_updated(vs, 0, 0, ds->width, ds->height);
+ if (ds->shared_buf) ds->data = pixels;
+}
+
+static void vnc_dpy_resize(DisplayState *ds, int w, int h)
+{
+ vnc_dpy_resize_shared(ds, w, h, 0, w * (ds->depth / 8), NULL);
}
/* fastest code */
ds->data = pixels;
}
-static void vnc_dpy_colourdepth(DisplayState *ds, int depth)
+static void vnc_colourdepth(DisplayState *ds, int depth)
{
int host_big_endian_flag;
struct VncState *vs = ds->opaque;
vs->write_pixels = vnc_write_pixels_generic;
}
}
-
- vnc_dpy_resize(ds, ds->width, ds->height, ds->linesize);
}
static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
vs->ds->data = NULL;
vs->ds->dpy_update = vnc_dpy_update;
vs->ds->dpy_resize = vnc_dpy_resize;
- vs->ds->dpy_colourdepth = vnc_dpy_colourdepth;
vs->ds->dpy_setdata = vnc_dpy_setdata;
+ vs->ds->dpy_resize_shared = vnc_dpy_resize_shared;
vs->ds->dpy_refresh = vnc_dpy_refresh;
vs->ds->width = 640;
vs->ds->height = 400;
vs->ds->linesize = 640 * 4;
- vnc_dpy_colourdepth(vs->ds, 24);
+ vnc_dpy_resize_shared(ds, ds->width, ds->height, 24, ds->linesize, NULL);
}
#if CONFIG_VNC_TLS