Result Shape::reset() noexcept
{
- auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
-
- impl->path->reset();
+ IMPL->path->reset();
- impl->flag |= RenderUpdateFlag::Path;
+ IMPL->flag |= RenderUpdateFlag::Path;
return Result::Success;
}
{
if (!cmds) return 0;
- auto impl = pImpl.get();
- if (!impl || !impl->path) return 0;
-
- *cmds = impl->path->cmds;
+ *cmds = IMPL->path->cmds;
- return impl->path->cmdCnt;
+ return IMPL->path->cmdCnt;
}
{
if (!pts) return 0;
- auto impl = pImpl.get();
- if (!impl || !impl->path) return 0;
+ *pts = IMPL->path->pts;
- *pts = impl->path->pts;
-
- return impl->path->ptsCnt;
+ return IMPL->path->ptsCnt;
}
{
if (cmdCnt < 0 || ptsCnt < 0 || !pts || !ptsCnt) return Result::InvalidArguments;
- auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
+ IMPL->path->grow(cmdCnt, ptsCnt);
+ IMPL->path->append(cmds, cmdCnt, pts, ptsCnt);
- impl->path->grow(cmdCnt, ptsCnt);
- impl->path->append(cmds, cmdCnt, pts, ptsCnt);
-
- impl->flag |= RenderUpdateFlag::Path;
+ IMPL->flag |= RenderUpdateFlag::Path;
return Result::Success;
}
Result Shape::moveTo(float x, float y) noexcept
{
- auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
+ IMPL->path->moveTo(x, y);
- impl->path->moveTo(x, y);
-
- impl->flag |= RenderUpdateFlag::Path;
+ IMPL->flag |= RenderUpdateFlag::Path;
return Result::Success;
}
Result Shape::lineTo(float x, float y) noexcept
{
- auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
+ IMPL->path->lineTo(x, y);
- impl->path->lineTo(x, y);
-
- impl->flag |= RenderUpdateFlag::Path;
+ IMPL->flag |= RenderUpdateFlag::Path;
return Result::Success;
}
Result Shape::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept
{
- auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
+ IMPL->path->cubicTo(cx1, cy1, cx2, cy2, x, y);
- impl->path->cubicTo(cx1, cy1, cx2, cy2, x, y);
-
- impl->flag |= RenderUpdateFlag::Path;
+ IMPL->flag |= RenderUpdateFlag::Path;
return Result::Success;
}
Result Shape::close() noexcept
{
- auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
+ IMPL->path->close();
- impl->path->close();
-
- impl->flag |= RenderUpdateFlag::Path;
+ IMPL->flag |= RenderUpdateFlag::Path;
return Result::Success;
}
Result Shape::appendCircle(float cx, float cy, float rx, float ry) noexcept
{
auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
auto rxKappa = rx * PATH_KAPPA;
auto ryKappa = ry * PATH_KAPPA;
Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) noexcept
{
auto impl = pImpl.get();
- if (!impl || !impl->path) return Result::MemoryCorruption;
auto halfW = w * 0.5f;
auto halfH = h * 0.5f;
Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
{
auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
impl->color[0] = r;
impl->color[1] = g;
Result Shape::fill(unique_ptr<Fill> f) noexcept
{
auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
auto p = f.release();
if (!p) return Result::MemoryCorruption;
Result Shape::fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept
{
auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
if (r) *r = impl->color[0];
if (g) *g = impl->color[1];
const Fill* Shape::fill() const noexcept
{
- auto impl = pImpl.get();
- if (!impl) return nullptr;
-
- return impl->fill;
+ return IMPL->fill;
}
Result Shape::stroke(float width) noexcept
{
- auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
-
- if (!impl->strokeWidth(width)) return Result::FailedAllocation;
+ if (!IMPL->strokeWidth(width)) return Result::FailedAllocation;
return Result::Success;
}
float Shape::strokeWidth() const noexcept
{
- auto impl = pImpl.get();
- if (!impl) return 0;
-
- if (!impl->stroke) return 0;
- return impl->stroke->width;
+ if (!IMPL->stroke) return 0;
+ return IMPL->stroke->width;
}
Result Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
{
- auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
-
- if (!impl->strokeColor(r, g, b, a)) return Result::FailedAllocation;
+ if (!IMPL->strokeColor(r, g, b, a)) return Result::FailedAllocation;
return Result::Success;
}
Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept
{
auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
if (!impl->stroke) return Result::InsufficientCondition;
{
if (cnt < 2 || !dashPattern) return Result::InvalidArguments;
- auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
-
- if (!impl->strokeDash(dashPattern, cnt)) return Result::FailedAllocation;
+ if (!IMPL->strokeDash(dashPattern, cnt)) return Result::FailedAllocation;
return Result::Success;
}
uint32_t Shape::strokeDash(const float** dashPattern) const noexcept
{
- auto impl = pImpl.get();
- assert(impl);
-
- if (!impl->stroke) return 0;
+ if (!IMPL->stroke) return 0;
- if (dashPattern) *dashPattern = impl->stroke->dashPattern;
- return impl->stroke->dashCnt;
+ if (dashPattern) *dashPattern = IMPL->stroke->dashPattern;
+ return IMPL->stroke->dashCnt;
}
Result Shape::stroke(StrokeCap cap) noexcept
{
- auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
-
- if (!impl->strokeCap(cap)) return Result::FailedAllocation;
+ if (!IMPL->strokeCap(cap)) return Result::FailedAllocation;
return Result::Success;
}
Result Shape::stroke(StrokeJoin join) noexcept
{
- auto impl = pImpl.get();
- if (!impl) return Result::MemoryCorruption;
-
- if (!impl->strokeJoin(join)) return Result::FailedAllocation;
+ if (!IMPL->strokeJoin(join)) return Result::FailedAllocation;
return Result::Success;
}
StrokeCap Shape::strokeCap() const noexcept
{
- auto impl = pImpl.get();
- assert(impl);
-
- if (!impl->stroke) return StrokeCap::Square;
+ if (!IMPL->stroke) return StrokeCap::Square;
- return impl->stroke->cap;
+ return IMPL->stroke->cap;
}
StrokeJoin Shape::strokeJoin() const noexcept
{
- auto impl = pImpl.get();
- assert(impl);
-
- if (!impl->stroke) return StrokeJoin::Bevel;
+ if (!IMPL->stroke) return StrokeJoin::Bevel;
- return impl->stroke->join;
+ return IMPL->stroke->join;
}