#define _read_tvg_ui32(dst, src) memcpy(dst, (src), sizeof(uint32_t))
#define _read_tvg_float(dst, src) memcpy(dst, (src), sizeof(float))
+
static Paint* _parsePaint(TvgBinBlock block);
static bool _paintProperty(TvgBinBlock block)
//View width
if (w) _read_tvg_float(w, *ptr);
- *ptr += sizeof(float);
+ *ptr += SIZE(float);
//View height
if (h) _read_tvg_float(h, *ptr);
- *ptr += sizeof(float);
+ *ptr += SIZE(float);
return true;
}
if (block.end > end) return false;
if (block.type != TVG_TAG_PAINT_CMP_METHOD) return false;
- if (block.length != sizeof(TvgBinFlag)) return false;
+ if (block.length != SIZE(TvgBinFlag)) return false;
CompositeMethod cmpMethod;
{
switch (block.type) {
case TVG_TAG_PAINT_OPACITY: {
- if (block.length != sizeof(uint8_t)) return false;
+ if (block.length != SIZE(uint8_t)) return false;
paint->opacity(*block.data);
return true;
}
case TVG_TAG_PAINT_TRANSFORM: {
- if (block.length != sizeof(Matrix)) return false;
+ if (block.length != SIZE(Matrix)) return false;
Matrix matrix;
- memcpy(&matrix, block.data, sizeof(Matrix));
+ memcpy(&matrix, block.data, SIZE(Matrix));
if (paint->transform(matrix) != Result::Success) return false;
return true;
}
switch (block.type) {
case TVG_FLAG_SCENE_RESERVEDCNT: {
- if (block.length != sizeof(uint32_t)) return false;
+ if (block.length != SIZE(uint32_t)) return false;
uint32_t reservedCnt;
_read_tvg_ui32(&reservedCnt, block.data);
scene->reserve(reservedCnt);
//Shape Path
uint32_t cmdCnt, ptsCnt;
_read_tvg_ui32(&cmdCnt, ptr);
- ptr += sizeof(uint32_t);
+ ptr += SIZE(uint32_t);
_read_tvg_ui32(&ptsCnt, ptr);
- ptr += sizeof(uint32_t);
+ ptr += SIZE(uint32_t);
const PathCommand* cmds = (PathCommand*) ptr;
- ptr += sizeof(PathCommand) * cmdCnt;
+ ptr += SIZE(PathCommand) * cmdCnt;
const Point* pts = (Point*) ptr;
- ptr += sizeof(Point) * ptsCnt;
+ ptr += SIZE(Point) * ptsCnt;
if (ptr > end) return false;
switch (block.type) {
case TVG_TAG_FILL_RADIAL_GRADIENT: {
- if (block.length != 3 * sizeof(float)) return false;
+ if (block.length != 3 * SIZE(float)) return false;
auto ptr = block.data;
float x, y, radius;
_read_tvg_float(&x, ptr);
- ptr += sizeof(float);
+ ptr += SIZE(float);
_read_tvg_float(&y, ptr);
- ptr += sizeof(float);
+ ptr += SIZE(float);
_read_tvg_float(&radius, ptr);
auto fillGradRadial = RadialGradient::gen();
break;
}
case TVG_TAG_FILL_LINEAR_GRADIENT: {
- if (block.length != 4 * sizeof(float)) return false;
+ if (block.length != 4 * SIZE(float)) return false;
auto ptr = block.data;
float x1, y1, x2, y2;
_read_tvg_float(&x1, ptr);
- ptr += sizeof(float);
+ ptr += SIZE(float);
_read_tvg_float(&y1, ptr);
- ptr += sizeof(float);
+ ptr += SIZE(float);
_read_tvg_float(&x2, ptr);
- ptr += sizeof(float);
+ ptr += SIZE(float);
_read_tvg_float(&y2, ptr);
auto fillGradLinear = LinearGradient::gen();
}
case TVG_TAG_FILL_FILLSPREAD: {
if (!fillGrad) return false;
- if (block.length != sizeof(TvgBinFlag)) return false;
+ if (block.length != SIZE(TvgBinFlag)) return false;
switch (*block.data) {
case TVG_FLAG_FILL_FILLSPREAD_PAD: {
fillGrad->spread(FillSpread::Pad);
{
uint32_t dashPatternCnt;
_read_tvg_ui32(&dashPatternCnt, ptr);
- ptr += sizeof(uint32_t);
+ ptr += SIZE(uint32_t);
const float* dashPattern = (float*) ptr;
- ptr += sizeof(float) * dashPatternCnt;
+ ptr += SIZE(float) * dashPatternCnt;
if (ptr > end) return false;
switch (block.type) {
case TVG_TAG_SHAPE_STROKE_CAP: {
- if (block.length != sizeof(TvgBinFlag)) return false;
+ if (block.length != SIZE(TvgBinFlag)) return false;
switch (*block.data) {
case TVG_FLAG_SHAPE_STROKE_CAP_SQUARE:
shape->stroke(StrokeCap::Square);
break;
}
case TVG_TAG_SHAPE_STROKE_JOIN: {
- if (block.length != sizeof(TvgBinFlag)) return false;
+ if (block.length != SIZE(TvgBinFlag)) return false;
switch (*block.data) {
case TVG_FLAG_SHAPE_STROKE_JOIN_BEVEL:
shape->stroke(StrokeJoin::Bevel);
break;
}
case TVG_TAG_SHAPE_STROKE_WIDTH: {
- if (block.length != sizeof(float)) return false;
+ if (block.length != SIZE(float)) return false;
float width;
_read_tvg_float(&width, block.data);
shape->stroke(width);
break;
}
case TVG_TAG_SHAPE_FILLRULE: {
- if (block.length != sizeof(TvgBinFlag)) return false;
+ if (block.length != SIZE(TvgBinFlag)) return false;
switch (*block.data) {
case TVG_FLAG_SHAPE_FILLRULE_WINDING:
shape->fill(FillRule::Winding);
switch (block.type) {
case TVG_TAG_PICTURE_RAW_IMAGE: {
- if (block.length < 2 * sizeof(uint32_t)) return false;
+ if (block.length < 2 * SIZE(uint32_t)) return false;
auto ptr = block.data;
uint32_t w, h;
_read_tvg_ui32(&w, ptr);
- ptr += sizeof(uint32_t);
+ ptr += SIZE(uint32_t);
_read_tvg_ui32(&h, ptr);
- ptr += sizeof(uint32_t);
+ ptr += SIZE(uint32_t);
- auto size = w * h * sizeof(uint32_t);
- if (block.length != 2 * sizeof(uint32_t) + size) return false;
+ auto size = w * h * SIZE(uint32_t);
+ if (block.length != 2 * SIZE(uint32_t) + size) return false;
picture->load((uint32_t*) ptr, w, h, true);
return true;