From 4bb0a369e5d84511c8515f7ff8cac3227a4878d1 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 81f7966e..98e16e22 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 + SIZE * (counter / NUM_PER_LINE) * (surface->pitch / 4) + (counter % NUM_PER_LINE) * SIZE, surface->pitch / 4, w, h, tvg::SwCanvas::ARGB8888)); content(canvas.get()); if (tvgexam::verify(canvas->draw())) { tvgexam::verify(canvas->sync());