| 130 | } |
| 131 | |
| 132 | Frame SequenceInfo::firstVisibleFrame(const Layer* layer) const { |
| 133 | if (sequence == nullptr || layer->type() != LayerType::PreCompose) { |
| 134 | return 0; |
| 135 | } |
| 136 | auto preComposeLayer = static_cast<const PreComposeLayer*>(layer); |
| 137 | auto composition = preComposeLayer->composition; |
| 138 | if (composition->type() != CompositionType::Video && |
| 139 | composition->type() != CompositionType::Bitmap) { |
| 140 | return 0; |
| 141 | } |
| 142 | auto timeScale = layer->containingComposition |
| 143 | ? (composition->frameRate / layer->containingComposition->frameRate) |
| 144 | : 1.0f; |
| 145 | auto compositionFrame = static_cast<Frame>(roundf( |
| 146 | static_cast<float>(layer->startTime - preComposeLayer->compositionStartTime) * timeScale)); |
| 147 | if (compositionFrame < 0) { |
| 148 | compositionFrame = 0; |
| 149 | } |
| 150 | return sequence->toSequenceFrame(compositionFrame); |
| 151 | } |
| 152 | } // namespace pag |
no test coverage detected