ati_2d_blt remains the public interface to the blitter but the bulk of
the implementation is moved down into ati_2d_do_blt which is passed an
ATI2DCtx.
ati_2d_do_blt returns a bool that is true when the blit succeeded, which
means that a screen region will need to be set dirty. Otherwise false is
returned.
Signed-off-by: Chad Jablonski <chad@jablonski.xyz>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/display/ati_2d.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c
index f1536e5425..df8975d9d7 100644
--- a/hw/display/ati_2d.c
+++ b/hw/display/ati_2d.c
@@ -123,27 +123,24 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
(ctx->top_to_bottom ? 'v' : '^'));
}
-void ati_2d_blt(ATIVGAState *s)
+static bool ati_2d_do_blt(ATIVGAState *s, ATI2DCtx *ctx)
{
bool use_pixman_fill = s->use_pixman & BIT(0);
bool use_pixman_blt = s->use_pixman & BIT(1);
- ATI2DCtx ctx_;
- ATI2DCtx *ctx = &ctx_;
- setup_2d_blt_ctx(s, ctx);
if (!ctx->bpp) {
qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n");
- return;
+ return false;
}
if (!ctx->dst_stride) {
qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n");
- return;
+ return false;
}
int dst_stride_words = ctx->dst_stride / sizeof(uint32_t);
if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff
|| ctx->dst_bits >= ctx->vram_end || ctx->dst_bits + ctx->dst.x
+ (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >= ctx->vram_end) {
qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
- return;
+ return false;
}
switch (ctx->rop3) {
case ROP3_SRCCOPY:
@@ -151,7 +148,7 @@ void ati_2d_blt(ATIVGAState *s)
bool fallback = false;
if (!ctx->src_stride) {
qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n");
- return;
+ return false;
}
int src_stride_words = ctx->src_stride / sizeof(uint32_t);
if (ctx->src.x > 0x3fff || ctx->src.y > 0x3fff
@@ -159,7 +156,7 @@ void ati_2d_blt(ATIVGAState *s)
|| ctx->src_bits + ctx->src.x + (ctx->src.y + ctx->dst.height)
* ctx->src_stride >= ctx->vram_end) {
qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
- return;
+ return false;
}
DPRINTF("pixman_blt(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n",
@@ -262,8 +259,17 @@ void ati_2d_blt(ATIVGAState *s)
default:
qemu_log_mask(LOG_UNIMP, "Unimplemented ati_2d blt op %x\n",
ctx->rop3 >> 16);
- return;
+ return false;
}
- ati_set_dirty(&s->vga, ctx);
+ return true;
+}
+
+void ati_2d_blt(ATIVGAState *s)
+{
+ ATI2DCtx ctx;
+ setup_2d_blt_ctx(s, &ctx);
+ if (ati_2d_do_blt(s, &ctx)) {
+ ati_set_dirty(&s->vga, &ctx);
+ }
}
--
2.52.0