From 9ffc1d40f6f9f1ffd439c5b25cfb3918ac96fc77 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 23 Jun 2020 18:59:12 +0900 Subject: [PATCH] sw_engine: optimize memory allocation. there are a logical wrong that memory increase size, it correct that also tune the number to reduce memory allocation time. Now scene transform test works smoothly. Change-Id: If0674e33426d794546801a96ad9de711b5de0dcd --- src/lib/sw_engine/tvgSwRle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRle.cpp b/src/lib/sw_engine/tvgSwRle.cpp index 5d7d5a73..5bb3a319 100644 --- a/src/lib/sw_engine/tvgSwRle.cpp +++ b/src/lib/sw_engine/tvgSwRle.cpp @@ -147,9 +147,9 @@ static void _genSpan(SwRleData* rle, SwSpan* spans, uint32_t count) /* alloc is required to prevent free and reallocation */ /* when the rle needs to be regenerated because of attribute change. */ if (rle->alloc < newSize) { - rle->spans = static_cast(realloc(rle->spans, (count + rle->size) << 2 * sizeof(SwSpan))); + rle->alloc = (newSize * 2); + rle->spans = static_cast(realloc(rle->spans, rle->alloc * sizeof(SwSpan))); assert(rle->spans); - rle->alloc = rle->size + (count << 2); } //copy the new spans to the allocated memory