{
if (threads == 0) threads = 1;
- auto mpool = new SwMpool;
+ auto mpool = static_cast<SwMpool*>(calloc(sizeof(SwMpool), 1));
mpool->outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * threads));
if (!mpool->outline) goto err;
free(mpool->strokeOutline);
mpool->strokeOutline = nullptr;
}
- delete(mpool);
+ free(mpool);
return nullptr;
}
mpool->strokeOutline = nullptr;
}
- delete(mpool);
+ free(mpool);
return true;
}
\ No newline at end of file
~Impl()
{
if (dup) delete(dup);
- if (colorStops) free(colorStops);
- if (transform) delete(transform);
+ free(colorStops);
+ free(transform);
}
void method(DuplicateMethod<Fill>* dup)
ret->pImpl->colorStops = static_cast<ColorStop*>(malloc(sizeof(ColorStop) * cnt));
memcpy(ret->pImpl->colorStops, colorStops, sizeof(ColorStop) * cnt);
if (transform) {
- ret->pImpl->transform = new Matrix;
+ ret->pImpl->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
*ret->pImpl->transform = *transform;
}
return ret;
struct ShapeStroke
{
- float width = 0;
- uint8_t color[4] = {0, 0, 0, 0};
- Fill *fill = nullptr;
- float* dashPattern = nullptr;
- uint32_t dashCnt = 0;
- StrokeCap cap = StrokeCap::Square;
- StrokeJoin join = StrokeJoin::Bevel;
-
- ShapeStroke() {}
-
- ShapeStroke(const ShapeStroke* src)
- : width(src->width),
- dashCnt(src->dashCnt),
- cap(src->cap),
- join(src->join)
+ float width;
+ uint8_t color[4];
+ Fill *fill;
+ float* dashPattern;
+ uint32_t dashCnt;
+ StrokeCap cap;
+ StrokeJoin join;
+
+ void copy(const ShapeStroke* src)
{
+ width = src->width;
+ dashCnt = src->dashCnt;
+ cap = src->cap;
+ join = src->join;
+
memcpy(color, src->color, sizeof(color));
if (dashCnt > 0) {
dashPattern = static_cast<float*>(malloc(sizeof(float) * dashCnt));
if (src->fill) fill = src->fill->duplicate();
}
- ~ShapeStroke()
+ void clear()
{
if (dashPattern) free(dashPattern);
if (fill) delete(fill);
~Impl()
{
if (fill) delete(fill);
- if (stroke) delete(stroke);
+ if (stroke) {
+ stroke->clear();
+ free (stroke);
+ }
}
bool dispose(RenderMethod& renderer)
{
//TODO: Size Exception?
- if (!stroke) stroke = new ShapeStroke();
+ if (!stroke) stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
stroke->width = width;
flag |= RenderUpdateFlag::Stroke;
bool strokeCap(StrokeCap cap)
{
- if (!stroke) stroke = new ShapeStroke();
+ if (!stroke) stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
stroke->cap = cap;
flag |= RenderUpdateFlag::Stroke;
bool strokeJoin(StrokeJoin join)
{
- if (!stroke) stroke = new ShapeStroke();
+ if (!stroke) stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
stroke->join = join;
flag |= RenderUpdateFlag::Stroke;
bool strokeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
- if (!stroke) stroke = new ShapeStroke();
+ if (!stroke) stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
if (stroke->fill) {
delete(stroke->fill);
stroke->fill = nullptr;
auto p = f.release();
if (!p) return Result::MemoryCorruption;
- if (!stroke) stroke = new ShapeStroke();
+ if (!stroke) stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
if (stroke->fill && stroke->fill != p) delete(stroke->fill);
stroke->fill = p;
free(stroke->dashPattern);
stroke->dashPattern = nullptr;
} else {
- if (!stroke) stroke = new ShapeStroke();
+ if (!stroke) stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
if (stroke->dashCnt != cnt) {
free(stroke->dashPattern);
stroke->dashPattern = nullptr;
//Stroke
if (stroke) {
- dup->stroke = new ShapeStroke(stroke);
+ dup->stroke = static_cast<ShapeStroke*>(calloc(sizeof(ShapeStroke), 1));
+ dup->stroke->copy(stroke);
dup->flag |= RenderUpdateFlag::Stroke;
if (stroke->fill)