qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Li Qiang <liqiang6-s@360.cn>,
	Laszlo Ersek <lersek@redhat.com>
Subject: [Qemu-devel] [PATCH v2] cirrus: handle negative pitch in cirrus_invalidate_region()
Date: Wed, 25 Jan 2017 14:48:57 +0100	[thread overview]
Message-ID: <1485352137-29367-1-git-send-email-w.bumiller@proxmox.com> (raw)

cirrus_invalidate_region() calls memory_region_set_dirty()
on a per-line basis, always ranging from off_begin to
off_begin+bytesperline. With a negative pitch off_begin
marks the top most used address and thus we need to do an
initial shift backwards by a line for negative pitches of
backward blits, otherwise the first iteration covers the
line going from the start offset forwards instead of
backwards.
Additionally since the start address is inclusive, if we
shift by a full `bytesperline` we move to the first address
*not* included in the blit, so we only shift by one less
than bytesperline.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
Changes to v1:
* Subtract only bytesperline-1 since the original address should be
  included while the byte at `begin-bytesperline` is exclusive.
* Added an assertion to ensure we don't call memory_region_set_dirty()
  with a negative size since it takes unsigned parameters.

 @Gerd: Still unclear: is -1 enough or should this somehow deal with
multiple depths? As far as I can see the backward blit functions
are all only byte based, as opposed to the patternfill functions in
cirrus_vga_rop2.h which have PUTPIXEL() macros for 8/16/24/32 bpp.
CIRRUS_BLTMODE_BACKWARDS only references cirrus_bkwd_rop[16] and
cirrus_bkwd_transp_rop[16][2] which only contain the bkwd rops
from cirrus_vga_rop.h.

 hw/display/cirrus_vga.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index b1a0773..755110f 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -670,9 +670,14 @@ static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin,
     int off_cur;
     int off_cur_end;
 
+    if (off_pitch < 0) {
+        off_begin -= bytesperline-1;
+    }
+
     for (y = 0; y < lines; y++) {
 	off_cur = off_begin;
 	off_cur_end = (off_cur + bytesperline) & s->cirrus_addr_mask;
+	assert(off_cur_end >= off_cur);
         memory_region_set_dirty(&s->vga.vram, off_cur, off_cur_end - off_cur);
 	off_begin += off_pitch;
     }
-- 
2.1.4

             reply	other threads:[~2017-01-25 13:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 13:48 Wolfgang Bumiller [this message]
2017-01-25 13:57 ` [Qemu-devel] [PATCH v2] cirrus: handle negative pitch in cirrus_invalidate_region() no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1485352137-29367-1-git-send-email-w.bumiller@proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=liqiang6-s@360.cn \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).