[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2 of 13] Introduce accessors for DisplayState
Import "Introduce accessors for DisplayState" from qemu mainstream, plus few following fixes. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5789 c046a42c-6fe2-441c-8c8c-71466251a162 Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- diff --git a/console.c b/console.c --- a/console.c +++ b/console.c @@ -184,7 +184,7 @@ { unsigned int r, g, b, color; - switch(ds->depth) { + switch(ds_get_bits_per_pixel(ds)) { case 8: r = (rgba >> 16) & 0xff; g = (rgba >> 8) & 0xff; @@ -217,9 +217,9 @@ uint8_t *d, *d1; int x, y, bpp; - bpp = (ds->depth + 7) >> 3; - d1 = ds->data + - ds->linesize * posy + bpp * posx; + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; + d1 = ds_get_data(ds) + + ds_get_linesize(ds) * posy + bpp * posx; for (y = 0; y < height; y++) { d = d1; switch(bpp) { @@ -242,7 +242,7 @@ } break; } - d1 += ds->linesize; + d1 += ds_get_linesize(ds); } } @@ -253,27 +253,27 @@ uint8_t *d; int wb, y, bpp; - bpp = (ds->depth + 7) >> 3; + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; wb = w * bpp; if (yd <= ys) { - s = ds->data + - ds->linesize * ys + bpp * xs; - d = ds->data + - ds->linesize * yd + bpp * xd; + s = ds_get_data(ds) + + ds_get_linesize(ds) * ys + bpp * xs; + d = ds_get_data(ds) + + ds_get_linesize(ds) * yd + bpp * xd; for (y = 0; y < h; y++) { memmove(d, s, wb); - d += ds->linesize; - s += ds->linesize; + d += ds_get_linesize(ds); + s += ds_get_linesize(ds); } } else { - s = ds->data + - ds->linesize * (ys + h - 1) + bpp * xs; - d = ds->data + - ds->linesize * (yd + h - 1) + bpp * xd; + s = ds_get_data(ds) + + ds_get_linesize(ds) * (ys + h - 1) + bpp * xs; + d = ds_get_data(ds) + + ds_get_linesize(ds) * (yd + h - 1) + bpp * xd; for (y = 0; y < h; y++) { memmove(d, s, wb); - d -= ds->linesize; - s -= ds->linesize; + d -= ds_get_linesize(ds); + s -= ds_get_linesize(ds); } } } @@ -363,7 +363,7 @@ static inline unsigned int col_expand(DisplayState *ds, unsigned int col) { - switch(ds->depth) { + switch(ds_get_bits_per_pixel(ds)) { case 8: col |= col << 8; col |= col << 16; @@ -433,13 +433,13 @@ bgcol = color_table[t_attrib->bold][t_attrib->bgcol]; } - bpp = (ds->depth + 7) >> 3; - d = ds->data + - ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH; - linesize = ds->linesize; + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; + d = ds_get_data(ds) + + ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH; + linesize = ds_get_linesize(ds); font_ptr = vgafont16 + FONT_HEIGHT * ch; xorcol = bgcol ^ fgcol; - switch(ds->depth) { + switch(ds_get_bits_per_pixel(ds)) { case 8: for(i = 0; i < FONT_HEIGHT; i++) { font_data = *font_ptr++; @@ -573,7 +573,7 @@ if (s != active_console) return; - vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height, + vga_fill_rect(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds), color_table[0][COLOR_BLACK]); y1 = s->y_displayed; for(y = 0; y < s->height; y++) { @@ -586,7 +586,7 @@ if (++y1 == s->total_height) y1 = 0; } - dpy_update(s->ds, 0, 0, s->ds->width, s->ds->height); + dpy_update(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds)); console_show_cursor(s, 1); } @@ -1121,12 +1121,12 @@ { TextConsole *s = (TextConsole *) opaque; - if (s->g_width != s->ds->width || s->g_height != s->ds->height) { + if (s->g_width != ds_get_width(s->ds) || s->g_height != ds_get_height(s->ds)) { if (s->console_type == TEXT_CONSOLE_FIXED_SIZE) dpy_resize(s->ds, s->g_width, s->g_height); else { - s->g_width = s->ds->width; - s->g_height = s->ds->height; + s->g_width = ds_get_width(s->ds); + s->g_height = ds_get_height(s->ds); text_console_resize(s); } } @@ -1287,7 +1287,7 @@ void qemu_console_resize(QEMUConsole *console, int width, int height) { if (console->g_width != width || console->g_height != height - || !console->ds->data) { + || !ds_get_data(console->ds)) { console->g_width = width; console->g_height = height; if (active_console == console) { diff --git a/console.h b/console.h --- a/console.h +++ b/console.h @@ -113,6 +113,36 @@ s->dpy_text_cursor(s, x, y); } +static inline int ds_get_linesize(DisplayState *ds) +{ + return ds->linesize; +} + +static inline uint8_t* ds_get_data(DisplayState *ds) +{ + return ds->data; +} + +static inline int ds_get_width(DisplayState *ds) +{ + return ds->width; +} + +static inline int ds_get_height(DisplayState *ds) +{ + return ds->height; +} + +static inline int ds_get_bits_per_pixel(DisplayState *ds) +{ + return ds->depth; +} + +static inline int ds_get_bytes_per_pixel(DisplayState *ds) +{ + return (ds->depth / 8); +} + typedef unsigned long console_ch_t; static inline void console_write_ch(console_ch_t *dest, uint32_t ch) { diff --git a/hw/blizzard.c b/hw/blizzard.c --- a/hw/blizzard.c +++ b/hw/blizzard.c @@ -166,7 +166,7 @@ s->my[1] = s->data.y + s->data.dy; bypp[0] = s->bpp; - bypp[1] = (s->state->depth + 7) >> 3; + bypp[1] = (ds_get_bits_per_pixel(s->state) + 7) >> 3; bypl[0] = bypp[0] * s->data.pitch; bypl[1] = bypp[1] * s->x; bypl[2] = bypp[0] * s->data.dx; @@ -895,7 +895,7 @@ if (!s->enable) return; - if (s->x != s->state->width || s->y != s->state->height) { + if (s->x != ds_get_width(s->state) || s->y != ds_get_height(s->state)) { s->invalidate = 1; qemu_console_resize(s->console, s->x, s->y); } @@ -904,8 +904,8 @@ s->invalidate = 0; if (s->blank) { - bypp = (s->state->depth + 7) >> 3; - memset(s->state->data, 0, bypp * s->x * s->y); + bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3; + memset(ds_get_data(s->state), 0, bypp * s->x * s->y); return; } @@ -918,12 +918,12 @@ if (s->mx[1] <= s->mx[0]) return; - bypp = (s->state->depth + 7) >> 3; + bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3; bypl = bypp * s->x; bwidth = bypp * (s->mx[1] - s->mx[0]); y = s->my[0]; src = s->fb + bypl * y + bypp * s->mx[0]; - dst = s->state->data + bypl * y + bypp * s->mx[0]; + dst = ds_get_data(s->state) + bypl * y + bypp * s->mx[0]; for (; y < s->my[1]; y ++, src += bypl, dst += bypl) memcpy(dst, src, bwidth); @@ -940,8 +940,8 @@ struct blizzard_s *s = (struct blizzard_s *) opaque; blizzard_update_display(opaque); - if (s && s->state->data) - ppm_save(filename, s->state->data, s->x, s->y, s->state->linesize); + if (s && ds_get_data(s->state)) + ppm_save(filename, ds_get_data(s->state), s->x, s->y, ds_get_linesize(s->state)); } #define DEPTH 8 @@ -962,7 +962,7 @@ s->state = ds; s->fb = qemu_malloc(0x180000); - switch (s->state->depth) { + switch (ds_get_bits_per_pixel(s->state)) { case 0: s->line_fn_tab[0] = s->line_fn_tab[1] = qemu_mallocz(sizeof(blizzard_fn_t) * 0x10); diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -2342,9 +2342,9 @@ color1 = s->rgb_to_pixel(c6_to_8(palette[0xf * 3]), c6_to_8(palette[0xf * 3 + 1]), c6_to_8(palette[0xf * 3 + 2])); - bpp = ((s->ds->depth + 7) >> 3); + bpp = ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); d1 += x1 * bpp; - switch(s->ds->depth) { + switch(ds_get_bits_per_pixel(s->ds)) { default: break; case 8: diff --git a/hw/g364fb.c b/hw/g364fb.c --- a/hw/g364fb.c +++ b/hw/g364fb.c @@ -72,7 +72,7 @@ static void g364fb_draw_graphic(G364State *s, int full_update) { - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 8: g364fb_draw_graphic8(s, full_update); break; @@ -86,7 +86,7 @@ g364fb_draw_graphic32(s, full_update); break; default: - printf("g364fb: unknown depth %d\n", s->ds->depth); + printf("g364fb: unknown depth %d\n", ds_get_bits_per_pixel(s->ds)); return; } @@ -101,11 +101,11 @@ if (!full_update) return; - w = s->scr_width * ((s->ds->depth + 7) >> 3); - d = s->ds->data; + w = s->scr_width * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); + d = ds_get_data(s->ds); for(i = 0; i < s->scr_height; i++) { memset(d, 0, w); - d += s->ds->linesize; + d += ds_get_linesize(s->ds); } dpy_update(s->ds, 0, 0, s->scr_width, s->scr_height); @@ -131,7 +131,7 @@ s->graphic_mode = graphic_mode; full_update = 1; } - if (s->scr_width != s->ds->width || s->scr_height != s->ds->height) { + if (s->scr_width != ds_get_width(s->ds) || s->scr_height != ds_get_height(s->ds)) { qemu_console_resize(s->console, s->scr_width, s->scr_height); full_update = 1; } diff --git a/hw/g364fb_template.h b/hw/g364fb_template.h --- a/hw/g364fb_template.h +++ b/hw/g364fb_template.h @@ -28,7 +28,7 @@ data_buffer = s->vram_buffer; w_display = s->scr_width * PIXEL_WIDTH / 8; - data_display = s->ds->data; + data_display = ds_get_data(s->ds); for(i = 0; i < s->scr_height; i++) { dd = data_display; for (j = 0; j < s->scr_width; j++, dd += PIXEL_WIDTH / 8, data_buffer++) { @@ -38,6 +38,6 @@ s->palette[index][1], s->palette[index][2]); } - data_display += s->ds->linesize; + data_display += ds_get_linesize(s->ds); } } diff --git a/hw/jazz_led.c b/hw/jazz_led.c --- a/hw/jazz_led.c +++ b/hw/jazz_led.c @@ -155,8 +155,8 @@ uint8_t *d; int x, bpp; - bpp = (ds->depth + 7) >> 3; - d = ds->data + ds->linesize * posy + bpp * posx1; + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; + d = ds_get_data(ds) + ds_get_linesize(ds) * posy + bpp * posx1; switch(bpp) { case 1: for (x = posx1; x <= posx2; x++) { @@ -184,25 +184,25 @@ uint8_t *d; int y, bpp; - bpp = (ds->depth + 7) >> 3; - d = ds->data + ds->linesize * posy1 + bpp * posx; + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; + d = ds_get_data(ds) + ds_get_linesize(ds) * posy1 + bpp * posx; switch(bpp) { case 1: for (y = posy1; y <= posy2; y++) { *((uint8_t *)d) = color; - d += ds->linesize; + d += ds_get_linesize(ds); } break; case 2: for (y = posy1; y <= posy2; y++) { *((uint16_t *)d) = color; - d += ds->linesize; + d += ds_get_linesize(ds); } break; case 4: for (y = posy1; y <= posy2; y++) { *((uint32_t *)d) = color; - d += ds->linesize; + d += ds_get_linesize(ds); } break; } @@ -218,17 +218,17 @@ if (s->state & REDRAW_BACKGROUND) { /* clear screen */ - bpp = (ds->depth + 7) >> 3; - d1 = ds->data; - for (y = 0; y < ds->height; y++) { - memset(d1, 0x00, ds->width * bpp); - d1 += ds->linesize; + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; + d1 = ds_get_data(ds); + for (y = 0; y < ds_get_height(ds); y++) { + memset(d1, 0x00, ds_get_width(ds) * bpp); + d1 += ds_get_linesize(ds); } } if (s->state & REDRAW_SEGMENTS) { /* set colors according to bpp */ - switch (ds->depth) { + switch (ds_get_bits_per_pixel(ds)) { case 8: color_segment = rgb_to_pixel8(0xaa, 0xaa, 0xaa); color_led = rgb_to_pixel8(0x00, 0xff, 0x00); @@ -272,7 +272,7 @@ } s->state = REDRAW_NONE; - dpy_update(ds, 0, 0, ds->width, ds->height); + dpy_update(ds, 0, 0, ds_get_width(ds), ds_get_height(ds)); } static void jazz_led_invalidate_display(void *opaque) diff --git a/hw/musicpal.c b/hw/musicpal.c --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -801,7 +801,7 @@ (musicpal_lcd_state *s, int x, int y, type col) \ { \ int dx, dy; \ - type *pixel = &((type *) s->ds->data)[(y * 128 * 3 + x) * 3]; \ + type *pixel = &((type *) ds_get_data(s->ds))[(y * 128 * 3 + x) * 3]; \ \ for (dy = 0; dy < 3; dy++, pixel += 127 * 3) \ for (dx = 0; dx < 3; dx++, pixel++) \ @@ -818,7 +818,7 @@ musicpal_lcd_state *s = opaque; int x, y, col; - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 0: return; #define LCD_REFRESH(depth, func) \ @@ -838,7 +838,7 @@ LCD_REFRESH(32, (s->ds->bgr ? rgb_to_pixel32bgr : rgb_to_pixel32)) default: cpu_abort(cpu_single_env, "unsupported colour depth %i\n", - s->ds->depth); + ds_get_bits_per_pixel(s->ds)); } dpy_update(s->ds, 0, 0, 128*3, 64*3); diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c --- a/hw/omap_lcdc.c +++ b/hw/omap_lcdc.c @@ -125,7 +125,7 @@ uint8_t *s, *d; if (!omap_lcd || omap_lcd->plm == 1 || - !omap_lcd->enable || !omap_lcd->state->depth) + !omap_lcd->enable || !ds_get_bits_per_pixel(omap_lcd->state)) return; frame_offset = 0; @@ -145,25 +145,25 @@ /* Colour depth */ switch ((omap_lcd->palette[0] >> 12) & 7) { case 1: - draw_line = draw_line_table2[omap_lcd->state->depth]; + draw_line = draw_line_table2[ds_get_bits_per_pixel(omap_lcd->state)]; bpp = 2; break; case 2: - draw_line = draw_line_table4[omap_lcd->state->depth]; + draw_line = draw_line_table4[ds_get_bits_per_pixel(omap_lcd->state)]; bpp = 4; break; case 3: - draw_line = draw_line_table8[omap_lcd->state->depth]; + draw_line = draw_line_table8[ds_get_bits_per_pixel(omap_lcd->state)]; bpp = 8; break; case 4 ... 7: if (!omap_lcd->tft) - draw_line = draw_line_table12[omap_lcd->state->depth]; + draw_line = draw_line_table12[ds_get_bits_per_pixel(omap_lcd->state)]; else - draw_line = draw_line_table16[omap_lcd->state->depth]; + draw_line = draw_line_table16[ds_get_bits_per_pixel(omap_lcd->state)]; bpp = 16; break; @@ -174,8 +174,8 @@ /* Resolution */ width = omap_lcd->width; - if (width != omap_lcd->state->width || - omap_lcd->height != omap_lcd->state->height) { + if (width != ds_get_width(omap_lcd->state) || + omap_lcd->height != ds_get_height(omap_lcd->state)) { qemu_console_resize(omap_lcd->console, omap_lcd->width, omap_lcd->height); omap_lcd->invalidate = 1; @@ -202,7 +202,7 @@ if (omap_lcd->dma->dual) omap_lcd->dma->current_frame ^= 1; - if (!omap_lcd->state->depth) + if (!ds_get_bits_per_pixel(omap_lcd->state)) return; line = 0; @@ -217,8 +217,8 @@ step = width * bpp >> 3; scanline = frame_base + step * line; s = (uint8_t *) (phys_ram_base + scanline); - d = omap_lcd->state->data; - linesize = omap_lcd->state->linesize; + d = ds_get_data(omap_lcd->state); + linesize = ds_get_linesize(omap_lcd->state); dirty[0] = dirty[1] = cpu_physical_memory_get_dirty(scanline, VGA_DIRTY_FLAG); @@ -293,10 +293,10 @@ static void omap_screen_dump(void *opaque, const char *filename) { struct omap_lcd_panel_s *omap_lcd = opaque; omap_update_display(opaque); - if (omap_lcd && omap_lcd->state->data) - ppm_save(filename, omap_lcd->state->data, + if (omap_lcd && ds_get_data(omap_lcd->state)) + ppm_save(filename, ds_get_data(omap_lcd->state), omap_lcd->width, omap_lcd->height, - omap_lcd->state->linesize); + ds_get_linesize(omap_lcd->state)); } static void omap_invalidate_display(void *opaque) { diff --git a/hw/pl110.c b/hw/pl110.c --- a/hw/pl110.c +++ b/hw/pl110.c @@ -124,7 +124,7 @@ if (!pl110_enabled(s)) return; - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 0: return; case 8: @@ -190,7 +190,7 @@ if (base > 0x80000000) base -= 0x80000000; src = phys_ram_base + base; - dest = s->ds->data; + dest = ds_get_data(s->ds); first = -1; addr = base; @@ -249,7 +249,7 @@ b = (raw & 0x1f) << 3; /* The I bit is ignored. */ raw >>= 6; - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 8: s->pallette[n] = rgb_to_pixel8(r, g, b); break; diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c --- a/hw/pxa2xx_lcd.c +++ b/hw/pxa2xx_lcd.c @@ -650,7 +650,7 @@ } break; } - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 8: *dest = rgb_to_pixel8(r, g, b) | alpha; break; @@ -693,7 +693,7 @@ else if (s->bpp > pxa_lcdc_8bpp) src_width *= 2; - dest = s->ds->data; + dest = ds_get_data(s->ds); dest_width = s->xres * s->dest_width; addr = (ram_addr_t) (fb - phys_ram_base); @@ -750,7 +750,7 @@ src_width *= 2; dest_width = s->yres * s->dest_width; - dest = s->ds->data + dest_width * (s->xres - 1); + dest = ds_get_data(s->ds) + dest_width * (s->xres - 1); addr = (ram_addr_t) (fb - phys_ram_base); start = addr + s->yres * src_width; @@ -1006,7 +1006,7 @@ pxa2xx_invalidate_display, pxa2xx_screen_dump, NULL, s); - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 0: s->dest_width = 0; break; diff --git a/hw/ssd0303.c b/hw/ssd0303.c --- a/hw/ssd0303.c +++ b/hw/ssd0303.c @@ -206,7 +206,7 @@ if (!s->redraw) return; - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 0: return; case 15: @@ -238,7 +238,7 @@ colors[0] = colortab + dest_width; colors[1] = colortab; } - dest = s->ds->data; + dest = ds_get_data(s->ds); for (y = 0; y < 16; y++) { line = (y + s->start_line) & 63; src = s->framebuffer + 132 * (line >> 3) + 36; diff --git a/hw/ssd0323.c b/hw/ssd0323.c --- a/hw/ssd0323.c +++ b/hw/ssd0323.c @@ -187,7 +187,7 @@ if (!s->redraw) return; - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 0: return; case 15: @@ -210,7 +210,7 @@ for (i = 0; i < 16; i++) { int n; colors[i] = p; - switch (s->ds->depth) { + switch (ds_get_bits_per_pixel(s->ds)) { case 15: n = i * 2 + (i >> 3); p[0] = n | (n << 5); @@ -233,7 +233,7 @@ p += dest_width; } /* TODO: Implement row/column remapping. */ - dest = s->ds->data; + dest = ds_get_data(s->ds); for (y = 0; y < 64; y++) { line = y; src = s->framebuffer + 64 * line; diff --git a/hw/tcx.c b/hw/tcx.c --- a/hw/tcx.c +++ b/hw/tcx.c @@ -55,7 +55,7 @@ { int i; for(i = start; i < end; i++) { - switch(s->ds->depth) { + switch(ds_get_bits_per_pixel(s->ds)) { default: case 8: s->palette[i] = rgb_to_pixel8(s->r[i], s->g[i], s->b[i]); @@ -200,18 +200,18 @@ uint8_t *d, *s; void (*f)(TCXState *s1, uint8_t *dst, const uint8_t *src, int width); - if (ts->ds->depth == 0) + if (ds_get_bits_per_pixel(ts->ds) == 0) return; page = ts->vram_offset; y_start = -1; page_min = 0xffffffff; page_max = 0; - d = ts->ds->data; + d = ds_get_data(ts->ds); s = ts->vram; - dd = ts->ds->linesize; + dd = ds_get_linesize(ts->ds); ds = 1024; - switch (ts->ds->depth) { + switch (ds_get_bits_per_pixel(ts->ds)) { case 32: f = tcx_draw_line32; break; @@ -278,7 +278,7 @@ uint8_t *d, *s; uint32_t *cptr, *s24; - if (ts->ds->depth != 32) + if (ds_get_bits_per_pixel(ts->ds) != 32) return; page = ts->vram_offset; page24 = ts->vram24_offset; @@ -286,11 +286,11 @@ y_start = -1; page_min = 0xffffffff; page_max = 0; - d = ts->ds->data; + d = ds_get_data(ts->ds); s = ts->vram; s24 = ts->vram24; cptr = ts->cplane; - dd = ts->ds->linesize; + dd = ds_get_linesize(ts->ds); ds = 1024; for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE, diff --git a/hw/vga.c b/hw/vga.c --- a/hw/vga.c +++ b/hw/vga.c @@ -1164,7 +1164,7 @@ static inline int get_depth_index(DisplayState *s) { - switch(s->depth) { + switch(ds_get_bits_per_pixel(s)) { default: case 8: return 0; @@ -1326,7 +1326,7 @@ cw = 9; if (s->sr[1] & 0x08) cw = 16; /* NOTE: no 18 pixel wide */ - x_incr = cw * ((s->ds->depth + 7) >> 3); + x_incr = cw * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); width = (s->cr[0x01] + 1); if (s->cr[0x06] == 100) { /* ugly hack for CGA 160x100x16 - explain me the logic */ @@ -1376,8 +1376,8 @@ vga_draw_glyph8 = vga_draw_glyph8_table[depth_index]; vga_draw_glyph9 = vga_draw_glyph9_table[depth_index]; - dest = s->ds->data; - linesize = s->ds->linesize; + dest = ds_get_data(s->ds); + linesize = ds_get_linesize(s->ds); ch_attr_ptr = s->last_ch_attr; for(cy = 0; cy < height; cy++) { d1 = dest; @@ -1870,7 +1870,7 @@ VGAState *s = (VGAState *)opaque; int full_update, graphic_mode; - if (s->ds->depth == 0) { + if (ds_get_bits_per_pixel(s->ds) == 0) { /* nothing to do */ } else { full_update = 0; @@ -2755,10 +2755,10 @@ s->graphic_mode = -1; vga_update_display(s); - if (ds->data) { - ppm_save(filename, ds->data, vga_save_w, vga_save_h, - s->ds->linesize); - qemu_free(ds->data); + if (ds_get_data(ds)) { + ppm_save(filename, ds_get_data(ds), vga_save_w, vga_save_h, + ds_get_linesize(s->ds)); + qemu_free(ds_get_data(ds)); } s->ds = saved_ds; } diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -321,7 +321,7 @@ width = s->bypp * w; start = s->bypp * x + bypl * y; src = s->vram + start; - dst = s->ds->data + start; + dst = ds_get_data(s->ds) + start; for (; line > 0; line --, src += bypl, dst += bypl) memcpy(dst, src, width); @@ -333,7 +333,7 @@ static inline void vmsvga_update_screen(struct vmsvga_state_s *s) { #ifndef DIRECT_VRAM - memcpy(s->ds->data, s->vram, s->bypp * s->width * s->height); + memcpy(ds_get_data(s->ds), s->vram, s->bypp * s->width * s->height); #endif dpy_update(s->ds, 0, 0, s->width, s->height); @@ -375,7 +375,7 @@ int x0, int y0, int x1, int y1, int w, int h) { # ifdef DIRECT_VRAM - uint8_t *vram = s->ds->data; + uint8_t *vram = ds_get_data(s->ds); # else uint8_t *vram = s->vram; # endif @@ -412,7 +412,7 @@ uint32_t c, int x, int y, int w, int h) { # ifdef DIRECT_VRAM - uint8_t *vram = s->ds->data; + uint8_t *vram = ds_get_data(s->ds); # else uint8_t *vram = s->vram; # endif @@ -917,7 +917,7 @@ s->width = -1; s->height = -1; s->svgaid = SVGA_ID; - s->depth = s->ds->depth ? s->ds->depth : 24; + s->depth = ds_get_bits_per_pixel(s->ds) ? ds_get_bits_per_pixel(s->ds) : 24; s->bypp = (s->depth + 7) >> 3; s->cursor.on = 0; s->redraw_fifo_first = 0; @@ -978,7 +978,7 @@ } if (s->depth == 32) { - ppm_save(filename, s->vram, s->width, s->height, s->ds->linesize); + ppm_save(filename, s->vram, s->width, s->height, ds_get_linesize(s->ds)); } } @@ -996,7 +996,7 @@ struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base; if (addr < s->fb_size) - return *(uint8_t *) (s->ds->data + addr); + return *(uint8_t *) (ds_get_data(s->ds) + addr); else return *(uint8_t *) (s->vram + addr); } @@ -1006,7 +1006,7 @@ struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base; if (addr < s->fb_size) - return *(uint16_t *) (s->ds->data + addr); + return *(uint16_t *) (ds_get_data(s->ds) + addr); else return *(uint16_t *) (s->vram + addr); } @@ -1016,7 +1016,7 @@ struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base; if (addr < s->fb_size) - return *(uint32_t *) (s->ds->data + addr); + return *(uint32_t *) (ds_get_data(s->ds) + addr); else return *(uint32_t *) (s->vram + addr); } @@ -1027,7 +1027,7 @@ struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base; if (addr < s->fb_size) - *(uint8_t *) (s->ds->data + addr) = value; + *(uint8_t *) (ds_get_data(s->ds) + addr) = value; else *(uint8_t *) (s->vram + addr) = value; } @@ -1038,7 +1038,7 @@ struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base; if (addr < s->fb_size) - *(uint16_t *) (s->ds->data + addr) = value; + *(uint16_t *) (ds_get_data(s->ds) + addr) = value; else *(uint16_t *) (s->vram + addr) = value; } @@ -1049,7 +1049,7 @@ struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base; if (addr < s->fb_size) - *(uint32_t *) (s->ds->data + addr) = value; + *(uint32_t *) (ds_get_data(s->ds) + addr) = value; else *(uint32_t *) (s->vram + addr) = value; } diff --git a/hw/xenfb.c b/hw/xenfb.c --- a/hw/xenfb.c +++ b/hw/xenfb.c @@ -325,8 +325,8 @@ if (xenfb->abs_pointer_wanted) xenfb_send_position(xenfb, - dx * (xenfb->c.ds->width - 1) / 0x7fff, - dy * (xenfb->c.ds->height - 1) / 0x7fff, + dx * (ds_get_width(xenfb->c.ds) - 1) / 0x7fff, + dy * (ds_get_height(xenfb->c.ds) - 1) / 0x7fff, dz); else xenfb_send_motion(xenfb, dx, dy, dz); @@ -566,9 +566,9 @@ + xenfb->offset \ + (line * xenfb->row_stride) \ + (x * xenfb->depth / 8)); \ - DST_T *dst = (DST_T *)(xenfb->c.ds->data \ - + (line * xenfb->c.ds->linesize) \ - + (x * xenfb->c.ds->depth / 8)); \ + DST_T *dst = (DST_T *)(ds_get_data(xenfb->c.ds) \ + + (line * ds_get_linesize(xenfb->c.ds)) \ + + (x * ds_get_bytes_per_pixel(xenfb->c.ds))); \ int col; \ const int RSS = 32 - (RSB + GSB + BSB); \ const int GSS = 32 - (GSB + BSB); \ @@ -588,7 +588,7 @@ (((spix << GSS) & GSM & GDM) >> GDS) | \ (((spix << BSS) & BSM & BDM) >> BDS); \ src = (SRC_T *) ((unsigned long) src + xenfb->depth / 8); \ - dst = (DST_T *) ((unsigned long) dst + xenfb->c.ds->depth / 8); \ + dst = (DST_T *) ((unsigned long) dst + ds_get_bytes_per_pixel(xenfb->c.ds)); \ } \ } @@ -610,9 +610,9 @@ * - Put ds->shared_buf back into use then. */ if (1 /* !xenfb->c.ds->shared_buf */) { - if (xenfb->depth == xenfb->c.ds->depth) { /* Perfect match can use fast path */ + if (xenfb->depth == ds_get_bits_per_pixel(xenfb->c.ds)) { /* Perfect match can use fast path */ for (line = y ; line < (y+h) ; line++) { - memcpy(xenfb->c.ds->data + (line * xenfb->c.ds->linesize) + (x * xenfb->c.ds->depth / 8), + memcpy(ds_get_data(xenfb->c.ds) + (line * ds_get_linesize(xenfb->c.ds)) + (x * ds_get_bytes_per_pixel(xenfb->c.ds)), xenfb->pixels + xenfb->offset + (line * xenfb->row_stride) + (x * xenfb->depth / 8), w * xenfb->depth / 8); } @@ -622,23 +622,23 @@ /* 24 bit == r:8 g:8 b:8 */ /* 32 bit == r:8 g:8 b:8 (padding:8) */ if (xenfb->depth == 8) { - if (xenfb->c.ds->depth == 16) { + if (ds_get_bits_per_pixel(xenfb->c.ds) == 16) { BLT(uint8_t, uint16_t, 3, 3, 2, 5, 6, 5); - } else if (xenfb->c.ds->depth == 32) { + } else if (ds_get_bits_per_pixel(xenfb->c.ds) == 32) { BLT(uint8_t, uint32_t, 3, 3, 2, 8, 8, 8); } } else if (xenfb->depth == 16) { - if (xenfb->c.ds->depth == 8) { + if (ds_get_bits_per_pixel(xenfb->c.ds) == 8) { BLT(uint16_t, uint8_t, 5, 6, 5, 3, 3, 2); - } else if (xenfb->c.ds->depth == 32) { + } else if (ds_get_bits_per_pixel(xenfb->c.ds) == 32) { BLT(uint16_t, uint32_t, 5, 6, 5, 8, 8, 8); } } else if (xenfb->depth == 24 || xenfb->depth == 32) { - if (xenfb->c.ds->depth == 8) { + if (ds_get_bits_per_pixel(xenfb->c.ds) == 8) { BLT(uint32_t, uint8_t, 8, 8, 8, 3, 3, 2); - } else if (xenfb->c.ds->depth == 16) { + } else if (ds_get_bits_per_pixel(xenfb->c.ds) == 16) { BLT(uint32_t, uint16_t, 8, 8, 8, 5, 6, 5); - } else if (xenfb->c.ds->depth == 32) { + } else if (ds_get_bits_per_pixel(xenfb->c.ds) == 32) { BLT(uint32_t, uint32_t, 8, 8, 8, 8, 8, 8); } } @@ -730,7 +730,7 @@ } /* resize if needed */ - if (xenfb->width != xenfb->c.ds->width || xenfb->height != xenfb->c.ds->height) { + if (xenfb->width != ds_get_width(xenfb->c.ds) || xenfb->height != ds_get_height(xenfb->c.ds)) { xen_be_printf(&xenfb->c.xendev, 1, "update: resizing: %dx%d\n", xenfb->width, xenfb->height); dpy_resize(xenfb->c.ds, xenfb->width, xenfb->height); diff --git a/sdl.c b/sdl.c --- a/sdl.c +++ b/sdl.c @@ -88,7 +88,7 @@ glGenTextures(1, &texture_ref); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_ref); glPixelStorei(GL_UNPACK_LSB_FIRST, 1); - switch (ds->depth) { + switch (ds_get_bits_per_pixel(ds)) { case 8: if (ds->palette == NULL) { tex_format = GL_RGB; @@ -128,8 +128,8 @@ } break; } - glPixelStorei(GL_UNPACK_ROW_LENGTH, (ds->linesize * 8) / ds->depth); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, gl_format, ds->width, ds->height, 0, tex_format, tex_type, pixels); + glPixelStorei(GL_UNPACK_ROW_LENGTH, (ds_get_linesize(ds) / ds_get_bytes_per_pixel(ds))); + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, gl_format, ds_get_width(ds), ds_get_height(ds), 0, tex_format, tex_type, pixels); glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_PRIORITY, 1.0); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -140,10 +140,10 @@ static void opengl_update(DisplayState *ds, int x, int y, int w, int h) { - int bpp = ds->depth / 8; - GLvoid *pixels = ds->data + y * ds->linesize + x * bpp; + int bpp = ds_get_bytes_per_pixel(ds); + GLvoid *pixels = ds_get_data(ds) + y * ds_get_linesize(ds) + x * bpp; glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_ref); - glPixelStorei(GL_UNPACK_ROW_LENGTH, ds->linesize / bpp); + glPixelStorei(GL_UNPACK_ROW_LENGTH, ds_get_linesize(ds) / bpp); glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, x, y, w, h, tex_format, tex_type, pixels); glBegin(GL_QUADS); glTexCoord2d(0, 0); @@ -177,7 +177,7 @@ static void sdl_setdata(DisplayState *ds, void *pixels) { uint32_t rmask, gmask, bmask, amask = 0; - switch (ds->depth) { + switch (ds_get_bits_per_pixel(ds)) { case 8: rmask = 0x000000E0; gmask = 0x0000001C; @@ -201,8 +201,8 @@ default: return; } - shared = SDL_CreateRGBSurfaceFrom(pixels, width, height, ds->depth, ds->linesize, rmask , gmask, bmask, amask); - if (ds->depth == 8 && ds->palette != NULL) { + shared = SDL_CreateRGBSurfaceFrom(pixels, width, height, ds_get_bits_per_pixel(ds), ds_get_linesize(ds), rmask , gmask, bmask, amask); + if (ds_get_bits_per_pixel(ds) == 8 && ds->palette != NULL) { SDL_Color palette[256]; int i; for (i = 0; i < 256; i++) { @@ -309,7 +309,7 @@ static void sdl_resize(DisplayState *ds, int w, int h) { - sdl_resize_shared(ds, w, h, 0, w * (ds->depth / 8), NULL); + sdl_resize_shared(ds, w, h, 0, w * ds_get_bytes_per_pixel(ds), NULL); } static void sdl_colourdepth(DisplayState *ds, int depth) @@ -537,7 +537,7 @@ static void toggle_full_screen(DisplayState *ds) { gui_fullscreen = !gui_fullscreen; - sdl_resize_shared(ds, ds->width, ds->height, ds->depth, ds->linesize, ds->data); + sdl_resize_shared(ds, ds_get_width(ds), ds_get_height(ds), ds_get_bits_per_pixel(ds), ds_get_linesize(ds), ds_get_data(ds)); if (gui_fullscreen) { gui_saved_grab = gui_grab; sdl_grab_start(); diff --git a/vnc.c b/vnc.c --- a/vnc.c +++ b/vnc.c @@ -514,10 +514,10 @@ vnc_framebuffer_update(vs, x, y, w, h, 0); - row = vs->ds->data + y * vs->ds->linesize + x * vs->depth; + row = ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * vs->depth; for (i = 0; i < h; i++) { vs->write_pixels(vs, row, w * vs->depth); - row += vs->ds->linesize; + row += ds_get_linesize(vs->ds); } } @@ -594,7 +594,7 @@ uint8_t *dst_row; uint8_t *old_row; int y = 0; - int pitch = ds->linesize; + int pitch = ds_get_linesize(ds); VncState *vs = ds->opaque; int updating_client = 1; @@ -620,11 +620,11 @@ pitch = -pitch; } - src = (ds->linesize * (src_y + y) + vs->depth * src_x); - dst = (ds->linesize * (dst_y + y) + vs->depth * dst_x); + src = (ds_get_linesize(ds) * (src_y + y) + vs->depth * src_x); + dst = (ds_get_linesize(ds) * (dst_y + y) + vs->depth * dst_x); - src_row = ds->data + src; - dst_row = ds->data + dst; + src_row = ds_get_data(ds) + src; + dst_row = ds_get_data(ds) + dst; old_row = vs->old_data + dst; for (y = 0; y < h; y++) { @@ -1916,10 +1916,10 @@ vga_hw_update(); - vs->width = vs->ds->width; - vs->height = vs->ds->height; - vnc_write_u16(vs, vs->ds->width); - vnc_write_u16(vs, vs->ds->height); + vs->width = ds_get_width(vs->ds); + vs->height = ds_get_height(vs->ds); + vnc_write_u16(vs, ds_get_width(vs->ds)); + vnc_write_u16(vs, ds_get_height(vs->ds)); pixel_format_message(vs); diff --git a/vnchextile.h b/vnchextile.h --- a/vnchextile.h +++ b/vnchextile.h @@ -13,7 +13,7 @@ void *last_fg_, int *has_bg, int *has_fg) { - uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth); + uint8_t *row = (ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * vs->depth); pixel_t *irow = (pixel_t *)row; int j, i; pixel_t *last_bg = (pixel_t *)last_bg_; @@ -57,7 +57,7 @@ } if (n_colors > 2) break; - irow += vs->ds->linesize / sizeof(pixel_t); + irow += ds_get_linesize(vs->ds) / sizeof(pixel_t); } if (n_colors > 1 && fg_count > bg_count) { @@ -105,7 +105,7 @@ n_data += 2; n_subtiles++; } - irow += vs->ds->linesize / sizeof(pixel_t); + irow += ds_get_linesize(vs->ds) / sizeof(pixel_t); } break; case 3: @@ -161,7 +161,7 @@ n_data += 2; n_subtiles++; } - irow += vs->ds->linesize / sizeof(pixel_t); + irow += ds_get_linesize(vs->ds) / sizeof(pixel_t); } /* A SubrectsColoured subtile invalidates the foreground color */ @@ -198,7 +198,7 @@ } else { for (j = 0; j < h; j++) { vs->write_pixels(vs, row, w * vs->depth); - row += vs->ds->linesize; + row += ds_get_linesize(vs->ds); } } } diff --git a/xenfbfront.c b/xenfbfront.c --- a/xenfbfront.c +++ b/xenfbfront.c @@ -73,10 +73,10 @@ if (ds->shared_buf) { offset = pixels - xs->vga_vram; ds->data = pixels; - fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, offset); + fbfront_resize(fb_dev, ds_get_width(ds), ds_get_height(ds), ds_get_linesize(ds), ds_get_bits_per_pixel(ds), offset); } else { ds->data = xs->nonshared_vram; - fbfront_resize(fb_dev, w, h, linesize, ds->depth, vga_ram_size); + fbfront_resize(fb_dev, w, h, linesize, ds_get_bits_per_pixel(ds), vga_ram_size); } } @@ -93,7 +93,7 @@ ds->data = pixels; if (!fb_dev) return; - fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, offset); + fbfront_resize(fb_dev, ds_get_width(ds), ds_get_height(ds), ds_get_linesize(ds), ds_get_bits_per_pixel(ds), offset); } static void xenfb_pv_refresh(DisplayState *ds) @@ -151,14 +151,14 @@ { int new_x = buf[i].pos.abs_x; int new_y = buf[i].pos.abs_y; - if (new_x >= s->width) - new_x = s->width - 1; - if (new_y >= s->height) - new_y = s->height - 1; + if (new_x >= ds_get_width(s)) + new_x = ds_get_width(s) - 1; + if (new_y >= ds_get_height(s)) + new_y = ds_get_height(s) - 1; if (kbd_mouse_is_absolute()) { kbd_mouse_event( - new_x * 0x7FFF / (s->width - 1), - new_y * 0x7FFF / (s->height - 1), + new_x * 0x7FFF / (ds_get_width(s) - 1), + new_y * 0x7FFF / (ds_get_height(s) - 1), buf[i].pos.rel_z, buttons); } else { @@ -192,8 +192,8 @@ buttons &= ~button; if (kbd_mouse_is_absolute()) kbd_mouse_event( - x * 0x7FFF / (s->width - 1), - y * 0x7FFF / (s->height - 1), + x * 0x7FFF / (ds_get_width(s) - 1), + y * 0x7FFF / (ds_get_height(s) - 1), 0, buttons); else @@ -287,7 +287,7 @@ for (i = 0; i < n; i++) mfns[n + i] = virtual_to_mfn(xs->nonshared_vram + i * PAGE_SIZE); - fb_dev = init_fbfront(fb_path, mfns, ds->width, ds->height, ds->depth, ds->linesize, 2 * n); + fb_dev = init_fbfront(fb_path, mfns, ds_get_width(ds), ds_get_height(ds), ds_get_bits_per_pixel(ds), ds_get_linesize(ds), 2 * n); free(mfns); if (!fb_dev) { fprintf(stderr,"can't open frame buffer\n"); @@ -302,7 +302,7 @@ ds->data = xs->nonshared_vram; } if (offset) - fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, offset); + fbfront_resize(fb_dev, ds_get_width(ds), ds_get_height(ds), ds_get_linesize(ds), ds_get_bits_per_pixel(ds), offset); down(&xs->kbd_sem); free(kbd_path); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |