Skip to content

Commit

Permalink
Added comments to computeOptimumTileSize. Also, Ensure isDivExact is …
Browse files Browse the repository at this point in the history
…set to false if needed.
  • Loading branch information
fthevenet committed Mar 6, 2020
1 parent e13b5a0 commit 9ec2d25
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1524,13 +1524,19 @@ private void renderWholeImage(int x, int y, int w, int h, ResourceFactory rf, Qu
}

private int computeOptimumTileSize(int size, int maxSize, AtomicBoolean isDivExact) {
// This methods attempts to find the smallest integer divider for the provided `size`
// while the result of the division is less than `maxSize`.
// It tests all potential dividers from 2 to 6 and returns the result of the division
// if all conditions can be satisfied or, failing that, `maxSize`.
// The value for `isDivExact` reflects whether or not an exact divider could be found.
for (int n = 2; n <= 6; n++) {
int optimumSize = size / n;
if (optimumSize <= maxSize && optimumSize * n == size) {
isDivExact.set(true);
return optimumSize;
}
}
isDivExact.set(false);
return maxSize;
}

Expand Down

0 comments on commit 9ec2d25

Please sign in to comment.