qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] cirrus: handle negative pitch in cirrus_invalidate_region()
@ 2017-01-25 13:48 Wolfgang Bumiller
  2017-01-25 13:57 ` no-reply
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfgang Bumiller @ 2017-01-25 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Li Qiang, Laszlo Ersek

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-25 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25 13:48 [Qemu-devel] [PATCH v2] cirrus: handle negative pitch in cirrus_invalidate_region() Wolfgang Bumiller
2017-01-25 13:57 ` no-reply

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).