mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-28 13:36:27 +08:00
feat(thorvg): use LVGL's malloc/realloc/zalloc/free (#7772)
This commit is contained in:
committed by
GitHub
parent
2bf2ab46ce
commit
fc5c156385
@@ -7,17 +7,17 @@
|
|||||||
*/
|
*/
|
||||||
void lv_example_lottie_1(void)
|
void lv_example_lottie_1(void)
|
||||||
{
|
{
|
||||||
extern const uint8_t lv_example_lottie_approve[];
|
extern const uint8_t rain[];
|
||||||
extern const size_t lv_example_lottie_approve_size;
|
extern const size_t rain_size;
|
||||||
|
|
||||||
lv_obj_t * lottie = lv_lottie_create(lv_screen_active());
|
lv_obj_t * lottie = lv_lottie_create(lv_screen_active());
|
||||||
lv_lottie_set_src_data(lottie, lv_example_lottie_approve, lv_example_lottie_approve_size);
|
lv_lottie_set_src_data(lottie, rain, rain_size);
|
||||||
|
|
||||||
#if LV_DRAW_BUF_ALIGN == 4 && LV_DRAW_BUF_STRIDE_ALIGN == 1
|
#if LV_DRAW_BUF_ALIGN == 4 && LV_DRAW_BUF_STRIDE_ALIGN == 1
|
||||||
/*If there are no special requirements, just declare a buffer
|
/*If there are no special requirements, just declare a buffer
|
||||||
x4 because the Lottie is rendered in ARGB8888 format*/
|
x4 because the Lottie is rendered in ARGB8888 format*/
|
||||||
static uint8_t buf[64 * 64 * 4];
|
static uint8_t buf[364 * 364 * 4];
|
||||||
lv_lottie_set_buffer(lottie, 64, 64, buf);
|
lv_lottie_set_buffer(lottie, 364, 364, buf);
|
||||||
#else
|
#else
|
||||||
/*For GPUs and special alignment/strid setting use a draw_buf instead*/
|
/*For GPUs and special alignment/strid setting use a draw_buf instead*/
|
||||||
LV_DRAW_BUF_DEFINE(draw_buf, 64, 64, LV_COLOR_FORMAT_ARGB8888);
|
LV_DRAW_BUF_DEFINE(draw_buf, 64, 64, LV_COLOR_FORMAT_ARGB8888);
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ void lv_draw_sw_vector(lv_draw_task_t * t, const lv_draw_vector_task_dsc_t * dsc
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tvg_Canvas * canvas = tvg_swcanvas_create();
|
Tvg_Canvas * canvas = tvg_swcanvas_create();
|
||||||
tvg_swcanvas_set_target(canvas, buf, stride / 4, width, height, TVG_COLORSPACE_ARGB8888);
|
tvg_swcanvas_set_target(canvas, buf, stride / 4, width, height, TVG_COLORSPACE_ARGB8888S);
|
||||||
|
|
||||||
_tvg_rect rc;
|
_tvg_rect rc;
|
||||||
lv_area_to_tvg(&rc, &t->clip_area);
|
lv_area_to_tvg(&rc, &t->clip_area);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../../misc/lv_assert.h"
|
||||||
|
|
||||||
RAPIDJSON_NAMESPACE_BEGIN
|
RAPIDJSON_NAMESPACE_BEGIN
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -84,10 +86,13 @@ class CrtAllocator {
|
|||||||
public:
|
public:
|
||||||
static const bool kNeedFree = true;
|
static const bool kNeedFree = true;
|
||||||
void* Malloc(size_t size) {
|
void* Malloc(size_t size) {
|
||||||
if (size) // behavior of malloc(0) is implementation defined.
|
if (size) { // behavior of malloc(0) is implementation defined.
|
||||||
return RAPIDJSON_MALLOC(size);
|
void * p = RAPIDJSON_MALLOC(size);
|
||||||
else
|
LV_ASSERT_MALLOC(p);
|
||||||
|
return p;
|
||||||
|
} else {
|
||||||
return NULL; // standardize to returning NULL.
|
return NULL; // standardize to returning NULL.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {
|
void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {
|
||||||
(void)originalSize;
|
(void)originalSize;
|
||||||
@@ -95,7 +100,9 @@ public:
|
|||||||
RAPIDJSON_FREE(originalPtr);
|
RAPIDJSON_FREE(originalPtr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return RAPIDJSON_REALLOC(originalPtr, newSize);
|
void * p = RAPIDJSON_REALLOC(originalPtr, newSize);
|
||||||
|
LV_ASSERT_MALLOC(p);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
static void Free(void *ptr) RAPIDJSON_NOEXCEPT { RAPIDJSON_FREE(ptr); }
|
static void Free(void *ptr) RAPIDJSON_NOEXCEPT { RAPIDJSON_FREE(ptr); }
|
||||||
|
|
||||||
|
|||||||
@@ -690,18 +690,18 @@ RAPIDJSON_NAMESPACE_END
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// malloc/realloc/free
|
// malloc/realloc/free
|
||||||
|
#include "../../../stdlib/lv_mem.h"
|
||||||
#ifndef RAPIDJSON_MALLOC
|
#ifndef RAPIDJSON_MALLOC
|
||||||
///! customization point for global \c malloc
|
///! customization point for global \c malloc
|
||||||
#define RAPIDJSON_MALLOC(size) std::malloc(size)
|
#define RAPIDJSON_MALLOC(size) lv_malloc(size)
|
||||||
#endif
|
#endif
|
||||||
#ifndef RAPIDJSON_REALLOC
|
#ifndef RAPIDJSON_REALLOC
|
||||||
///! customization point for global \c realloc
|
///! customization point for global \c realloc
|
||||||
#define RAPIDJSON_REALLOC(ptr, new_size) std::realloc(ptr, new_size)
|
#define RAPIDJSON_REALLOC(ptr, new_size) lv_realloc(ptr, new_size)
|
||||||
#endif
|
#endif
|
||||||
#ifndef RAPIDJSON_FREE
|
#ifndef RAPIDJSON_FREE
|
||||||
///! customization point for global \c free
|
///! customization point for global \c free
|
||||||
#define RAPIDJSON_FREE(ptr) std::free(ptr)
|
#define RAPIDJSON_FREE(ptr) lv_free(ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "../../stdlib/lv_mem.h"
|
||||||
|
#include "../../stdlib/lv_string.h"
|
||||||
|
#include "../../misc/lv_assert.h"
|
||||||
|
|
||||||
#ifdef TVG_API
|
#ifdef TVG_API
|
||||||
#undef TVG_API
|
#undef TVG_API
|
||||||
@@ -1056,7 +1059,7 @@ public:
|
|||||||
* @param[in] miterlimit The miterlimit imposes a limit on the extent of the stroke join, when the @c StrokeJoin::Miter join style is set. The default value is 4.
|
* @param[in] miterlimit The miterlimit imposes a limit on the extent of the stroke join, when the @c StrokeJoin::Miter join style is set. The default value is 4.
|
||||||
*
|
*
|
||||||
* @retval Result::InvalidArgument for @p miterlimit values less than zero.
|
* @retval Result::InvalidArgument for @p miterlimit values less than zero.
|
||||||
*
|
*
|
||||||
* @since 0.11
|
* @since 0.11
|
||||||
*/
|
*/
|
||||||
Result strokeMiterlimit(float miterlimit) noexcept;
|
Result strokeMiterlimit(float miterlimit) noexcept;
|
||||||
@@ -1605,7 +1608,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @note If the font data is currently in use, it will not be immediately unloaded.
|
* @note If the font data is currently in use, it will not be immediately unloaded.
|
||||||
* @see Text::load(const std::string& path)
|
* @see Text::load(const std::string& path)
|
||||||
*
|
*
|
||||||
* @since 0.15
|
* @since 0.15
|
||||||
*/
|
*/
|
||||||
static Result unload(const std::string& path) noexcept;
|
static Result unload(const std::string& path) noexcept;
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ struct Array
|
|||||||
{
|
{
|
||||||
if (count + 1 > reserved) {
|
if (count + 1 > reserved) {
|
||||||
reserved = count + (count + 2) / 2;
|
reserved = count + (count + 2) / 2;
|
||||||
data = static_cast<T*>(realloc(data, sizeof(T) * reserved));
|
data = static_cast<T*>(lv_realloc(data, sizeof(T) * reserved));
|
||||||
|
LV_ASSERT_MALLOC(data);
|
||||||
}
|
}
|
||||||
data[count++] = element;
|
data[count++] = element;
|
||||||
}
|
}
|
||||||
@@ -74,7 +75,8 @@ struct Array
|
|||||||
{
|
{
|
||||||
if (size > reserved) {
|
if (size > reserved) {
|
||||||
reserved = size;
|
reserved = size;
|
||||||
data = static_cast<T*>(realloc(data, sizeof(T) * reserved));
|
data = static_cast<T*>(lv_realloc(data, sizeof(T) * reserved));
|
||||||
|
LV_ASSERT_MALLOC(data);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -141,7 +143,7 @@ struct Array
|
|||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
free(data);
|
lv_free(data);
|
||||||
data = nullptr;
|
data = nullptr;
|
||||||
count = reserved = 0;
|
count = reserved = 0;
|
||||||
}
|
}
|
||||||
@@ -171,7 +173,7 @@ struct Array
|
|||||||
|
|
||||||
~Array()
|
~Array()
|
||||||
{
|
{
|
||||||
free(data);
|
lv_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -57,8 +57,7 @@
|
|||||||
* http://marknelson.us/1989/10/01/lzw-data-compression/
|
* http://marknelson.us/1989/10/01/lzw-data-compression/
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "thorvg.h"
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@@ -112,7 +111,8 @@ struct BitStreamWriter
|
|||||||
|
|
||||||
uint8_t* allocBytes(const int bytesWanted, uint8_t * oldPtr, const int oldSize)
|
uint8_t* allocBytes(const int bytesWanted, uint8_t * oldPtr, const int oldSize)
|
||||||
{
|
{
|
||||||
auto newMemory = static_cast<uint8_t *>(malloc(bytesWanted));
|
auto newMemory = static_cast<uint8_t *>(lv_malloc(bytesWanted));
|
||||||
|
LV_ASSERT_MALLOC(newMemory);
|
||||||
memset(newMemory, 0, bytesWanted);
|
memset(newMemory, 0, bytesWanted);
|
||||||
|
|
||||||
if (oldPtr) {
|
if (oldPtr) {
|
||||||
@@ -349,7 +349,8 @@ uint8_t* lzwDecode(const uint8_t* compressed, uint32_t compressedSizeBytes, uint
|
|||||||
int firstByte = 0;
|
int firstByte = 0;
|
||||||
int bytesDecoded = 0;
|
int bytesDecoded = 0;
|
||||||
int codeBitsWidth = StartBits;
|
int codeBitsWidth = StartBits;
|
||||||
auto uncompressed = (uint8_t*) malloc(sizeof(uint8_t) * uncompressedSizeBytes);
|
auto uncompressed = (uint8_t*) lv_malloc(sizeof(uint8_t) * uncompressedSizeBytes);
|
||||||
|
LV_ASSERT_MALLOC(uncompressed);
|
||||||
auto ptr = uncompressed;
|
auto ptr = uncompressed;
|
||||||
|
|
||||||
/* We'll reconstruct the dictionary based on the bit stream codes.
|
/* We'll reconstruct the dictionary based on the bit stream codes.
|
||||||
@@ -445,7 +446,8 @@ size_t b64Decode(const char* encoded, const size_t len, char** decoded)
|
|||||||
if (!decoded || !encoded || len == 0) return 0;
|
if (!decoded || !encoded || len == 0) return 0;
|
||||||
|
|
||||||
auto reserved = 3 * (1 + (len >> 2)) + 1;
|
auto reserved = 3 * (1 + (len >> 2)) + 1;
|
||||||
auto output = static_cast<char*>(malloc(reserved * sizeof(char)));
|
auto output = static_cast<char*>(lv_malloc(reserved * sizeof(char)));
|
||||||
|
LV_ASSERT_MALLOC(output);
|
||||||
if (!output) return 0;
|
if (!output) return 0;
|
||||||
output[reserved - 1] = '\0';
|
output[reserved - 1] = '\0';
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ Result Fill::colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pImpl->cnt != cnt) {
|
if (pImpl->cnt != cnt) {
|
||||||
pImpl->colorStops = static_cast<ColorStop*>(realloc(pImpl->colorStops, cnt * sizeof(ColorStop)));
|
pImpl->colorStops = static_cast<ColorStop*>(lv_realloc(pImpl->colorStops, cnt * sizeof(ColorStop)));
|
||||||
|
LV_ASSERT_MALLOC(pImpl->colorStops);
|
||||||
}
|
}
|
||||||
|
|
||||||
pImpl->cnt = cnt;
|
pImpl->cnt = cnt;
|
||||||
@@ -138,7 +139,8 @@ FillSpread Fill::spread() const noexcept
|
|||||||
Result Fill::transform(const Matrix& m) noexcept
|
Result Fill::transform(const Matrix& m) noexcept
|
||||||
{
|
{
|
||||||
if (!pImpl->transform) {
|
if (!pImpl->transform) {
|
||||||
pImpl->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
|
pImpl->transform = static_cast<Matrix*>(lv_malloc(sizeof(Matrix)));
|
||||||
|
LV_ASSERT_MALLOC(pImpl->transform);
|
||||||
}
|
}
|
||||||
*pImpl->transform = m;
|
*pImpl->transform = m;
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ struct Fill::Impl
|
|||||||
~Impl()
|
~Impl()
|
||||||
{
|
{
|
||||||
delete(dup);
|
delete(dup);
|
||||||
free(colorStops);
|
lv_free(colorStops);
|
||||||
free(transform);
|
lv_free(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void method(DuplicateMethod<Fill>* dup)
|
void method(DuplicateMethod<Fill>* dup)
|
||||||
@@ -78,10 +78,12 @@ struct Fill::Impl
|
|||||||
|
|
||||||
ret->pImpl->cnt = cnt;
|
ret->pImpl->cnt = cnt;
|
||||||
ret->pImpl->spread = spread;
|
ret->pImpl->spread = spread;
|
||||||
ret->pImpl->colorStops = static_cast<ColorStop*>(malloc(sizeof(ColorStop) * cnt));
|
ret->pImpl->colorStops = static_cast<ColorStop*>(lv_malloc(sizeof(ColorStop) * cnt));
|
||||||
|
LV_ASSERT_MALLOC(ret->pImpl->colorStops);
|
||||||
memcpy(ret->pImpl->colorStops, colorStops, sizeof(ColorStop) * cnt);
|
memcpy(ret->pImpl->colorStops, colorStops, sizeof(ColorStop) * cnt);
|
||||||
if (transform) {
|
if (transform) {
|
||||||
ret->pImpl->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
|
ret->pImpl->transform = static_cast<Matrix*>(lv_malloc(sizeof(Matrix)));
|
||||||
|
LV_ASSERT_MALLOC(ret->pImpl->transform);
|
||||||
*ret->pImpl->transform = *transform;
|
*ret->pImpl->transform = *transform;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ struct LoadModule
|
|||||||
LoadModule(FileType type) : type(type) {}
|
LoadModule(FileType type) : type(type) {}
|
||||||
virtual ~LoadModule()
|
virtual ~LoadModule()
|
||||||
{
|
{
|
||||||
if (pathcache) free(hashpath);
|
if (pathcache) lv_free(hashpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool open(const string& path) { return false; }
|
virtual bool open(const string& path) { return false; }
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ LoadModule* LoaderMgr::loader(const string& path, bool* invalid)
|
|||||||
if (auto loader = _findByPath(path)) {
|
if (auto loader = _findByPath(path)) {
|
||||||
if (loader->open(path)) {
|
if (loader->open(path)) {
|
||||||
if (allowCache) {
|
if (allowCache) {
|
||||||
loader->hashpath = strdup(path.c_str());
|
loader->hashpath = lv_strdup(path.c_str());
|
||||||
loader->pathcache = true;
|
loader->pathcache = true;
|
||||||
{
|
{
|
||||||
ScopedLock lock(key);
|
ScopedLock lock(key);
|
||||||
@@ -325,7 +325,7 @@ LoadModule* LoaderMgr::loader(const string& path, bool* invalid)
|
|||||||
if (auto loader = _find(static_cast<FileType>(i))) {
|
if (auto loader = _find(static_cast<FileType>(i))) {
|
||||||
if (loader->open(path)) {
|
if (loader->open(path)) {
|
||||||
if (allowCache) {
|
if (allowCache) {
|
||||||
loader->hashpath = strdup(path.c_str());
|
loader->hashpath = lv_strdup(path.c_str());
|
||||||
loader->pathcache = true;
|
loader->pathcache = true;
|
||||||
{
|
{
|
||||||
ScopedLock lock(key);
|
ScopedLock lock(key);
|
||||||
@@ -448,7 +448,7 @@ LoadModule* LoaderMgr::loader(const char* name, const char* data, uint32_t size,
|
|||||||
//function is dedicated for ttf loader (the only supported font loader)
|
//function is dedicated for ttf loader (the only supported font loader)
|
||||||
auto loader = new TtfLoader;
|
auto loader = new TtfLoader;
|
||||||
if (loader->open(data, size, copy)) {
|
if (loader->open(data, size, copy)) {
|
||||||
loader->hashpath = strdup(name);
|
loader->hashpath = lv_strdup(name);
|
||||||
loader->pathcache = true;
|
loader->pathcache = true;
|
||||||
ScopedLock lock(key);
|
ScopedLock lock(key);
|
||||||
_activeLoaders.back(loader);
|
_activeLoaders.back(loader);
|
||||||
|
|||||||
@@ -181,7 +181,10 @@ void LottieBuilder::updateTransform(LottieGroup* parent, LottieObject** child, f
|
|||||||
uint8_t opacity;
|
uint8_t opacity;
|
||||||
|
|
||||||
if (parent->mergeable()) {
|
if (parent->mergeable()) {
|
||||||
if (!ctx->transform) ctx->transform = (Matrix*)malloc(sizeof(Matrix));
|
if (!ctx->transform) {
|
||||||
|
ctx->transform = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||||
|
LV_ASSERT_MALLOC(ctx->transform);
|
||||||
|
}
|
||||||
_updateTransform(transform, frameNo, false, *ctx->transform, opacity, exps);
|
_updateTransform(transform, frameNo, false, *ctx->transform, opacity, exps);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -481,7 +484,7 @@ void LottieBuilder::updateRect(LottieGroup* parent, LottieObject** child, float
|
|||||||
} else {
|
} else {
|
||||||
r = std::min({r, size.x * 0.5f, size.y * 0.5f});
|
r = std::min({r, size.x * 0.5f, size.y * 0.5f});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->repeaters.empty()) {
|
if (!ctx->repeaters.empty()) {
|
||||||
auto shape = rect->pooling();
|
auto shape = rect->pooling();
|
||||||
shape->reset();
|
shape->reset();
|
||||||
@@ -531,7 +534,7 @@ static void _appendCircle(Shape* shape, float cx, float cy, float rx, float ry,
|
|||||||
points[i] *= *transform;
|
points[i] *= *transform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shape->appendPath(commands, cmdsCnt, points, ptsCnt);
|
shape->appendPath(commands, cmdsCnt, points, ptsCnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ struct RenderContext
|
|||||||
~RenderContext()
|
~RenderContext()
|
||||||
{
|
{
|
||||||
PP(propagator)->unref();
|
PP(propagator)->unref();
|
||||||
free(transform);
|
lv_free(transform);
|
||||||
delete(roundness);
|
delete(roundness);
|
||||||
delete(offsetPath);
|
delete(offsetPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ static LottieExpressions* exps = nullptr; //singleton instance engine
|
|||||||
|
|
||||||
static ExpContent* _expcontent(LottieExpression* exp, float frameNo, LottieObject* obj)
|
static ExpContent* _expcontent(LottieExpression* exp, float frameNo, LottieObject* obj)
|
||||||
{
|
{
|
||||||
auto data = (ExpContent*)malloc(sizeof(ExpContent));
|
auto data = (ExpContent*)lv_malloc(sizeof(ExpContent));
|
||||||
|
LV_ASSERT_MALLOC(ndata);
|
||||||
data->exp = exp;
|
data->exp = exp;
|
||||||
data->frameNo = frameNo;
|
data->frameNo = frameNo;
|
||||||
data->obj = obj;
|
data->obj = obj;
|
||||||
@@ -73,7 +74,7 @@ static ExpContent* _expcontent(LottieExpression* exp, float frameNo, LottieObjec
|
|||||||
|
|
||||||
static void contentFree(void *native_p, struct jerry_object_native_info_t *info_p)
|
static void contentFree(void *native_p, struct jerry_object_native_info_t *info_p)
|
||||||
{
|
{
|
||||||
free(native_p);
|
lv_free(native_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jerry_object_native_info_t freeCb {contentFree, 0, 0};
|
static jerry_object_native_info_t freeCb {contentFree, 0, 0};
|
||||||
@@ -84,7 +85,8 @@ static char* _name(jerry_value_t args)
|
|||||||
{
|
{
|
||||||
auto arg0 = jerry_value_to_string(args);
|
auto arg0 = jerry_value_to_string(args);
|
||||||
auto len = jerry_string_length(arg0);
|
auto len = jerry_string_length(arg0);
|
||||||
auto name = (jerry_char_t*)malloc(len * sizeof(jerry_char_t) + 1);
|
auto name = (jerry_char_t*)lv_malloc(len * sizeof(jerry_char_t) + 1);
|
||||||
|
LV_ASSERT_MALLOC(name);
|
||||||
jerry_string_to_buffer(arg0, JERRY_ENCODING_UTF8, name, len);
|
jerry_string_to_buffer(arg0, JERRY_ENCODING_UTF8, name, len);
|
||||||
name[len] = '\0';
|
name[len] = '\0';
|
||||||
jerry_value_free(arg0);
|
jerry_value_free(arg0);
|
||||||
@@ -96,7 +98,7 @@ static unsigned long _idByName(jerry_value_t args)
|
|||||||
{
|
{
|
||||||
auto name = _name(args);
|
auto name = _name(args);
|
||||||
auto id = djb2Encode(name);
|
auto id = djb2Encode(name);
|
||||||
free(name);
|
lv_free(name);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +834,7 @@ static bool _loopOutCommon(LottieExpression* exp, const jerry_value_t args[], co
|
|||||||
else if (!strcmp(name, EXP_PINGPONG)) exp->loop.mode = LottieExpression::LoopMode::OutPingPong;
|
else if (!strcmp(name, EXP_PINGPONG)) exp->loop.mode = LottieExpression::LoopMode::OutPingPong;
|
||||||
else if (!strcmp(name, EXP_OFFSET)) exp->loop.mode = LottieExpression::LoopMode::OutOffset;
|
else if (!strcmp(name, EXP_OFFSET)) exp->loop.mode = LottieExpression::LoopMode::OutOffset;
|
||||||
else if (!strcmp(name, EXP_CONTINUE)) exp->loop.mode = LottieExpression::LoopMode::OutContinue;
|
else if (!strcmp(name, EXP_CONTINUE)) exp->loop.mode = LottieExpression::LoopMode::OutContinue;
|
||||||
free(name);
|
lv_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp->loop.mode != LottieExpression::LoopMode::OutCycle && exp->loop.mode != LottieExpression::LoopMode::OutPingPong) {
|
if (exp->loop.mode != LottieExpression::LoopMode::OutCycle && exp->loop.mode != LottieExpression::LoopMode::OutPingPong) {
|
||||||
@@ -884,7 +886,7 @@ static bool _loopInCommon(LottieExpression* exp, const jerry_value_t args[], con
|
|||||||
else if (!strcmp(name, EXP_PINGPONG)) exp->loop.mode = LottieExpression::LoopMode::InPingPong;
|
else if (!strcmp(name, EXP_PINGPONG)) exp->loop.mode = LottieExpression::LoopMode::InPingPong;
|
||||||
else if (!strcmp(name, EXP_OFFSET)) exp->loop.mode = LottieExpression::LoopMode::InOffset;
|
else if (!strcmp(name, EXP_OFFSET)) exp->loop.mode = LottieExpression::LoopMode::InOffset;
|
||||||
else if (!strcmp(name, EXP_CONTINUE)) exp->loop.mode = LottieExpression::LoopMode::InContinue;
|
else if (!strcmp(name, EXP_CONTINUE)) exp->loop.mode = LottieExpression::LoopMode::InContinue;
|
||||||
free(name);
|
lv_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp->loop.mode != LottieExpression::LoopMode::InCycle && exp->loop.mode != LottieExpression::LoopMode::InPingPong) {
|
if (exp->loop.mode != LottieExpression::LoopMode::InCycle && exp->loop.mode != LottieExpression::LoopMode::InPingPong) {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ float LottieInterpolator::progress(float t)
|
|||||||
|
|
||||||
void LottieInterpolator::set(const char* key, Point& inTangent, Point& outTangent)
|
void LottieInterpolator::set(const char* key, Point& inTangent, Point& outTangent)
|
||||||
{
|
{
|
||||||
this->key = strdup(key);
|
this->key = lv_strdup(key);
|
||||||
this->inTangent = inTangent;
|
this->inTangent = inTangent;
|
||||||
this->outTangent = outTangent;
|
this->outTangent = outTangent;
|
||||||
|
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ void LottieLoader::run(unsigned tid)
|
|||||||
void LottieLoader::release()
|
void LottieLoader::release()
|
||||||
{
|
{
|
||||||
if (copy) {
|
if (copy) {
|
||||||
free((char*)content);
|
lv_free((char*)content);
|
||||||
content = nullptr;
|
content = nullptr;
|
||||||
}
|
}
|
||||||
free(dirName);
|
lv_free(dirName);
|
||||||
dirName = nullptr;
|
dirName = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,13 +201,14 @@ bool LottieLoader::header()
|
|||||||
bool LottieLoader::open(const char* data, uint32_t size, bool copy)
|
bool LottieLoader::open(const char* data, uint32_t size, bool copy)
|
||||||
{
|
{
|
||||||
if (copy) {
|
if (copy) {
|
||||||
content = (char*)malloc(size + 1);
|
content = (char*)lv_malloc(size + 1);
|
||||||
|
LV_ASSERT_MALLOC(content);
|
||||||
if (!content) return false;
|
if (!content) return false;
|
||||||
memcpy((char*)content, data, size);
|
memcpy((char*)content, data, size);
|
||||||
const_cast<char*>(content)[size] = '\0';
|
const_cast<char*>(content)[size] = '\0';
|
||||||
} else content = data;
|
} else content = data;
|
||||||
|
|
||||||
this->dirName = strdup(".");
|
this->dirName = lv_strdup(".");
|
||||||
|
|
||||||
this->size = size;
|
this->size = size;
|
||||||
this->copy = copy;
|
this->copy = copy;
|
||||||
@@ -229,7 +230,8 @@ bool LottieLoader::open(const string& path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto content = (char*)(malloc(sizeof(char) * size + 1));
|
auto content = (char*)(lv_malloc(sizeof(char) * size + 1));
|
||||||
|
LV_ASSERT_MALLOC(content);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
auto ret = fread(content, sizeof(char), size, f);
|
auto ret = fread(content, sizeof(char), size, f);
|
||||||
if (ret < size) {
|
if (ret < size) {
|
||||||
@@ -298,7 +300,7 @@ bool LottieLoader::override(const char* slot)
|
|||||||
//override slots
|
//override slots
|
||||||
if (slot) {
|
if (slot) {
|
||||||
//Copy the input data because the JSON parser will encode the data immediately.
|
//Copy the input data because the JSON parser will encode the data immediately.
|
||||||
auto temp = strdup(slot);
|
auto temp = lv_strdup(slot);
|
||||||
|
|
||||||
//parsing slot json
|
//parsing slot json
|
||||||
LottieParser parser(temp, dirName);
|
LottieParser parser(temp, dirName);
|
||||||
@@ -315,7 +317,7 @@ bool LottieLoader::override(const char* slot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idx < 1) success = false;
|
if (idx < 1) success = false;
|
||||||
free(temp);
|
lv_free(temp);
|
||||||
rebuild = overridden = success;
|
rebuild = overridden = success;
|
||||||
//reset slots
|
//reset slots
|
||||||
} else if (overridden) {
|
} else if (overridden) {
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ void LottieTextRange::range(float frameNo, float totalLen, float& start, float&
|
|||||||
|
|
||||||
LottieImage::~LottieImage()
|
LottieImage::~LottieImage()
|
||||||
{
|
{
|
||||||
free(b64Data);
|
lv_free(b64Data);
|
||||||
free(mimeType);
|
lv_free(mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ LottieLayer::~LottieLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete(transform);
|
delete(transform);
|
||||||
free(name);
|
lv_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -473,13 +473,13 @@ LottieComposition::~LottieComposition()
|
|||||||
if (!initiated && root) delete(root->scene);
|
if (!initiated && root) delete(root->scene);
|
||||||
|
|
||||||
delete(root);
|
delete(root);
|
||||||
free(version);
|
lv_free(version);
|
||||||
free(name);
|
lv_free(name);
|
||||||
|
|
||||||
//delete interpolators
|
//delete interpolators
|
||||||
for (auto i = interpolators.begin(); i < interpolators.end(); ++i) {
|
for (auto i = interpolators.begin(); i < interpolators.end(); ++i) {
|
||||||
free((*i)->key);
|
lv_free((*i)->key);
|
||||||
free(*i);
|
lv_free(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete assets
|
//delete assets
|
||||||
@@ -496,7 +496,7 @@ LottieComposition::~LottieComposition()
|
|||||||
for (auto s = slots.begin(); s < slots.end(); ++s) {
|
for (auto s = slots.begin(); s < slots.end(); ++s) {
|
||||||
delete(*s);
|
delete(*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto m = markers.begin(); m < markers.end(); ++m) {
|
for (auto m = markers.begin(); m < markers.end(); ++m) {
|
||||||
delete(*m);
|
delete(*m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ struct LottieGlyph
|
|||||||
~LottieGlyph()
|
~LottieGlyph()
|
||||||
{
|
{
|
||||||
for (auto p = children.begin(); p < children.end(); ++p) delete(*p);
|
for (auto p = children.begin(); p < children.end(); ++p) delete(*p);
|
||||||
free(code);
|
lv_free(code);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -229,9 +229,9 @@ struct LottieFont
|
|||||||
~LottieFont()
|
~LottieFont()
|
||||||
{
|
{
|
||||||
for (auto c = chars.begin(); c < chars.end(); ++c) delete(*c);
|
for (auto c = chars.begin(); c < chars.end(); ++c) delete(*c);
|
||||||
free(style);
|
lv_free(style);
|
||||||
free(family);
|
lv_free(family);
|
||||||
free(name);
|
lv_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<LottieGlyph*> chars;
|
Array<LottieGlyph*> chars;
|
||||||
@@ -247,10 +247,10 @@ struct LottieMarker
|
|||||||
char* name = nullptr;
|
char* name = nullptr;
|
||||||
float time = 0.0f;
|
float time = 0.0f;
|
||||||
float duration = 0.0f;
|
float duration = 0.0f;
|
||||||
|
|
||||||
~LottieMarker()
|
~LottieMarker()
|
||||||
{
|
{
|
||||||
free(name);
|
lv_free(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -500,7 +500,7 @@ struct LottieTransform : LottieObject
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct LottieSolid : LottieObject
|
struct LottieSolid : LottieObject
|
||||||
{
|
{
|
||||||
LottieColor color = RGB24{255, 255, 255};
|
LottieColor color = RGB24{255, 255, 255};
|
||||||
LottieOpacity opacity = 255;
|
LottieOpacity opacity = 255;
|
||||||
@@ -836,7 +836,7 @@ struct LottieSlot
|
|||||||
|
|
||||||
~LottieSlot()
|
~LottieSlot()
|
||||||
{
|
{
|
||||||
free(sid);
|
lv_free(sid);
|
||||||
if (!overridden) return;
|
if (!overridden) return;
|
||||||
for (auto pair = pairs.begin(); pair < pairs.end(); ++pair) {
|
for (auto pair = pairs.begin(); pair < pairs.end(); ++pair) {
|
||||||
delete(pair->prop);
|
delete(pair->prop);
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ template<typename T>
|
|||||||
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
|
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
|
||||||
{
|
{
|
||||||
if (KEY_AS("ti") && getValue(value.inTangent)) ;
|
if (KEY_AS("ti") && getValue(value.inTangent)) ;
|
||||||
else if (KEY_AS("to") && getValue(value.outTangent)) ;
|
else if (KEY_AS("to") && getValue(value.outTangent)) ;
|
||||||
else return false;
|
else return false;
|
||||||
|
|
||||||
value.hasTangent = true;
|
value.hasTangent = true;
|
||||||
@@ -406,7 +406,8 @@ LottieInterpolator* LottieParser::getInterpolator(const char* key, Point& in, Po
|
|||||||
|
|
||||||
//new interpolator
|
//new interpolator
|
||||||
if (!interpolator) {
|
if (!interpolator) {
|
||||||
interpolator = static_cast<LottieInterpolator*>(malloc(sizeof(LottieInterpolator)));
|
interpolator = static_cast<LottieInterpolator*>(lv_malloc(sizeof(LottieInterpolator)));
|
||||||
|
LV_ASSERT_MALLOC(interpolator);
|
||||||
interpolator->set(key, in, out);
|
interpolator->set(key, in, out);
|
||||||
comp->interpolators.push(interpolator);
|
comp->interpolators.push(interpolator);
|
||||||
}
|
}
|
||||||
@@ -944,7 +945,8 @@ LottieImage* LottieParser::parseImage(const char* data, const char* subPath, boo
|
|||||||
//external image resource
|
//external image resource
|
||||||
} else {
|
} else {
|
||||||
auto len = strlen(dirName) + strlen(subPath) + strlen(data) + 1;
|
auto len = strlen(dirName) + strlen(subPath) + strlen(data) + 1;
|
||||||
image->path = static_cast<char*>(malloc(len));
|
image->path = static_cast<char*>(lv_malloc(len));
|
||||||
|
LV_ASSERT_MALLOC(image->path);
|
||||||
snprintf(image->path, len, "%s%s%s", dirName, subPath, data);
|
snprintf(image->path, len, "%s%s%s", dirName, subPath, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1024,16 +1026,16 @@ void LottieParser::parseAssets()
|
|||||||
LottieMarker* LottieParser::parseMarker()
|
LottieMarker* LottieParser::parseMarker()
|
||||||
{
|
{
|
||||||
enterObject();
|
enterObject();
|
||||||
|
|
||||||
auto marker = new LottieMarker;
|
auto marker = new LottieMarker;
|
||||||
|
|
||||||
while (auto key = nextObjectKey()) {
|
while (auto key = nextObjectKey()) {
|
||||||
if (KEY_AS("cm")) marker->name = getStringCopy();
|
if (KEY_AS("cm")) marker->name = getStringCopy();
|
||||||
else if (KEY_AS("tm")) marker->time = getFloat();
|
else if (KEY_AS("tm")) marker->time = getFloat();
|
||||||
else if (KEY_AS("dr")) marker->duration = getFloat();
|
else if (KEY_AS("dr")) marker->duration = getFloat();
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1406,8 +1408,8 @@ void LottieParser::postProcess(Array<LottieGlyph*>& glyphs)
|
|||||||
auto& font = comp->fonts[i];
|
auto& font = comp->fonts[i];
|
||||||
if (!strcmp(font->family, glyph->family) && !strcmp(font->style, glyph->style)) {
|
if (!strcmp(font->family, glyph->family) && !strcmp(font->style, glyph->style)) {
|
||||||
font->chars.push(glyph);
|
font->chars.push(glyph);
|
||||||
free(glyph->family);
|
lv_free(glyph->family);
|
||||||
free(glyph->style);
|
lv_free(glyph->style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ const char* LookaheadParserHandler::getString()
|
|||||||
char* LookaheadParserHandler::getStringCopy()
|
char* LookaheadParserHandler::getStringCopy()
|
||||||
{
|
{
|
||||||
auto str = getString();
|
auto str = getString();
|
||||||
if (str) return strdup(str);
|
if (str) return lv_strdup(str);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ struct LottieExpression
|
|||||||
|
|
||||||
~LottieExpression()
|
~LottieExpression()
|
||||||
{
|
{
|
||||||
free(code);
|
lv_free(code);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -364,17 +364,17 @@ struct LottiePathSet : LottieProperty
|
|||||||
exp = nullptr;
|
exp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(value.cmds);
|
lv_free(value.cmds);
|
||||||
free(value.pts);
|
lv_free(value.pts);
|
||||||
|
|
||||||
if (!frames) return;
|
if (!frames) return;
|
||||||
|
|
||||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||||
free((*p).value.cmds);
|
lv_free((*p).value.cmds);
|
||||||
free((*p).value.pts);
|
lv_free((*p).value.pts);
|
||||||
}
|
}
|
||||||
free(frames->data);
|
lv_free(frames->data);
|
||||||
free(frames);
|
lv_free(frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t nearest(float frameNo) override
|
uint32_t nearest(float frameNo) override
|
||||||
@@ -395,7 +395,8 @@ struct LottiePathSet : LottieProperty
|
|||||||
LottieScalarFrame<PathSet>& newFrame()
|
LottieScalarFrame<PathSet>& newFrame()
|
||||||
{
|
{
|
||||||
if (!frames) {
|
if (!frames) {
|
||||||
frames = static_cast<Array<LottieScalarFrame<PathSet>>*>(calloc(1, sizeof(Array<LottieScalarFrame<PathSet>>)));
|
frames = static_cast<Array<LottieScalarFrame<PathSet>>*>(lv_zalloc(sizeof(Array<LottieScalarFrame<PathSet>>)));
|
||||||
|
LV_ASSERT_MALLOC(frames);
|
||||||
}
|
}
|
||||||
if (frames->count + 1 >= frames->reserved) {
|
if (frames->count + 1 >= frames->reserved) {
|
||||||
auto old = frames->reserved;
|
auto old = frames->reserved;
|
||||||
@@ -465,7 +466,8 @@ struct LottiePathSet : LottieProperty
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto interpPts = (Point*)malloc(frame->value.ptsCnt * sizeof(Point));
|
auto interpPts = (Point*)lv_malloc(frame->value.ptsCnt * sizeof(Point));
|
||||||
|
LV_ASSERT_MALLOC(interpPts);
|
||||||
auto p = interpPts;
|
auto p = interpPts;
|
||||||
for (auto i = 0; i < frame->value.ptsCnt; ++i, ++s, ++e, ++p) {
|
for (auto i = 0; i < frame->value.ptsCnt; ++i, ++s, ++e, ++p) {
|
||||||
*p = lerp(*s, *e, t);
|
*p = lerp(*s, *e, t);
|
||||||
@@ -481,7 +483,7 @@ struct LottiePathSet : LottieProperty
|
|||||||
} else roundness->modifyPath(frame->value.cmds, frame->value.cmdsCnt, interpPts, frame->value.ptsCnt, cmds, pts, nullptr);
|
} else roundness->modifyPath(frame->value.cmds, frame->value.cmdsCnt, interpPts, frame->value.ptsCnt, cmds, pts, nullptr);
|
||||||
} else if (offsetPath) offsetPath->modifyPath(frame->value.cmds, frame->value.cmdsCnt, interpPts, frame->value.ptsCnt, cmds, pts);
|
} else if (offsetPath) offsetPath->modifyPath(frame->value.cmds, frame->value.cmdsCnt, interpPts, frame->value.ptsCnt, cmds, pts);
|
||||||
|
|
||||||
free(interpPts);
|
lv_free(interpPts);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -520,17 +522,17 @@ struct LottieColorStop : LottieProperty
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value.data) {
|
if (value.data) {
|
||||||
free(value.data);
|
lv_free(value.data);
|
||||||
value.data = nullptr;
|
value.data = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!frames) return;
|
if (!frames) return;
|
||||||
|
|
||||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||||
free((*p).value.data);
|
lv_free((*p).value.data);
|
||||||
}
|
}
|
||||||
free(frames->data);
|
lv_free(frames->data);
|
||||||
free(frames);
|
lv_free(frames);
|
||||||
frames = nullptr;
|
frames = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,7 +554,8 @@ struct LottieColorStop : LottieProperty
|
|||||||
LottieScalarFrame<ColorStop>& newFrame()
|
LottieScalarFrame<ColorStop>& newFrame()
|
||||||
{
|
{
|
||||||
if (!frames) {
|
if (!frames) {
|
||||||
frames = static_cast<Array<LottieScalarFrame<ColorStop>>*>(calloc(1, sizeof(Array<LottieScalarFrame<ColorStop>>)));
|
frames = static_cast<Array<LottieScalarFrame<ColorStop>>*>(lv_zalloc(sizeof(Array<LottieScalarFrame<ColorStop>>)));
|
||||||
|
LV_ASSERT_MALLOC(frames);
|
||||||
}
|
}
|
||||||
if (frames->count + 1 >= frames->reserved) {
|
if (frames->count + 1 >= frames->reserved) {
|
||||||
auto old = frames->reserved;
|
auto old = frames->reserved;
|
||||||
@@ -753,19 +756,19 @@ struct LottieTextDoc : LottieProperty
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value.text) {
|
if (value.text) {
|
||||||
free(value.text);
|
lv_free(value.text);
|
||||||
value.text = nullptr;
|
value.text = nullptr;
|
||||||
}
|
}
|
||||||
if (value.name) {
|
if (value.name) {
|
||||||
free(value.name);
|
lv_free(value.name);
|
||||||
value.name = nullptr;
|
value.name = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!frames) return;
|
if (!frames) return;
|
||||||
|
|
||||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||||
free((*p).value.text);
|
lv_free((*p).value.text);
|
||||||
free((*p).value.name);
|
lv_free((*p).value.name);
|
||||||
}
|
}
|
||||||
delete(frames);
|
delete(frames);
|
||||||
frames = nullptr;
|
frames = nullptr;
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ void Paint::Impl::reset()
|
|||||||
|
|
||||||
if (compData) {
|
if (compData) {
|
||||||
if (P(compData->target)->unref() == 0) delete(compData->target);
|
if (P(compData->target)->unref() == 0) delete(compData->target);
|
||||||
free(compData);
|
lv_free(compData);
|
||||||
compData = nullptr;
|
compData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace tvg
|
|||||||
{
|
{
|
||||||
if (compData) {
|
if (compData) {
|
||||||
if (P(compData->target)->unref() == 0) delete(compData->target);
|
if (P(compData->target)->unref() == 0) delete(compData->target);
|
||||||
free(compData);
|
lv_free(compData);
|
||||||
}
|
}
|
||||||
if (clipper && P(clipper)->unref() == 0) delete(clipper);
|
if (clipper && P(clipper)->unref() == 0) delete(clipper);
|
||||||
if (renderer && (renderer->unref() == 0)) delete(renderer);
|
if (renderer && (renderer->unref() == 0)) delete(renderer);
|
||||||
@@ -151,13 +151,14 @@ namespace tvg
|
|||||||
}
|
}
|
||||||
//Reset scenario
|
//Reset scenario
|
||||||
if (!target && method == CompositeMethod::None) {
|
if (!target && method == CompositeMethod::None) {
|
||||||
free(compData);
|
lv_free(compData);
|
||||||
compData = nullptr;
|
compData = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!target && method == CompositeMethod::None) return true;
|
if (!target && method == CompositeMethod::None) return true;
|
||||||
compData = static_cast<Composite*>(calloc(1, sizeof(Composite)));
|
compData = static_cast<Composite*>(lv_zalloc(sizeof(Composite)));
|
||||||
|
LV_ASSERT_MALLOC(compData);
|
||||||
}
|
}
|
||||||
P(target)->ref();
|
P(target)->ref();
|
||||||
compData->target = target;
|
compData->target = target;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ RawLoader::RawLoader() : ImageLoader(FileType::Raw)
|
|||||||
|
|
||||||
RawLoader::~RawLoader()
|
RawLoader::~RawLoader()
|
||||||
{
|
{
|
||||||
if (copy) free(surface.buf32);
|
if (copy) lv_free(surface.buf32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +59,8 @@ bool RawLoader::open(const uint32_t* data, uint32_t w, uint32_t h, bool copy)
|
|||||||
this->copy = copy;
|
this->copy = copy;
|
||||||
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
surface.buf32 = (uint32_t*)malloc(sizeof(uint32_t) * w * h);
|
surface.buf32 = (uint32_t*)lv_malloc(sizeof(uint32_t) * w * h);
|
||||||
|
LV_ASSERT_MALLOC(surface.buf32);
|
||||||
if (!surface.buf32) return false;
|
if (!surface.buf32) return false;
|
||||||
memcpy((void*)surface.buf32, data, sizeof(uint32_t) * w * h);
|
memcpy((void*)surface.buf32, data, sizeof(uint32_t) * w * h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,9 +132,10 @@ struct RenderStroke
|
|||||||
if (rhs.fill) fill = rhs.fill->duplicate();
|
if (rhs.fill) fill = rhs.fill->duplicate();
|
||||||
else fill = nullptr;
|
else fill = nullptr;
|
||||||
|
|
||||||
free(dashPattern);
|
lv_free(dashPattern);
|
||||||
if (rhs.dashCnt > 0) {
|
if (rhs.dashCnt > 0) {
|
||||||
dashPattern = static_cast<float*>(malloc(sizeof(float) * rhs.dashCnt));
|
dashPattern = static_cast<float*>(lv_malloc(sizeof(float) * rhs.dashCnt));
|
||||||
|
LV_ASSERT_MALLOC(dashPattern);
|
||||||
memcpy(dashPattern, rhs.dashPattern, sizeof(float) * rhs.dashCnt);
|
memcpy(dashPattern, rhs.dashPattern, sizeof(float) * rhs.dashCnt);
|
||||||
} else {
|
} else {
|
||||||
dashPattern = nullptr;
|
dashPattern = nullptr;
|
||||||
@@ -175,7 +176,7 @@ struct RenderStroke
|
|||||||
|
|
||||||
~RenderStroke()
|
~RenderStroke()
|
||||||
{
|
{
|
||||||
free(dashPattern);
|
lv_free(dashPattern);
|
||||||
delete(fill);
|
delete(fill);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -275,7 +276,7 @@ struct RenderEffect
|
|||||||
|
|
||||||
virtual ~RenderEffect()
|
virtual ~RenderEffect()
|
||||||
{
|
{
|
||||||
free(rd);
|
lv_free(rd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ struct Shape::Impl
|
|||||||
|
|
||||||
if ((needComp = needComposition(opacity))) {
|
if ((needComp = needComposition(opacity))) {
|
||||||
/* Overriding opacity value. If this scene is half-translucent,
|
/* Overriding opacity value. If this scene is half-translucent,
|
||||||
It must do intermediate composition with that opacity value. */
|
It must do intermediate composition with that opacity value. */
|
||||||
this->opacity = opacity;
|
this->opacity = opacity;
|
||||||
opacity = 255;
|
opacity = 255;
|
||||||
}
|
}
|
||||||
@@ -310,16 +310,17 @@ struct Shape::Impl
|
|||||||
|
|
||||||
//Reset dash
|
//Reset dash
|
||||||
if (!pattern && cnt == 0) {
|
if (!pattern && cnt == 0) {
|
||||||
free(rs.stroke->dashPattern);
|
lv_free(rs.stroke->dashPattern);
|
||||||
rs.stroke->dashPattern = nullptr;
|
rs.stroke->dashPattern = nullptr;
|
||||||
} else {
|
} else {
|
||||||
if (!rs.stroke) rs.stroke = new RenderStroke();
|
if (!rs.stroke) rs.stroke = new RenderStroke();
|
||||||
if (rs.stroke->dashCnt != cnt) {
|
if (rs.stroke->dashCnt != cnt) {
|
||||||
free(rs.stroke->dashPattern);
|
lv_free(rs.stroke->dashPattern);
|
||||||
rs.stroke->dashPattern = nullptr;
|
rs.stroke->dashPattern = nullptr;
|
||||||
}
|
}
|
||||||
if (!rs.stroke->dashPattern) {
|
if (!rs.stroke->dashPattern) {
|
||||||
rs.stroke->dashPattern = static_cast<float*>(malloc(sizeof(float) * cnt));
|
rs.stroke->dashPattern = static_cast<float*>(lv_malloc(sizeof(float) * cnt));
|
||||||
|
LV_ASSERT_MALLOC(rs.stroke->dashPattern);
|
||||||
if (!rs.stroke->dashPattern) return Result::FailedAllocation;
|
if (!rs.stroke->dashPattern) return Result::FailedAllocation;
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < cnt; ++i) {
|
for (uint32_t i = 0; i < cnt; ++i) {
|
||||||
|
|||||||
@@ -215,7 +215,8 @@ char* strDuplicate(const char *str, size_t n)
|
|||||||
auto len = strlen(str);
|
auto len = strlen(str);
|
||||||
if (len < n) n = len;
|
if (len < n) n = len;
|
||||||
|
|
||||||
auto ret = (char *) malloc(n + 1);
|
auto ret = (char *) lv_malloc(n + 1);
|
||||||
|
LV_ASSERT_MALLOC(ret);
|
||||||
if (!ret) return nullptr;
|
if (!ret) return nullptr;
|
||||||
ret[n] = '\0';
|
ret[n] = '\0';
|
||||||
|
|
||||||
@@ -226,7 +227,8 @@ char* strAppend(char* lhs, const char* rhs, size_t n)
|
|||||||
{
|
{
|
||||||
if (!rhs) return lhs;
|
if (!rhs) return lhs;
|
||||||
if (!lhs) return strDuplicate(rhs, n);
|
if (!lhs) return strDuplicate(rhs, n);
|
||||||
lhs = (char*)realloc(lhs, strlen(lhs) + n + 1);
|
lhs = (char*)lv_realloc(lhs, strlen(lhs) + n + 1);
|
||||||
|
LV_ASSERT_MALLOC(lhs);
|
||||||
return strncat(lhs, rhs, n);
|
return strncat(lhs, rhs, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ static void _copyStyle(SvgStyleProperty* to, const SvgStyleProperty* from)
|
|||||||
to->fill.paint.none = from->fill.paint.none;
|
to->fill.paint.none = from->fill.paint.none;
|
||||||
to->fill.paint.curColor = from->fill.paint.curColor;
|
to->fill.paint.curColor = from->fill.paint.curColor;
|
||||||
if (from->fill.paint.url) {
|
if (from->fill.paint.url) {
|
||||||
if (to->fill.paint.url) free(to->fill.paint.url);
|
if (to->fill.paint.url) lv_free(to->fill.paint.url);
|
||||||
to->fill.paint.url = strdup(from->fill.paint.url);
|
to->fill.paint.url = lv_strdup(from->fill.paint.url);
|
||||||
}
|
}
|
||||||
to->fill.flags = (to->fill.flags | SvgFillFlags::Paint);
|
to->fill.flags = (to->fill.flags | SvgFillFlags::Paint);
|
||||||
to->flags = (to->flags | SvgStyleFlags::Fill);
|
to->flags = (to->flags | SvgStyleFlags::Fill);
|
||||||
@@ -109,8 +109,8 @@ static void _copyStyle(SvgStyleProperty* to, const SvgStyleProperty* from)
|
|||||||
to->stroke.paint.none = from->stroke.paint.none;
|
to->stroke.paint.none = from->stroke.paint.none;
|
||||||
to->stroke.paint.curColor = from->stroke.paint.curColor;
|
to->stroke.paint.curColor = from->stroke.paint.curColor;
|
||||||
if (from->stroke.paint.url) {
|
if (from->stroke.paint.url) {
|
||||||
if (to->stroke.paint.url) free(to->stroke.paint.url);
|
if (to->stroke.paint.url) lv_free(to->stroke.paint.url);
|
||||||
to->stroke.paint.url = strdup(from->stroke.paint.url);
|
to->stroke.paint.url = lv_strdup(from->stroke.paint.url);
|
||||||
}
|
}
|
||||||
to->stroke.flags = (to->stroke.flags | SvgStrokeFlags::Paint);
|
to->stroke.flags = (to->stroke.flags | SvgStrokeFlags::Paint);
|
||||||
to->flags = (to->flags | SvgStyleFlags::Stroke);
|
to->flags = (to->flags | SvgStyleFlags::Stroke);
|
||||||
@@ -190,7 +190,8 @@ void cssCopyStyleAttr(SvgNode* to, const SvgNode* from)
|
|||||||
{
|
{
|
||||||
//Copy matrix attribute
|
//Copy matrix attribute
|
||||||
if (from->transform && !(to->style->flags & SvgStyleFlags::Transform)) {
|
if (from->transform && !(to->style->flags & SvgStyleFlags::Transform)) {
|
||||||
to->transform = (Matrix*)malloc(sizeof(Matrix));
|
to->transform = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||||
|
LV_ASSERT_MALLOC(to->transform);
|
||||||
if (to->transform) {
|
if (to->transform) {
|
||||||
*to->transform = *from->transform;
|
*to->transform = *from->transform;
|
||||||
to->style->flags = (to->style->flags | SvgStyleFlags::Transform);
|
to->style->flags = (to->style->flags | SvgStyleFlags::Transform);
|
||||||
@@ -200,12 +201,12 @@ void cssCopyStyleAttr(SvgNode* to, const SvgNode* from)
|
|||||||
_copyStyle(to->style, from->style);
|
_copyStyle(to->style, from->style);
|
||||||
|
|
||||||
if (from->style->clipPath.url) {
|
if (from->style->clipPath.url) {
|
||||||
if (to->style->clipPath.url) free(to->style->clipPath.url);
|
if (to->style->clipPath.url) lv_free(to->style->clipPath.url);
|
||||||
to->style->clipPath.url = strdup(from->style->clipPath.url);
|
to->style->clipPath.url = lv_strdup(from->style->clipPath.url);
|
||||||
}
|
}
|
||||||
if (from->style->mask.url) {
|
if (from->style->mask.url) {
|
||||||
if (to->style->mask.url) free(to->style->mask.url);
|
if (to->style->mask.url) lv_free(to->style->mask.url);
|
||||||
to->style->mask.url = strdup(from->style->mask.url);
|
to->style->mask.url = lv_strdup(from->style->mask.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -459,11 +459,11 @@ struct SvgStyleGradient
|
|||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
stops.reset();
|
stops.reset();
|
||||||
free(transform);
|
lv_free(transform);
|
||||||
free(radial);
|
lv_free(radial);
|
||||||
free(linear);
|
lv_free(linear);
|
||||||
free(ref);
|
lv_free(ref);
|
||||||
free(id);
|
lv_free(id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
|||||||
//Update the stops
|
//Update the stops
|
||||||
stopCount = g->stops.count;
|
stopCount = g->stops.count;
|
||||||
if (stopCount > 0) {
|
if (stopCount > 0) {
|
||||||
stops = (Fill::ColorStop*)calloc(stopCount, sizeof(Fill::ColorStop));
|
stops = (Fill::ColorStop*)lv_zalloc(stopCount * sizeof(Fill::ColorStop));
|
||||||
|
LV_ASSERT_MALLOC(stops);
|
||||||
if (!stops) return fillGrad;
|
if (!stops) return fillGrad;
|
||||||
auto prevOffset = 0.0f;
|
auto prevOffset = 0.0f;
|
||||||
for (uint32_t i = 0; i < g->stops.count; ++i) {
|
for (uint32_t i = 0; i < g->stops.count; ++i) {
|
||||||
@@ -139,7 +140,7 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
|||||||
prevOffset = stops[i].offset;
|
prevOffset = stops[i].offset;
|
||||||
}
|
}
|
||||||
fillGrad->colorStops(stops, stopCount);
|
fillGrad->colorStops(stops, stopCount);
|
||||||
free(stops);
|
lv_free(stops);
|
||||||
}
|
}
|
||||||
return fillGrad;
|
return fillGrad;
|
||||||
}
|
}
|
||||||
@@ -181,7 +182,8 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
|||||||
//Update the stops
|
//Update the stops
|
||||||
stopCount = g->stops.count;
|
stopCount = g->stops.count;
|
||||||
if (stopCount > 0) {
|
if (stopCount > 0) {
|
||||||
stops = (Fill::ColorStop*)calloc(stopCount, sizeof(Fill::ColorStop));
|
stops = (Fill::ColorStop*)lv_zalloc(stopCount * sizeof(Fill::ColorStop));
|
||||||
|
LV_ASSERT_MALLOC(stops);
|
||||||
if (!stops) return fillGrad;
|
if (!stops) return fillGrad;
|
||||||
auto prevOffset = 0.0f;
|
auto prevOffset = 0.0f;
|
||||||
for (uint32_t i = 0; i < g->stops.count; ++i) {
|
for (uint32_t i = 0; i < g->stops.count; ++i) {
|
||||||
@@ -198,7 +200,7 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
|||||||
prevOffset = stops[i].offset;
|
prevOffset = stops[i].offset;
|
||||||
}
|
}
|
||||||
fillGrad->colorStops(stops, stopCount);
|
fillGrad->colorStops(stops, stopCount);
|
||||||
free(stops);
|
lv_free(stops);
|
||||||
}
|
}
|
||||||
return fillGrad;
|
return fillGrad;
|
||||||
}
|
}
|
||||||
@@ -588,14 +590,14 @@ static unique_ptr<Picture> _imageBuildHelper(SvgLoaderData& loaderData, SvgNode*
|
|||||||
if (encoding == imageMimeTypeEncoding::base64) {
|
if (encoding == imageMimeTypeEncoding::base64) {
|
||||||
auto size = b64Decode(href, strlen(href), &decoded);
|
auto size = b64Decode(href, strlen(href), &decoded);
|
||||||
if (picture->load(decoded, size, mimetype, false) != Result::Success) {
|
if (picture->load(decoded, size, mimetype, false) != Result::Success) {
|
||||||
free(decoded);
|
lv_free(decoded);
|
||||||
TaskScheduler::async(true);
|
TaskScheduler::async(true);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto size = svgUtilURLDecode(href, &decoded);
|
auto size = svgUtilURLDecode(href, &decoded);
|
||||||
if (picture->load(decoded, size, mimetype, false) != Result::Success) {
|
if (picture->load(decoded, size, mimetype, false) != Result::Success) {
|
||||||
free(decoded);
|
lv_free(decoded);
|
||||||
TaskScheduler::async(true);
|
TaskScheduler::async(true);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ size_t svgUtilURLDecode(const char *src, char** dst)
|
|||||||
auto length = strlen(src);
|
auto length = strlen(src);
|
||||||
if (length == 0) return 0;
|
if (length == 0) return 0;
|
||||||
|
|
||||||
char* decoded = (char*)malloc(sizeof(char) * length + 1);
|
char* decoded = (char*)lv_malloc(sizeof(char) * length + 1);
|
||||||
|
LV_ASSERT_MALLOC(decoded);
|
||||||
|
|
||||||
char a, b;
|
char a, b;
|
||||||
int idx =0;
|
int idx =0;
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface*
|
|||||||
if (fill->solid) return true;
|
if (fill->solid) return true;
|
||||||
|
|
||||||
if (!fill->ctable) {
|
if (!fill->ctable) {
|
||||||
fill->ctable = static_cast<uint32_t*>(malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
|
fill->ctable = static_cast<uint32_t*>(lv_malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
|
||||||
|
LV_ASSERT_MALLOC(fill->ctable);
|
||||||
if (!fill->ctable) return false;
|
if (!fill->ctable) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,7 +858,7 @@ const Fill::ColorStop* fillFetchSolid(const SwFill* fill, const Fill* fdata)
|
|||||||
void fillReset(SwFill* fill)
|
void fillReset(SwFill* fill)
|
||||||
{
|
{
|
||||||
if (fill->ctable) {
|
if (fill->ctable) {
|
||||||
free(fill->ctable);
|
lv_free(fill->ctable);
|
||||||
fill->ctable = nullptr;
|
fill->ctable = nullptr;
|
||||||
}
|
}
|
||||||
fill->translucent = false;
|
fill->translucent = false;
|
||||||
@@ -869,9 +870,9 @@ void fillFree(SwFill* fill)
|
|||||||
{
|
{
|
||||||
if (!fill) return;
|
if (!fill) return;
|
||||||
|
|
||||||
if (fill->ctable) free(fill->ctable);
|
if (fill->ctable) lv_free(fill->ctable);
|
||||||
|
|
||||||
free(fill);
|
lv_free(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LV_USE_THORVG_INTERNAL */
|
#endif /* LV_USE_THORVG_INTERNAL */
|
||||||
|
|||||||
@@ -84,10 +84,14 @@ SwMpool* mpoolInit(uint32_t threads)
|
|||||||
{
|
{
|
||||||
auto allocSize = threads + 1;
|
auto allocSize = threads + 1;
|
||||||
|
|
||||||
auto mpool = static_cast<SwMpool*>(calloc(1, sizeof(SwMpool)));
|
auto mpool = static_cast<SwMpool*>(lv_zalloc(sizeof(SwMpool)));
|
||||||
mpool->outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
LV_ASSERT_MALLOC(mpool);
|
||||||
mpool->strokeOutline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
mpool->outline = static_cast<SwOutline*>(lv_zalloc(sizeof(SwOutline) * allocSize));
|
||||||
mpool->dashOutline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
LV_ASSERT_MALLOC(mpool->outline);
|
||||||
|
mpool->strokeOutline = static_cast<SwOutline*>(lv_zalloc(sizeof(SwOutline) * allocSize));
|
||||||
|
LV_ASSERT_MALLOC(mpool->strokeOutline);
|
||||||
|
mpool->dashOutline = static_cast<SwOutline*>(lv_zalloc(sizeof(SwOutline) * allocSize));
|
||||||
|
LV_ASSERT_MALLOC(mpool->dashOutline);
|
||||||
mpool->allocSize = allocSize;
|
mpool->allocSize = allocSize;
|
||||||
|
|
||||||
return mpool;
|
return mpool;
|
||||||
@@ -123,10 +127,10 @@ bool mpoolTerm(SwMpool* mpool)
|
|||||||
|
|
||||||
mpoolClear(mpool);
|
mpoolClear(mpool);
|
||||||
|
|
||||||
free(mpool->outline);
|
lv_free(mpool->outline);
|
||||||
free(mpool->strokeOutline);
|
lv_free(mpool->strokeOutline);
|
||||||
free(mpool->dashOutline);
|
lv_free(mpool->dashOutline);
|
||||||
free(mpool);
|
lv_free(mpool);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ static int _gaussianInit(int* kernel, float sigma, int level)
|
|||||||
|
|
||||||
bool effectGaussianPrepare(RenderEffectGaussian* params)
|
bool effectGaussianPrepare(RenderEffectGaussian* params)
|
||||||
{
|
{
|
||||||
auto data = (SwGaussianBlur*)malloc(sizeof(SwGaussianBlur));
|
auto data = (SwGaussianBlur*)lv_malloc(sizeof(SwGaussianBlur));
|
||||||
|
LV_ASSERT_MALLOC(data);
|
||||||
|
|
||||||
//compute box kernel sizes
|
//compute box kernel sizes
|
||||||
data->level = int(SwGaussianBlur::MAX_LEVEL * ((params->quality - 1) * 0.01f)) + 1;
|
data->level = int(SwGaussianBlur::MAX_LEVEL * ((params->quality - 1) * 0.01f)) + 1;
|
||||||
@@ -140,7 +141,7 @@ bool effectGaussianPrepare(RenderEffectGaussian* params)
|
|||||||
//skip, if the parameters are invalid.
|
//skip, if the parameters are invalid.
|
||||||
if (extends == 0) {
|
if (extends == 0) {
|
||||||
params->invalid = true;
|
params->invalid = true;
|
||||||
free(data);
|
lv_free(data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -831,14 +831,16 @@ static AASpans* _AASpans(float ymin, float ymax, const SwImage* image, const SwB
|
|||||||
|
|
||||||
if (!_arrange(image, region, yStart, yEnd)) return nullptr;
|
if (!_arrange(image, region, yStart, yEnd)) return nullptr;
|
||||||
|
|
||||||
auto aaSpans = static_cast<AASpans*>(malloc(sizeof(AASpans)));
|
auto aaSpans = static_cast<AASpans*>(lv_malloc(sizeof(AASpans)));
|
||||||
|
LV_ASSERT_MALLOC(aaSpans);
|
||||||
aaSpans->yStart = yStart;
|
aaSpans->yStart = yStart;
|
||||||
aaSpans->yEnd = yEnd;
|
aaSpans->yEnd = yEnd;
|
||||||
|
|
||||||
//Initialize X range
|
//Initialize X range
|
||||||
auto height = yEnd - yStart;
|
auto height = yEnd - yStart;
|
||||||
|
|
||||||
aaSpans->lines = static_cast<AALine*>(malloc(height * sizeof(AALine)));
|
aaSpans->lines = static_cast<AALine*>(lv_malloc(height * sizeof(AALine)));
|
||||||
|
LV_ASSERT_MALLOC(aaSpans->lines);
|
||||||
|
|
||||||
for (int32_t i = 0; i < height; i++) {
|
for (int32_t i = 0; i < height; i++) {
|
||||||
aaSpans->lines[i].x[0] = INT32_MAX;
|
aaSpans->lines[i].x[0] = INT32_MAX;
|
||||||
@@ -1094,8 +1096,8 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans)
|
|||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(aaSpans->lines);
|
lv_free(aaSpans->lines);
|
||||||
free(aaSpans);
|
lv_free(aaSpans);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ void SwRenderer::clearCompositors()
|
|||||||
{
|
{
|
||||||
//Free Composite Caches
|
//Free Composite Caches
|
||||||
for (auto comp = compositors.begin(); comp < compositors.end(); ++comp) {
|
for (auto comp = compositors.begin(); comp < compositors.end(); ++comp) {
|
||||||
free((*comp)->compositor->image.data);
|
lv_free((*comp)->compositor->image.data);
|
||||||
delete((*comp)->compositor);
|
delete((*comp)->compositor);
|
||||||
delete(*comp);
|
delete(*comp);
|
||||||
}
|
}
|
||||||
@@ -566,7 +566,8 @@ SwSurface* SwRenderer::request(int channelSize)
|
|||||||
//Inherits attributes from main surface
|
//Inherits attributes from main surface
|
||||||
cmp = new SwSurface(surface);
|
cmp = new SwSurface(surface);
|
||||||
cmp->compositor = new SwCompositor;
|
cmp->compositor = new SwCompositor;
|
||||||
cmp->compositor->image.data = (pixel_t*)malloc(channelSize * surface->stride * surface->h);
|
cmp->compositor->image.data = (pixel_t*)lv_malloc(channelSize * surface->stride * surface->h);
|
||||||
|
LV_ASSERT_MALLOC(cmp->compositor->image.data);
|
||||||
cmp->compositor->image.w = surface->w;
|
cmp->compositor->image.w = surface->w;
|
||||||
cmp->compositor->image.h = surface->h;
|
cmp->compositor->image.h = surface->h;
|
||||||
cmp->compositor->image.stride = surface->stride;
|
cmp->compositor->image.stride = surface->stride;
|
||||||
@@ -701,7 +702,7 @@ void* SwRenderer::prepareCommon(SwTask* task, const Matrix& transform, const Arr
|
|||||||
|
|
||||||
task->clips = clips;
|
task->clips = clips;
|
||||||
task->transform = transform;
|
task->transform = transform;
|
||||||
|
|
||||||
//zero size?
|
//zero size?
|
||||||
if (task->transform.e11 == 0.0f && task->transform.e12 == 0.0f) return task; //zero width
|
if (task->transform.e11 == 0.0f && task->transform.e12 == 0.0f) return task; //zero width
|
||||||
if (task->transform.e21 == 0.0f && task->transform.e22 == 0.0f) return task; //zero height
|
if (task->transform.e21 == 0.0f && task->transform.e22 == 0.0f) return task; //zero height
|
||||||
|
|||||||
@@ -359,10 +359,11 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
|
|||||||
auto newSize = (rle->size > 0) ? (rle->size * 2) : 256;
|
auto newSize = (rle->size > 0) ? (rle->size * 2) : 256;
|
||||||
if (rle->alloc < newSize) {
|
if (rle->alloc < newSize) {
|
||||||
rle->alloc = newSize;
|
rle->alloc = newSize;
|
||||||
rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
|
rle->spans = static_cast<SwSpan*>(lv_realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
|
||||||
|
LV_ASSERT_MALLOC(rle->spans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clip x range
|
//Clip x range
|
||||||
SwCoord xOver = 0;
|
SwCoord xOver = 0;
|
||||||
if (x + aCount >= rw.cellMax.x) xOver -= (x + aCount - rw.cellMax.x);
|
if (x + aCount >= rw.cellMax.x) xOver -= (x + aCount - rw.cellMax.x);
|
||||||
@@ -842,7 +843,7 @@ static SwSpan* _intersectSpansRect(const SwBBox *bbox, const SwRle *targetRle, S
|
|||||||
|
|
||||||
void _replaceClipSpan(SwRle *rle, SwSpan* clippedSpans, uint32_t size)
|
void _replaceClipSpan(SwRle *rle, SwSpan* clippedSpans, uint32_t size)
|
||||||
{
|
{
|
||||||
free(rle->spans);
|
lv_free(rle->spans);
|
||||||
rle->spans = clippedSpans;
|
rle->spans = clippedSpans;
|
||||||
rle->size = rle->alloc = size;
|
rle->size = rle->alloc = size;
|
||||||
}
|
}
|
||||||
@@ -880,7 +881,10 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegio
|
|||||||
rw.bandShoot = 0;
|
rw.bandShoot = 0;
|
||||||
rw.antiAlias = antiAlias;
|
rw.antiAlias = antiAlias;
|
||||||
|
|
||||||
if (!rle) rw.rle = reinterpret_cast<SwRle*>(calloc(1, sizeof(SwRle)));
|
if (!rle) {
|
||||||
|
rw.rle = reinterpret_cast<SwRle*>(lv_zalloc(sizeof(SwRle)));
|
||||||
|
LV_ASSERT_MALLOC(rw.rle);
|
||||||
|
}
|
||||||
else rw.rle = rle;
|
else rw.rle = rle;
|
||||||
|
|
||||||
//Generate RLE
|
//Generate RLE
|
||||||
@@ -966,7 +970,7 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegio
|
|||||||
return rw.rle;
|
return rw.rle;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(rw.rle);
|
lv_free(rw.rle);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,8 +980,10 @@ SwRle* rleRender(const SwBBox* bbox)
|
|||||||
auto width = static_cast<uint16_t>(bbox->max.x - bbox->min.x);
|
auto width = static_cast<uint16_t>(bbox->max.x - bbox->min.x);
|
||||||
auto height = static_cast<uint16_t>(bbox->max.y - bbox->min.y);
|
auto height = static_cast<uint16_t>(bbox->max.y - bbox->min.y);
|
||||||
|
|
||||||
auto rle = static_cast<SwRle*>(malloc(sizeof(SwRle)));
|
auto rle = static_cast<SwRle*>(lv_malloc(sizeof(SwRle)));
|
||||||
rle->spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * height));
|
LV_ASSERT_MALLOC(rle);
|
||||||
|
rle->spans = static_cast<SwSpan*>(lv_malloc(sizeof(SwSpan) * height));
|
||||||
|
LV_ASSERT_MALLOC(rle->spans);
|
||||||
rle->size = height;
|
rle->size = height;
|
||||||
rle->alloc = height;
|
rle->alloc = height;
|
||||||
|
|
||||||
@@ -1003,8 +1009,8 @@ void rleReset(SwRle* rle)
|
|||||||
void rleFree(SwRle* rle)
|
void rleFree(SwRle* rle)
|
||||||
{
|
{
|
||||||
if (!rle) return;
|
if (!rle) return;
|
||||||
if (rle->spans) free(rle->spans);
|
if (rle->spans) lv_free(rle->spans);
|
||||||
free(rle);
|
lv_free(rle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1012,7 +1018,8 @@ void rleClip(SwRle *rle, const SwRle *clip)
|
|||||||
{
|
{
|
||||||
if (rle->size == 0 || clip->size == 0) return;
|
if (rle->size == 0 || clip->size == 0) return;
|
||||||
auto spanCnt = rle->size > clip->size ? rle->size : clip->size;
|
auto spanCnt = rle->size > clip->size ? rle->size : clip->size;
|
||||||
auto spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * (spanCnt)));
|
auto spans = static_cast<SwSpan*>(lv_malloc(sizeof(SwSpan) * (spanCnt)));
|
||||||
|
LV_ASSERT_MALLOC(spans);
|
||||||
auto spansEnd = _intersectSpansRegion(clip, rle, spans, spanCnt);
|
auto spansEnd = _intersectSpansRegion(clip, rle, spans, spanCnt);
|
||||||
|
|
||||||
_replaceClipSpan(rle, spans, spansEnd - spans);
|
_replaceClipSpan(rle, spans, spansEnd - spans);
|
||||||
@@ -1024,7 +1031,8 @@ void rleClip(SwRle *rle, const SwRle *clip)
|
|||||||
void rleClip(SwRle *rle, const SwBBox* clip)
|
void rleClip(SwRle *rle, const SwBBox* clip)
|
||||||
{
|
{
|
||||||
if (rle->size == 0) return;
|
if (rle->size == 0) return;
|
||||||
auto spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * (rle->size)));
|
auto spans = static_cast<SwSpan*>(lv_malloc(sizeof(SwSpan) * (rle->size)));
|
||||||
|
LV_ASSERT_MALLOC(spans);
|
||||||
auto spansEnd = _intersectSpansRect(clip, rle, spans, rle->size);
|
auto spansEnd = _intersectSpansRect(clip, rle, spans, rle->size);
|
||||||
|
|
||||||
_replaceClipSpan(rle, spans, spansEnd - spans);
|
_replaceClipSpan(rle, spans, spansEnd - spans);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ static void _outlineCubicTo(SwOutline& outline, const Point* ctrl1, const Point*
|
|||||||
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
||||||
|
|
||||||
outline.pts.push(mathTransform(ctrl2, transform));
|
outline.pts.push(mathTransform(ctrl2, transform));
|
||||||
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
||||||
|
|
||||||
outline.pts.push(mathTransform(to, transform));
|
outline.pts.push(mathTransform(to, transform));
|
||||||
outline.types.push(SW_CURVE_TYPE_POINT);
|
outline.types.push(SW_CURVE_TYPE_POINT);
|
||||||
@@ -347,7 +347,10 @@ static SwOutline* _genDashOutline(const RenderShape* rshape, const Matrix& trans
|
|||||||
if (trimmed) rshape->stroke->strokeTrim(trimBegin, trimEnd);
|
if (trimmed) rshape->stroke->strokeTrim(trimBegin, trimEnd);
|
||||||
|
|
||||||
if (dash.cnt == 0) {
|
if (dash.cnt == 0) {
|
||||||
if (trimmed) dash.pattern = (float*)malloc(sizeof(float) * 4);
|
if (trimmed) {
|
||||||
|
dash.pattern = (float*)lv_malloc(sizeof(float) * 4);
|
||||||
|
LV_ASSERT_MALLOC(dash.pattern);
|
||||||
|
}
|
||||||
else return nullptr;
|
else return nullptr;
|
||||||
} else {
|
} else {
|
||||||
//TODO: handle dash + trim - for now trimming ignoring is forced
|
//TODO: handle dash + trim - for now trimming ignoring is forced
|
||||||
@@ -414,7 +417,7 @@ static SwOutline* _genDashOutline(const RenderShape* rshape, const Matrix& trans
|
|||||||
|
|
||||||
_outlineEnd(*dash.outline);
|
_outlineEnd(*dash.outline);
|
||||||
|
|
||||||
if (trimmed) free(dash.pattern);
|
if (trimmed) lv_free(dash.pattern);
|
||||||
|
|
||||||
return dash.outline;
|
return dash.outline;
|
||||||
}
|
}
|
||||||
@@ -580,7 +583,10 @@ void shapeDelStroke(SwShape* shape)
|
|||||||
|
|
||||||
void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& transform)
|
void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& transform)
|
||||||
{
|
{
|
||||||
if (!shape->stroke) shape->stroke = static_cast<SwStroke*>(calloc(1, sizeof(SwStroke)));
|
if (!shape->stroke) {
|
||||||
|
shape->stroke = static_cast<SwStroke*>(lv_zalloc(sizeof(SwStroke)));
|
||||||
|
LV_ASSERT_MALLOC(shape->stroke);
|
||||||
|
}
|
||||||
auto stroke = shape->stroke;
|
auto stroke = shape->stroke;
|
||||||
if (!stroke) return;
|
if (!stroke) return;
|
||||||
|
|
||||||
@@ -647,7 +653,8 @@ bool shapeGenStrokeFillColors(SwShape* shape, const Fill* fill, const Matrix& tr
|
|||||||
void shapeResetFill(SwShape* shape)
|
void shapeResetFill(SwShape* shape)
|
||||||
{
|
{
|
||||||
if (!shape->fill) {
|
if (!shape->fill) {
|
||||||
shape->fill = static_cast<SwFill*>(calloc(1, sizeof(SwFill)));
|
shape->fill = static_cast<SwFill*>(lv_zalloc(sizeof(SwFill)));
|
||||||
|
LV_ASSERT_MALLOC(shape->fill);
|
||||||
if (!shape->fill) return;
|
if (!shape->fill) return;
|
||||||
}
|
}
|
||||||
fillReset(shape->fill);
|
fillReset(shape->fill);
|
||||||
@@ -657,7 +664,8 @@ void shapeResetFill(SwShape* shape)
|
|||||||
void shapeResetStrokeFill(SwShape* shape)
|
void shapeResetStrokeFill(SwShape* shape)
|
||||||
{
|
{
|
||||||
if (!shape->stroke->fill) {
|
if (!shape->stroke->fill) {
|
||||||
shape->stroke->fill = static_cast<SwFill*>(calloc(1, sizeof(SwFill)));
|
shape->stroke->fill = static_cast<SwFill*>(lv_zalloc(sizeof(SwFill)));
|
||||||
|
LV_ASSERT_MALLOC(shape->stroke->fill);
|
||||||
if (!shape->stroke->fill) return;
|
if (!shape->stroke->fill) return;
|
||||||
}
|
}
|
||||||
fillReset(shape->stroke->fill);
|
fillReset(shape->stroke->fill);
|
||||||
|
|||||||
@@ -61,8 +61,10 @@ static void _growBorder(SwStrokeBorder* border, uint32_t newPts)
|
|||||||
while (maxCur < maxNew)
|
while (maxCur < maxNew)
|
||||||
maxCur += (maxCur >> 1) + 16;
|
maxCur += (maxCur >> 1) + 16;
|
||||||
//OPTIMIZE: use mempool!
|
//OPTIMIZE: use mempool!
|
||||||
border->pts = static_cast<SwPoint*>(realloc(border->pts, maxCur * sizeof(SwPoint)));
|
border->pts = static_cast<SwPoint*>(lv_realloc(border->pts, maxCur * sizeof(SwPoint)));
|
||||||
border->tags = static_cast<uint8_t*>(realloc(border->tags, maxCur * sizeof(uint8_t)));
|
LV_ASSERT_MALLOC(border->pts);
|
||||||
|
border->tags = static_cast<uint8_t*>(lv_realloc(border->tags, maxCur * sizeof(uint8_t)));
|
||||||
|
LV_ASSERT_MALLOC(border->tags);
|
||||||
border->maxPts = maxCur;
|
border->maxPts = maxCur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,15 +808,15 @@ void strokeFree(SwStroke* stroke)
|
|||||||
if (!stroke) return;
|
if (!stroke) return;
|
||||||
|
|
||||||
//free borders
|
//free borders
|
||||||
if (stroke->borders[0].pts) free(stroke->borders[0].pts);
|
if (stroke->borders[0].pts) lv_free(stroke->borders[0].pts);
|
||||||
if (stroke->borders[0].tags) free(stroke->borders[0].tags);
|
if (stroke->borders[0].tags) lv_free(stroke->borders[0].tags);
|
||||||
if (stroke->borders[1].pts) free(stroke->borders[1].pts);
|
if (stroke->borders[1].pts) lv_free(stroke->borders[1].pts);
|
||||||
if (stroke->borders[1].tags) free(stroke->borders[1].tags);
|
if (stroke->borders[1].tags) lv_free(stroke->borders[1].tags);
|
||||||
|
|
||||||
fillFree(stroke->fill);
|
fillFree(stroke->fill);
|
||||||
stroke->fill = nullptr;
|
stroke->fill = nullptr;
|
||||||
|
|
||||||
free(stroke);
|
lv_free(stroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ struct Text::Impl
|
|||||||
|
|
||||||
~Impl()
|
~Impl()
|
||||||
{
|
{
|
||||||
free(utf8);
|
lv_free(utf8);
|
||||||
LoaderMgr::retrieve(loader);
|
LoaderMgr::retrieve(loader);
|
||||||
delete(shape);
|
delete(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result text(const char* utf8)
|
Result text(const char* utf8)
|
||||||
{
|
{
|
||||||
free(this->utf8);
|
lv_free(this->utf8);
|
||||||
if (utf8) this->utf8 = strdup(utf8);
|
if (utf8) this->utf8 = lv_strdup(utf8);
|
||||||
else this->utf8 = nullptr;
|
else this->utf8 = nullptr;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ struct Text::Impl
|
|||||||
++dup->loader->sharing;
|
++dup->loader->sharing;
|
||||||
}
|
}
|
||||||
|
|
||||||
dup->utf8 = strdup(utf8);
|
dup->utf8 = lv_strdup(utf8);
|
||||||
dup->italic = italic;
|
dup->italic = italic;
|
||||||
dup->fontSize = fontSize;
|
dup->fontSize = fontSize;
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,8 @@ bool isIgnoreUnsupportedLogElements(TVG_UNUSED const char* tagName)
|
|||||||
bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data)
|
bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data)
|
||||||
{
|
{
|
||||||
const char *itr = buf, *itrEnd = buf + bufLength;
|
const char *itr = buf, *itrEnd = buf + bufLength;
|
||||||
char* tmpBuf = (char*)malloc(bufLength + 1);
|
char* tmpBuf = (char*)lv_malloc(bufLength + 1);
|
||||||
|
LV_ASSERT_MALLOC(tmpBuf);
|
||||||
|
|
||||||
if (!buf || !func || !tmpBuf) goto error;
|
if (!buf || !func || !tmpBuf) goto error;
|
||||||
|
|
||||||
@@ -366,11 +367,11 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
|
|||||||
}
|
}
|
||||||
|
|
||||||
success:
|
success:
|
||||||
free(tmpBuf);
|
lv_free(tmpBuf);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(tmpBuf);
|
lv_free(tmpBuf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +565,7 @@ const char* simpleXmlParseCSSAttribute(const char* buf, unsigned bufLength, char
|
|||||||
if (*p == '.') break;
|
if (*p == '.') break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p == itr) *tag = strdup("all");
|
if (p == itr) *tag = lv_strdup("all");
|
||||||
else *tag = strDuplicate(itr, p - itr);
|
else *tag = strDuplicate(itr, p - itr);
|
||||||
|
|
||||||
if (p == itrEnd) *name = nullptr;
|
if (p == itrEnd) *name = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user