[common] rects: refactor rect buffer copy code to common module

This also fixes a bug of accidentally multiplying the stride by 4 when
the stride is already in bytes and not pixels.
This commit is contained in:
Quantum
2021-08-06 23:51:07 -04:00
committed by Geoffrey McRae
parent 4205e49786
commit cab95c5eed
5 changed files with 224 additions and 150 deletions

View File

@@ -26,6 +26,7 @@
#include "common/option.h"
#include "common/framebuffer.h"
#include "common/event.h"
#include "common/rects.h"
#include "common/thread.h"
#include "common/KVMFR.h"
#include <assert.h>
@@ -482,17 +483,6 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame,
return CAPTURE_RESULT_OK;
}
inline static void rectCopyUnaligned(uint8_t * dest, uint8_t * src, int ystart,
int yend, int dx, int dstStride, int srcStride, int width)
{
for (int i = ystart; i < yend; ++i)
{
unsigned int srcOffset = i * srcStride + dx;
unsigned int dstOffset = i * dstStride + dx;
memcpy(dest + dstOffset, src + srcOffset, width);
}
}
static CaptureResult nvfbc_getFrame(FrameBuffer * frame,
const unsigned int height, int frameIndex)
{