Mir

Code review comment for lp:~alan-griffiths/mir/more-surface-resize

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

122+ auto const error = new_size.height.as_int()*(long)ar.width - new_size.width.as_int()*(long)ar.height;
123+
124+ if (error > 0)
125+ {
126+ if (new_size.height.as_int() > new_size.width.as_int())
127+ {
128+ new_size.width = new_size.width + DeltaX((error+(ar.height-1))/ar.height);
129+ }
130+ else
131+ {
132+ new_size.height = new_size.height - DeltaY((error+(ar.width-1))/ar.width);
133+ }
134+ }

Some questions (Aw=aspect W, Ah=aspect H):

1. In this case, since W/H < Aw/Ah, we can either increase W or decrease H to increase the ratio, as is done in the two branches of the if statement. What's the rationale behind using the relation between W and H to decide whether to change W or H?

2. What's the logic behind the formula in DeltaX (and DeltaY respectively)? If we want W/H to reach Aw/Ah we could increase W by error/Ah, so it's not clear why we need the other terms (the proposed formula leads to an increase of error/Ah + 1 + 1/Ah).

It would be good to add a comment documenting how the proposed computations and decisions work.

review: Needs Information

« Back to merge proposal