Refactor clipIfOverlaps() so it does not have a return value. #947
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. Additionally, make sure you've done all of these things:
PR Description
What type of PR is this? (Check one of the boxes below)
What does this pull request do?
This change removes the return value for clipIfOverlaps() and updates all callers. This was done to address a comment made in #930 (comment)
Have you tested your changes (if applicable)? If so, how?
Yes. I verified all the tests still pass on Windows and Linux (https://github.com/acolwell/Natron/actions/runs/7944427820). I also did some testing on Windows using an installer build including these changes (https://github.com/acolwell/Natron/actions/runs/7944419132). I did not notice any issues associated with these changes.
Futher details of this pull request
The vast majority of the changes do not change the existing behavior. The only case where there is technically a behavior change is in Image::halveRoIForDepth() where a clipIfOverlaps() is changed to an intersect(). I've determined that this is safe though because it appears that the roi is verified to be contained within the bounds of the image by the downscaleMipmap() call that eventually invokes halveRoIForDepth(). This guarantees that roi and srcBounds, in halveRoIForDepth(), should always overlap which means clipIfOverlaps() is equivalent to an intersect(). This was not immediately obvious when looking at the code, so I added assert(bounds_.contains(roi)) calls to the function levels between downscaleMipmap() and halveRoIForDepth() to help make it clear this precondition is expected to be maintained at each of these levels.
I suspect many/all of the remaining clipIfOverlap() calls that remain can likely be replaced with clip() or intersect(), but I have not sufficiently proved the safety of those transformations to myself. What I have in this PR I believe are perfectly safe and fulfill my previous commitment to remove the clipIfOverlaps() return value. I'll look into replacing the other calls to clipIfOverlap() as time permits and I have figured out how to prove they are safe.