X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flottie%2Flottieitem.cpp;h=ee29113ca3779153cb80faad9300f503e5290acf;hb=f1d1ace6997dee9715ca54db55e96feb7740173d;hp=d190483bdf0262bb1f047c94cd572a0db2f56eee;hpb=15b256d1bf2e7282ea0d629bc622d4d8b7a5028f;p=platform%2Fcore%2Fuifw%2Flottie-player.git diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index d190483..ee29113 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -966,14 +966,87 @@ void LOTTrimItem::update() // when both path and trim are not dirty if (!(mDirty || pathDirty())) return; - //@TODO take the offset and trim type into account. - for (auto &i : mPathItems) { - VPathMesure pm; - pm.setStart(mCache.mStart); - pm.setEnd(mCache.mEnd); - pm.setOffset(mCache.mOffset); - i->updatePath(pm.trim(i->localPath())); + if (vCompare(std::fabs(mCache.mStart - mCache.mEnd) , 1)) return; + + if (vCompare(mCache.mStart, mCache.mEnd)) { + for (auto &i : mPathItems) { + i->updatePath(VPath()); + } + return; + } + + + if (mData->type() == LOTTrimData::TrimType::Simultaneously) { + for (auto &i : mPathItems) { + VPathMesure pm; + pm.setStart(mCache.mStart); + pm.setEnd(mCache.mEnd); + pm.setOffset(mCache.mOffset); + i->updatePath(pm.trim(i->localPath())); + } + } else { // LOTTrimData::TrimType::Individually + float totalLength = 0.0; + for (auto &i : mPathItems) { + totalLength += i->localPath().length(); + } + float offset = totalLength * mCache.mOffset; + float start = totalLength * mCache.mStart; + float end = totalLength * mCache.mEnd; + start += offset; + end +=offset; + // normalize start, end value to 0 - totalLength + if (fabs(start) > totalLength) start = fmod(start, totalLength); + if (fabs(end) > totalLength) end = fmod(end, totalLength); + + if (start >= 0 && end >= 0) { + if (start > end) std::swap(start, end); + } else if ( start < 0 && end < 0) { + start += totalLength; + end += totalLength; + if (start > end) std::swap(start, end); + } else { + // one is +ve and one is -ve so the + // segment will be wrapped from end segment to start segment. + // we need to split it in two segment. + //@TODO + return; + } + + if (start < end ) { + float curLen = 0.0; + for (auto &i : mPathItems) { + if (curLen > end) { + // update with empty path. + i->updatePath(VPath()); + continue; + } + float len = i->localPath().length(); + + if (curLen < start && curLen + len < start) { + curLen += len; + // update with empty path. + i->updatePath(VPath()); + continue; + } else if (start <= curLen && end >= curLen + len) { + // inside segment + curLen += len; + continue; + } else { + float local_start = start > curLen ? start - curLen : 0; + local_start /= len; + float local_end = curLen + len < end ? len : end - curLen; + local_end /= len; + VPathMesure pm; + pm.setStart(local_start); + pm.setEnd(local_end); + VPath p = pm.trim(i->localPath()); + i->updatePath(p); + curLen += len; + } + } + } } + }