On Tue, 18 Nov 2025, Chad Jablonski wrote:
This creates helper functions for building QemuRects using the dst and
sc registers. These are useful during blit setup and the next patch in
this series will make use of them.
Signed-off-by: Chad Jablonski <[email protected]>
---
hw/display/ati_2d.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c
index a8c4c534b9..0695c26b3b 100644
--- a/hw/display/ati_2d.c
+++ b/hw/display/ati_2d.c
@@ -13,6 +13,7 @@
#include "qemu/log.h"
#include "ui/pixel_ops.h"
#include "ui/console.h"
+#include "ui/rect.h"
/*
* NOTE:
@@ -43,6 +44,29 @@ static int ati_bpp_from_datatype(ATIVGAState *s)
}
}
+static QemuRect dst_rect(ATIVGAState *s)
+{
+ QemuRect dst;
+ unsigned dst_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
+ s->regs.dst_x :
+ s->regs.dst_x + 1 - s->regs.dst_width);
+ unsigned dst_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
+ s->regs.dst_y :
+ s->regs.dst_y + 1 - s->regs.dst_height);
+ qemu_rect_init(&dst, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height);
+ return dst;
+}
+
+static QemuRect sc_rect(ATIVGAState *s)
+{
+ QemuRect sc;
+ qemu_rect_init(&sc,
+ s->regs.sc_left, s->regs.sc_top,
+ s->regs.sc_right - s->regs.sc_left + 1,
+ s->regs.sc_bottom - s->regs.sc_top + 1);
+ return sc;
+}
Also there's nothing special in this sc_rect function so it could just be
inlined. If it's used only once then maybe isn't worth to put it in a
function. The only advantage seems to be that you can use it to init at
defining the variable but calling qemu_rect_init separately is not a big
deal and actually 4 lines less. The dst_rect hides some ugliness and two
local variables so that may worth to have a function for.
Regards,
BALATON Zoltan