code refactoring

Now, stabilizing is pretty enough.

Remove assert code so that we never abort process in any cases.
This also reduce the binary size.

Change-Id: Ia7d2d5c5a0757b12481eaebad7a86aade6a89c1e
This commit is contained in:
Hermet Park 2020-08-19 14:50:49 +09:00
parent 70b4703707
commit ffa4a7248b
15 changed files with 8 additions and 108 deletions

View file

@ -36,11 +36,9 @@
static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surface) static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surface)
{ {
assert(fill && fdata);
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*>(malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
assert(fill->ctable); if (!fill->ctable) return false;
} }
const Fill::ColorStop* colors; const Fill::ColorStop* colors;
@ -71,7 +69,6 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surfac
for (uint32_t j = 0; j < cnt - 1; ++j) { for (uint32_t j = 0; j < cnt - 1; ++j) {
auto curr = colors + j; auto curr = colors + j;
auto next = curr + 1; auto next = curr + 1;
assert(curr && next);
auto delta = 1.0f / (next->offset - curr->offset); auto delta = 1.0f / (next->offset - curr->offset);
if (next->a < 255) fill->translucent = true; if (next->a < 255) fill->translucent = true;
@ -104,8 +101,6 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surfac
bool _prepareLinear(SwFill* fill, const LinearGradient* linear, const Matrix* transform) bool _prepareLinear(SwFill* fill, const LinearGradient* linear, const Matrix* transform)
{ {
assert(fill && linear);
float x1, x2, y1, y2; float x1, x2, y1, y2;
if (linear->linear(&x1, &y1, &x2, &y2) != Result::Success) return false; if (linear->linear(&x1, &y1, &x2, &y2) != Result::Success) return false;
@ -140,8 +135,6 @@ bool _prepareLinear(SwFill* fill, const LinearGradient* linear, const Matrix* tr
bool _prepareRadial(SwFill* fill, const RadialGradient* radial, const Matrix* transform) bool _prepareRadial(SwFill* fill, const RadialGradient* radial, const Matrix* transform)
{ {
assert(fill && radial);
float radius; float radius;
if (radial->radial(&fill->radial.cx, &fill->radial.cy, &radius) != Result::Success) return false; if (radial->radial(&fill->radial.cx, &fill->radial.cy, &radius) != Result::Success) return false;
if (radius < FLT_EPSILON) return true; if (radius < FLT_EPSILON) return true;
@ -286,8 +279,6 @@ bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform,
{ {
if (!fill) return false; if (!fill) return false;
assert(fdata);
fill->spread = fdata->spread(); fill->spread = fdata->spread();
if (ctable) { if (ctable) {

View file

@ -384,8 +384,6 @@ SwFixed mathLength(SwPoint& pt)
void mathSplitCubic(SwPoint* base) void mathSplitCubic(SwPoint* base)
{ {
assert(base);
SwCoord a, b, c, d; SwCoord a, b, c, d;
base[6].x = base[3].x; base[6].x = base[3].x;

View file

@ -101,7 +101,7 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
auto shape = static_cast<SwShape*>(data); auto shape = static_cast<SwShape*>(data);
if (!shape) { if (!shape) {
shape = static_cast<SwShape*>(calloc(1, sizeof(SwShape))); shape = static_cast<SwShape*>(calloc(1, sizeof(SwShape)));
assert(shape); if (!shape) return nullptr;
} }
if (flags == RenderUpdateFlag::None) return shape; if (flags == RenderUpdateFlag::None) return shape;

View file

@ -145,8 +145,6 @@ static inline SwCoord HYPOT(SwPoint pt)
static void _genSpan(SwRleData* rle, SwSpan* spans, uint32_t count) static void _genSpan(SwRleData* rle, SwSpan* spans, uint32_t count)
{ {
assert(rle && spans);
auto newSize = rle->size + count; auto newSize = rle->size + count;
/* allocate enough memory for new spans */ /* allocate enough memory for new spans */
@ -155,12 +153,10 @@ static void _genSpan(SwRleData* rle, SwSpan* spans, uint32_t count)
if (rle->alloc < newSize) { if (rle->alloc < newSize) {
rle->alloc = (newSize * 2); rle->alloc = (newSize * 2);
rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan))); rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
assert(rle->spans);
} }
//copy the new spans to the allocated memory //copy the new spans to the allocated memory
SwSpan* lastSpan = rle->spans + rle->size; SwSpan* lastSpan = rle->spans + rle->size;
assert(lastSpan);
memcpy(lastSpan, spans, count * sizeof(SwSpan)); memcpy(lastSpan, spans, count * sizeof(SwSpan));
rle->size = newSize; rle->size = newSize;
@ -205,7 +201,6 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
if (!rw.antiAlias) coverage = 255; if (!rw.antiAlias) coverage = 255;
auto count = rw.spansCnt; auto count = rw.spansCnt;
auto span = rw.spans + count - 1; auto span = rw.spans + count - 1;
assert(span);
//see whether we can add this span to the current list //see whether we can add this span to the current list
if ((count > 0) && (rw.ySpan == y) && if ((count > 0) && (rw.ySpan == y) &&
@ -226,10 +221,8 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
rw.spansCnt = 0; rw.spansCnt = 0;
rw.ySpan = 0; rw.ySpan = 0;
span = rw.spans; span = rw.spans;
assert(span);
} else { } else {
++span; ++span;
assert(span);
} }
//Clip x range //Clip x range
@ -290,7 +283,6 @@ static Cell* _findCell(RleWorker& rw)
if (x > rw.cellXCnt) x = rw.cellXCnt; if (x > rw.cellXCnt) x = rw.cellXCnt;
auto pcell = &rw.yCells[rw.cellPos.y]; auto pcell = &rw.yCells[rw.cellPos.y];
assert(pcell);
while(true) { while(true) {
Cell* cell = *pcell; Cell* cell = *pcell;
@ -302,7 +294,6 @@ static Cell* _findCell(RleWorker& rw)
if (rw.cellsCnt >= rw.maxCells) longjmp(rw.jmpBuf, 1); if (rw.cellsCnt >= rw.maxCells) longjmp(rw.jmpBuf, 1);
auto cell = rw.cells + rw.cellsCnt++; auto cell = rw.cells + rw.cellsCnt++;
assert(cell);
cell->x = x; cell->x = x;
cell->area = 0; cell->area = 0;
cell->cover = 0; cell->cover = 0;
@ -317,7 +308,6 @@ static void _recordCell(RleWorker& rw)
{ {
if (rw.area | rw.cover) { if (rw.area | rw.cover) {
auto cell = _findCell(rw); auto cell = _findCell(rw);
assert(cell);
cell->area += rw.area; cell->area += rw.area;
cell->cover += rw.cover; cell->cover += rw.cover;
} }
@ -498,8 +488,6 @@ static void _lineTo(RleWorker& rw, const SwPoint& to)
static void _cubicTo(RleWorker& rw, const SwPoint& ctrl1, const SwPoint& ctrl2, const SwPoint& to) static void _cubicTo(RleWorker& rw, const SwPoint& ctrl1, const SwPoint& ctrl2, const SwPoint& to)
{ {
auto arc = rw.bezStack; auto arc = rw.bezStack;
assert(arc);
arc[0] = to; arc[0] = to;
arc[1] = ctrl2; arc[1] = ctrl2;
arc[2] = ctrl1; arc[2] = ctrl1;
@ -668,7 +656,6 @@ SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize&
rw.clip = clip; rw.clip = clip;
rw.antiAlias = antiAlias; rw.antiAlias = antiAlias;
rw.rle = reinterpret_cast<SwRleData*>(calloc(1, sizeof(SwRleData))); rw.rle = reinterpret_cast<SwRleData*>(calloc(1, sizeof(SwRleData)));
assert(rw.rle);
//Generate RLE //Generate RLE
Band bands[BAND_SIZE]; Band bands[BAND_SIZE];

View file

@ -76,7 +76,6 @@ static void _growOutlineContour(SwOutline& outline, uint32_t n)
if (outline.reservedCntrsCnt >= outline.cntrsCnt + n) return; if (outline.reservedCntrsCnt >= outline.cntrsCnt + n) return;
outline.reservedCntrsCnt = outline.cntrsCnt + n; outline.reservedCntrsCnt = outline.cntrsCnt + n;
outline.cntrs = static_cast<uint32_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint32_t))); outline.cntrs = static_cast<uint32_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint32_t)));
assert(outline.cntrs);
} }
@ -85,9 +84,7 @@ static void _growOutlinePoint(SwOutline& outline, uint32_t n)
if (outline.reservedPtsCnt >= outline.ptsCnt + n) return; if (outline.reservedPtsCnt >= outline.ptsCnt + n) return;
outline.reservedPtsCnt = outline.ptsCnt + n; outline.reservedPtsCnt = outline.ptsCnt + n;
outline.pts = static_cast<SwPoint*>(realloc(outline.pts, outline.reservedPtsCnt * sizeof(SwPoint))); outline.pts = static_cast<SwPoint*>(realloc(outline.pts, outline.reservedPtsCnt * sizeof(SwPoint)));
assert(outline.pts);
outline.types = static_cast<uint8_t*>(realloc(outline.types, outline.reservedPtsCnt * sizeof(uint8_t))); outline.types = static_cast<uint8_t*>(realloc(outline.types, outline.reservedPtsCnt * sizeof(uint8_t)));
assert(outline.types);
} }
@ -114,8 +111,6 @@ static void _outlineEnd(SwOutline& outline)
static void _outlineMoveTo(SwOutline& outline, const Point* to, const Matrix* transform) static void _outlineMoveTo(SwOutline& outline, const Point* to, const Matrix* transform)
{ {
assert(to);
_growOutlinePoint(outline, 1); _growOutlinePoint(outline, 1);
outline.pts[outline.ptsCnt] = _transform(to, transform); outline.pts[outline.ptsCnt] = _transform(to, transform);
@ -134,8 +129,6 @@ static void _outlineMoveTo(SwOutline& outline, const Point* to, const Matrix* tr
static void _outlineLineTo(SwOutline& outline, const Point* to, const Matrix* transform) static void _outlineLineTo(SwOutline& outline, const Point* to, const Matrix* transform)
{ {
assert(to);
_growOutlinePoint(outline, 1); _growOutlinePoint(outline, 1);
outline.pts[outline.ptsCnt] = _transform(to, transform); outline.pts[outline.ptsCnt] = _transform(to, transform);
@ -146,8 +139,6 @@ static void _outlineLineTo(SwOutline& outline, const Point* to, const Matrix* tr
static void _outlineCubicTo(SwOutline& outline, const Point* ctrl1, const Point* ctrl2, const Point* to, const Matrix* transform) static void _outlineCubicTo(SwOutline& outline, const Point* ctrl1, const Point* ctrl2, const Point* to, const Matrix* transform)
{ {
assert(ctrl1 && ctrl2 && to);
_growOutlinePoint(outline, 3); _growOutlinePoint(outline, 3);
outline.pts[outline.ptsCnt] = _transform(ctrl1, transform); outline.pts[outline.ptsCnt] = _transform(ctrl1, transform);
@ -203,7 +194,6 @@ static bool _updateBBox(SwOutline* outline, SwBBox& bbox)
if (!outline) return false; if (!outline) return false;
auto pt = outline->pts; auto pt = outline->pts;
assert(pt);
if (outline->ptsCnt <= 0) { if (outline->ptsCnt <= 0) {
_initBBox(bbox); _initBBox(bbox);
@ -236,8 +226,6 @@ static bool _updateBBox(SwOutline* outline, SwBBox& bbox)
static bool _checkValid(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip) static bool _checkValid(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip)
{ {
assert(outline);
if (outline->ptsCnt == 0 || outline->cntrsCnt <= 0) return false; if (outline->ptsCnt == 0 || outline->cntrsCnt <= 0) return false;
//Check boundary //Check boundary
@ -341,8 +329,6 @@ static void _dashCubicTo(SwDashStroke& dash, const Point* ctrl1, const Point* ct
SwOutline* _genDashOutline(const Shape* sdata, const Matrix* transform) SwOutline* _genDashOutline(const Shape* sdata, const Matrix* transform)
{ {
assert(sdata);
const PathCommand* cmds = nullptr; const PathCommand* cmds = nullptr;
auto cmdCnt = sdata->pathCommands(&cmds); auto cmdCnt = sdata->pathCommands(&cmds);
@ -361,12 +347,10 @@ SwOutline* _genDashOutline(const Shape* sdata, const Matrix* transform)
const float* pattern; const float* pattern;
dash.cnt = sdata->strokeDash(&pattern); dash.cnt = sdata->strokeDash(&pattern);
assert(dash.cnt > 0 && pattern);
//Is it safe to mutual exclusive? //Is it safe to mutual exclusive?
dash.pattern = const_cast<float*>(pattern); dash.pattern = const_cast<float*>(pattern);
dash.outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline))); dash.outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline)));
assert(dash.outline);
dash.outline->opened = true; dash.outline->opened = true;
//smart reservation //smart reservation
@ -510,8 +494,6 @@ void shapeReset(SwShape* shape)
bool shapeGenOutline(SwShape* shape, const Shape* sdata, const Matrix* transform) bool shapeGenOutline(SwShape* shape, const Shape* sdata, const Matrix* transform)
{ {
assert(sdata);
const PathCommand* cmds = nullptr; const PathCommand* cmds = nullptr;
auto cmdCnt = sdata->pathCommands(&cmds); auto cmdCnt = sdata->pathCommands(&cmds);
@ -552,7 +534,6 @@ bool shapeGenOutline(SwShape* shape, const Shape* sdata, const Matrix* transform
auto outline = shape->outline; auto outline = shape->outline;
if (!outline) outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline))); if (!outline) outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline)));
assert(outline);
outline->opened = true; outline->opened = true;
_growOutlinePoint(*outline, outlinePtsCnt); _growOutlinePoint(*outline, outlinePtsCnt);
@ -638,8 +619,6 @@ void shapeResetStroke(SwShape* shape, const Shape* sdata, const Matrix* transfor
bool shapeGenStrokeRle(SwShape* shape, const Shape* sdata, const Matrix* transform, const SwSize& clip) bool shapeGenStrokeRle(SwShape* shape, const Shape* sdata, const Matrix* transform, const SwSize& clip)
{ {
assert(sdata);
SwOutline* shapeOutline = nullptr; SwOutline* shapeOutline = nullptr;
//Dash Style Stroke //Dash Style Stroke

View file

@ -48,8 +48,6 @@ static inline void SCALE(SwStroke& stroke, SwPoint& pt)
static void _growBorder(SwStrokeBorder* border, uint32_t newPts) static void _growBorder(SwStrokeBorder* border, uint32_t newPts)
{ {
assert(border);
auto maxOld = border->maxPts; auto maxOld = border->maxPts;
auto maxNew = border->ptsCnt + newPts; auto maxNew = border->ptsCnt + newPts;
@ -61,21 +59,15 @@ static void _growBorder(SwStrokeBorder* border, uint32_t newPts)
maxCur += (maxCur >> 1) + 16; maxCur += (maxCur >> 1) + 16;
border->pts = static_cast<SwPoint*>(realloc(border->pts, maxCur * sizeof(SwPoint))); border->pts = static_cast<SwPoint*>(realloc(border->pts, maxCur * sizeof(SwPoint)));
assert(border->pts);
border->tags = static_cast<uint8_t*>(realloc(border->tags, maxCur * sizeof(uint8_t))); border->tags = static_cast<uint8_t*>(realloc(border->tags, maxCur * sizeof(uint8_t)));
assert(border->tags);
border->maxPts = maxCur; border->maxPts = maxCur;
} }
static void _borderClose(SwStrokeBorder* border, bool reverse) static void _borderClose(SwStrokeBorder* border, bool reverse)
{ {
assert(border && border->start >= 0); auto start = border->start;
auto count = border->ptsCnt;
uint32_t start = border->start;
uint32_t count = border->ptsCnt;
//Don't record empty paths! //Don't record empty paths!
if (count <= start + 1U) { if (count <= start + 1U) {
@ -123,8 +115,6 @@ static void _borderClose(SwStrokeBorder* border, bool reverse)
static void _borderCubicTo(SwStrokeBorder* border, SwPoint& ctrl1, SwPoint& ctrl2, SwPoint& to) static void _borderCubicTo(SwStrokeBorder* border, SwPoint& ctrl1, SwPoint& ctrl2, SwPoint& to)
{ {
assert(border && border->start >= 0);
_growBorder(border, 3); _growBorder(border, 3);
auto pt = border->pts + border->ptsCnt; auto pt = border->pts + border->ptsCnt;
@ -199,8 +189,6 @@ static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius
static void _borderLineTo(SwStrokeBorder* border, SwPoint& to, bool movable) static void _borderLineTo(SwStrokeBorder* border, SwPoint& to, bool movable)
{ {
assert(border && border->start >= 0);
if (border->movable) { if (border->movable) {
//move last point //move last point
border->pts[border->ptsCnt - 1] = to; border->pts[border->ptsCnt - 1] = to;
@ -221,8 +209,6 @@ static void _borderLineTo(SwStrokeBorder* border, SwPoint& to, bool movable)
static void _borderMoveTo(SwStrokeBorder* border, SwPoint& to) static void _borderMoveTo(SwStrokeBorder* border, SwPoint& to)
{ {
assert(border);
//close current open path if any? //close current open path if any?
if (border->start >= 0) _borderClose(border, false); if (border->start >= 0) _borderClose(border, false);
@ -249,10 +235,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
{ {
constexpr SwFixed MITER_LIMIT = 4 * (1 << 16); constexpr SwFixed MITER_LIMIT = 4 * (1 << 16);
assert(MITER_LIMIT >= 0x10000);
auto border = stroke.borders + side; auto border = stroke.borders + side;
assert(border);
if (stroke.join == StrokeJoin::Round) { if (stroke.join == StrokeJoin::Round) {
_arcTo(stroke, side); _arcTo(stroke, side);
@ -640,8 +623,6 @@ static void _addReverseLeft(SwStroke& stroke, bool opened)
{ {
auto right = stroke.borders + 0; auto right = stroke.borders + 0;
auto left = stroke.borders + 1; auto left = stroke.borders + 1;
assert(left->start >= 0);
auto newPts = left->ptsCnt - left->start; auto newPts = left->ptsCnt - left->start;
if (newPts <= 0) return; if (newPts <= 0) return;
@ -708,7 +689,6 @@ static void _endSubPath(SwStroke& stroke)
{ {
if (stroke.openSubPath) { if (stroke.openSubPath) {
auto right = stroke.borders; auto right = stroke.borders;
assert(right);
/* all right, this is an opened path, we need to add a cap between /* all right, this is an opened path, we need to add a cap between
right & left, add the reverse of left, then add a final cap right & left, add the reverse of left, then add a final cap
@ -756,8 +736,6 @@ static void _endSubPath(SwStroke& stroke)
static void _getCounts(SwStrokeBorder* border, uint32_t& ptsCnt, uint32_t& cntrsCnt) static void _getCounts(SwStrokeBorder* border, uint32_t& ptsCnt, uint32_t& cntrsCnt)
{ {
assert(border);
auto count = border->ptsCnt; auto count = border->ptsCnt;
auto tags = border->tags; auto tags = border->tags;
uint32_t _ptsCnt = 0; uint32_t _ptsCnt = 0;
@ -796,7 +774,6 @@ fail:
static void _exportBorderOutline(SwStroke& stroke, SwOutline* outline, uint32_t side) static void _exportBorderOutline(SwStroke& stroke, SwOutline* outline, uint32_t side)
{ {
auto border = stroke.borders + side; auto border = stroke.borders + side;
assert(border);
if (!border->valid) return; if (!border->valid) return;
@ -850,8 +827,6 @@ void strokeFree(SwStroke* stroke)
void strokeReset(SwStroke* stroke, const Shape* sdata, const Matrix* transform) void strokeReset(SwStroke* stroke, const Shape* sdata, const Matrix* transform)
{ {
assert(sdata);
if (transform) { if (transform) {
stroke->sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2)); stroke->sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2));
stroke->sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2)); stroke->sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2));
@ -941,16 +916,9 @@ SwOutline* strokeExportOutline(SwStroke* stroke)
auto cntrsCnt = count2 + count4; auto cntrsCnt = count2 + count4;
auto outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline))); auto outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline)));
assert(outline);
outline->pts = static_cast<SwPoint*>(malloc(sizeof(SwPoint) * ptsCnt)); outline->pts = static_cast<SwPoint*>(malloc(sizeof(SwPoint) * ptsCnt));
assert(outline->pts);
outline->types = static_cast<uint8_t*>(malloc(sizeof(uint8_t) * ptsCnt)); outline->types = static_cast<uint8_t*>(malloc(sizeof(uint8_t) * ptsCnt));
assert(outline->types);
outline->cntrs = static_cast<uint32_t*>(malloc(sizeof(uint32_t) * cntrsCnt)); outline->cntrs = static_cast<uint32_t*>(malloc(sizeof(uint32_t) * cntrsCnt));
assert(outline->cntrs);
_exportBorderOutline(*stroke, outline, 0); //left _exportBorderOutline(*stroke, outline, 0); //left
_exportBorderOutline(*stroke, outline, 1); //right _exportBorderOutline(*stroke, outline, 1); //right

View file

@ -25,7 +25,6 @@
#include "config.h" #include "config.h"
#include <iostream> #include <iostream>
#include <cassert>
#include <vector> #include <vector>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>

View file

@ -81,10 +81,7 @@ Result GlCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t
unique_ptr<GlCanvas> GlCanvas::gen() noexcept unique_ptr<GlCanvas> GlCanvas::gen() noexcept
{ {
#ifdef THORVG_GL_RASTER_SUPPORT #ifdef THORVG_GL_RASTER_SUPPORT
auto canvas = unique_ptr<GlCanvas>(new GlCanvas); return unique_ptr<GlCanvas>(new GlCanvas);
assert(canvas);
return canvas;
#endif #endif
return nullptr; return nullptr;
} }

View file

@ -76,10 +76,7 @@ Result LinearGradient::linear(float* x1, float* y1, float* x2, float* y2) const
unique_ptr<LinearGradient> LinearGradient::gen() noexcept unique_ptr<LinearGradient> LinearGradient::gen() noexcept
{ {
auto fill = unique_ptr<LinearGradient>(new LinearGradient); return unique_ptr<LinearGradient>(new LinearGradient);
assert(fill);
return fill;
} }
#endif /* _TVG_LINEAR_GRADIENT_CPP_ */ #endif /* _TVG_LINEAR_GRADIENT_CPP_ */

View file

@ -73,10 +73,7 @@ Result RadialGradient::radial(float* cx, float* cy, float* radius) const noexcep
unique_ptr<RadialGradient> RadialGradient::gen() noexcept unique_ptr<RadialGradient> RadialGradient::gen() noexcept
{ {
auto fill = unique_ptr<RadialGradient>(new RadialGradient); return unique_ptr<RadialGradient>(new RadialGradient);
assert(fill);
return fill;
} }
#endif /* _TVG_RADIAL_GRADIENT_CPP_ */ #endif /* _TVG_RADIAL_GRADIENT_CPP_ */

View file

@ -107,8 +107,6 @@ RenderTransform::RenderTransform()
RenderTransform::RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs) RenderTransform::RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs)
{ {
assert(lhs && rhs);
m.e11 = lhs->m.e11 * rhs->m.e11 + lhs->m.e12 * rhs->m.e21 + lhs->m.e13 * rhs->m.e31; m.e11 = lhs->m.e11 * rhs->m.e11 + lhs->m.e12 * rhs->m.e21 + lhs->m.e13 * rhs->m.e31;
m.e12 = lhs->m.e11 * rhs->m.e12 + lhs->m.e12 * rhs->m.e22 + lhs->m.e13 * rhs->m.e32; m.e12 = lhs->m.e11 * rhs->m.e12 + lhs->m.e12 * rhs->m.e22 + lhs->m.e13 * rhs->m.e32;
m.e13 = lhs->m.e11 * rhs->m.e13 + lhs->m.e12 * rhs->m.e23 + lhs->m.e13 * rhs->m.e33; m.e13 = lhs->m.e11 * rhs->m.e13 + lhs->m.e12 * rhs->m.e23 + lhs->m.e13 * rhs->m.e33;

View file

@ -76,7 +76,6 @@ struct RenderInitializer
static bool init(RenderInitializer& renderInit, RenderMethod* engine) static bool init(RenderInitializer& renderInit, RenderMethod* engine)
{ {
assert(engine);
if (renderInit.pInst || renderInit.refCnt > 0) return false; if (renderInit.pInst || renderInit.refCnt > 0) return false;
renderInit.pInst = engine; renderInit.pInst = engine;
renderInit.refCnt = 0; renderInit.refCnt = 0;
@ -100,7 +99,6 @@ struct RenderInitializer
static uint32_t unref(RenderInitializer& renderInit) static uint32_t unref(RenderInitializer& renderInit)
{ {
assert(renderInit.refCnt > 0);
--renderInit.refCnt; --renderInit.refCnt;
//engine has been requested to termination //engine has been requested to termination
@ -115,7 +113,6 @@ struct RenderInitializer
static RenderMethod* inst(RenderInitializer& renderInit) static RenderMethod* inst(RenderInitializer& renderInit)
{ {
assert(renderInit.pInst);
return renderInit.pInst; return renderInit.pInst;
} }

View file

@ -144,8 +144,6 @@ struct Shape::Impl
bool strokeDash(const float* pattern, uint32_t cnt) bool strokeDash(const float* pattern, uint32_t cnt)
{ {
assert(pattern);
if (!stroke) stroke = new ShapeStroke(); if (!stroke) stroke = new ShapeStroke();
if (!stroke) return false; if (!stroke) return false;
@ -155,7 +153,6 @@ struct Shape::Impl
} }
if (!stroke->dashPattern) stroke->dashPattern = static_cast<float*>(malloc(sizeof(float) * cnt)); if (!stroke->dashPattern) stroke->dashPattern = static_cast<float*>(malloc(sizeof(float) * cnt));
assert(stroke->dashPattern);
for (uint32_t i = 0; i < cnt; ++i) for (uint32_t i = 0; i < cnt; ++i)
stroke->dashPattern[i] = pattern[i]; stroke->dashPattern[i] = pattern[i];

View file

@ -50,7 +50,6 @@ struct ShapePath
if (cmdCnt <= reservedCmdCnt) return; if (cmdCnt <= reservedCmdCnt) return;
reservedCmdCnt = cmdCnt; reservedCmdCnt = cmdCnt;
cmds = static_cast<PathCommand*>(realloc(cmds, sizeof(PathCommand) * reservedCmdCnt)); cmds = static_cast<PathCommand*>(realloc(cmds, sizeof(PathCommand) * reservedCmdCnt));
assert(cmds);
} }
void reservePts(uint32_t ptsCnt) void reservePts(uint32_t ptsCnt)
@ -58,7 +57,6 @@ struct ShapePath
if (ptsCnt <= reservedPtsCnt) return; if (ptsCnt <= reservedPtsCnt) return;
reservedPtsCnt = ptsCnt; reservedPtsCnt = ptsCnt;
pts = static_cast<Point*>(realloc(pts, sizeof(Point) * reservedPtsCnt)); pts = static_cast<Point*>(realloc(pts, sizeof(Point) * reservedPtsCnt));
assert(pts);
} }
void grow(uint32_t cmdCnt, uint32_t ptsCnt) void grow(uint32_t cmdCnt, uint32_t ptsCnt)

View file

@ -80,10 +80,7 @@ Result SwCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t
unique_ptr<SwCanvas> SwCanvas::gen() noexcept unique_ptr<SwCanvas> SwCanvas::gen() noexcept
{ {
#ifdef THORVG_SW_RASTER_SUPPORT #ifdef THORVG_SW_RASTER_SUPPORT
auto canvas = unique_ptr<SwCanvas>(new SwCanvas); return unique_ptr<SwCanvas>(new SwCanvas);
assert(canvas);
return canvas;
#endif #endif
return nullptr; return nullptr;
} }