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
This commit is contained in:
Hermet Park 2020-06-09 15:22:33 +09:00
parent 33e1d4b170
commit 58de99aea3
16 changed files with 56 additions and 56 deletions

View file

@ -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> 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<Paint> 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<SwCanvas> 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<GlCanvas> gen() noexcept;

View file

@ -2,7 +2,7 @@
#define _TVG_GL_GPU_BUFFER_H_
#include <stdlib.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2.h>
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;

View file

@ -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);
}

View file

@ -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();

View file

@ -149,7 +149,7 @@ struct SwDashStroke
Point ptStart;
Point ptCur;
float* pattern;
size_t cnt;
uint32_t cnt;
bool curOpGap;
};

View file

@ -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);
}

View file

@ -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();

View file

@ -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;

View file

@ -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<GlRenderer*>(Canvas::pImpl.get()->renderer);
if (!renderer) return Result::MemoryCorruption;

View file

@ -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;
}

View file

@ -53,7 +53,7 @@ Result Scene::push(unique_ptr<Paint> 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;

View file

@ -27,7 +27,7 @@ struct Scene::Impl
{
vector<Paint*> 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<Scene*>(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;

View file

@ -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);

View file

@ -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<float*>(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;

View file

@ -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;

View file

@ -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<SwRenderer*>(Canvas::pImpl.get()->renderer);
if (!renderer) return Result::MemoryCorruption;