From ff2cacd25deab3718cd27f86dff5e675f8c259a3 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 30 Sep 2024 16:57:29 +0900 Subject: [PATCH] examples: fixed an incorrect buffer size. adjusted the size according to the offsets. --- examples/MultiCanvas.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/MultiCanvas.cpp b/examples/MultiCanvas.cpp index 168d31fe..a269464b 100644 --- a/examples/MultiCanvas.cpp +++ b/examples/MultiCanvas.cpp @@ -103,7 +103,11 @@ void runSw() for (int counter = 0; counter < NUM_PER_LINE * NUM_PER_LINE; ++counter) { auto canvas = tvg::SwCanvas::gen(); - tvgexam::verify(canvas->target((uint32_t*)surface->pixels + SIZE * (counter / NUM_PER_LINE) * (surface->pitch / 4) + (counter % NUM_PER_LINE) * SIZE, surface->w, surface->pitch / 4, surface->h, tvg::SwCanvas::ARGB8888)); + auto offx = (counter % NUM_PER_LINE) * SIZE; + auto offy = SIZE * (counter / NUM_PER_LINE); + auto w = surface->w - offx; + auto h = surface->h - offy; + tvgexam::verify(canvas->target((uint32_t*)surface->pixels + offy * (surface->pitch / 4) + offx, surface->pitch / 4, w, h, tvg::SwCanvas::ARGB8888)); content(canvas.get()); if (tvgexam::verify(canvas->draw())) { tvgexam::verify(canvas->sync());