#endif
#ifdef TVG_BUILD
- #define TVG_EXPORT __attribute__ ((visibility ("default")))
+ #ifdef _WIN32
+ #define TVG_EXPORT __declspec(dllexport)
+ #else
+ #define TVG_EXPORT __attribute__ ((visibility ("default")))
+ #endif
#else
#define TVG_EXPORT
#endif
-
#ifdef __cplusplus
extern "C" {
#endif
* SOFTWARE.
*/
#include <memory.h>
+
+#ifdef _WIN32
+ #include <malloc.h>
+#else
+ #include <alloca.h>
+#endif
+
#include "tvgTvgCommon.h"
if (ptr > end) return false;
/* Recover to PathCommand(4 bytes) from TvgBinFlag(1 byte) */
- PathCommand inCmds[cmdCnt];
+ PathCommand* inCmds = (PathCommand*)alloca(sizeof(PathCommand) * cmdCnt);
for (uint32_t i = 0; i < cmdCnt; ++i) {
inCmds[i] = static_cast<PathCommand>(cmds[i]);
}
if (block.length == 0 || block.length & 0x07) return nullptr;
uint32_t stopsCnt = block.length >> 3; // 8 bytes per ColorStop
if (stopsCnt > 1023) return nullptr;
- Fill::ColorStop stops[stopsCnt];
+ Fill::ColorStop* stops = (Fill::ColorStop*)alloca(sizeof(Fill::ColorStop) * stopsCnt);
auto p = block.data;
for (uint32_t i = 0; i < stopsCnt; i++, p += 8) {
READ_FLOAT(&stops[i].offset, p);
#include "tvgTvgSaver.h"
#include "tvgLzw.h"
+#ifdef _WIN32
+ #include <malloc.h>
+#else
+ #include <alloca.h>
+#endif
+
#define SIZE(A) sizeof(A)
/************************************************************************/
/* Reduce the binary size.
Convert PathCommand(4 bytes) to TvgBinFlag(1 byte) */
- TvgBinFlag outCmds[cmdCnt];
+ TvgBinFlag* outCmds = (TvgBinFlag*)alloca(SIZE(TvgBinFlag) * cmdCnt);
for (uint32_t i = 0; i < cmdCnt; ++i) {
outCmds[i] = static_cast<TvgBinFlag>(cmds[i]);
}
Tvg_Color_Stop color_stops[2] =
{
- {.offset=0.0, .r=0, .g=0, .b=0, .a=255},
- {.offset=1, .r=0, .g=255, .b=0, .a=255},
+ {0.0, 0, 0, 0, 255},
+ {1.0, 0, 255, 0, 255},
};
const Tvg_Color_Stop *color_stops_ret;
Tvg_Color_Stop color_stops[2] =
{
- {.offset=0.0, .r=0, .g=0, .b=0, .a=255},
- {.offset=1, .r=0, .g=255, .b=0, .a=255},
+ {0.0, 0, 0, 0, 255},
+ {1.0, 0, 255, 0, 255},
};
const Tvg_Color_Stop *color_stops_ret = NULL;
Tvg_Color_Stop color_stops[2] =
{
- {.offset=0.0, .r=0, .g=0, .b=0, .a=255},
- {.offset=1, .r=0, .g=255, .b=0, .a=255},
+ {0.0, 0, 0, 0, 255},
+ {1.0, 0, 255, 0, 255},
};
Tvg_Gradient *gradient_ret = NULL;
REQUIRE(gradient);
Tvg_Color_Stop color_stops[2] = {
- {.offset=0.0, .r=0, .g=0, .b=0, .a=255},
- {.offset=1, .r=0, .g=255, .b=0, .a=255},
+ {0.0, 0, 0, 0, 255},
+ {1.0, 0, 255, 0, 255},
};
const Tvg_Color_Stop *color_stops_ret;
REQUIRE(gradient);
Tvg_Color_Stop color_stops[2] = {
- {.offset=0.0, .r=0, .g=0, .b=0, .a=255},
- {.offset=1, .r=0, .g=255, .b=0, .a=255},
+ {0.0, 0, 0, 0, 255},
+ {1.0, 0, 255, 0, 255},
};
const Tvg_Color_Stop *color_stops_ret;
REQUIRE(tvg_radial_gradient_set(gradient, 10.0, 15.0, 30.0) == TVG_RESULT_SUCCESS);
- Tvg_Color_Stop color_stops[2] =
- {
- {.offset=0.0, .r=0, .g=0, .b=0, .a=255},
- {.offset=1, .r=0, .g=255, .b=0, .a=255},
+ Tvg_Color_Stop color_stops[2] = {
+ {0.0, 0, 0, 0, 255},
+ {1.0, 0, 255, 0, 255},
};
Tvg_Gradient *gradient_ret = NULL;