make sure to take the buffer's orientation into account. Change-Id: I9fef89e66368ad2dec1cb8c7b77ac2b3b4858efb