- // If not, look at the input phases, if any. We select the largest one
- // (really assuming they all have the same aspect currently), by pixel count.
- if (!phase->inputs.empty()) {
- unsigned best_width = 0, best_height = 0;
- for (unsigned i = 0; i < phase->inputs.size(); ++i) {
- Node *input = phase->inputs[i];
- assert(input->phase->output_width != 0);
- assert(input->phase->output_height != 0);
- if (input->phase->output_width * input->phase->output_height > best_width * best_height) {
- best_width = input->phase->output_width;
- best_height = input->phase->output_height;
- }
+ // If not, look at the input phases and textures.
+ // We select the largest one (by fit into the current aspect).
+ unsigned best_width = 0;
+ for (unsigned i = 0; i < phase->inputs.size(); ++i) {
+ Node *input = phase->inputs[i];
+ assert(input->phase->output_width != 0);
+ assert(input->phase->output_height != 0);
+ unsigned width = fit_rectangle_to_aspect(input->phase->output_width, input->phase->output_height);
+ if (width > best_width) {
+ best_width = width;