2019-08-06 11:24:07 -05:00
|
|
|
// Copyright 2019 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <algorithm>
|
2019-08-06 10:54:12 -05:00
|
|
|
#include "common/assert.h"
|
2023-04-26 23:38:28 -05:00
|
|
|
#include "common/texture.h"
|
2019-08-06 10:54:12 -05:00
|
|
|
|
|
|
|
namespace Common {
|
2023-04-26 23:38:28 -05:00
|
|
|
|
|
|
|
void FlipRGBA8Texture(std::span<u8> tex, u32 width, u32 height) {
|
2019-08-06 10:54:12 -05:00
|
|
|
ASSERT(tex.size() == width * height * 4);
|
2022-05-11 23:23:23 -05:00
|
|
|
const u32 line_size = width * 4;
|
|
|
|
for (u32 line = 0; line < height / 2; line++) {
|
2019-08-06 11:24:07 -05:00
|
|
|
const u32 offset_1 = line * line_size;
|
|
|
|
const u32 offset_2 = (height - line - 1) * line_size;
|
2019-08-06 10:54:12 -05:00
|
|
|
// Swap lines
|
2019-08-06 11:24:07 -05:00
|
|
|
std::swap_ranges(tex.begin() + offset_1, tex.begin() + offset_1 + line_size,
|
|
|
|
tex.begin() + offset_2);
|
2019-08-06 10:54:12 -05:00
|
|
|
}
|
|
|
|
}
|
2023-04-26 23:38:28 -05:00
|
|
|
|
2019-08-06 11:24:07 -05:00
|
|
|
} // namespace Common
|