1
0
Fork 0
forked from wry/wry

render: fix sampling of transformed buffers with crop

This commit is contained in:
Julian Orth 2024-07-11 20:43:47 +02:00
parent ae87b3ef7a
commit 73c5010e4e

View file

@ -72,13 +72,43 @@ impl SampleRect {
let y2 = self.y2;
match self.buffer_transform {
None => [[x2, y1], [x1, y1], [x2, y2], [x1, y2]],
Rotate90 => [[y1, x1], [y1, x2], [y2, x1], [y2, x2]],
Rotate180 => [[x1, y2], [x2, y2], [x1, y1], [x2, y1]],
Rotate270 => [[y2, x2], [y2, x1], [y1, x2], [y1, x1]],
Flip => [[x1, y1], [x2, y1], [x1, y2], [x2, y2]],
Rotate90 => [
[y1, 1.0 - x2],
[y1, 1.0 - x1],
[y2, 1.0 - x2],
[y2, 1.0 - x1],
],
Rotate180 => [
[1.0 - x2, 1.0 - y1],
[1.0 - x1, 1.0 - y1],
[1.0 - x2, 1.0 - y2],
[1.0 - x1, 1.0 - y2],
],
Rotate270 => [
[1.0 - y1, x2],
[1.0 - y1, x1],
[1.0 - y2, x2],
[1.0 - y2, x1],
],
Flip => [
[1.0 - x2, y1],
[1.0 - x1, y1],
[1.0 - x2, y2],
[1.0 - x1, y2],
],
FlipRotate90 => [[y1, x2], [y1, x1], [y2, x2], [y2, x1]],
FlipRotate180 => [[x2, y2], [x1, y2], [x2, y1], [x1, y1]],
FlipRotate270 => [[y2, x1], [y2, x2], [y1, x1], [y1, x2]],
FlipRotate180 => [
[x2, 1.0 - y1],
[x1, 1.0 - y1],
[x2, 1.0 - y2],
[x1, 1.0 - y2],
],
FlipRotate270 => [
[1.0 - y1, 1.0 - x2],
[1.0 - y1, 1.0 - x1],
[1.0 - y2, 1.0 - x2],
[1.0 - y2, 1.0 - x1],
],
}
}
}