MCPcopy Create free account
hub / github.com/Tencent/libpag / BuildContentTimeRemap

Method BuildContentTimeRemap

src/rendering/layers/PAGImageLayer.cpp:437–466  ·  view source on GitHub ↗

输出的时间轴不包含startTime

Source from the content-addressed store, hash-verified

435
436// 输出的时间轴不包含startTime
437void PAGImageLayer::BuildContentTimeRemap(AnimatableProperty<float>* property, PAGFile* fileOwner,
438 const TimeRange& visibleRange, double frameScale) {
439 auto fileDuration = fileOwner->frameDuration();
440 auto fileStretchedDuration = fileOwner->stretchedFrameDuration();
441 auto hasRepeat = (fileOwner->_timeStretchMode == PAGTimeStretchMode::Repeat ||
442 fileOwner->_timeStretchMode == PAGTimeStretchMode::RepeatInverted) &&
443 (fileDuration < fileStretchedDuration);
444 auto fileEndFrame = hasRepeat ? fileDuration - 1 : fileStretchedDuration - 1;
445 auto scaleDuration = ScaleTimeRemap(property, visibleRange, frameScale, fileEndFrame);
446 auto& keyframes = property->keyframes;
447 // 补齐头尾的空缺。
448 auto firstKeyframe = keyframes.front();
449 if (firstKeyframe->startTime > 0) {
450 auto newKeyframe = CreateKeyframe(0, firstKeyframe->startTime, firstKeyframe->startValue,
451 firstKeyframe->startValue);
452 keyframes.insert(keyframes.begin(), newKeyframe);
453 newKeyframe->initialize();
454 }
455 auto lastKeyframe = keyframes.back();
456 if (lastKeyframe->endTime < fileEndFrame) {
457 auto newKeyframe = CreateKeyframe(lastKeyframe->endTime, fileEndFrame, lastKeyframe->endValue,
458 lastKeyframe->endValue);
459 keyframes.push_back(newKeyframe);
460 newKeyframe->initialize();
461 }
462 if (hasRepeat) {
463 // 处理file存在repeat拉伸的情况。
464 ExpandPropertyByRepeat(property, fileOwner, scaleDuration);
465 }
466}
467
468TimeRange PAGImageLayer::getVisibleRangeInFile() {
469 TimeRange timeRange = {};

Callers

nothing calls this directly

Calls 6

CreateKeyframeFunction · 0.85
insertMethod · 0.80
push_backMethod · 0.80
frameDurationMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected