opti in addBuffer (use of std::for_each)

This commit is contained in:
Clément Le Bihan
2021-07-06 22:43:26 +02:00
parent 00435259c4
commit a3ddadacc5
+13 -2
View File
@@ -82,12 +82,23 @@ namespace ComSquare::PPU::Utils
static void addBuffer(std::array<std::array<uint32_t, DEST_SIZE_Y>, DEST_SIZE_X> &bufferDest,
const std::array<std::array<uint32_t, SRC_SIZE_Y>, SRC_SIZE_X> &bufferSrc)
{
for (unsigned long i = 0; i < bufferSrc.size(); i++) {
int i = 0;
int j = 0;
std::for_each(bufferSrc.begin(), bufferSrc.end(), [&bufferDest, &i, &j](auto &sourceRow) {
i++;
std::for_each(sourceRow.begin(), sourceRow.end(), [&bufferDest, &i, &j](auto &pixel) {
if (pixel > 0xFF)
bufferDest[i][j] = pixel;
j++;
});
j = 0;
});
/* for (unsigned long i = 0; i < bufferSrc.size(); i++) {
for (unsigned long j = 0; j < bufferSrc[i].size(); j++) {
if (bufferSrc[i][j] > 0xFF) // 0xFF correspond to a black pixel with full brightness
bufferDest[i][j] = bufferSrc[i][j];
}
}
}*/
}
}