mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
common array: ++enhance the usability.
+ end() which indicates the end of the data pointer.
This commit is contained in:
parent
bd87f1398c
commit
4482664740
4 changed files with 18 additions and 18 deletions
|
@ -167,7 +167,7 @@ struct SwShapeTask : SwTask
|
||||||
shapeDelOutline(&shape, mpool, tid);
|
shapeDelOutline(&shape, mpool, tid);
|
||||||
|
|
||||||
//Clip Path
|
//Clip Path
|
||||||
for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {
|
for (auto clip = clips.data; clip < clips.end(); ++clip) {
|
||||||
auto clipper = static_cast<SwTask*>(*clip);
|
auto clipper = static_cast<SwTask*>(*clip);
|
||||||
//Clip shape rle
|
//Clip shape rle
|
||||||
if (shape.rle && !clipper->clip(shape.rle)) goto err;
|
if (shape.rle && !clipper->clip(shape.rle)) goto err;
|
||||||
|
@ -228,7 +228,7 @@ struct SwSceneTask : SwTask
|
||||||
rleMerge(sceneRle, clipper1->rle(), clipper2->rle());
|
rleMerge(sceneRle, clipper1->rle(), clipper2->rle());
|
||||||
|
|
||||||
//Unify the remained clippers
|
//Unify the remained clippers
|
||||||
for (auto rd = scene.data + 2; rd < (scene.data + scene.count); ++rd) {
|
for (auto rd = scene.data + 2; rd < scene.end(); ++rd) {
|
||||||
auto clipper = static_cast<SwTask*>(*rd);
|
auto clipper = static_cast<SwTask*>(*rd);
|
||||||
rleMerge(sceneRle, sceneRle, clipper->rle());
|
rleMerge(sceneRle, sceneRle, clipper->rle());
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ struct SwImageTask : SwTask
|
||||||
if (image.rle) {
|
if (image.rle) {
|
||||||
//Clear current task memorypool here if the clippers would use the same memory pool
|
//Clear current task memorypool here if the clippers would use the same memory pool
|
||||||
imageDelOutline(&image, mpool, tid);
|
imageDelOutline(&image, mpool, tid);
|
||||||
for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {
|
for (auto clip = clips.data; clip < clips.end(); ++clip) {
|
||||||
auto clipper = static_cast<SwTask*>(*clip);
|
auto clipper = static_cast<SwTask*>(*clip);
|
||||||
if (!clipper->clip(image.rle)) goto err;
|
if (!clipper->clip(image.rle)) goto err;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ SwRenderer::~SwRenderer()
|
||||||
|
|
||||||
bool SwRenderer::clear()
|
bool SwRenderer::clear()
|
||||||
{
|
{
|
||||||
for (auto task = tasks.data; task < (tasks.data + tasks.count); ++task) {
|
for (auto task = tasks.data; task < tasks.end(); ++task) {
|
||||||
if ((*task)->disposed) {
|
if ((*task)->disposed) {
|
||||||
delete(*task);
|
delete(*task);
|
||||||
} else {
|
} else {
|
||||||
|
@ -440,7 +440,7 @@ bool SwRenderer::preRender()
|
||||||
void SwRenderer::clearCompositors()
|
void SwRenderer::clearCompositors()
|
||||||
{
|
{
|
||||||
//Free Composite Caches
|
//Free Composite Caches
|
||||||
for (auto comp = compositors.data; comp < (compositors.data + compositors.count); ++comp) {
|
for (auto comp = compositors.data; comp < compositors.end(); ++comp) {
|
||||||
free((*comp)->compositor->image.data);
|
free((*comp)->compositor->image.data);
|
||||||
delete((*comp)->compositor);
|
delete((*comp)->compositor);
|
||||||
delete(*comp);
|
delete(*comp);
|
||||||
|
@ -456,7 +456,7 @@ bool SwRenderer::postRender()
|
||||||
rasterUnpremultiply(surface);
|
rasterUnpremultiply(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto task = tasks.data; task < (tasks.data + tasks.count); ++task) {
|
for (auto task = tasks.data; task < tasks.end(); ++task) {
|
||||||
(*task)->pushed = false;
|
(*task)->pushed = false;
|
||||||
}
|
}
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
|
@ -613,7 +613,7 @@ Compositor* SwRenderer::target(const RenderRegion& region, ColorSpace cs)
|
||||||
auto reqChannelSize = CHANNEL_SIZE(cs);
|
auto reqChannelSize = CHANNEL_SIZE(cs);
|
||||||
|
|
||||||
//Use cached data
|
//Use cached data
|
||||||
for (auto p = compositors.data; p < (compositors.data + compositors.count); ++p) {
|
for (auto p = compositors.data; p < compositors.end(); ++p) {
|
||||||
if ((*p)->compositor->valid && (*p)->compositor->image.channelSize == reqChannelSize) {
|
if ((*p)->compositor->valid && (*p)->compositor->image.channelSize == reqChannelSize) {
|
||||||
cmp = *p;
|
cmp = *p;
|
||||||
break;
|
break;
|
||||||
|
@ -719,7 +719,7 @@ void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform,
|
||||||
//TODO: Failed threading them. It would be better if it's possible.
|
//TODO: Failed threading them. It would be better if it's possible.
|
||||||
//See: https://github.com/thorvg/thorvg/issues/1409
|
//See: https://github.com/thorvg/thorvg/issues/1409
|
||||||
//Guarantee composition targets get ready.
|
//Guarantee composition targets get ready.
|
||||||
for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {
|
for (auto clip = clips.data; clip < clips.end(); ++clip) {
|
||||||
static_cast<SwTask*>(*clip)->done();
|
static_cast<SwTask*>(*clip)->done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ RenderData SwRenderer::prepare(const Array<RenderData>& scene, RenderData data,
|
||||||
//TODO: Failed threading them. It would be better if it's possible.
|
//TODO: Failed threading them. It would be better if it's possible.
|
||||||
//See: https://github.com/thorvg/thorvg/issues/1409
|
//See: https://github.com/thorvg/thorvg/issues/1409
|
||||||
//Guarantee composition targets get ready.
|
//Guarantee composition targets get ready.
|
||||||
for (auto task = scene.data; task < (scene.data + scene.count); ++task) {
|
for (auto task = scene.data; task < scene.end(); ++task) {
|
||||||
static_cast<SwTask*>(*task)->done();
|
static_cast<SwTask*>(*task)->done();
|
||||||
}
|
}
|
||||||
return prepareCommon(task, transform, clips, opacity, flags);
|
return prepareCommon(task, transform, clips, opacity, flags);
|
||||||
|
|
|
@ -68,12 +68,12 @@ struct Array
|
||||||
return reserve(count + size);
|
return reserve(count + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
T* ptr()
|
T* end() const
|
||||||
{
|
{
|
||||||
return data + count;
|
return data + count;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* last()
|
T* last() const
|
||||||
{
|
{
|
||||||
return data + count - 1;
|
return data + count - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ bool TvgSaver::writeHeader()
|
||||||
buffer.grow(headerSize);
|
buffer.grow(headerSize);
|
||||||
|
|
||||||
//1. Signature
|
//1. Signature
|
||||||
auto ptr = buffer.ptr();
|
auto ptr = buffer.end();
|
||||||
memcpy(ptr, TVG_HEADER_SIGNATURE, TVG_HEADER_SIGNATURE_LENGTH);
|
memcpy(ptr, TVG_HEADER_SIGNATURE, TVG_HEADER_SIGNATURE_LENGTH);
|
||||||
ptr += TVG_HEADER_SIGNATURE_LENGTH;
|
ptr += TVG_HEADER_SIGNATURE_LENGTH;
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ bool TvgSaver::writeHeader()
|
||||||
void TvgSaver::writeTag(TvgBinTag tag)
|
void TvgSaver::writeTag(TvgBinTag tag)
|
||||||
{
|
{
|
||||||
buffer.grow(SIZE(TvgBinTag));
|
buffer.grow(SIZE(TvgBinTag));
|
||||||
memcpy(buffer.ptr(), &tag, SIZE(TvgBinTag));
|
memcpy(buffer.end(), &tag, SIZE(TvgBinTag));
|
||||||
buffer.count += SIZE(TvgBinTag);
|
buffer.count += SIZE(TvgBinTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,14 +252,14 @@ void TvgSaver::writeTag(TvgBinTag tag)
|
||||||
void TvgSaver::writeCount(TvgBinCounter cnt)
|
void TvgSaver::writeCount(TvgBinCounter cnt)
|
||||||
{
|
{
|
||||||
buffer.grow(SIZE(TvgBinCounter));
|
buffer.grow(SIZE(TvgBinCounter));
|
||||||
memcpy(buffer.ptr(), &cnt, SIZE(TvgBinCounter));
|
memcpy(buffer.end(), &cnt, SIZE(TvgBinCounter));
|
||||||
buffer.count += SIZE(TvgBinCounter);
|
buffer.count += SIZE(TvgBinCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TvgSaver::writeReservedCount(TvgBinCounter cnt)
|
void TvgSaver::writeReservedCount(TvgBinCounter cnt)
|
||||||
{
|
{
|
||||||
memcpy(buffer.ptr() - cnt - SIZE(TvgBinCounter), &cnt, SIZE(TvgBinCounter));
|
memcpy(buffer.end() - cnt - SIZE(TvgBinCounter), &cnt, SIZE(TvgBinCounter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ void TvgSaver::reserveCount()
|
||||||
TvgBinCounter TvgSaver::writeData(const void* data, TvgBinCounter cnt)
|
TvgBinCounter TvgSaver::writeData(const void* data, TvgBinCounter cnt)
|
||||||
{
|
{
|
||||||
buffer.grow(cnt);
|
buffer.grow(cnt);
|
||||||
memcpy(buffer.ptr(), data, cnt);
|
memcpy(buffer.end(), data, cnt);
|
||||||
buffer.count += cnt;
|
buffer.count += cnt;
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
|
@ -286,7 +286,7 @@ TvgBinCounter TvgSaver::writeTagProperty(TvgBinTag tag, TvgBinCounter cnt, const
|
||||||
|
|
||||||
buffer.grow(growCnt);
|
buffer.grow(growCnt);
|
||||||
|
|
||||||
auto ptr = buffer.ptr();
|
auto ptr = buffer.end();
|
||||||
|
|
||||||
*ptr = tag;
|
*ptr = tag;
|
||||||
++ptr;
|
++ptr;
|
||||||
|
|
|
@ -189,7 +189,7 @@ public:
|
||||||
mBounds[0], mBounds[1] + mBounds[3], //(x1, y2)
|
mBounds[0], mBounds[1] + mBounds[3], //(x1, y2)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto paint = parents.data; paint < (parents.data + parents.count); ++paint) {
|
for (auto paint = parents.data; paint < parents.end(); ++paint) {
|
||||||
auto m = const_cast<Paint*>(*paint)->transform();
|
auto m = const_cast<Paint*>(*paint)->transform();
|
||||||
for (int i = 0; i<8; i += 2) {
|
for (int i = 0; i<8; i += 2) {
|
||||||
float x = points[i] * m.e11 + points[i+1] * m.e12 + m.e13;
|
float x = points[i] * m.e11 + points[i+1] * m.e12 + m.e13;
|
||||||
|
|
Loading…
Add table
Reference in a new issue