Skip to content

Commit

Permalink
framebuffer: make display updates thread safe
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20170421091632.30900-6-kraxel@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
kraxel committed Apr 24, 2017
1 parent fec5e8c commit 167e9c7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions hw/display/framebuffer.c
Expand Up @@ -67,7 +67,7 @@ void framebuffer_update_display(
int *first_row, /* Input and output. */
int *last_row /* Output only */)
{
hwaddr src_len;
DirtyBitmapSnapshot *snap;
uint8_t *dest;
uint8_t *src;
int first, last = 0;
Expand All @@ -78,7 +78,6 @@ void framebuffer_update_display(

i = *first_row;
*first_row = -1;
src_len = (hwaddr)src_width * rows;

mem = mem_section->mr;
if (!mem) {
Expand All @@ -102,9 +101,10 @@ void framebuffer_update_display(
src += i * src_width;
dest += i * dest_row_pitch;

snap = memory_region_snapshot_and_clear_dirty(mem, addr, src_width * rows,
DIRTY_MEMORY_VGA);
for (; i < rows; i++) {
dirty = memory_region_get_dirty(mem, addr, src_width,
DIRTY_MEMORY_VGA);
dirty = memory_region_snapshot_get_dirty(mem, snap, addr, src_width);
if (dirty || invalidate) {
fn(opaque, dest, src, cols, dest_col_pitch);
if (first == -1)
Expand All @@ -115,11 +115,10 @@ void framebuffer_update_display(
src += src_width;
dest += dest_row_pitch;
}
g_free(snap);
if (first < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section->offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*first_row = first;
*last_row = last;
}

0 comments on commit 167e9c7

Please sign in to comment.