Pointer and reference parameters should be "const" if the corresponding object is not modified
TVG_EXPORT Tvg_Paint* tvg_paint_duplicate(Tvg_Paint* paint)
{
- if (!paint) return NULL;
+ if (!paint) return nullptr;
return (Tvg_Paint*) reinterpret_cast<Paint*>(paint)->duplicate();
}
TVG_EXPORT Tvg_Result tvg_shape_append_path(Tvg_Paint* paint, const Tvg_Path_Command* cmds, uint32_t cmdCnt, const Tvg_Point* pts, uint32_t ptsCnt)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
- return (Tvg_Result) reinterpret_cast<Shape*>(paint)->appendPath((PathCommand*)cmds, cmdCnt, (Point*)pts, ptsCnt);
+ return (Tvg_Result) reinterpret_cast<Shape*>(paint)->appendPath((const PathCommand*)cmds, cmdCnt, (const Point*)pts, ptsCnt);
}
TVG_EXPORT Tvg_Result tvg_shape_get_path_coords(const Tvg_Paint* paint, const Tvg_Point** pts, uint32_t* cnt)
SwFixed mathSin(SwFixed angle);
void mathSplitCubic(SwPoint* base);
SwFixed mathDiff(SwFixed angle1, SwFixed angle2);
-SwFixed mathLength(SwPoint& pt);
-bool mathSmallCubic(SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
+SwFixed mathLength(const SwPoint& pt);
+bool mathSmallCubic(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
SwFixed mathMean(SwFixed angle1, SwFixed angle2);
SwPoint mathTransform(const Point* to, const Matrix* transform);
void shapeReset(SwShape* shape);
bool shapeGenOutline(SwShape* shape, const Shape* sdata, unsigned tid, const Matrix* transform);
bool shapePrepare(SwShape* shape, const Shape* sdata, unsigned tid, const SwSize& clip, const Matrix* transform, SwBBox& bbox);
-bool shapePrepared(SwShape* shape);
+bool shapePrepared(const SwShape* shape);
bool shapeGenRle(SwShape* shape, const Shape* sdata, const SwSize& clip, bool antiAlias, bool hasComposite);
void shapeDelOutline(SwShape* shape, uint32_t tid);
void shapeResetStroke(SwShape* shape, const Shape* sdata, const Matrix* transform);
void strokeFree(SwStroke* stroke);
bool imagePrepare(SwImage* image, const Picture* pdata, unsigned tid, const SwSize& clip, const Matrix* transform, SwBBox& bbox);
-bool imagePrepared(SwImage* image);
-bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwSize& clip, SwBBox& bbox, bool antiAlias, bool hasComposite);
+bool imagePrepared(const SwImage* image);
+bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwSize& clip, const SwBBox& bbox, bool antiAlias, bool hasComposite);
void imageDelOutline(SwImage* image, uint32_t tid);
void imageReset(SwImage* image);
bool imageGenOutline(SwImage* image, const Picture* pdata, unsigned tid, const Matrix* transform);
bool rasterCompositor(SwSurface* surface);
bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id);
bool rasterSolidShape(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
-bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, SwBBox& bbox, uint32_t opacity);
+bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, const SwBBox& bbox, uint32_t opacity);
bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
bool rasterClear(SwSurface* surface);
#define FIXPT_SIZE (1<<FIXPT_BITS)
-static bool _updateColorTable(SwFill* fill, const Fill* fdata, SwSurface* surface, uint32_t opacity)
+static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface* surface, uint32_t opacity)
{
if (!fill->ctable) {
fill->ctable = static_cast<uint32_t*>(malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
if (fill->ctable) free(fill->ctable);
free(fill);
-}
\ No newline at end of file
+}
}
-static bool _updateBBox(SwOutline* outline, SwBBox& bbox, const SwSize& clip)
+static bool _updateBBox(const SwOutline* outline, SwBBox& bbox, const SwSize& clip)
{
if (!outline) return false;
}
-bool imagePrepared(SwImage* image)
+bool imagePrepared(const SwImage* image)
{
return image->rle ? true : false;
}
-bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwSize& clip, SwBBox& bbox, bool antiAlias, bool hasComposite)
+bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwSize& clip, const SwBBox& bbox, bool antiAlias, bool hasComposite)
{
if ((image->rle = rleRender(image->rle, image->outline, bbox, clip, antiAlias))) return true;
}
-bool mathSmallCubic(SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut)
+bool mathSmallCubic(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut)
{
auto d1 = base[2] - base[3];
auto d2 = base[1] - base[2];
}
-SwFixed mathLength(SwPoint& pt)
+SwFixed mathLength(const SwPoint& pt)
{
auto v = pt;
}
-static SwBBox _clipRegion(Surface* surface, SwBBox& in)
+static SwBBox _clipRegion(const Surface* surface, const SwBBox& in)
{
auto bbox = in;
}
-static bool _translucent(SwSurface* surface, uint8_t a)
+static bool _translucent(const SwSurface* surface, uint8_t a)
{
if (a < 255) return true;
if (!surface->compositor || surface->compositor->method == CompositeMethod::None) return false;
/************************************************************************/
-static bool _translucentRle(SwSurface* surface, SwRleData* rle, uint32_t color)
+static bool _translucentRle(SwSurface* surface, const SwRleData* rle, uint32_t color)
{
auto span = rle->spans;
uint32_t src;
}
-static bool _translucentRleAlphaMask(SwSurface* surface, SwRleData* rle, uint32_t color)
+static bool _translucentRleAlphaMask(SwSurface* surface, const SwRleData* rle, uint32_t color)
{
#ifdef THORVG_LOG_ENABLED
printf("SW_ENGINE: Rle Alpha Mask Composition\n");
}
-static bool _rasterSolidRle(SwSurface* surface, SwRleData* rle, uint32_t color)
+static bool _rasterSolidRle(SwSurface* surface, const SwRleData* rle, uint32_t color)
{
if (!rle) return false;
/* Image */
/************************************************************************/
-static bool _rasterTranslucentImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity)
+static bool _rasterTranslucentImageRle(SwSurface* surface, const SwRleData* rle, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity)
{
auto span = rle->spans;
}
-static bool _rasterTranslucentImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const Matrix* invTransform)
+static bool _rasterTranslucentImageRle(SwSurface* surface, const SwRleData* rle, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const Matrix* invTransform)
{
auto span = rle->spans;
}
-static bool _translucentImage(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
+static bool _translucentImage(SwSurface* surface, const uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
{
for (auto y = region.min.y; y < region.max.y; ++y) {
auto dst = &surface->buffer[y * surface->stride + region.min.x];
}
-static bool _translucentImageAlphaMask(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
+static bool _translucentImageAlphaMask(SwSurface* surface, const uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
{
#ifdef THORVG_LOG_ENABLED
printf("SW_ENGINE: Transformed Image Alpha Mask Composition\n");
return true;
}
-static bool _translucentImageInvAlphaMask(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
+static bool _translucentImageInvAlphaMask(SwSurface* surface, const uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
{
#ifdef THORVG_LOG_ENABLED
printf("SW_ENGINE: Transformed Image Alpha Mask Composition\n");
return true;
}
-static bool _rasterTranslucentImage(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
+static bool _rasterTranslucentImage(SwSurface* surface, const uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform)
{
if (surface->compositor) {
if (surface->compositor->method == CompositeMethod::AlphaMask) {
}
-static bool _rasterImage(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t h, const SwBBox& region, const Matrix* invTransform)
+static bool _rasterImage(SwSurface* surface, const uint32_t *img, uint32_t w, uint32_t h, const SwBBox& region, const Matrix* invTransform)
{
for (auto y = region.min.y; y < region.max.y; ++y) {
auto dst = &surface->buffer[y * surface->stride + region.min.x];
}
-static bool _rasterLinearGradientRle(SwSurface* surface, SwRleData* rle, const SwFill* fill)
+static bool _rasterLinearGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill)
{
if (!rle || !fill || fill->linear.len < FLT_EPSILON) return false;
}
-static bool _rasterRadialGradientRle(SwSurface* surface, SwRleData* rle, const SwFill* fill)
+static bool _rasterRadialGradientRle(SwSurface* surface, const SwRleData* rle, const SwFill* fill)
{
if (!rle || !fill || fill->radial.a < FLT_EPSILON) return false;
}
-bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, SwBBox& bbox, uint32_t opacity)
+bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, const SwBBox& bbox, uint32_t opacity)
{
Matrix invTransform;
}
-void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag flags)
+void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, const Array<RenderData>& clips, RenderUpdateFlag flags)
{
if (flags == RenderUpdateFlag::None) return task;
SwRenderer(){};
~SwRenderer();
- RenderData prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag flags);
+ RenderData prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, const Array<RenderData>& clips, RenderUpdateFlag flags);
};
}
return ((pt.x > pt.y) ? (pt.x + (3 * pt.y >> 3)) : (pt.y + (3 * pt.x >> 3)));
}
-static void _genSpan(SwRleData* rle, SwSpan* spans, uint32_t count)
+static void _genSpan(SwRleData* rle, const SwSpan* spans, uint32_t count)
{
auto newSize = rle->size + count;
free(rle);
}
-void updateRleSpans(SwRleData *rle, SwSpan* curSpans, uint32_t size)
+void updateRleSpans(SwRleData *rle, const SwSpan* curSpans, uint32_t size)
{
if (size == 0) {
rle->size = 0;
}
-static bool _updateBBox(SwOutline* outline, SwBBox& bbox)
+static bool _updateBBox(const SwOutline* outline, SwBBox& bbox)
{
if (!outline) return false;
}
-bool shapePrepared(SwShape* shape)
+bool shapePrepared(const SwShape* shape)
{
return shape->rle ? true : false;
}
}
-static inline void SCALE(SwStroke& stroke, SwPoint& pt)
+static inline void SCALE(const SwStroke& stroke, SwPoint& pt)
{
pt.x *= stroke.sx;
pt.y *= stroke.sy;
}
-static void _borderCubicTo(SwStrokeBorder* border, SwPoint& ctrl1, SwPoint& ctrl2, SwPoint& to)
+static void _borderCubicTo(SwStrokeBorder* border, const SwPoint& ctrl1, const SwPoint& ctrl2, const SwPoint& to)
{
_growBorder(border, 3);
}
-static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius, SwFixed angleStart, SwFixed angleDiff, SwStroke& stroke)
+static void _borderArcTo(SwStrokeBorder* border, const SwPoint& center, SwFixed radius, SwFixed angleStart, SwFixed angleDiff, SwStroke& stroke)
{
constexpr SwFixed ARC_CUBIC_ANGLE = SW_ANGLE_PI / 2;
SwPoint a = {static_cast<SwCoord>(radius), 0};
}
-static void _borderLineTo(SwStrokeBorder* border, SwPoint& to, bool movable)
+static void _borderLineTo(SwStrokeBorder* border, const SwPoint& to, bool movable)
{
if (border->movable) {
//move last point
}
-static void _beginSubPath(SwStroke& stroke, SwPoint& to, bool opened)
+static void _beginSubPath(SwStroke& stroke, const SwPoint& to, bool opened)
{
/* We cannot process the first point because there is not enough
information regarding its corner/cap. Later, it will be processed
}
-static void _exportBorderOutline(SwStroke& stroke, SwOutline* outline, uint32_t side)
+static void _exportBorderOutline(const SwStroke& stroke, SwOutline* outline, uint32_t side)
{
auto border = stroke.borders + side;
_exportBorderOutline(*stroke, outline, 1); //right
return outline;
-}
\ No newline at end of file
+}
return unique_ptr<GlCanvas>(new GlCanvas);
#endif
return nullptr;
-}
\ No newline at end of file
+}
}
-unique_ptr<Loader> LoaderMgr::loader(uint32_t *data, uint32_t w, uint32_t h, bool copy)
+unique_ptr<Loader> LoaderMgr::loader(const uint32_t *data, uint32_t w, uint32_t h, bool copy)
{
for (int i = 0; i < static_cast<int>(FileType::Unknown); i++) {
auto loader = _find(static_cast<FileType>(i));
static bool term();
static unique_ptr<Loader> loader(const string& path);
static unique_ptr<Loader> loader(const char* data, uint32_t size);
- static unique_ptr<Loader> loader(uint32_t* data, uint32_t w, uint32_t h, bool copy);
+ static unique_ptr<Loader> loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
};
#endif //_TVG_LOADER_MGR_H_
* Since this documentation is not obvious, more clean recalculation with dpi
* is required, but for now default w3 constants would be used
*/
-static float _toFloat(SvgParser* svgParse, const char* str, SvgParserLengthType type)
+static float _toFloat(const SvgParser* svgParse, const char* str, SvgParserLengthType type)
{
float parsedValue = strtof(str, nullptr);
}
-static float _gradientToFloat(SvgParser* svgParse, const char* str, SvgParserLengthType type)
+static float _gradientToFloat(const SvgParser* svgParse, const char* str, SvgParserLengthType type)
{
char* end = nullptr;
}
-static SvgNode* _findChildById(SvgNode* node, const char* id)
+static SvgNode* _findChildById(const SvgNode* node, const char* id)
{
if (!node) return nullptr;
return result;
}
-static void _cloneGradStops(Array<Fill::ColorStop*>* dst, Array<Fill::ColorStop*>* src)
+static void _cloneGradStops(Array<Fill::ColorStop*>* dst, const Array<Fill::ColorStop*>* src)
{
for (uint32_t i = 0; i < src->count; ++i) {
auto stop = static_cast<Fill::ColorStop *>(malloc(sizeof(Fill::ColorStop)));
}
-static void _copyAttr(SvgNode* to, SvgNode* from)
+static void _copyAttr(SvgNode* to, const SvgNode* from)
{
//Copy matrix attribute
if (from->transform) {
}
-static void _styleInherit(SvgStyleProperty* child, SvgStyleProperty* parent)
+static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* parent)
{
if (parent == nullptr) return;
//Inherit the property of parent if not present in child.
}
-static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, string* id)
+static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const string* id)
{
SvgStyleGradient* result = nullptr;
return false;
}
-unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient* g, Shape* vg, float rx, float ry, float rw, float rh)
+unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient* g, const Shape* vg, float rx, float ry, float rw, float rh)
{
Fill::ColorStop* stops;
int stopCount = 0;
}
-unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient* g, Shape* vg, float rx, float ry, float rw, float rh)
+unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient* g, const Shape* vg, float rx, float ry, float rw, float rh)
{
Fill::ColorStop *stops;
int stopCount = 0;
return true;
}
-unique_ptr<Scene> _sceneBuildHelper(SvgNode* node, float vx, float vy, float vw, float vh)
+unique_ptr<Scene> _sceneBuildHelper(const SvgNode* node, float vx, float vy, float vw, float vh)
{
if (_isGroupType(node->type)) {
auto scene = Scene::gen();