citra/src/common/texture.cpp

23 lines
749 B
C++
Raw Normal View History

// Copyright 2019 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <algorithm>
2019-08-06 15:54:12 +00:00
#include <vector>
#include "common/assert.h"
#include "common/common_types.h"
namespace Common {
void FlipRGBA8Texture(std::vector<u8>& tex, u64 width, u64 height) {
ASSERT(tex.size() == width * height * 4);
const u64 line_size = width * 4;
for (u64 line = 0; line < height / 2; line++) {
const u32 offset_1 = line * line_size;
const u32 offset_2 = (height - line - 1) * line_size;
2019-08-06 15:54:12 +00:00
// Swap lines
std::swap_ranges(tex.begin() + offset_1, tex.begin() + offset_1 + line_size,
tex.begin() + offset_2);
2019-08-06 15:54:12 +00:00
}
}
} // namespace Common