From: JunsuChoi Date: Fri, 19 Feb 2021 06:47:44 +0000 (+0900) Subject: common: Pointer that can declare const are refactored to use const X-Git-Tag: accepted/tizen/unified/20210223.065502~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=640904fe5aeb53634eaf89ca77086b625d6dccd9;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git common: Pointer that can declare const are refactored to use const Pointer and reference parameters should be "const" if the corresponding object is not modified --- diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index a75fcf9..ff80aed 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -165,7 +165,7 @@ TVG_EXPORT Tvg_Result tvg_paint_transform(Tvg_Paint* paint, const Tvg_Matrix* m) TVG_EXPORT Tvg_Paint* tvg_paint_duplicate(Tvg_Paint* paint) { - if (!paint) return NULL; + if (!paint) return nullptr; return (Tvg_Paint*) reinterpret_cast(paint)->duplicate(); } @@ -263,7 +263,7 @@ TVG_EXPORT Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float 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(paint)->appendPath((PathCommand*)cmds, cmdCnt, (Point*)pts, ptsCnt); + return (Tvg_Result) reinterpret_cast(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) diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index 82a6023..24450db 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -281,15 +281,15 @@ SwFixed mathCos(SwFixed angle); 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); @@ -306,8 +306,8 @@ SwOutline* strokeExportOutline(SwStroke* stroke, unsigned tid); 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); @@ -337,7 +337,7 @@ void mpoolRetStrokeOutline(unsigned idx); 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); diff --git a/src/lib/sw_engine/tvgSwFill.cpp b/src/lib/sw_engine/tvgSwFill.cpp index 407c9d5..654da50 100644 --- a/src/lib/sw_engine/tvgSwFill.cpp +++ b/src/lib/sw_engine/tvgSwFill.cpp @@ -33,7 +33,7 @@ #define FIXPT_SIZE (1<ctable) { fill->ctable = static_cast(malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t))); @@ -311,4 +311,4 @@ void fillFree(SwFill* fill) if (fill->ctable) free(fill->ctable); free(fill); -} \ No newline at end of file +} diff --git a/src/lib/sw_engine/tvgSwImage.cpp b/src/lib/sw_engine/tvgSwImage.cpp index 342a28a..d66da6a 100644 --- a/src/lib/sw_engine/tvgSwImage.cpp +++ b/src/lib/sw_engine/tvgSwImage.cpp @@ -34,7 +34,7 @@ static void _initBBox(SwBBox& bbox) } -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; @@ -102,13 +102,13 @@ bool imagePrepare(SwImage* image, const Picture* pdata, unsigned tid, const SwSi } -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; diff --git a/src/lib/sw_engine/tvgSwMath.cpp b/src/lib/sw_engine/tvgSwMath.cpp index 3ba1b86..33ad563 100644 --- a/src/lib/sw_engine/tvgSwMath.cpp +++ b/src/lib/sw_engine/tvgSwMath.cpp @@ -194,7 +194,7 @@ SwFixed mathMean(SwFixed angle1, SwFixed angle2) } -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]; @@ -362,7 +362,7 @@ SwFixed mathCos(SwFixed angle) } -SwFixed mathLength(SwPoint& pt) +SwFixed mathLength(const SwPoint& pt) { auto v = pt; diff --git a/src/lib/sw_engine/tvgSwRaster.cpp b/src/lib/sw_engine/tvgSwRaster.cpp index ca2226e..1e116c0 100644 --- a/src/lib/sw_engine/tvgSwRaster.cpp +++ b/src/lib/sw_engine/tvgSwRaster.cpp @@ -85,7 +85,7 @@ static bool _identify(const Matrix* transform) } -static SwBBox _clipRegion(Surface* surface, SwBBox& in) +static SwBBox _clipRegion(const Surface* surface, const SwBBox& in) { auto bbox = in; @@ -98,7 +98,7 @@ static SwBBox _clipRegion(Surface* surface, SwBBox& 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; @@ -208,7 +208,7 @@ static bool _rasterSolidRect(SwSurface* surface, const SwBBox& region, uint32_t /************************************************************************/ -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; @@ -227,7 +227,7 @@ static bool _translucentRle(SwSurface* surface, SwRleData* rle, uint32_t color) } -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"); @@ -298,7 +298,7 @@ static bool _rasterTranslucentRle(SwSurface* surface, SwRleData* rle, uint32_t c } -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; @@ -325,7 +325,7 @@ static bool _rasterSolidRle(SwSurface* surface, SwRleData* rle, uint32_t color) /* 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; @@ -342,7 +342,7 @@ static bool _rasterTranslucentImageRle(SwSurface* surface, SwRleData* rle, uint3 } -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; @@ -401,7 +401,7 @@ static bool _rasterImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, u } -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]; @@ -419,7 +419,7 @@ static bool _translucentImage(SwSurface* surface, uint32_t *img, uint32_t w, uin } -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"); @@ -440,7 +440,7 @@ static bool _translucentImageAlphaMask(SwSurface* surface, uint32_t *img, uint32 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"); @@ -461,7 +461,7 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, uint32_t *img, uin 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) { @@ -568,7 +568,7 @@ static bool _rasterImage(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t } -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]; @@ -653,7 +653,7 @@ static bool _rasterRadialGradientRect(SwSurface* surface, const SwBBox& region, } -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; @@ -699,7 +699,7 @@ static bool _rasterLinearGradientRle(SwSurface* surface, SwRleData* rle, const S } -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; @@ -832,7 +832,7 @@ bool rasterClear(SwSurface* surface) } -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; diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index 09b199b..470f1a4 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -468,7 +468,7 @@ bool SwRenderer::dispose(RenderData data) } -void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, Array& clips, RenderUpdateFlag flags) +void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, const Array& clips, RenderUpdateFlag flags) { if (flags == RenderUpdateFlag::None) return task; diff --git a/src/lib/sw_engine/tvgSwRenderer.h b/src/lib/sw_engine/tvgSwRenderer.h index e681c84..650a2de 100644 --- a/src/lib/sw_engine/tvgSwRenderer.h +++ b/src/lib/sw_engine/tvgSwRenderer.h @@ -63,7 +63,7 @@ private: SwRenderer(){}; ~SwRenderer(); - RenderData prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, Array& clips, RenderUpdateFlag flags); + RenderData prepareCommon(SwTask* task, const RenderTransform* transform, uint32_t opacity, const Array& clips, RenderUpdateFlag flags); }; } diff --git a/src/lib/sw_engine/tvgSwRle.cpp b/src/lib/sw_engine/tvgSwRle.cpp index 3255b6c..cdc6fea 100644 --- a/src/lib/sw_engine/tvgSwRle.cpp +++ b/src/lib/sw_engine/tvgSwRle.cpp @@ -135,7 +135,7 @@ static inline SwCoord HYPOT(SwPoint pt) 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; @@ -915,7 +915,7 @@ void rleFree(SwRleData* rle) 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; diff --git a/src/lib/sw_engine/tvgSwShape.cpp b/src/lib/sw_engine/tvgSwShape.cpp index d20fc95..6a2b4f5 100644 --- a/src/lib/sw_engine/tvgSwShape.cpp +++ b/src/lib/sw_engine/tvgSwShape.cpp @@ -164,7 +164,7 @@ static void _initBBox(SwBBox& bbox) } -static bool _updateBBox(SwOutline* outline, SwBBox& bbox) +static bool _updateBBox(const SwOutline* outline, SwBBox& bbox) { if (!outline) return false; @@ -434,7 +434,7 @@ bool shapePrepare(SwShape* shape, const Shape* sdata, unsigned tid, const SwSize } -bool shapePrepared(SwShape* shape) +bool shapePrepared(const SwShape* shape) { return shape->rle ? true : false; } diff --git a/src/lib/sw_engine/tvgSwStroke.cpp b/src/lib/sw_engine/tvgSwStroke.cpp index 96c8b95..4f46185 100644 --- a/src/lib/sw_engine/tvgSwStroke.cpp +++ b/src/lib/sw_engine/tvgSwStroke.cpp @@ -39,7 +39,7 @@ static inline SwFixed SIDE_TO_ROTATE(const int32_t s) } -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; @@ -113,7 +113,7 @@ static void _borderClose(SwStrokeBorder* border, bool reverse) } -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); @@ -134,7 +134,7 @@ static void _borderCubicTo(SwStrokeBorder* border, SwPoint& ctrl1, SwPoint& ctrl } -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(radius), 0}; @@ -187,7 +187,7 @@ static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius } -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 @@ -660,7 +660,7 @@ static void _addReverseLeft(SwStroke& stroke, bool opened) } -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 @@ -771,7 +771,7 @@ fail: } -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; @@ -930,4 +930,4 @@ SwOutline* strokeExportOutline(SwStroke* stroke, unsigned tid) _exportBorderOutline(*stroke, outline, 1); //right return outline; -} \ No newline at end of file +} diff --git a/src/lib/tvgGlCanvas.cpp b/src/lib/tvgGlCanvas.cpp index 416ed44..049ff7a 100644 --- a/src/lib/tvgGlCanvas.cpp +++ b/src/lib/tvgGlCanvas.cpp @@ -80,4 +80,4 @@ unique_ptr GlCanvas::gen() noexcept return unique_ptr(new GlCanvas); #endif return nullptr; -} \ No newline at end of file +} diff --git a/src/lib/tvgLoaderMgr.cpp b/src/lib/tvgLoaderMgr.cpp index 3b8f26b..d41671c 100644 --- a/src/lib/tvgLoaderMgr.cpp +++ b/src/lib/tvgLoaderMgr.cpp @@ -112,7 +112,7 @@ unique_ptr LoaderMgr::loader(const char* data, uint32_t size) } -unique_ptr LoaderMgr::loader(uint32_t *data, uint32_t w, uint32_t h, bool copy) +unique_ptr LoaderMgr::loader(const uint32_t *data, uint32_t w, uint32_t h, bool copy) { for (int i = 0; i < static_cast(FileType::Unknown); i++) { auto loader = _find(static_cast(i)); diff --git a/src/lib/tvgLoaderMgr.h b/src/lib/tvgLoaderMgr.h index 8b26154..5d2056b 100644 --- a/src/lib/tvgLoaderMgr.h +++ b/src/lib/tvgLoaderMgr.h @@ -32,7 +32,7 @@ struct LoaderMgr static bool term(); static unique_ptr loader(const string& path); static unique_ptr loader(const char* data, uint32_t size); - static unique_ptr loader(uint32_t* data, uint32_t w, uint32_t h, bool copy); + static unique_ptr loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy); }; #endif //_TVG_LOADER_MGR_H_ diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 59f10cf..4ce916f 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -79,7 +79,7 @@ static bool _parseNumber(const char** content, float* number) * 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); @@ -106,7 +106,7 @@ static float _toFloat(SvgParser* svgParse, const char* str, SvgParserLengthType } -static float _gradientToFloat(SvgParser* svgParse, const char* str, SvgParserLengthType type) +static float _gradientToFloat(const SvgParser* svgParse, const char* str, SvgParserLengthType type) { char* end = nullptr; @@ -1467,7 +1467,7 @@ static SvgNode* _getDefsNode(SvgNode* node) } -static SvgNode* _findChildById(SvgNode* node, const char* id) +static SvgNode* _findChildById(const SvgNode* node, const char* id) { if (!node) return nullptr; @@ -1493,7 +1493,7 @@ static SvgNode* _findNodeById(SvgNode *node, string* id) return result; } -static void _cloneGradStops(Array* dst, Array* src) +static void _cloneGradStops(Array* dst, const Array* src) { for (uint32_t i = 0; i < src->count; ++i) { auto stop = static_cast(malloc(sizeof(Fill::ColorStop))); @@ -1543,7 +1543,7 @@ error_grad_alloc: } -static void _copyAttr(SvgNode* to, SvgNode* from) +static void _copyAttr(SvgNode* to, const SvgNode* from) { //Copy matrix attribute if (from->transform) { @@ -2226,7 +2226,7 @@ static bool _svgLoaderParser(void* data, SimpleXMLType type, const char* content } -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. @@ -2329,7 +2329,7 @@ static void _updateStyle(SvgNode* node, SvgStyleProperty* parentStyle) } -static SvgStyleGradient* _gradientDup(Array* gradients, string* id) +static SvgStyleGradient* _gradientDup(Array* gradients, const string* id) { SvgStyleGradient* result = nullptr; diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index 0558584..096730b 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -32,7 +32,7 @@ bool _isGroupType(SvgNodeType type) return false; } -unique_ptr _applyLinearGradientProperty(SvgStyleGradient* g, Shape* vg, float rx, float ry, float rw, float rh) +unique_ptr _applyLinearGradientProperty(SvgStyleGradient* g, const Shape* vg, float rx, float ry, float rw, float rh) { Fill::ColorStop* stops; int stopCount = 0; @@ -114,7 +114,7 @@ unique_ptr _applyLinearGradientProperty(SvgStyleGradient* g, Sha } -unique_ptr _applyRadialGradientProperty(SvgStyleGradient* g, Shape* vg, float rx, float ry, float rw, float rh) +unique_ptr _applyRadialGradientProperty(SvgStyleGradient* g, const Shape* vg, float rx, float ry, float rw, float rh) { Fill::ColorStop *stops; int stopCount = 0; @@ -339,7 +339,7 @@ bool _appendShape(SvgNode* node, Shape* shape, float vx, float vy, float vw, flo return true; } -unique_ptr _sceneBuildHelper(SvgNode* node, float vx, float vy, float vw, float vh) +unique_ptr _sceneBuildHelper(const SvgNode* node, float vx, float vy, float vw, float vh) { if (_isGroupType(node->type)) { auto scene = Scene::gen();