From 58de99aea32d76242e4f875918c0608848aac233 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 9 Jun 2020 15:22:33 +0900 Subject: [PATCH] common interface: replace arguements size_t to uint32_t We prefer to build up a tiny compact engine at memory rather than compatibility, this engine is not considerd for end-users but designed for middle-level framework and some low-level users. Thus, we won't consider 64bits data size, use explicit 32 bits data until coming next upgrade... Change-Id: I0704d5f1e0eb909cccc10922bc5972e115fbbcc0 --- inc/tizenvg.h | 18 +++++++++--------- src/lib/gl_engine/tvgGlGpuBuffer.h | 4 ++-- src/lib/gl_engine/tvgGlRenderer.cpp | 4 ++-- src/lib/gl_engine/tvgGlRenderer.h | 6 +++--- src/lib/sw_engine/tvgSwCommon.h | 2 +- src/lib/sw_engine/tvgSwRenderer.cpp | 6 +++--- src/lib/sw_engine/tvgSwRenderer.h | 6 +++--- src/lib/tvgCanvas.cpp | 2 +- src/lib/tvgGlCanvas.cpp | 2 +- src/lib/tvgRenderCommon.h | 14 +++++++------- src/lib/tvgScene.cpp | 2 +- src/lib/tvgSceneImpl.h | 6 +++--- src/lib/tvgShape.cpp | 10 +++++----- src/lib/tvgShapeImpl.h | 10 +++++----- src/lib/tvgShapePath.h | 18 +++++++++--------- src/lib/tvgSwCanvas.cpp | 2 +- 16 files changed, 56 insertions(+), 56 deletions(-) diff --git a/inc/tizenvg.h b/inc/tizenvg.h index 16e60f0..88abfdd 100644 --- a/inc/tizenvg.h +++ b/inc/tizenvg.h @@ -102,7 +102,7 @@ public: Canvas(RenderMethod*); virtual ~Canvas(); - Result reserve(size_t n) noexcept; + Result reserve(uint32_t n) noexcept; virtual Result push(std::unique_ptr paint) noexcept; virtual Result clear() noexcept; virtual Result update() noexcept; @@ -139,12 +139,12 @@ public: //Shape Result appendRect(float x, float y, float w, float h, float cornerRadius) noexcept; Result appendCircle(float cx, float cy, float radiusW, float radiusH) noexcept; - Result appendPath(const PathCommand* cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept; + Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept; //Stroke Result stroke(float width) noexcept; Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept; - Result stroke(const float* dashPattern, size_t cnt) noexcept; + Result stroke(const float* dashPattern, uint32_t cnt) noexcept; Result stroke(StrokeCap cap) noexcept; Result stroke(StrokeJoin join) noexcept; @@ -157,14 +157,14 @@ public: Result translate(float x, float y) noexcept override; //Getters - size_t pathCommands(const PathCommand** cmds) const noexcept; - size_t pathCoords(const Point** pts) const noexcept; + uint32_t pathCommands(const PathCommand** cmds) const noexcept; + uint32_t pathCoords(const Point** pts) const noexcept; Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept; Result bounds(float* x, float* y, float* w, float* h) const noexcept override; float strokeWidth() const noexcept; Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept; - size_t strokeDash(const float** dashPattern) const noexcept; + uint32_t strokeDash(const float** dashPattern) const noexcept; StrokeCap strokeCap() const noexcept; StrokeJoin strokeJoin() const noexcept; @@ -190,7 +190,7 @@ public: ~Scene(); Result push(std::unique_ptr shape) noexcept; - Result reserve(size_t size) noexcept; + Result reserve(uint32_t size) noexcept; Result rotate(float degree) noexcept override; Result scale(float factor) noexcept override; @@ -218,7 +218,7 @@ class TIZENVG_EXPORT SwCanvas final : public Canvas public: ~SwCanvas(); - Result target(uint32_t* buffer, size_t stride, size_t w, size_t h) noexcept; + Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept; Result sync() noexcept override; static std::unique_ptr gen() noexcept; @@ -241,7 +241,7 @@ public: //TODO: Gl Specific methods. Need gl backend configuration methods as well. - Result target(uint32_t* buffer, size_t stride, size_t w, size_t h) noexcept; + Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept; Result sync() noexcept override; static std::unique_ptr gen() noexcept; diff --git a/src/lib/gl_engine/tvgGlGpuBuffer.h b/src/lib/gl_engine/tvgGlGpuBuffer.h index fd7086a..79dd26d 100644 --- a/src/lib/gl_engine/tvgGlGpuBuffer.h +++ b/src/lib/gl_engine/tvgGlGpuBuffer.h @@ -2,7 +2,7 @@ #define _TVG_GL_GPU_BUFFER_H_ #include -#include +#include class GlGpuBuffer { @@ -15,7 +15,7 @@ public: GlGpuBuffer(); ~GlGpuBuffer(); - void updateBufferData(Target target, size_t size, void* data); + void updateBufferData(Target target, uint32_t size, void* data); private: uint32_t mGlBufferId = 0; diff --git a/src/lib/gl_engine/tvgGlRenderer.cpp b/src/lib/gl_engine/tvgGlRenderer.cpp index 0eb9beb..14bdbaa 100644 --- a/src/lib/gl_engine/tvgGlRenderer.cpp +++ b/src/lib/gl_engine/tvgGlRenderer.cpp @@ -95,13 +95,13 @@ int GlRenderer::term() } -size_t GlRenderer::unref() +uint32_t GlRenderer::unref() { return RenderInitializer::unref(renderInit); } -size_t GlRenderer::ref() +uint32_t GlRenderer::ref() { return RenderInitializer::ref(renderInit); } diff --git a/src/lib/gl_engine/tvgGlRenderer.h b/src/lib/gl_engine/tvgGlRenderer.h index fcde08f..3ef0ee9 100644 --- a/src/lib/gl_engine/tvgGlRenderer.h +++ b/src/lib/gl_engine/tvgGlRenderer.h @@ -30,13 +30,13 @@ public: void* prepare(const Shape& shape, void* data, const RenderTransform* transform, RenderUpdateFlag flags) override; bool dispose(const Shape& shape, void *data) override; bool render(const Shape& shape, void *data) override; - bool target(uint32_t* buffer, size_t stride, size_t w, size_t h) + bool target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) { return 0; }; bool clear() override; - size_t ref() override; - size_t unref() override; + uint32_t ref() override; + uint32_t unref() override; static GlRenderer* inst(); static int init(); diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index 16d4c1e..e6f432d 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -149,7 +149,7 @@ struct SwDashStroke Point ptStart; Point ptCur; float* pattern; - size_t cnt; + uint32_t cnt; bool curOpGap; }; diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index 60c3a6d..d2143fe 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -45,7 +45,7 @@ bool SwRenderer::clear() return true; } -bool SwRenderer::target(uint32_t* buffer, size_t stride, size_t w, size_t h) +bool SwRenderer::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) { if (!buffer || stride == 0 || w == 0 || h == 0) return false; @@ -137,13 +137,13 @@ int SwRenderer::term() } -size_t SwRenderer::unref() +uint32_t SwRenderer::unref() { return RenderInitializer::unref(renderInit); } -size_t SwRenderer::ref() +uint32_t SwRenderer::ref() { return RenderInitializer::ref(renderInit); } diff --git a/src/lib/sw_engine/tvgSwRenderer.h b/src/lib/sw_engine/tvgSwRenderer.h index 3dfb076..4a4fafd 100644 --- a/src/lib/sw_engine/tvgSwRenderer.h +++ b/src/lib/sw_engine/tvgSwRenderer.h @@ -25,10 +25,10 @@ public: void* prepare(const Shape& shape, void* data, const RenderTransform* transform, RenderUpdateFlag flags) override; bool dispose(const Shape& shape, void *data) override; bool render(const Shape& shape, void *data) override; - bool target(uint32_t* buffer, size_t stride, size_t w, size_t h); + bool target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h); bool clear() override; - size_t ref() override; - size_t unref() override; + uint32_t ref() override; + uint32_t unref() override; static SwRenderer* inst(); static int init(); diff --git a/src/lib/tvgCanvas.cpp b/src/lib/tvgCanvas.cpp index 79057c7..dc05d66 100644 --- a/src/lib/tvgCanvas.cpp +++ b/src/lib/tvgCanvas.cpp @@ -34,7 +34,7 @@ Canvas::~Canvas() } -Result Canvas::reserve(size_t n) noexcept +Result Canvas::reserve(uint32_t n) noexcept { auto impl = pImpl.get(); if (!impl) return Result::MemoryCorruption; diff --git a/src/lib/tvgGlCanvas.cpp b/src/lib/tvgGlCanvas.cpp index 2bf3868..024fed5 100644 --- a/src/lib/tvgGlCanvas.cpp +++ b/src/lib/tvgGlCanvas.cpp @@ -45,7 +45,7 @@ GlCanvas::~GlCanvas() } -Result GlCanvas::target(uint32_t* buffer, size_t stride, size_t w, size_t h) noexcept +Result GlCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept { auto renderer = dynamic_cast(Canvas::pImpl.get()->renderer); if (!renderer) return Result::MemoryCorruption; diff --git a/src/lib/tvgRenderCommon.h b/src/lib/tvgRenderCommon.h index 61cd655..0e98e17 100644 --- a/src/lib/tvgRenderCommon.h +++ b/src/lib/tvgRenderCommon.h @@ -24,8 +24,8 @@ struct Surface { //TODO: Union for multiple types uint32_t* buffer; - size_t stride; - size_t w, h; + uint32_t stride; + uint32_t w, h; }; enum RenderUpdateFlag {None = 0, Path = 1, Fill = 2, Stroke = 4, Transform = 8, All = 16}; @@ -126,14 +126,14 @@ public: virtual bool dispose(const Shape& shape, void *data) = 0; virtual bool render(const Shape& shape, void *data) = 0; virtual bool clear() = 0; - virtual size_t ref() = 0; - virtual size_t unref() = 0; + virtual uint32_t ref() = 0; + virtual uint32_t unref() = 0; }; struct RenderInitializer { RenderMethod* pInst = nullptr; - size_t refCnt = 0; + uint32_t refCnt = 0; bool initialized = false; static int init(RenderInitializer& renderInit, RenderMethod* engine) @@ -160,7 +160,7 @@ struct RenderInitializer return 0; } - static size_t unref(RenderInitializer& renderInit) + static uint32_t unref(RenderInitializer& renderInit) { assert(renderInit.refCnt > 0); --renderInit.refCnt; @@ -181,7 +181,7 @@ struct RenderInitializer return renderInit.pInst; } - static size_t ref(RenderInitializer& renderInit) + static uint32_t ref(RenderInitializer& renderInit) { return ++renderInit.refCnt; } diff --git a/src/lib/tvgScene.cpp b/src/lib/tvgScene.cpp index 12b96ec..75e2720 100644 --- a/src/lib/tvgScene.cpp +++ b/src/lib/tvgScene.cpp @@ -53,7 +53,7 @@ Result Scene::push(unique_ptr paint) noexcept } -Result Scene::reserve(size_t size) noexcept +Result Scene::reserve(uint32_t size) noexcept { auto impl = pImpl.get(); if (!impl) return Result::MemoryCorruption; diff --git a/src/lib/tvgSceneImpl.h b/src/lib/tvgSceneImpl.h index a08afc6..edaa6d8 100644 --- a/src/lib/tvgSceneImpl.h +++ b/src/lib/tvgSceneImpl.h @@ -27,7 +27,7 @@ struct Scene::Impl { vector paints; RenderTransform *transform = nullptr; - size_t flag = RenderUpdateFlag::None; + uint32_t flag = RenderUpdateFlag::None; ~Impl() { @@ -51,7 +51,7 @@ struct Scene::Impl return true; } - bool updateInternal(RenderMethod &renderer, const RenderTransform* transform, size_t flag) + bool updateInternal(RenderMethod &renderer, const RenderTransform* transform, uint32_t flag) { for(auto paint: paints) { if (auto scene = dynamic_cast(paint)) { @@ -63,7 +63,7 @@ struct Scene::Impl return true; } - bool update(RenderMethod &renderer, const RenderTransform* pTransform = nullptr, size_t pFlag = 0) + bool update(RenderMethod &renderer, const RenderTransform* pTransform = nullptr, uint32_t pFlag = 0) { if (flag & RenderUpdateFlag::Transform) { if (!transform) return false; diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index c41c6b1..ad1736b 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -59,7 +59,7 @@ Result Shape::reset() noexcept } -size_t Shape::pathCommands(const PathCommand** cmds) const noexcept +uint32_t Shape::pathCommands(const PathCommand** cmds) const noexcept { if (!cmds) return 0; @@ -72,7 +72,7 @@ size_t Shape::pathCommands(const PathCommand** cmds) const noexcept } -size_t Shape::pathCoords(const Point** pts) const noexcept +uint32_t Shape::pathCoords(const Point** pts) const noexcept { if (!pts) return 0; @@ -85,7 +85,7 @@ size_t Shape::pathCoords(const Point** pts) const noexcept } -Result Shape::appendPath(const PathCommand *cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept +Result Shape::appendPath(const PathCommand *cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept { if (cmdCnt < 0 || ptsCnt < 0 || !pts || !ptsCnt) return Result::InvalidArguments; @@ -337,7 +337,7 @@ Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const } -Result Shape::stroke(const float* dashPattern, size_t cnt) noexcept +Result Shape::stroke(const float* dashPattern, uint32_t cnt) noexcept { if (cnt < 2 || !dashPattern) return Result::InvalidArguments; @@ -350,7 +350,7 @@ Result Shape::stroke(const float* dashPattern, size_t cnt) noexcept } -size_t Shape::strokeDash(const float** dashPattern) const noexcept +uint32_t Shape::strokeDash(const float** dashPattern) const noexcept { auto impl = pImpl.get(); assert(impl); diff --git a/src/lib/tvgShapeImpl.h b/src/lib/tvgShapeImpl.h index 9218417..08acb36 100644 --- a/src/lib/tvgShapeImpl.h +++ b/src/lib/tvgShapeImpl.h @@ -33,7 +33,7 @@ struct ShapeStroke float width = 0; uint8_t color[4] = {0, 0, 0, 0}; float* dashPattern = nullptr; - size_t dashCnt = 0; + uint32_t dashCnt = 0; StrokeCap cap = StrokeCap::Square; StrokeJoin join = StrokeJoin::Bevel; @@ -51,7 +51,7 @@ struct Shape::Impl ShapePath *path = nullptr; RenderTransform *transform = nullptr; uint8_t color[4] = {0, 0, 0, 0}; //r, g, b, a - size_t flag = RenderUpdateFlag::None; + uint32_t flag = RenderUpdateFlag::None; void *edata = nullptr; //engine data @@ -77,7 +77,7 @@ struct Shape::Impl return renderer.render(shape, edata); } - bool update(Shape& shape, RenderMethod& renderer, const RenderTransform* pTransform = nullptr, size_t pFlag = 0) + bool update(Shape& shape, RenderMethod& renderer, const RenderTransform* pTransform = nullptr, uint32_t pFlag = 0) { if (flag & RenderUpdateFlag::Transform) { if (!transform) return false; @@ -203,7 +203,7 @@ struct Shape::Impl return true; } - bool strokeDash(const float* pattern, size_t cnt) + bool strokeDash(const float* pattern, uint32_t cnt) { assert(pattern); @@ -218,7 +218,7 @@ struct Shape::Impl if (!stroke->dashPattern) stroke->dashPattern = static_cast(malloc(sizeof(float) * cnt)); assert(stroke->dashPattern); - for (size_t i = 0; i < cnt; ++i) + for (uint32_t i = 0; i < cnt; ++i) stroke->dashPattern[i] = pattern[i]; stroke->dashCnt = cnt; diff --git a/src/lib/tvgShapePath.h b/src/lib/tvgShapePath.h index 7e020e8..38ed3eb 100644 --- a/src/lib/tvgShapePath.h +++ b/src/lib/tvgShapePath.h @@ -26,12 +26,12 @@ struct ShapePath { PathCommand* cmds = nullptr; - size_t cmdCnt = 0; - size_t reservedCmdCnt = 0; + uint32_t cmdCnt = 0; + uint32_t reservedCmdCnt = 0; Point *pts = nullptr; - size_t ptsCnt = 0; - size_t reservedPtsCnt = 0; + uint32_t ptsCnt = 0; + uint32_t reservedPtsCnt = 0; ~ShapePath() @@ -40,7 +40,7 @@ struct ShapePath if (pts) free(pts); } - void reserveCmd(size_t cmdCnt) + void reserveCmd(uint32_t cmdCnt) { if (cmdCnt <= reservedCmdCnt) return; reservedCmdCnt = cmdCnt; @@ -48,7 +48,7 @@ struct ShapePath assert(cmds); } - void reservePts(size_t ptsCnt) + void reservePts(uint32_t ptsCnt) { if (ptsCnt <= reservedPtsCnt) return; reservedPtsCnt = ptsCnt; @@ -56,7 +56,7 @@ struct ShapePath assert(pts); } - void grow(size_t cmdCnt, size_t ptsCnt) + void grow(uint32_t cmdCnt, uint32_t ptsCnt) { reserveCmd(this->cmdCnt + cmdCnt); reservePts(this->ptsCnt + ptsCnt); @@ -68,7 +68,7 @@ struct ShapePath ptsCnt = 0; } - void append(const PathCommand* cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) + void append(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) { memcpy(this->cmds + this->cmdCnt, cmds, sizeof(PathCommand) * cmdCnt); memcpy(this->pts + this->ptsCnt, pts, sizeof(Point) * ptsCnt); @@ -120,7 +120,7 @@ struct ShapePath Point min = { pts[0].x, pts[0].y }; Point max = { pts[0].x, pts[0].y }; - for(size_t i = 1; i < ptsCnt; ++i) { + for(uint32_t i = 1; i < ptsCnt; ++i) { if (pts[i].x < min.x) min.x = pts[i].x; if (pts[i].y < min.y) min.y = pts[i].y; if (pts[i].x > max.x) max.x = pts[i].x; diff --git a/src/lib/tvgSwCanvas.cpp b/src/lib/tvgSwCanvas.cpp index ec18dbf..560a975 100644 --- a/src/lib/tvgSwCanvas.cpp +++ b/src/lib/tvgSwCanvas.cpp @@ -45,7 +45,7 @@ SwCanvas::~SwCanvas() { } -Result SwCanvas::target(uint32_t* buffer, size_t stride, size_t w, size_t h) noexcept +Result SwCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept { auto renderer = dynamic_cast(Canvas::pImpl.get()->renderer); if (!renderer) return Result::MemoryCorruption; -- 2.7.4