mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 04:24:28 +00:00
common array: + copy constructor
introduce the copy constructor to prevent duplicated code.
This commit is contained in:
parent
b7dfe661b5
commit
95ebbe4339
3 changed files with 13 additions and 10 deletions
|
@ -35,6 +35,15 @@ struct Array
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
uint32_t reserved = 0;
|
uint32_t reserved = 0;
|
||||||
|
|
||||||
|
Array(){}
|
||||||
|
|
||||||
|
Array(const Array& rhs)
|
||||||
|
{
|
||||||
|
reserve(rhs.reserved);
|
||||||
|
count = rhs.count;
|
||||||
|
memcpy(data, rhs.data, sizeof(T) * count);
|
||||||
|
}
|
||||||
|
|
||||||
void push(T element)
|
void push(T element)
|
||||||
{
|
{
|
||||||
if (count + 1 > reserved) {
|
if (count + 1 > reserved) {
|
||||||
|
|
|
@ -316,16 +316,10 @@ struct Shape::Impl
|
||||||
|
|
||||||
//Path
|
//Path
|
||||||
if (rs.path.cmds.count > 0 && rs.path.pts.count > 0) {
|
if (rs.path.cmds.count > 0 && rs.path.pts.count > 0) {
|
||||||
dup->rs.path.cmds.reserve(rs.path.cmds.reserved);
|
dup->rs.path.cmds = rs.path.cmds;
|
||||||
dup->rs.path.pts.reserve(rs.path.pts.reserved);
|
dup->rs.path.pts = rs.path.pts;
|
||||||
|
dup->flag |= RenderUpdateFlag::Path;
|
||||||
dup->rs.path.cmds.count = rs.path.cmds.count;
|
|
||||||
memcpy(dup->rs.path.cmds.data, rs.path.cmds.data, sizeof(PathCommand) * dup->rs.path.cmds.count);
|
|
||||||
|
|
||||||
dup->rs.path.pts.count = rs.path.pts.count;
|
|
||||||
memcpy(dup->rs.path.pts.data, rs.path.pts.data, sizeof(Point) * dup->rs.path.pts.count);
|
|
||||||
}
|
}
|
||||||
dup->flag |= RenderUpdateFlag::Path;
|
|
||||||
|
|
||||||
//Stroke
|
//Stroke
|
||||||
if (rs.stroke) {
|
if (rs.stroke) {
|
||||||
|
|
|
@ -542,7 +542,7 @@ struct SvgNodeIdPair
|
||||||
|
|
||||||
struct SvgLoaderData
|
struct SvgLoaderData
|
||||||
{
|
{
|
||||||
Array<SvgNode*> stack = {nullptr, 0, 0};
|
Array<SvgNode*> stack;
|
||||||
SvgNode* doc = nullptr;
|
SvgNode* doc = nullptr;
|
||||||
SvgNode* def = nullptr;
|
SvgNode* def = nullptr;
|
||||||
SvgNode* cssStyle = nullptr;
|
SvgNode* cssStyle = nullptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue