sw_engine image: code refactoring

revert d520da2db8

After considered the scneario seriously,
this doesn't helpful for the performance at all...
just increased code complexity. earlier bad decision... revert it.
This commit is contained in:
Hermet Park 2021-11-15 11:26:31 +09:00
parent 8362ddda74
commit ee60a04f20
3 changed files with 6 additions and 36 deletions

View file

@ -323,7 +323,7 @@ bool strokeParseOutline(SwStroke* stroke, const SwOutline& outline);
SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid); SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid);
void strokeFree(SwStroke* stroke); void strokeFree(SwStroke* stroke);
bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool outline); bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid);
bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwBBox& renderRegion, bool antiAlias); bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwBBox& renderRegion, bool antiAlias);
void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid); void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid);
void imageReset(SwImage* image); void imageReset(SwImage* image);

View file

@ -72,38 +72,10 @@ static bool _genOutline(SwImage* image, const Matrix* transform, SwMpool* mpool,
/************************************************************************/ /************************************************************************/
bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool outline) bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid)
{ {
if (outline || !mathRightAngle(transform)) {
if (!_genOutline(image, transform, mpool, tid)) return false; if (!_genOutline(image, transform, mpool, tid)) return false;
return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, false); return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, false);
//Fast Track, don't need outlines.
} else {
auto w = static_cast<float>(image->w);
auto h = static_cast<float>(image->h);
Point pt[4] = {{0 ,0}, {w, 0}, {w, h}, {0, h}};
for (int i = 0; i < 4; i++) mathMultiply(&pt[i], transform);
auto xMin = pt[0].x;
auto xMax = pt[0].x;
auto yMin = pt[0].y;
auto yMax = pt[0].y;
for (uint32_t i = 1; i < 4; ++i) {
if (xMin > pt[i].x) xMin = pt[i].x;
if (xMax < pt[i].x) xMax = pt[i].x;
if (yMin > pt[i].y) yMin = pt[i].y;
if (yMax < pt[i].y) yMax = pt[i].y;
}
renderRegion.min.x = static_cast<SwCoord>(xMin);
renderRegion.max.x = static_cast<SwCoord>(round(xMax));
renderRegion.min.y = static_cast<SwCoord>(yMin);
renderRegion.max.y = static_cast<SwCoord>(round(yMax));
return mathClipBBox(clipRegion, renderRegion);
}
} }

View file

@ -192,11 +192,9 @@ struct SwImageTask : SwTask
if (!image.data || image.w == 0 || image.h == 0) goto end; if (!image.data || image.w == 0 || image.h == 0) goto end;
image.stride = image.w; //same, pixel buffer size. image.stride = image.w; //same, pixel buffer size.
auto clipPath = (clips.count > 0) ? true : false; if (!imagePrepare(&image, transform, clipRegion, bbox, mpool, tid)) goto end;
if (!imagePrepare(&image, transform, clipRegion, bbox, mpool, tid, clipPath)) goto end; if (clips.count > 0) {
if (clipPath) {
if (!imageGenRle(&image, pdata, bbox, false)) goto end; if (!imageGenRle(&image, pdata, bbox, false)) goto end;
if (image.rle) { if (image.rle) {
for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) { for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {