Commit 0e1f5a0c495dd7a5c72c9321a29541bdde8f423a
1 parent
cab3bee2
Introduce accessors for DisplayState (Stefano Stabellini)
Introducing some accessors: ds_get_linesize ds_get_bits_per_pixel ds_get_width ds_get_height ds_get_data Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5789 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
20 changed files
with
205 additions
and
180 deletions
console.c
... | ... | @@ -190,7 +190,7 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba) |
190 | 190 | { |
191 | 191 | unsigned int r, g, b, color; |
192 | 192 | |
193 | - switch(ds->depth) { | |
193 | + switch(ds_get_bits_per_pixel(ds)) { | |
194 | 194 | #if 0 |
195 | 195 | case 8: |
196 | 196 | r = (rgba >> 16) & 0xff; |
... | ... | @@ -227,9 +227,9 @@ static void vga_fill_rect (DisplayState *ds, |
227 | 227 | uint8_t *d, *d1; |
228 | 228 | int x, y, bpp; |
229 | 229 | |
230 | - bpp = (ds->depth + 7) >> 3; | |
231 | - d1 = ds->data + | |
232 | - ds->linesize * posy + bpp * posx; | |
230 | + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; | |
231 | + d1 = ds_get_data(ds) + | |
232 | + ds_get_linesize(ds) * posy + bpp * posx; | |
233 | 233 | for (y = 0; y < height; y++) { |
234 | 234 | d = d1; |
235 | 235 | switch(bpp) { |
... | ... | @@ -252,7 +252,7 @@ static void vga_fill_rect (DisplayState *ds, |
252 | 252 | } |
253 | 253 | break; |
254 | 254 | } |
255 | - d1 += ds->linesize; | |
255 | + d1 += ds_get_linesize(ds); | |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
... | ... | @@ -263,27 +263,27 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w, |
263 | 263 | uint8_t *d; |
264 | 264 | int wb, y, bpp; |
265 | 265 | |
266 | - bpp = (ds->depth + 7) >> 3; | |
266 | + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; | |
267 | 267 | wb = w * bpp; |
268 | 268 | if (yd <= ys) { |
269 | - s = ds->data + | |
270 | - ds->linesize * ys + bpp * xs; | |
271 | - d = ds->data + | |
272 | - ds->linesize * yd + bpp * xd; | |
269 | + s = ds_get_data(ds) + | |
270 | + ds_get_linesize(ds) * ys + bpp * xs; | |
271 | + d = ds_get_data(ds) + | |
272 | + ds_get_linesize(ds) * yd + bpp * xd; | |
273 | 273 | for (y = 0; y < h; y++) { |
274 | 274 | memmove(d, s, wb); |
275 | - d += ds->linesize; | |
276 | - s += ds->linesize; | |
275 | + d += ds_get_linesize(ds); | |
276 | + s += ds_get_linesize(ds); | |
277 | 277 | } |
278 | 278 | } else { |
279 | - s = ds->data + | |
280 | - ds->linesize * (ys + h - 1) + bpp * xs; | |
281 | - d = ds->data + | |
282 | - ds->linesize * (yd + h - 1) + bpp * xd; | |
279 | + s = ds_get_data(ds) + | |
280 | + ds_get_linesize(ds) * (ys + h - 1) + bpp * xs; | |
281 | + d = ds_get_data(ds) + | |
282 | + ds_get_linesize(ds) * (yd + h - 1) + bpp * xd; | |
283 | 283 | for (y = 0; y < h; y++) { |
284 | 284 | memmove(d, s, wb); |
285 | - d -= ds->linesize; | |
286 | - s -= ds->linesize; | |
285 | + d -= ds_get_linesize(ds); | |
286 | + s -= ds_get_linesize(ds); | |
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
... | ... | @@ -373,7 +373,7 @@ static const uint32_t color_table_rgb[2][8] = { |
373 | 373 | |
374 | 374 | static inline unsigned int col_expand(DisplayState *ds, unsigned int col) |
375 | 375 | { |
376 | - switch(ds->depth) { | |
376 | + switch(ds_get_bits_per_pixel(ds)) { | |
377 | 377 | case 8: |
378 | 378 | col |= col << 8; |
379 | 379 | col |= col << 16; |
... | ... | @@ -443,13 +443,13 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, |
443 | 443 | bgcol = color_table[t_attrib->bold][t_attrib->bgcol]; |
444 | 444 | } |
445 | 445 | |
446 | - bpp = (ds->depth + 7) >> 3; | |
447 | - d = ds->data + | |
448 | - ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH; | |
449 | - linesize = ds->linesize; | |
446 | + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; | |
447 | + d = ds_get_data(ds) + | |
448 | + ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH; | |
449 | + linesize = ds_get_linesize(ds); | |
450 | 450 | font_ptr = vgafont16 + FONT_HEIGHT * ch; |
451 | 451 | xorcol = bgcol ^ fgcol; |
452 | - switch(ds->depth) { | |
452 | + switch(ds_get_bits_per_pixel(ds)) { | |
453 | 453 | case 8: |
454 | 454 | for(i = 0; i < FONT_HEIGHT; i++) { |
455 | 455 | font_data = *font_ptr++; |
... | ... | @@ -543,7 +543,7 @@ static void update_xy(TextConsole *s, int x, int y) |
543 | 543 | int y1, y2; |
544 | 544 | |
545 | 545 | if (s == active_console) { |
546 | - if (!s->ds->depth) { | |
546 | + if (!ds_get_bits_per_pixel(s->ds)) { | |
547 | 547 | text_update_xy(s, x, y); |
548 | 548 | return; |
549 | 549 | } |
... | ... | @@ -570,7 +570,7 @@ static void console_show_cursor(TextConsole *s, int show) |
570 | 570 | if (s == active_console) { |
571 | 571 | int x = s->x; |
572 | 572 | |
573 | - if (!s->ds->depth) { | |
573 | + if (!ds_get_bits_per_pixel(s->ds)) { | |
574 | 574 | s->cursor_invalidate = 1; |
575 | 575 | return; |
576 | 576 | } |
... | ... | @@ -604,7 +604,7 @@ static void console_refresh(TextConsole *s) |
604 | 604 | |
605 | 605 | if (s != active_console) |
606 | 606 | return; |
607 | - if (!s->ds->depth) { | |
607 | + if (!ds_get_bits_per_pixel(s->ds)) { | |
608 | 608 | s->text_x[0] = 0; |
609 | 609 | s->text_y[0] = 0; |
610 | 610 | s->text_x[1] = s->width - 1; |
... | ... | @@ -613,7 +613,7 @@ static void console_refresh(TextConsole *s) |
613 | 613 | return; |
614 | 614 | } |
615 | 615 | |
616 | - vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height, | |
616 | + vga_fill_rect(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds), | |
617 | 617 | color_table[0][COLOR_BLACK]); |
618 | 618 | y1 = s->y_displayed; |
619 | 619 | for(y = 0; y < s->height; y++) { |
... | ... | @@ -626,7 +626,7 @@ static void console_refresh(TextConsole *s) |
626 | 626 | if (++y1 == s->total_height) |
627 | 627 | y1 = 0; |
628 | 628 | } |
629 | - dpy_update(s->ds, 0, 0, s->ds->width, s->ds->height); | |
629 | + dpy_update(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds)); | |
630 | 630 | console_show_cursor(s, 1); |
631 | 631 | } |
632 | 632 | |
... | ... | @@ -689,7 +689,7 @@ static void console_put_lf(TextConsole *s) |
689 | 689 | c++; |
690 | 690 | } |
691 | 691 | if (s == active_console && s->y_displayed == s->y_base) { |
692 | - if (!s->ds->depth) { | |
692 | + if (!ds_get_bits_per_pixel(s->ds)) { | |
693 | 693 | s->text_x[0] = 0; |
694 | 694 | s->text_y[0] = 0; |
695 | 695 | s->text_x[1] = s->width - 1; |
... | ... | @@ -1048,7 +1048,7 @@ void console_select(unsigned int index) |
1048 | 1048 | if (s) { |
1049 | 1049 | active_console = s; |
1050 | 1050 | if (s->console_type != TEXT_CONSOLE && s->g_width && s->g_height |
1051 | - && (s->g_width != s->ds->width || s->g_height != s->ds->height)) | |
1051 | + && (s->g_width != ds_get_width(s->ds) || s->g_height != ds_get_height(s->ds))) | |
1052 | 1052 | dpy_resize(s->ds, s->g_width, s->g_height); |
1053 | 1053 | vga_hw_invalidate(); |
1054 | 1054 | } |
... | ... | @@ -1158,12 +1158,12 @@ static void text_console_invalidate(void *opaque) |
1158 | 1158 | { |
1159 | 1159 | TextConsole *s = (TextConsole *) opaque; |
1160 | 1160 | |
1161 | - if (s->g_width != s->ds->width || s->g_height != s->ds->height) { | |
1161 | + if (s->g_width != ds_get_width(s->ds) || s->g_height != ds_get_height(s->ds)) { | |
1162 | 1162 | if (s->console_type == TEXT_CONSOLE_FIXED_SIZE) |
1163 | 1163 | dpy_resize(s->ds, s->g_width, s->g_height); |
1164 | 1164 | else { |
1165 | - s->g_width = s->ds->width; | |
1166 | - s->g_height = s->ds->height; | |
1165 | + s->g_width = ds_get_width(s->ds); | |
1166 | + s->g_height = ds_get_height(s->ds); | |
1167 | 1167 | text_console_resize(s); |
1168 | 1168 | } |
1169 | 1169 | } |
... | ... | @@ -1302,8 +1302,8 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p) |
1302 | 1302 | s->total_height = DEFAULT_BACKSCROLL; |
1303 | 1303 | s->x = 0; |
1304 | 1304 | s->y = 0; |
1305 | - width = s->ds->width; | |
1306 | - height = s->ds->height; | |
1305 | + width = ds_get_width(s->ds); | |
1306 | + height = ds_get_height(s->ds); | |
1307 | 1307 | if (p != 0) { |
1308 | 1308 | width = strtoul(p, (char **)&p, 10); |
1309 | 1309 | if (*p == 'C') { |
... | ... | @@ -1347,7 +1347,7 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p) |
1347 | 1347 | void qemu_console_resize(QEMUConsole *console, int width, int height) |
1348 | 1348 | { |
1349 | 1349 | if (console->g_width != width || console->g_height != height |
1350 | - || !console->ds->data) { | |
1350 | + || !ds_get_data(console->ds)) { | |
1351 | 1351 | console->g_width = width; |
1352 | 1352 | console->g_height = height; |
1353 | 1353 | if (active_console == console) { | ... | ... |
console.h
... | ... | @@ -114,6 +114,31 @@ static inline void dpy_cursor(DisplayState *s, int x, int y) |
114 | 114 | s->dpy_text_cursor(s, x, y); |
115 | 115 | } |
116 | 116 | |
117 | +static inline int ds_get_linesize(DisplayState *ds) | |
118 | +{ | |
119 | + return ds->linesize; | |
120 | +} | |
121 | + | |
122 | +static inline uint8_t* ds_get_data(DisplayState *ds) | |
123 | +{ | |
124 | + return ds->data; | |
125 | +} | |
126 | + | |
127 | +static inline int ds_get_width(DisplayState *ds) | |
128 | +{ | |
129 | + return ds->width; | |
130 | +} | |
131 | + | |
132 | +static inline int ds_get_height(DisplayState *ds) | |
133 | +{ | |
134 | + return ds->height; | |
135 | +} | |
136 | + | |
137 | +static inline int ds_get_bits_per_pixel(DisplayState *ds) | |
138 | +{ | |
139 | + return ds->depth; | |
140 | +} | |
141 | + | |
117 | 142 | typedef unsigned long console_ch_t; |
118 | 143 | static inline void console_write_ch(console_ch_t *dest, uint32_t ch) |
119 | 144 | { | ... | ... |
hw/blizzard.c
... | ... | @@ -166,7 +166,7 @@ static void blizzard_window(struct blizzard_s *s) |
166 | 166 | s->my[1] = s->data.y + s->data.dy; |
167 | 167 | |
168 | 168 | bypp[0] = s->bpp; |
169 | - bypp[1] = (s->state->depth + 7) >> 3; | |
169 | + bypp[1] = (ds_get_bits_per_pixel(s->state) + 7) >> 3; | |
170 | 170 | bypl[0] = bypp[0] * s->data.pitch; |
171 | 171 | bypl[1] = bypp[1] * s->x; |
172 | 172 | bypl[2] = bypp[0] * s->data.dx; |
... | ... | @@ -895,7 +895,7 @@ static void blizzard_update_display(void *opaque) |
895 | 895 | if (!s->enable) |
896 | 896 | return; |
897 | 897 | |
898 | - if (s->x != s->state->width || s->y != s->state->height) { | |
898 | + if (s->x != ds_get_width(s->state) || s->y != ds_get_height(s->state)) { | |
899 | 899 | s->invalidate = 1; |
900 | 900 | qemu_console_resize(s->console, s->x, s->y); |
901 | 901 | } |
... | ... | @@ -904,8 +904,8 @@ static void blizzard_update_display(void *opaque) |
904 | 904 | s->invalidate = 0; |
905 | 905 | |
906 | 906 | if (s->blank) { |
907 | - bypp = (s->state->depth + 7) >> 3; | |
908 | - memset(s->state->data, 0, bypp * s->x * s->y); | |
907 | + bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3; | |
908 | + memset(ds_get_data(s->state), 0, bypp * s->x * s->y); | |
909 | 909 | return; |
910 | 910 | } |
911 | 911 | |
... | ... | @@ -918,12 +918,12 @@ static void blizzard_update_display(void *opaque) |
918 | 918 | if (s->mx[1] <= s->mx[0]) |
919 | 919 | return; |
920 | 920 | |
921 | - bypp = (s->state->depth + 7) >> 3; | |
921 | + bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3; | |
922 | 922 | bypl = bypp * s->x; |
923 | 923 | bwidth = bypp * (s->mx[1] - s->mx[0]); |
924 | 924 | y = s->my[0]; |
925 | 925 | src = s->fb + bypl * y + bypp * s->mx[0]; |
926 | - dst = s->state->data + bypl * y + bypp * s->mx[0]; | |
926 | + dst = ds_get_data(s->state) + bypl * y + bypp * s->mx[0]; | |
927 | 927 | for (; y < s->my[1]; y ++, src += bypl, dst += bypl) |
928 | 928 | memcpy(dst, src, bwidth); |
929 | 929 | |
... | ... | @@ -940,8 +940,8 @@ static void blizzard_screen_dump(void *opaque, const char *filename) { |
940 | 940 | struct blizzard_s *s = (struct blizzard_s *) opaque; |
941 | 941 | |
942 | 942 | blizzard_update_display(opaque); |
943 | - if (s && s->state->data) | |
944 | - ppm_save(filename, s->state->data, s->x, s->y, s->state->linesize); | |
943 | + if (s && ds_get_data(s->state)) | |
944 | + ppm_save(filename, ds_get_data(s->state), s->x, s->y, ds_get_linesize(s->state)); | |
945 | 945 | } |
946 | 946 | |
947 | 947 | #define DEPTH 8 |
... | ... | @@ -962,7 +962,7 @@ void *s1d13745_init(qemu_irq gpio_int, DisplayState *ds) |
962 | 962 | s->state = ds; |
963 | 963 | s->fb = qemu_malloc(0x180000); |
964 | 964 | |
965 | - switch (s->state->depth) { | |
965 | + switch (ds_get_bits_per_pixel(s->state)) { | |
966 | 966 | case 0: |
967 | 967 | s->line_fn_tab[0] = s->line_fn_tab[1] = |
968 | 968 | qemu_mallocz(sizeof(blizzard_fn_t) * 0x10); | ... | ... |
hw/cirrus_vga.c
... | ... | @@ -2321,9 +2321,9 @@ static void cirrus_cursor_draw_line(VGAState *s1, uint8_t *d1, int scr_y) |
2321 | 2321 | color1 = s->rgb_to_pixel(c6_to_8(palette[0xf * 3]), |
2322 | 2322 | c6_to_8(palette[0xf * 3 + 1]), |
2323 | 2323 | c6_to_8(palette[0xf * 3 + 2])); |
2324 | - bpp = ((s->ds->depth + 7) >> 3); | |
2324 | + bpp = ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); | |
2325 | 2325 | d1 += x1 * bpp; |
2326 | - switch(s->ds->depth) { | |
2326 | + switch(ds_get_bits_per_pixel(s->ds)) { | |
2327 | 2327 | default: |
2328 | 2328 | break; |
2329 | 2329 | case 8: | ... | ... |
hw/g364fb.c
... | ... | @@ -72,7 +72,7 @@ typedef struct G364State { |
72 | 72 | |
73 | 73 | static void g364fb_draw_graphic(G364State *s, int full_update) |
74 | 74 | { |
75 | - switch (s->ds->depth) { | |
75 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
76 | 76 | case 8: |
77 | 77 | g364fb_draw_graphic8(s, full_update); |
78 | 78 | break; |
... | ... | @@ -86,7 +86,7 @@ static void g364fb_draw_graphic(G364State *s, int full_update) |
86 | 86 | g364fb_draw_graphic32(s, full_update); |
87 | 87 | break; |
88 | 88 | default: |
89 | - printf("g364fb: unknown depth %d\n", s->ds->depth); | |
89 | + printf("g364fb: unknown depth %d\n", ds_get_bits_per_pixel(s->ds)); | |
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
... | ... | @@ -101,11 +101,11 @@ static void g364fb_draw_blank(G364State *s, int full_update) |
101 | 101 | if (!full_update) |
102 | 102 | return; |
103 | 103 | |
104 | - w = s->scr_width * ((s->ds->depth + 7) >> 3); | |
105 | - d = s->ds->data; | |
104 | + w = s->scr_width * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); | |
105 | + d = ds_get_data(s->ds); | |
106 | 106 | for(i = 0; i < s->scr_height; i++) { |
107 | 107 | memset(d, 0, w); |
108 | - d += s->ds->linesize; | |
108 | + d += ds_get_linesize(s->ds); | |
109 | 109 | } |
110 | 110 | |
111 | 111 | dpy_update(s->ds, 0, 0, s->scr_width, s->scr_height); |
... | ... | @@ -131,7 +131,7 @@ static void g364fb_update_display(void *opaque) |
131 | 131 | s->graphic_mode = graphic_mode; |
132 | 132 | full_update = 1; |
133 | 133 | } |
134 | - if (s->scr_width != s->ds->width || s->scr_height != s->ds->height) { | |
134 | + if (s->scr_width != ds_get_width(s->ds) || s->scr_height != ds_get_height(s->ds)) { | |
135 | 135 | qemu_console_resize(s->console, s->scr_width, s->scr_height); |
136 | 136 | full_update = 1; |
137 | 137 | } | ... | ... |
hw/g364fb_template.h
... | ... | @@ -28,7 +28,7 @@ static void glue(g364fb_draw_graphic, BPP)(G364State *s, int full_update) |
28 | 28 | |
29 | 29 | data_buffer = s->vram_buffer; |
30 | 30 | w_display = s->scr_width * PIXEL_WIDTH / 8; |
31 | - data_display = s->ds->data; | |
31 | + data_display = ds_get_data(s->ds); | |
32 | 32 | for(i = 0; i < s->scr_height; i++) { |
33 | 33 | dd = data_display; |
34 | 34 | for (j = 0; j < s->scr_width; j++, dd += PIXEL_WIDTH / 8, data_buffer++) { |
... | ... | @@ -38,6 +38,6 @@ static void glue(g364fb_draw_graphic, BPP)(G364State *s, int full_update) |
38 | 38 | s->palette[index][1], |
39 | 39 | s->palette[index][2]); |
40 | 40 | } |
41 | - data_display += s->ds->linesize; | |
41 | + data_display += ds_get_linesize(s->ds); | |
42 | 42 | } |
43 | 43 | } | ... | ... |
hw/jazz_led.c
... | ... | @@ -155,8 +155,8 @@ static void draw_horizontal_line(DisplayState *ds, int posy, int posx1, int posx |
155 | 155 | uint8_t *d; |
156 | 156 | int x, bpp; |
157 | 157 | |
158 | - bpp = (ds->depth + 7) >> 3; | |
159 | - d = ds->data + ds->linesize * posy + bpp * posx1; | |
158 | + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; | |
159 | + d = ds_get_data(ds) + ds_get_linesize(ds) * posy + bpp * posx1; | |
160 | 160 | switch(bpp) { |
161 | 161 | case 1: |
162 | 162 | for (x = posx1; x <= posx2; x++) { |
... | ... | @@ -184,25 +184,25 @@ static void draw_vertical_line(DisplayState *ds, int posx, int posy1, int posy2, |
184 | 184 | uint8_t *d; |
185 | 185 | int y, bpp; |
186 | 186 | |
187 | - bpp = (ds->depth + 7) >> 3; | |
188 | - d = ds->data + ds->linesize * posy1 + bpp * posx; | |
187 | + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; | |
188 | + d = ds_get_data(ds) + ds_get_linesize(ds) * posy1 + bpp * posx; | |
189 | 189 | switch(bpp) { |
190 | 190 | case 1: |
191 | 191 | for (y = posy1; y <= posy2; y++) { |
192 | 192 | *((uint8_t *)d) = color; |
193 | - d += ds->linesize; | |
193 | + d += ds_get_linesize(ds); | |
194 | 194 | } |
195 | 195 | break; |
196 | 196 | case 2: |
197 | 197 | for (y = posy1; y <= posy2; y++) { |
198 | 198 | *((uint16_t *)d) = color; |
199 | - d += ds->linesize; | |
199 | + d += ds_get_linesize(ds); | |
200 | 200 | } |
201 | 201 | break; |
202 | 202 | case 4: |
203 | 203 | for (y = posy1; y <= posy2; y++) { |
204 | 204 | *((uint32_t *)d) = color; |
205 | - d += ds->linesize; | |
205 | + d += ds_get_linesize(ds); | |
206 | 206 | } |
207 | 207 | break; |
208 | 208 | } |
... | ... | @@ -218,17 +218,17 @@ static void jazz_led_update_display(void *opaque) |
218 | 218 | |
219 | 219 | if (s->state & REDRAW_BACKGROUND) { |
220 | 220 | /* clear screen */ |
221 | - bpp = (ds->depth + 7) >> 3; | |
222 | - d1 = ds->data; | |
223 | - for (y = 0; y < ds->height; y++) { | |
224 | - memset(d1, 0x00, ds->width * bpp); | |
225 | - d1 += ds->linesize; | |
221 | + bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; | |
222 | + d1 = ds_get_data(ds); | |
223 | + for (y = 0; y < ds_get_height(ds); y++) { | |
224 | + memset(d1, 0x00, ds_get_width(ds) * bpp); | |
225 | + d1 += ds_get_linesize(ds); | |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | 229 | if (s->state & REDRAW_SEGMENTS) { |
230 | 230 | /* set colors according to bpp */ |
231 | - switch (ds->depth) { | |
231 | + switch (ds_get_bits_per_pixel(ds)) { | |
232 | 232 | case 8: |
233 | 233 | color_segment = rgb_to_pixel8(0xaa, 0xaa, 0xaa); |
234 | 234 | color_led = rgb_to_pixel8(0x00, 0xff, 0x00); |
... | ... | @@ -272,7 +272,7 @@ static void jazz_led_update_display(void *opaque) |
272 | 272 | } |
273 | 273 | |
274 | 274 | s->state = REDRAW_NONE; |
275 | - dpy_update(ds, 0, 0, ds->width, ds->height); | |
275 | + dpy_update(ds, 0, 0, ds_get_width(ds), ds_get_height(ds)); | |
276 | 276 | } |
277 | 277 | |
278 | 278 | static void jazz_led_invalidate_display(void *opaque) | ... | ... |
hw/musicpal.c
... | ... | @@ -801,7 +801,7 @@ static inline void glue(set_lcd_pixel, depth) \ |
801 | 801 | (musicpal_lcd_state *s, int x, int y, type col) \ |
802 | 802 | { \ |
803 | 803 | int dx, dy; \ |
804 | - type *pixel = &((type *) s->ds->data)[(y * 128 * 3 + x) * 3]; \ | |
804 | + type *pixel = &((type *) ds_get_data(s->ds))[(y * 128 * 3 + x) * 3]; \ | |
805 | 805 | \ |
806 | 806 | for (dy = 0; dy < 3; dy++, pixel += 127 * 3) \ |
807 | 807 | for (dx = 0; dx < 3; dx++, pixel++) \ |
... | ... | @@ -818,7 +818,7 @@ static void lcd_refresh(void *opaque) |
818 | 818 | musicpal_lcd_state *s = opaque; |
819 | 819 | int x, y, col; |
820 | 820 | |
821 | - switch (s->ds->depth) { | |
821 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
822 | 822 | case 0: |
823 | 823 | return; |
824 | 824 | #define LCD_REFRESH(depth, func) \ |
... | ... | @@ -838,7 +838,7 @@ static void lcd_refresh(void *opaque) |
838 | 838 | LCD_REFRESH(32, (s->ds->bgr ? rgb_to_pixel32bgr : rgb_to_pixel32)) |
839 | 839 | default: |
840 | 840 | cpu_abort(cpu_single_env, "unsupported colour depth %i\n", |
841 | - s->ds->depth); | |
841 | + ds_get_bits_per_pixel(s->ds)); | |
842 | 842 | } |
843 | 843 | |
844 | 844 | dpy_update(s->ds, 0, 0, 128*3, 64*3); | ... | ... |
hw/omap_lcdc.c
... | ... | @@ -125,7 +125,7 @@ static void omap_update_display(void *opaque) |
125 | 125 | uint8_t *s, *d; |
126 | 126 | |
127 | 127 | if (!omap_lcd || omap_lcd->plm == 1 || |
128 | - !omap_lcd->enable || !omap_lcd->state->depth) | |
128 | + !omap_lcd->enable || !ds_get_bits_per_pixel(omap_lcd->state)) | |
129 | 129 | return; |
130 | 130 | |
131 | 131 | frame_offset = 0; |
... | ... | @@ -145,25 +145,25 @@ static void omap_update_display(void *opaque) |
145 | 145 | /* Colour depth */ |
146 | 146 | switch ((omap_lcd->palette[0] >> 12) & 7) { |
147 | 147 | case 1: |
148 | - draw_line = draw_line_table2[omap_lcd->state->depth]; | |
148 | + draw_line = draw_line_table2[ds_get_bits_per_pixel(omap_lcd->state)]; | |
149 | 149 | bpp = 2; |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 2: |
153 | - draw_line = draw_line_table4[omap_lcd->state->depth]; | |
153 | + draw_line = draw_line_table4[ds_get_bits_per_pixel(omap_lcd->state)]; | |
154 | 154 | bpp = 4; |
155 | 155 | break; |
156 | 156 | |
157 | 157 | case 3: |
158 | - draw_line = draw_line_table8[omap_lcd->state->depth]; | |
158 | + draw_line = draw_line_table8[ds_get_bits_per_pixel(omap_lcd->state)]; | |
159 | 159 | bpp = 8; |
160 | 160 | break; |
161 | 161 | |
162 | 162 | case 4 ... 7: |
163 | 163 | if (!omap_lcd->tft) |
164 | - draw_line = draw_line_table12[omap_lcd->state->depth]; | |
164 | + draw_line = draw_line_table12[ds_get_bits_per_pixel(omap_lcd->state)]; | |
165 | 165 | else |
166 | - draw_line = draw_line_table16[omap_lcd->state->depth]; | |
166 | + draw_line = draw_line_table16[ds_get_bits_per_pixel(omap_lcd->state)]; | |
167 | 167 | bpp = 16; |
168 | 168 | break; |
169 | 169 | |
... | ... | @@ -174,8 +174,8 @@ static void omap_update_display(void *opaque) |
174 | 174 | |
175 | 175 | /* Resolution */ |
176 | 176 | width = omap_lcd->width; |
177 | - if (width != omap_lcd->state->width || | |
178 | - omap_lcd->height != omap_lcd->state->height) { | |
177 | + if (width != ds_get_width(omap_lcd->state) || | |
178 | + omap_lcd->height != ds_get_height(omap_lcd->state)) { | |
179 | 179 | qemu_console_resize(omap_lcd->console, |
180 | 180 | omap_lcd->width, omap_lcd->height); |
181 | 181 | omap_lcd->invalidate = 1; |
... | ... | @@ -202,7 +202,7 @@ static void omap_update_display(void *opaque) |
202 | 202 | if (omap_lcd->dma->dual) |
203 | 203 | omap_lcd->dma->current_frame ^= 1; |
204 | 204 | |
205 | - if (!omap_lcd->state->depth) | |
205 | + if (!ds_get_bits_per_pixel(omap_lcd->state)) | |
206 | 206 | return; |
207 | 207 | |
208 | 208 | line = 0; |
... | ... | @@ -217,8 +217,8 @@ static void omap_update_display(void *opaque) |
217 | 217 | step = width * bpp >> 3; |
218 | 218 | scanline = frame_base + step * line; |
219 | 219 | s = (uint8_t *) (phys_ram_base + scanline); |
220 | - d = omap_lcd->state->data; | |
221 | - linesize = omap_lcd->state->linesize; | |
220 | + d = ds_get_data(omap_lcd->state); | |
221 | + linesize = ds_get_linesize(omap_lcd->state); | |
222 | 222 | |
223 | 223 | dirty[0] = dirty[1] = |
224 | 224 | cpu_physical_memory_get_dirty(scanline, VGA_DIRTY_FLAG); |
... | ... | @@ -293,10 +293,10 @@ static int ppm_save(const char *filename, uint8_t *data, |
293 | 293 | static void omap_screen_dump(void *opaque, const char *filename) { |
294 | 294 | struct omap_lcd_panel_s *omap_lcd = opaque; |
295 | 295 | omap_update_display(opaque); |
296 | - if (omap_lcd && omap_lcd->state->data) | |
297 | - ppm_save(filename, omap_lcd->state->data, | |
296 | + if (omap_lcd && ds_get_data(omap_lcd->state)) | |
297 | + ppm_save(filename, ds_get_data(omap_lcd->state), | |
298 | 298 | omap_lcd->width, omap_lcd->height, |
299 | - omap_lcd->state->linesize); | |
299 | + ds_get_linesize(omap_lcd->state)); | |
300 | 300 | } |
301 | 301 | |
302 | 302 | static void omap_invalidate_display(void *opaque) { | ... | ... |
hw/pl110.c
... | ... | @@ -124,7 +124,7 @@ static void pl110_update_display(void *opaque) |
124 | 124 | if (!pl110_enabled(s)) |
125 | 125 | return; |
126 | 126 | |
127 | - switch (s->ds->depth) { | |
127 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
128 | 128 | case 0: |
129 | 129 | return; |
130 | 130 | case 8: |
... | ... | @@ -190,7 +190,7 @@ static void pl110_update_display(void *opaque) |
190 | 190 | if (base > 0x80000000) |
191 | 191 | base -= 0x80000000; |
192 | 192 | src = phys_ram_base + base; |
193 | - dest = s->ds->data; | |
193 | + dest = ds_get_data(s->ds); | |
194 | 194 | first = -1; |
195 | 195 | addr = base; |
196 | 196 | |
... | ... | @@ -249,7 +249,7 @@ static void pl110_update_pallette(pl110_state *s, int n) |
249 | 249 | b = (raw & 0x1f) << 3; |
250 | 250 | /* The I bit is ignored. */ |
251 | 251 | raw >>= 6; |
252 | - switch (s->ds->depth) { | |
252 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
253 | 253 | case 8: |
254 | 254 | s->pallette[n] = rgb_to_pixel8(r, g, b); |
255 | 255 | break; | ... | ... |
hw/pxa2xx_lcd.c
... | ... | @@ -650,7 +650,7 @@ static void pxa2xx_palette_parse(struct pxa2xx_lcdc_s *s, int ch, int bpp) |
650 | 650 | } |
651 | 651 | break; |
652 | 652 | } |
653 | - switch (s->ds->depth) { | |
653 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
654 | 654 | case 8: |
655 | 655 | *dest = rgb_to_pixel8(r, g, b) | alpha; |
656 | 656 | break; |
... | ... | @@ -693,7 +693,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(struct pxa2xx_lcdc_s *s, |
693 | 693 | else if (s->bpp > pxa_lcdc_8bpp) |
694 | 694 | src_width *= 2; |
695 | 695 | |
696 | - dest = s->ds->data; | |
696 | + dest = ds_get_data(s->ds); | |
697 | 697 | dest_width = s->xres * s->dest_width; |
698 | 698 | |
699 | 699 | addr = (ram_addr_t) (fb - phys_ram_base); |
... | ... | @@ -750,7 +750,7 @@ static void pxa2xx_lcdc_dma0_redraw_vert(struct pxa2xx_lcdc_s *s, |
750 | 750 | src_width *= 2; |
751 | 751 | |
752 | 752 | dest_width = s->yres * s->dest_width; |
753 | - dest = s->ds->data + dest_width * (s->xres - 1); | |
753 | + dest = ds_get_data(s->ds) + dest_width * (s->xres - 1); | |
754 | 754 | |
755 | 755 | addr = (ram_addr_t) (fb - phys_ram_base); |
756 | 756 | start = addr + s->yres * src_width; |
... | ... | @@ -1006,7 +1006,7 @@ struct pxa2xx_lcdc_s *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq, |
1006 | 1006 | pxa2xx_invalidate_display, |
1007 | 1007 | pxa2xx_screen_dump, NULL, s); |
1008 | 1008 | |
1009 | - switch (s->ds->depth) { | |
1009 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
1010 | 1010 | case 0: |
1011 | 1011 | s->dest_width = 0; |
1012 | 1012 | break; | ... | ... |
hw/ssd0303.c
... | ... | @@ -206,7 +206,7 @@ static void ssd0303_update_display(void *opaque) |
206 | 206 | if (!s->redraw) |
207 | 207 | return; |
208 | 208 | |
209 | - switch (s->ds->depth) { | |
209 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
210 | 210 | case 0: |
211 | 211 | return; |
212 | 212 | case 15: |
... | ... | @@ -238,7 +238,7 @@ static void ssd0303_update_display(void *opaque) |
238 | 238 | colors[0] = colortab + dest_width; |
239 | 239 | colors[1] = colortab; |
240 | 240 | } |
241 | - dest = s->ds->data; | |
241 | + dest = ds_get_data(s->ds); | |
242 | 242 | for (y = 0; y < 16; y++) { |
243 | 243 | line = (y + s->start_line) & 63; |
244 | 244 | src = s->framebuffer + 132 * (line >> 3) + 36; | ... | ... |
hw/ssd0323.c
... | ... | @@ -187,7 +187,7 @@ static void ssd0323_update_display(void *opaque) |
187 | 187 | if (!s->redraw) |
188 | 188 | return; |
189 | 189 | |
190 | - switch (s->ds->depth) { | |
190 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
191 | 191 | case 0: |
192 | 192 | return; |
193 | 193 | case 15: |
... | ... | @@ -210,7 +210,7 @@ static void ssd0323_update_display(void *opaque) |
210 | 210 | for (i = 0; i < 16; i++) { |
211 | 211 | int n; |
212 | 212 | colors[i] = p; |
213 | - switch (s->ds->depth) { | |
213 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
214 | 214 | case 15: |
215 | 215 | n = i * 2 + (i >> 3); |
216 | 216 | p[0] = n | (n << 5); |
... | ... | @@ -233,7 +233,7 @@ static void ssd0323_update_display(void *opaque) |
233 | 233 | p += dest_width; |
234 | 234 | } |
235 | 235 | /* TODO: Implement row/column remapping. */ |
236 | - dest = s->ds->data; | |
236 | + dest = ds_get_data(s->ds); | |
237 | 237 | for (y = 0; y < 64; y++) { |
238 | 238 | line = y; |
239 | 239 | src = s->framebuffer + 64 * line; | ... | ... |
hw/tc6393xb.c
... | ... | @@ -430,7 +430,7 @@ static void tc6393xb_nand_writeb(struct tc6393xb_s *s, target_phys_addr_t addr, |
430 | 430 | |
431 | 431 | static void tc6393xb_draw_graphic(struct tc6393xb_s *s, int full_update) |
432 | 432 | { |
433 | - switch (s->ds->depth) { | |
433 | + switch (ds_get_bits_per_pixel(s->ds)) { | |
434 | 434 | case 8: |
435 | 435 | tc6393xb_draw_graphic8(s); |
436 | 436 | break; |
... | ... | @@ -447,7 +447,7 @@ static void tc6393xb_draw_graphic(struct tc6393xb_s *s, int full_update) |
447 | 447 | tc6393xb_draw_graphic32(s); |
448 | 448 | break; |
449 | 449 | default: |
450 | - printf("tc6393xb: unknown depth %d\n", s->ds->depth); | |
450 | + printf("tc6393xb: unknown depth %d\n", ds_get_bits_per_pixel(s->ds)); | |
451 | 451 | return; |
452 | 452 | } |
453 | 453 | |
... | ... | @@ -462,11 +462,11 @@ static void tc6393xb_draw_blank(struct tc6393xb_s *s, int full_update) |
462 | 462 | if (!full_update) |
463 | 463 | return; |
464 | 464 | |
465 | - w = s->scr_width * ((s->ds->depth + 7) >> 3); | |
466 | - d = s->ds->data; | |
465 | + w = s->scr_width * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); | |
466 | + d = ds_get_data(s->ds); | |
467 | 467 | for(i = 0; i < s->scr_height; i++) { |
468 | 468 | memset(d, 0, w); |
469 | - d += s->ds->linesize; | |
469 | + d += ds_get_linesize(s->ds); | |
470 | 470 | } |
471 | 471 | |
472 | 472 | dpy_update(s->ds, 0, 0, s->scr_width, s->scr_height); |
... | ... | @@ -485,7 +485,7 @@ static void tc6393xb_update_display(void *opaque) |
485 | 485 | s->blanked = s->blank; |
486 | 486 | full_update = 1; |
487 | 487 | } |
488 | - if (s->scr_width != s->ds->width || s->scr_height != s->ds->height) { | |
488 | + if (s->scr_width != ds_get_width(s->ds) || s->scr_height != ds_get_height(s->ds)) { | |
489 | 489 | qemu_console_resize(s->console, s->scr_width, s->scr_height); |
490 | 490 | full_update = 1; |
491 | 491 | } | ... | ... |
hw/tc6393xb_template.h
... | ... | @@ -46,12 +46,12 @@ static void glue(tc6393xb_draw_graphic, BITS)(struct tc6393xb_s *s) |
46 | 46 | |
47 | 47 | data_buffer = (uint16_t*)(phys_ram_base + s->vram_addr); |
48 | 48 | w_display = s->scr_width * BITS / 8; |
49 | - data_display = s->ds->data; | |
49 | + data_display = ds_get_data(s->ds); | |
50 | 50 | for(i = 0; i < s->scr_height; i++) { |
51 | 51 | #if (BITS == 16) |
52 | 52 | memcpy(data_display, data_buffer, s->scr_width * 2); |
53 | 53 | data_buffer += s->scr_width; |
54 | - data_display += s->ds->linesize; | |
54 | + data_display += ds_get_linesize(s->ds); | |
55 | 55 | #else |
56 | 56 | int j; |
57 | 57 | for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) { | ... | ... |
hw/tcx.c
... | ... | @@ -55,7 +55,7 @@ static void update_palette_entries(TCXState *s, int start, int end) |
55 | 55 | { |
56 | 56 | int i; |
57 | 57 | for(i = start; i < end; i++) { |
58 | - switch(s->ds->depth) { | |
58 | + switch(ds_get_bits_per_pixel(s->ds)) { | |
59 | 59 | default: |
60 | 60 | case 8: |
61 | 61 | s->palette[i] = rgb_to_pixel8(s->r[i], s->g[i], s->b[i]); |
... | ... | @@ -200,18 +200,18 @@ static void tcx_update_display(void *opaque) |
200 | 200 | uint8_t *d, *s; |
201 | 201 | void (*f)(TCXState *s1, uint8_t *dst, const uint8_t *src, int width); |
202 | 202 | |
203 | - if (ts->ds->depth == 0) | |
203 | + if (ds_get_bits_per_pixel(ts->ds) == 0) | |
204 | 204 | return; |
205 | 205 | page = ts->vram_offset; |
206 | 206 | y_start = -1; |
207 | 207 | page_min = 0xffffffff; |
208 | 208 | page_max = 0; |
209 | - d = ts->ds->data; | |
209 | + d = ds_get_data(ts->ds); | |
210 | 210 | s = ts->vram; |
211 | - dd = ts->ds->linesize; | |
211 | + dd = ds_get_linesize(ts->ds); | |
212 | 212 | ds = 1024; |
213 | 213 | |
214 | - switch (ts->ds->depth) { | |
214 | + switch (ds_get_bits_per_pixel(ts->ds)) { | |
215 | 215 | case 32: |
216 | 216 | f = tcx_draw_line32; |
217 | 217 | break; |
... | ... | @@ -278,7 +278,7 @@ static void tcx24_update_display(void *opaque) |
278 | 278 | uint8_t *d, *s; |
279 | 279 | uint32_t *cptr, *s24; |
280 | 280 | |
281 | - if (ts->ds->depth != 32) | |
281 | + if (ds_get_bits_per_pixel(ts->ds) != 32) | |
282 | 282 | return; |
283 | 283 | page = ts->vram_offset; |
284 | 284 | page24 = ts->vram24_offset; |
... | ... | @@ -286,11 +286,11 @@ static void tcx24_update_display(void *opaque) |
286 | 286 | y_start = -1; |
287 | 287 | page_min = 0xffffffff; |
288 | 288 | page_max = 0; |
289 | - d = ts->ds->data; | |
289 | + d = ds_get_data(ts->ds); | |
290 | 290 | s = ts->vram; |
291 | 291 | s24 = ts->vram24; |
292 | 292 | cptr = ts->cplane; |
293 | - dd = ts->ds->linesize; | |
293 | + dd = ds_get_linesize(ts->ds); | |
294 | 294 | ds = 1024; |
295 | 295 | |
296 | 296 | for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE, | ... | ... |
hw/vga.c
... | ... | @@ -1151,7 +1151,7 @@ static int update_basic_params(VGAState *s) |
1151 | 1151 | |
1152 | 1152 | static inline int get_depth_index(DisplayState *s) |
1153 | 1153 | { |
1154 | - switch(s->depth) { | |
1154 | + switch(ds_get_bits_per_pixel(s)) { | |
1155 | 1155 | default: |
1156 | 1156 | case 8: |
1157 | 1157 | return 0; |
... | ... | @@ -1279,7 +1279,7 @@ static void vga_draw_text(VGAState *s, int full_update) |
1279 | 1279 | cw = 9; |
1280 | 1280 | if (s->sr[1] & 0x08) |
1281 | 1281 | cw = 16; /* NOTE: no 18 pixel wide */ |
1282 | - x_incr = cw * ((s->ds->depth + 7) >> 3); | |
1282 | + x_incr = cw * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); | |
1283 | 1283 | width = (s->cr[0x01] + 1); |
1284 | 1284 | if (s->cr[0x06] == 100) { |
1285 | 1285 | /* ugly hack for CGA 160x100x16 - explain me the logic */ |
... | ... | @@ -1329,8 +1329,8 @@ static void vga_draw_text(VGAState *s, int full_update) |
1329 | 1329 | vga_draw_glyph8 = vga_draw_glyph8_table[depth_index]; |
1330 | 1330 | vga_draw_glyph9 = vga_draw_glyph9_table[depth_index]; |
1331 | 1331 | |
1332 | - dest = s->ds->data; | |
1333 | - linesize = s->ds->linesize; | |
1332 | + dest = ds_get_data(s->ds); | |
1333 | + linesize = ds_get_linesize(s->ds); | |
1334 | 1334 | ch_attr_ptr = s->last_ch_attr; |
1335 | 1335 | for(cy = 0; cy < height; cy++) { |
1336 | 1336 | d1 = dest; |
... | ... | @@ -1663,8 +1663,8 @@ static void vga_draw_graphic(VGAState *s, int full_update) |
1663 | 1663 | y_start = -1; |
1664 | 1664 | page_min = 0x7fffffff; |
1665 | 1665 | page_max = -1; |
1666 | - d = s->ds->data; | |
1667 | - linesize = s->ds->linesize; | |
1666 | + d = ds_get_data(s->ds); | |
1667 | + linesize = ds_get_linesize(s->ds); | |
1668 | 1668 | y1 = 0; |
1669 | 1669 | for(y = 0; y < height; y++) { |
1670 | 1670 | addr = addr1; |
... | ... | @@ -1743,15 +1743,15 @@ static void vga_draw_blank(VGAState *s, int full_update) |
1743 | 1743 | return; |
1744 | 1744 | if (s->last_scr_width <= 0 || s->last_scr_height <= 0) |
1745 | 1745 | return; |
1746 | - if (s->ds->depth == 8) | |
1746 | + if (ds_get_bits_per_pixel(s->ds) == 8) | |
1747 | 1747 | val = s->rgb_to_pixel(0, 0, 0); |
1748 | 1748 | else |
1749 | 1749 | val = 0; |
1750 | - w = s->last_scr_width * ((s->ds->depth + 7) >> 3); | |
1751 | - d = s->ds->data; | |
1750 | + w = s->last_scr_width * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); | |
1751 | + d = ds_get_data(s->ds); | |
1752 | 1752 | for(i = 0; i < s->last_scr_height; i++) { |
1753 | 1753 | memset(d, val, w); |
1754 | - d += s->ds->linesize; | |
1754 | + d += ds_get_linesize(s->ds); | |
1755 | 1755 | } |
1756 | 1756 | dpy_update(s->ds, 0, 0, |
1757 | 1757 | s->last_scr_width, s->last_scr_height); |
... | ... | @@ -1766,7 +1766,7 @@ static void vga_update_display(void *opaque) |
1766 | 1766 | VGAState *s = (VGAState *)opaque; |
1767 | 1767 | int full_update, graphic_mode; |
1768 | 1768 | |
1769 | - if (s->ds->depth == 0) { | |
1769 | + if (ds_get_bits_per_pixel(s->ds) == 0) { | |
1770 | 1770 | /* nothing to do */ |
1771 | 1771 | } else { |
1772 | 1772 | s->rgb_to_pixel = |
... | ... | @@ -2455,10 +2455,10 @@ static void vga_screen_dump(void *opaque, const char *filename) |
2455 | 2455 | s->graphic_mode = -1; |
2456 | 2456 | vga_update_display(s); |
2457 | 2457 | |
2458 | - if (ds->data) { | |
2459 | - ppm_save(filename, ds->data, vga_save_w, vga_save_h, | |
2460 | - s->ds->linesize); | |
2461 | - qemu_free(ds->data); | |
2458 | + if (ds_get_data(ds)) { | |
2459 | + ppm_save(filename, ds_get_data(ds), vga_save_w, vga_save_h, | |
2460 | + ds_get_linesize(s->ds)); | |
2461 | + qemu_free(ds_get_data(ds)); | |
2462 | 2462 | } |
2463 | 2463 | s->ds = saved_ds; |
2464 | 2464 | } | ... | ... |
hw/vmware_vga.c
... | ... | @@ -319,7 +319,7 @@ static inline void vmsvga_update_rect(struct vmsvga_state_s *s, |
319 | 319 | width = s->bypp * w; |
320 | 320 | start = s->bypp * x + bypl * y; |
321 | 321 | src = s->vram + start; |
322 | - dst = s->ds->data + start; | |
322 | + dst = ds_get_data(s->ds) + start; | |
323 | 323 | |
324 | 324 | for (; line > 0; line --, src += bypl, dst += bypl) |
325 | 325 | memcpy(dst, src, width); |
... | ... | @@ -331,7 +331,7 @@ static inline void vmsvga_update_rect(struct vmsvga_state_s *s, |
331 | 331 | static inline void vmsvga_update_screen(struct vmsvga_state_s *s) |
332 | 332 | { |
333 | 333 | #ifndef DIRECT_VRAM |
334 | - memcpy(s->ds->data, s->vram, s->bypp * s->width * s->height); | |
334 | + memcpy(ds_get_data(s->ds), s->vram, s->bypp * s->width * s->height); | |
335 | 335 | #endif |
336 | 336 | |
337 | 337 | dpy_update(s->ds, 0, 0, s->width, s->height); |
... | ... | @@ -373,7 +373,7 @@ static inline void vmsvga_copy_rect(struct vmsvga_state_s *s, |
373 | 373 | int x0, int y0, int x1, int y1, int w, int h) |
374 | 374 | { |
375 | 375 | # ifdef DIRECT_VRAM |
376 | - uint8_t *vram = s->ds->data; | |
376 | + uint8_t *vram = ds_get_data(s->ds); | |
377 | 377 | # else |
378 | 378 | uint8_t *vram = s->vram; |
379 | 379 | # endif |
... | ... | @@ -410,7 +410,7 @@ static inline void vmsvga_fill_rect(struct vmsvga_state_s *s, |
410 | 410 | uint32_t c, int x, int y, int w, int h) |
411 | 411 | { |
412 | 412 | # ifdef DIRECT_VRAM |
413 | - uint8_t *vram = s->ds->data; | |
413 | + uint8_t *vram = ds_get_data(s->ds); | |
414 | 414 | # else |
415 | 415 | uint8_t *vram = s->vram; |
416 | 416 | # endif |
... | ... | @@ -915,7 +915,7 @@ static void vmsvga_reset(struct vmsvga_state_s *s) |
915 | 915 | s->width = -1; |
916 | 916 | s->height = -1; |
917 | 917 | s->svgaid = SVGA_ID; |
918 | - s->depth = s->ds->depth ? s->ds->depth : 24; | |
918 | + s->depth = ds_get_bits_per_pixel(s->ds) ? ds_get_bits_per_pixel(s->ds) : 24; | |
919 | 919 | s->bypp = (s->depth + 7) >> 3; |
920 | 920 | s->cursor.on = 0; |
921 | 921 | s->redraw_fifo_first = 0; |
... | ... | @@ -976,7 +976,7 @@ static void vmsvga_screen_dump(void *opaque, const char *filename) |
976 | 976 | } |
977 | 977 | |
978 | 978 | if (s->depth == 32) { |
979 | - ppm_save(filename, s->vram, s->width, s->height, s->ds->linesize); | |
979 | + ppm_save(filename, s->vram, s->width, s->height, ds_get_linesize(s->ds)); | |
980 | 980 | } |
981 | 981 | } |
982 | 982 | |
... | ... | @@ -994,7 +994,7 @@ static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr) |
994 | 994 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
995 | 995 | addr -= s->vram_base; |
996 | 996 | if (addr < s->fb_size) |
997 | - return *(uint8_t *) (s->ds->data + addr); | |
997 | + return *(uint8_t *) (ds_get_data(s->ds) + addr); | |
998 | 998 | else |
999 | 999 | return *(uint8_t *) (s->vram + addr); |
1000 | 1000 | } |
... | ... | @@ -1004,7 +1004,7 @@ static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr) |
1004 | 1004 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1005 | 1005 | addr -= s->vram_base; |
1006 | 1006 | if (addr < s->fb_size) |
1007 | - return *(uint16_t *) (s->ds->data + addr); | |
1007 | + return *(uint16_t *) (ds_get_data(s->ds) + addr); | |
1008 | 1008 | else |
1009 | 1009 | return *(uint16_t *) (s->vram + addr); |
1010 | 1010 | } |
... | ... | @@ -1014,7 +1014,7 @@ static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr) |
1014 | 1014 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1015 | 1015 | addr -= s->vram_base; |
1016 | 1016 | if (addr < s->fb_size) |
1017 | - return *(uint32_t *) (s->ds->data + addr); | |
1017 | + return *(uint32_t *) (ds_get_data(s->ds) + addr); | |
1018 | 1018 | else |
1019 | 1019 | return *(uint32_t *) (s->vram + addr); |
1020 | 1020 | } |
... | ... | @@ -1025,7 +1025,7 @@ static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr, |
1025 | 1025 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1026 | 1026 | addr -= s->vram_base; |
1027 | 1027 | if (addr < s->fb_size) |
1028 | - *(uint8_t *) (s->ds->data + addr) = value; | |
1028 | + *(uint8_t *) (ds_get_data(s->ds) + addr) = value; | |
1029 | 1029 | else |
1030 | 1030 | *(uint8_t *) (s->vram + addr) = value; |
1031 | 1031 | } |
... | ... | @@ -1036,7 +1036,7 @@ static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr, |
1036 | 1036 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1037 | 1037 | addr -= s->vram_base; |
1038 | 1038 | if (addr < s->fb_size) |
1039 | - *(uint16_t *) (s->ds->data + addr) = value; | |
1039 | + *(uint16_t *) (ds_get_data(s->ds) + addr) = value; | |
1040 | 1040 | else |
1041 | 1041 | *(uint16_t *) (s->vram + addr) = value; |
1042 | 1042 | } |
... | ... | @@ -1047,7 +1047,7 @@ static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr, |
1047 | 1047 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1048 | 1048 | addr -= s->vram_base; |
1049 | 1049 | if (addr < s->fb_size) |
1050 | - *(uint32_t *) (s->ds->data + addr) = value; | |
1050 | + *(uint32_t *) (ds_get_data(s->ds) + addr) = value; | |
1051 | 1051 | else |
1052 | 1052 | *(uint32_t *) (s->vram + addr) = value; |
1053 | 1053 | } | ... | ... |
vnc.c
... | ... | @@ -321,7 +321,7 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h) |
321 | 321 | } |
322 | 322 | |
323 | 323 | memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); |
324 | - memset(vs->old_data, 42, vs->ds->linesize * vs->ds->height); | |
324 | + memset(vs->old_data, 42, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); | |
325 | 325 | } |
326 | 326 | |
327 | 327 | /* fastest code */ |
... | ... | @@ -414,10 +414,10 @@ static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h |
414 | 414 | |
415 | 415 | vnc_framebuffer_update(vs, x, y, w, h, 0); |
416 | 416 | |
417 | - row = vs->ds->data + y * vs->ds->linesize + x * vs->depth; | |
417 | + row = ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * vs->depth; | |
418 | 418 | for (i = 0; i < h; i++) { |
419 | 419 | vs->write_pixels(vs, row, w * vs->depth); |
420 | - row += vs->ds->linesize; | |
420 | + row += ds_get_linesize(vs->ds); | |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
... | ... | @@ -495,7 +495,7 @@ static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_ |
495 | 495 | uint8_t *dst_row; |
496 | 496 | char *old_row; |
497 | 497 | int y = 0; |
498 | - int pitch = ds->linesize; | |
498 | + int pitch = ds_get_linesize(ds); | |
499 | 499 | VncState *vs = ds->opaque; |
500 | 500 | |
501 | 501 | vnc_update_client(vs); |
... | ... | @@ -505,11 +505,11 @@ static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_ |
505 | 505 | pitch = -pitch; |
506 | 506 | } |
507 | 507 | |
508 | - src = (ds->linesize * (src_y + y) + vs->depth * src_x); | |
509 | - dst = (ds->linesize * (dst_y + y) + vs->depth * dst_x); | |
508 | + src = (ds_get_linesize(ds) * (src_y + y) + vs->depth * src_x); | |
509 | + dst = (ds_get_linesize(ds) * (dst_y + y) + vs->depth * dst_x); | |
510 | 510 | |
511 | - src_row = ds->data + src; | |
512 | - dst_row = ds->data + dst; | |
511 | + src_row = ds_get_data(ds) + src; | |
512 | + dst_row = ds_get_data(ds) + dst; | |
513 | 513 | old_row = vs->old_data + dst; |
514 | 514 | |
515 | 515 | for (y = 0; y < h; y++) { |
... | ... | @@ -563,7 +563,7 @@ static void vnc_update_client(void *opaque) |
563 | 563 | |
564 | 564 | /* Walk through the dirty map and eliminate tiles that |
565 | 565 | really aren't dirty */ |
566 | - row = vs->ds->data; | |
566 | + row = ds_get_data(vs->ds); | |
567 | 567 | old_row = vs->old_data; |
568 | 568 | |
569 | 569 | for (y = 0; y < vs->height; y++) { |
... | ... | @@ -575,7 +575,7 @@ static void vnc_update_client(void *opaque) |
575 | 575 | ptr = row; |
576 | 576 | old_ptr = (char*)old_row; |
577 | 577 | |
578 | - for (x = 0; x < vs->ds->width; x += 16) { | |
578 | + for (x = 0; x < ds_get_width(vs->ds); x += 16) { | |
579 | 579 | if (memcmp(old_ptr, ptr, 16 * vs->depth) == 0) { |
580 | 580 | vnc_clear_bit(vs->dirty_row[y], (x / 16)); |
581 | 581 | } else { |
... | ... | @@ -588,8 +588,8 @@ static void vnc_update_client(void *opaque) |
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
591 | - row += vs->ds->linesize; | |
592 | - old_row += vs->ds->linesize; | |
591 | + row += ds_get_linesize(vs->ds); | |
592 | + old_row += ds_get_linesize(vs->ds); | |
593 | 593 | } |
594 | 594 | |
595 | 595 | if (!has_dirty) { |
... | ... | @@ -918,7 +918,7 @@ static void check_pointer_type_change(VncState *vs, int absolute) |
918 | 918 | vnc_write_u8(vs, 0); |
919 | 919 | vnc_write_u16(vs, 1); |
920 | 920 | vnc_framebuffer_update(vs, absolute, 0, |
921 | - vs->ds->width, vs->ds->height, -257); | |
921 | + ds_get_width(vs->ds), ds_get_height(vs->ds), -257); | |
922 | 922 | vnc_flush(vs); |
923 | 923 | } |
924 | 924 | vs->absolute = absolute; |
... | ... | @@ -941,8 +941,8 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y) |
941 | 941 | dz = 1; |
942 | 942 | |
943 | 943 | if (vs->absolute) { |
944 | - kbd_mouse_event(x * 0x7FFF / (vs->ds->width - 1), | |
945 | - y * 0x7FFF / (vs->ds->height - 1), | |
944 | + kbd_mouse_event(x * 0x7FFF / (ds_get_width(vs->ds) - 1), | |
945 | + y * 0x7FFF / (ds_get_height(vs->ds) - 1), | |
946 | 946 | dz, buttons); |
947 | 947 | } else if (vs->has_pointer_type_change) { |
948 | 948 | x -= 0x7FFF; |
... | ... | @@ -1106,25 +1106,25 @@ static void framebuffer_update_request(VncState *vs, int incremental, |
1106 | 1106 | int x_position, int y_position, |
1107 | 1107 | int w, int h) |
1108 | 1108 | { |
1109 | - if (x_position > vs->ds->width) | |
1110 | - x_position = vs->ds->width; | |
1111 | - if (y_position > vs->ds->height) | |
1112 | - y_position = vs->ds->height; | |
1113 | - if (x_position + w >= vs->ds->width) | |
1114 | - w = vs->ds->width - x_position; | |
1115 | - if (y_position + h >= vs->ds->height) | |
1116 | - h = vs->ds->height - y_position; | |
1109 | + if (x_position > ds_get_width(vs->ds)) | |
1110 | + x_position = ds_get_width(vs->ds); | |
1111 | + if (y_position > ds_get_height(vs->ds)) | |
1112 | + y_position = ds_get_height(vs->ds); | |
1113 | + if (x_position + w >= ds_get_width(vs->ds)) | |
1114 | + w = ds_get_width(vs->ds) - x_position; | |
1115 | + if (y_position + h >= ds_get_height(vs->ds)) | |
1116 | + h = ds_get_height(vs->ds) - y_position; | |
1117 | 1117 | |
1118 | 1118 | int i; |
1119 | 1119 | vs->need_update = 1; |
1120 | 1120 | if (!incremental) { |
1121 | - char *old_row = vs->old_data + y_position * vs->ds->linesize; | |
1121 | + char *old_row = vs->old_data + y_position * ds_get_linesize(vs->ds); | |
1122 | 1122 | |
1123 | 1123 | for (i = 0; i < h; i++) { |
1124 | 1124 | vnc_set_bits(vs->dirty_row[y_position + i], |
1125 | - (vs->ds->width / 16), VNC_DIRTY_WORDS); | |
1126 | - memset(old_row, 42, vs->ds->width * vs->depth); | |
1127 | - old_row += vs->ds->linesize; | |
1125 | + (ds_get_width(vs->ds) / 16), VNC_DIRTY_WORDS); | |
1126 | + memset(old_row, 42, ds_get_width(vs->ds) * vs->depth); | |
1127 | + old_row += ds_get_linesize(vs->ds); | |
1128 | 1128 | } |
1129 | 1129 | } |
1130 | 1130 | } |
... | ... | @@ -1134,7 +1134,7 @@ static void send_ext_key_event_ack(VncState *vs) |
1134 | 1134 | vnc_write_u8(vs, 0); |
1135 | 1135 | vnc_write_u8(vs, 0); |
1136 | 1136 | vnc_write_u16(vs, 1); |
1137 | - vnc_framebuffer_update(vs, 0, 0, vs->ds->width, vs->ds->height, -258); | |
1137 | + vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds), ds_get_height(vs->ds), -258); | |
1138 | 1138 | vnc_flush(vs); |
1139 | 1139 | } |
1140 | 1140 | |
... | ... | @@ -1497,10 +1497,10 @@ static int protocol_client_init(VncState *vs, uint8_t *data, size_t len) |
1497 | 1497 | char buf[1024]; |
1498 | 1498 | int size; |
1499 | 1499 | |
1500 | - vs->width = vs->ds->width; | |
1501 | - vs->height = vs->ds->height; | |
1502 | - vnc_write_u16(vs, vs->ds->width); | |
1503 | - vnc_write_u16(vs, vs->ds->height); | |
1500 | + vs->width = ds_get_width(vs->ds); | |
1501 | + vs->height = ds_get_height(vs->ds); | |
1502 | + vnc_write_u16(vs, ds_get_width(vs->ds)); | |
1503 | + vnc_write_u16(vs, ds_get_height(vs->ds)); | |
1504 | 1504 | |
1505 | 1505 | pixel_format_message(vs); |
1506 | 1506 | |
... | ... | @@ -2116,7 +2116,7 @@ static void vnc_connect(VncState *vs) |
2116 | 2116 | vnc_write(vs, "RFB 003.008\n", 12); |
2117 | 2117 | vnc_flush(vs); |
2118 | 2118 | vnc_read_when(vs, protocol_version, 12); |
2119 | - memset(vs->old_data, 0, vs->ds->linesize * vs->ds->height); | |
2119 | + memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); | |
2120 | 2120 | memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); |
2121 | 2121 | vs->has_resize = 0; |
2122 | 2122 | vs->has_hextile = 0; | ... | ... |
vnchextile.h
... | ... | @@ -13,7 +13,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, |
13 | 13 | void *last_fg_, |
14 | 14 | int *has_bg, int *has_fg) |
15 | 15 | { |
16 | - uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth); | |
16 | + uint8_t *row = (ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * vs->depth); | |
17 | 17 | pixel_t *irow = (pixel_t *)row; |
18 | 18 | int j, i; |
19 | 19 | pixel_t *last_bg = (pixel_t *)last_bg_; |
... | ... | @@ -57,7 +57,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, |
57 | 57 | } |
58 | 58 | if (n_colors > 2) |
59 | 59 | break; |
60 | - irow += vs->ds->linesize / sizeof(pixel_t); | |
60 | + irow += ds_get_linesize(vs->ds) / sizeof(pixel_t); | |
61 | 61 | } |
62 | 62 | |
63 | 63 | if (n_colors > 1 && fg_count > bg_count) { |
... | ... | @@ -105,7 +105,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, |
105 | 105 | n_data += 2; |
106 | 106 | n_subtiles++; |
107 | 107 | } |
108 | - irow += vs->ds->linesize / sizeof(pixel_t); | |
108 | + irow += ds_get_linesize(vs->ds) / sizeof(pixel_t); | |
109 | 109 | } |
110 | 110 | break; |
111 | 111 | case 3: |
... | ... | @@ -161,7 +161,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, |
161 | 161 | n_data += 2; |
162 | 162 | n_subtiles++; |
163 | 163 | } |
164 | - irow += vs->ds->linesize / sizeof(pixel_t); | |
164 | + irow += ds_get_linesize(vs->ds) / sizeof(pixel_t); | |
165 | 165 | } |
166 | 166 | |
167 | 167 | /* A SubrectsColoured subtile invalidates the foreground color */ |
... | ... | @@ -198,7 +198,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, |
198 | 198 | } else { |
199 | 199 | for (j = 0; j < h; j++) { |
200 | 200 | vs->write_pixels(vs, row, w * vs->depth); |
201 | - row += vs->ds->linesize; | |
201 | + row += ds_get_linesize(vs->ds); | |
202 | 202 | } |
203 | 203 | } |
204 | 204 | } | ... | ... |