/ src / common / texture.cpp
texture.cpp
 1  // Copyright 2019 Citra Emulator Project
 2  // Licensed under GPLv2 or any later version
 3  // Refer to the license.txt file included.
 4  
 5  #include <algorithm>
 6  #include "common/assert.h"
 7  #include "common/texture.h"
 8  
 9  namespace Common {
10  
11  void FlipRGBA8Texture(std::span<u8> tex, u32 width, u32 height) {
12      ASSERT(tex.size() == width * height * 4);
13      const u32 line_size = width * 4;
14      for (u32 line = 0; line < height / 2; line++) {
15          const u32 offset_1 = line * line_size;
16          const u32 offset_2 = (height - line - 1) * line_size;
17          // Swap lines
18          std::swap_ranges(tex.begin() + offset_1, tex.begin() + offset_1 + line_size,
19                           tex.begin() + offset_2);
20      }
21  }
22  
23  } // namespace Common