From: subhransu mohanty Date: Wed, 1 Aug 2018 02:46:31 +0000 (+0900) Subject: lottie/optimization: move the rle object to rletask thread to reuse X-Git-Tag: submit/tizen/20180917.042405~149 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4954721403dccf1d5b3dfae1f0a57e559634131e;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie/optimization: move the rle object to rletask thread to reuse the object between frames. Change-Id: Ia551fea9346c27aa4b6c020670a287b83b8a472e --- diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index bef0c2d..111a069 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -184,7 +184,7 @@ void LOTMaskItem::update(int frameNo, const VMatrix &parentMatrix, VPath path = mLocalPath; path.transform(parentMatrix); - mRleTask = VRaster::instance().generateFillInfo(path); + mRleTask = VRaster::instance().generateFillInfo(path, std::move(mRle)); } VRle LOTMaskItem::rle() diff --git a/src/vector/vdrawable.cpp b/src/vector/vdrawable.cpp index 89be798..c04783e 100644 --- a/src/vector/vdrawable.cpp +++ b/src/vector/vdrawable.cpp @@ -12,10 +12,10 @@ void VDrawable::preprocess() newPath = dasher.dashed(mPath); } mRleTask = VRaster::instance().generateStrokeInfo( - newPath, mStroke.cap, mStroke.join, mStroke.width, + newPath, std::move(mRle), mStroke.cap, mStroke.join, mStroke.width, mStroke.meterLimit); } else { - mRleTask = VRaster::instance().generateFillInfo(mPath, mFillRule); + mRleTask = VRaster::instance().generateFillInfo(mPath, std::move(mRle), mFillRule); } mFlag &= ~DirtyFlag(DirtyState::Path); } diff --git a/src/vector/vraster.cpp b/src/vector/vraster.cpp index 5d8bb51..0e07e0f 100644 --- a/src/vector/vraster.cpp +++ b/src/vector/vraster.cpp @@ -239,6 +239,7 @@ struct RleTask { std::future receiver; bool stroke; VPath path; + VRle rle; FillRule fillRule; CapStyle cap; JoinStyle join; @@ -249,6 +250,7 @@ struct RleTask { VRle RleTask::operator()(FTOutline &outRef, SW_FT_Stroker &stroker) { + rle.reset(); if (stroke) { // Stroke Task outRef.convert(path); outRef.convert(cap, join, width, meterLimit); @@ -264,7 +266,6 @@ VRle RleTask::operator()(FTOutline &outRef, SW_FT_Stroker &stroker) SW_FT_Stroker_Export(stroker, &outRef.ft); - VRle rle; SW_FT_Raster_Params params; params.flags = SW_FT_RASTER_FLAG_DIRECT | SW_FT_RASTER_FLAG_AA; @@ -274,7 +275,6 @@ VRle RleTask::operator()(FTOutline &outRef, SW_FT_Stroker &stroker) sw_ft_grays_raster.raster_render(nullptr, ¶ms); - return rle; } else { // Fill Task outRef.convert(path); int fillRuleFlag = SW_FT_OUTLINE_NONE; @@ -287,7 +287,6 @@ VRle RleTask::operator()(FTOutline &outRef, SW_FT_Stroker &stroker) break; } outRef.ft.flags = fillRuleFlag; - VRle rle; SW_FT_Raster_Params params; params.flags = SW_FT_RASTER_FLAG_DIRECT | SW_FT_RASTER_FLAG_AA; @@ -296,8 +295,8 @@ VRle RleTask::operator()(FTOutline &outRef, SW_FT_Stroker &stroker) params.source = &outRef.ft; sw_ft_grays_raster.raster_render(nullptr, ¶ms); - return rle; } + return std::move(rle); } class RleTaskScheduler { @@ -361,12 +360,13 @@ public: return receiver; } - std::future strokeRle(const VPath &path, CapStyle cap, JoinStyle join, + std::future strokeRle(const VPath &path, VRle &&rle, CapStyle cap, JoinStyle join, float width, float meterLimit) { RleTask *task = new RleTask(); task->stroke = true; task->path = path; + task->rle = std::move(rle); task->cap = cap; task->join = join; task->width = width; @@ -374,10 +374,11 @@ public: return async(task); } - std::future fillRle(const VPath &path, FillRule fillRule) + std::future fillRle(const VPath &path, VRle &&rle, FillRule fillRule) { RleTask *task = new RleTask(); task->path = path; + task->rle = std::move(rle); task->fillRule = fillRule; task->stroke = false; return async(task); @@ -390,7 +391,7 @@ VRaster::VRaster() {} VRaster::~VRaster() {} -std::future VRaster::generateFillInfo(const VPath &path, +std::future VRaster::generateFillInfo(const VPath &path, VRle &&rle, FillRule fillRule) { if (path.isEmpty()) { @@ -398,10 +399,10 @@ std::future VRaster::generateFillInfo(const VPath &path, promise.set_value(VRle()); return promise.get_future(); } - return raster_scheduler.fillRle(path, fillRule); + return raster_scheduler.fillRle(path, std::move(rle), fillRule); } -std::future VRaster::generateStrokeInfo(const VPath &path, CapStyle cap, +std::future VRaster::generateStrokeInfo(const VPath &path, VRle &&rle, CapStyle cap, JoinStyle join, float width, float meterLimit) { @@ -410,7 +411,7 @@ std::future VRaster::generateStrokeInfo(const VPath &path, CapStyle cap, promise.set_value(VRle()); return promise.get_future(); } - return raster_scheduler.strokeRle(path, cap, join, width, meterLimit); + return raster_scheduler.strokeRle(path, std::move(rle), cap, join, width, meterLimit); } V_END_NAMESPACE diff --git a/src/vector/vraster.h b/src/vector/vraster.h index 178786c..5d47dfe 100644 --- a/src/vector/vraster.h +++ b/src/vector/vraster.h @@ -22,9 +22,9 @@ public: VRaster &operator=(VRaster const &) = delete; VRaster &operator=(VRaster &&) = delete; - std::future generateFillInfo(const VPath &path, + std::future generateFillInfo(const VPath &path, VRle &&rle, FillRule fillRule = FillRule::Winding); - std::future generateStrokeInfo(const VPath &path, CapStyle cap, + std::future generateStrokeInfo(const VPath &path, VRle &&rle, CapStyle cap, JoinStyle join, float width, float meterLimit);