Skip to content

Commit ae1565b

Browse files
committed
android: Fix no-op swizzle to actually convert from BGR(A) to RGB(A)
When a temporary buffer copy for swizzling and padding was implemented in commit a16fb9a ("android: Implement format swizzle via buffer copies"), the swizzle was implemented incorrectly and kept the b component in the lowest byte matching `softbuffer`'s BGR order while Android only has RGB formats. The inversion in the comment and forgotten alpha channel didn't make things any clearer.
1 parent a9bae73 commit ae1565b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backends/android.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl
160160
assert_eq!(output.len(), input.len() * 4);
161161

162162
for (i, pixel) in input.iter().enumerate() {
163-
// Swizzle colors from RGBX to BGR
164-
let [b, g, r, _] = pixel.to_le_bytes();
165-
output[i * 4].write(b);
163+
// Swizzle colors from BGR(A) to RGB(A)
164+
let [b, g, r, a] = pixel.to_le_bytes();
165+
output[i * 4].write(r);
166166
output[i * 4 + 1].write(g);
167-
output[i * 4 + 2].write(r);
168-
// TODO alpha?
167+
output[i * 4 + 2].write(b);
168+
output[i * 4 + 3].write(a);
169169
}
170170
}
171171
Ok(())

0 commit comments

Comments
 (0)