VideoFlint / Cabbage

A video composition framework build on top of AVFoundation. It's simple to use and easy to extend.
MIT License
1.52k stars 221 forks source link

Applying user transform before content mode in TrackConfiguration #57

Closed gazadge closed 3 years ago

gazadge commented 3 years ago

Context: TrackConfiguration's transform property lets developers applying custom transformations on TrackItem while TrackConfiguration's contentMode is responsible for how the TrackItem's content is displayed on screen (aspectFit/aspectFill/custom).

Issue: The CGAffineTransform stored in TrackConfiguration's transform property gets applied only after the contentMode transformations, so if a user transformation (e.g. rotation by 90 degrees) is set then .aspectFit and .aspectFill content modes won't work as expected:

https://github.com/VideoFlint/Cabbage/blob/e65b80fc04c026d14ca0a3a3ed0567d597233f86/Cabbage/Sources/Track/Configuration/TrackConfiguration.swift#L61-L84

Proposed solution: Move the user transform implementation just before the contentMode transformations.

@vitoziv what do you think? I would expect the content modes to work even if the TrackItem is e.g. rotated via the transform property, but I also don't know how you specify the purpose of transform property.

I'll create a pull request for this, please let me know what's your take on this proposal.

vitoziv commented 3 years ago

Make sense, apply transform before content mode is better in this case.

gazadge commented 3 years ago

@vitoziv thank you for your fast response! 👍

I updated the pod version to 0.5.1 in the podspec. Can you draft a new release for the repository with version 0.5.1 so this patch can be published on Cocoapods?

vitoziv commented 3 years ago

I pushed version 0.5.1 to Cocoapods, you can try it later.

gazadge commented 3 years ago

Awesome, thanks Vito!