| 427 | } |
| 428 | |
| 429 | static void RebuildVideoComposition(std::shared_ptr<PAGExportSession> session, |
| 430 | pag::VideoComposition* composition, |
| 431 | std::vector<pag::Composition*>& compositions, int left, int top, |
| 432 | int right, int bottom) { |
| 433 | auto newComposition = new pag::VectorComposition(); |
| 434 | auto newLayer = new pag::PreComposeLayer(); |
| 435 | |
| 436 | newLayer->id = GetLayerUniqueID(session->compositions); |
| 437 | newLayer->transform = new pag::Transform2D(); |
| 438 | newLayer->transform->position = new pag::Property<pag::Point>(); |
| 439 | newLayer->transform->anchorPoint = new pag::Property<pag::Point>(); |
| 440 | newLayer->transform->scale = new pag::Property<pag::Point>(); |
| 441 | newLayer->transform->rotation = new pag::Property<float>(); |
| 442 | newLayer->transform->opacity = new pag::Property<pag::Opacity>(); |
| 443 | |
| 444 | newLayer->transform->anchorPoint->value.x = static_cast<float>(right - left) / 2.0f; |
| 445 | newLayer->transform->anchorPoint->value.y = static_cast<float>(bottom - top) / 2.0f; |
| 446 | newLayer->transform->position->value.x = static_cast<float>(left + right) / 2.0f; |
| 447 | newLayer->transform->position->value.y = static_cast<float>(top + bottom) / 2.0f; |
| 448 | newLayer->transform->scale->value.x = 1.0f; |
| 449 | newLayer->transform->scale->value.y = 1.0f; |
| 450 | newLayer->transform->rotation->value = 0.0f; |
| 451 | newLayer->transform->opacity->value = pag::Opaque; |
| 452 | newLayer->composition = composition; |
| 453 | newLayer->containingComposition = newComposition; |
| 454 | newLayer->startTime = 0; |
| 455 | newLayer->duration = composition->duration; |
| 456 | |
| 457 | auto originalID = composition->id; |
| 458 | AEGP_ItemH originalItemHandle = nullptr; |
| 459 | auto itemIter = session->itemHandleMap.find(originalID); |
| 460 | if (itemIter != session->itemHandleMap.end()) { |
| 461 | originalItemHandle = itemIter->second; |
| 462 | } |
| 463 | |
| 464 | newComposition->layers.push_back(newLayer); |
| 465 | newComposition->width = composition->width; |
| 466 | newComposition->height = composition->height; |
| 467 | newComposition->duration = composition->duration; |
| 468 | newComposition->frameRate = composition->frameRate; |
| 469 | newComposition->id = originalID; |
| 470 | newComposition->backgroundColor = composition->backgroundColor; |
| 471 | |
| 472 | newComposition->audioBytes = composition->audioBytes; |
| 473 | newComposition->audioMarkers = composition->audioMarkers; |
| 474 | newComposition->audioStartTime = composition->audioStartTime; |
| 475 | composition->audioBytes = nullptr; |
| 476 | composition->audioMarkers.clear(); |
| 477 | composition->audioStartTime = pag::ZeroFrame; |
| 478 | auto iter = std::find(compositions.begin(), compositions.end(), composition); |
| 479 | if (iter != compositions.end()) { |
| 480 | compositions.insert(iter + 1, newComposition); |
| 481 | } |
| 482 | |
| 483 | auto sessionIter = |
| 484 | std::find(session->compositions.begin(), session->compositions.end(), composition); |
| 485 | if (sessionIter != session->compositions.end()) { |
| 486 | session->compositions.insert(sessionIter + 1, newComposition); |
no test coverage detected