From patchwork Tue Sep 2 08:00:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 385002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 14DAD1400D5 for ; Tue, 2 Sep 2014 18:03:43 +1000 (EST) Received: from localhost ([::1]:36414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj41-00024M-7T for incoming@patchwork.ozlabs.org; Tue, 02 Sep 2014 04:03:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj1M-0005hP-I7 for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:01:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOj1E-0004gl-Q3 for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:00:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj1E-0004gF-Hg for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:00:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8280j1I011188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 2 Sep 2014 04:00:46 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8280iGn027851; Tue, 2 Sep 2014 04:00:45 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B461C808C4; Tue, 2 Sep 2014 10:00:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 2 Sep 2014 10:00:19 +0200 Message-Id: <1409644827-26317-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1409644827-26317-1-git-send-email-kraxel@redhat.com> References: <1409644827-26317-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Anthony Liguori Subject: [Qemu-devel] [PATCH 06/14] console: add dpy_gfx_update_dirty X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Calls dpy_gfx_update for all dirty scanlines. Works for DisplaySurfaces backed by guest memory (i.e. the ones created using qemu_create_displaysurface_guestmem). Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 4 ++++ ui/console.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 61901f7..58a7d4b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -232,6 +232,10 @@ void dpy_text_resize(QemuConsole *con, int w, int h); void dpy_mouse_set(QemuConsole *con, int x, int y, int on); void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor); bool dpy_cursor_define_supported(QemuConsole *con); +void dpy_gfx_update_dirty(QemuConsole *con, + MemoryRegion *address_space, + uint64_t base, + bool invalidate); static inline int surface_stride(DisplaySurface *s) { diff --git a/ui/console.c b/ui/console.c index 654c0d3..d1342ca 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1581,6 +1581,67 @@ bool dpy_cursor_define_supported(QemuConsole *con) return false; } +/* + * Call dpy_gfx_update for all dirity scanlines. Works for + * DisplaySurfaces backed by guest memory (i.e. the ones created + * using qemu_create_displaysurface_guestmem). + */ +void dpy_gfx_update_dirty(QemuConsole *con, + MemoryRegion *address_space, + hwaddr base, + bool invalidate) +{ + DisplaySurface *ds = qemu_console_surface(con); + int width = surface_stride(ds); + int height = surface_height(ds); + hwaddr size = width * height; + MemoryRegionSection mem_section; + MemoryRegion *mem; + ram_addr_t addr; + int first, last, i; + bool dirty; + + mem_section = memory_region_find(address_space, base, size); + mem = mem_section.mr; + if (int128_get64(mem_section.size) != size || + !memory_region_is_ram(mem_section.mr)) { + goto out; + } + assert(mem); + + memory_region_sync_dirty_bitmap(mem); + addr = mem_section.offset_within_region; + + first = -1; + last = -1; + for (i = 0; i < height; i++, addr += width) { + dirty = invalidate || + memory_region_get_dirty(mem, addr, width, DIRTY_MEMORY_VGA); + if (dirty) { + if (first == -1) { + first = i; + } + last = i; + } + if (first != -1 && !dirty) { + assert(last != -1 && last >= first); + dpy_gfx_update(con, 0, first, surface_width(ds), + last - first + 1); + first = -1; + } + } + if (first != -1) { + assert(last != -1 && last >= first); + dpy_gfx_update(con, 0, first, surface_width(ds), + last - first + 1); + } + + memory_region_reset_dirty(mem, mem_section.offset_within_region, size, + DIRTY_MEMORY_VGA); +out: + memory_region_unref(mem); +} + /***********************************************************/ /* register display */