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
This commit is contained in:
Hermet Park 2020-06-23 18:59:12 +09:00
parent b212df1061
commit 9ffc1d40f6

View file

@ -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<SwSpan*>(realloc(rle->spans, (count + rle->size) << 2 * sizeof(SwSpan)));
rle->alloc = (newSize * 2);
rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
assert(rle->spans);
rle->alloc = rle->size + (count << 2);
}
//copy the new spans to the allocated memory