From 02294ee7175ac3e2b400569508a432c19ee2be13 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier Date: Tue, 15 Aug 2017 23:28:36 +0000 Subject: [PATCH] GRAPHICS: Use memcpy when copying to same-format-no-alpha destination Accelerates when source format is compatible with destination except for alpha channel bit-loss. Ex: from: 32bits A << 24 | R << 16 | G << 8 | B to: 32bits R << 16 | G << 8 | B --- graphics/pixelbuffer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/graphics/pixelbuffer.cpp b/graphics/pixelbuffer.cpp index e762b94215b..306cf14cbe1 100644 --- a/graphics/pixelbuffer.cpp +++ b/graphics/pixelbuffer.cpp @@ -87,7 +87,17 @@ void PixelBuffer::clear(int length) { } void PixelBuffer::copyBuffer(int thisFrom, int otherFrom, int length, const PixelBuffer &buf) { - if (buf._format == _format) { + if (buf._format.bytesPerPixel == _format.bytesPerPixel && + buf._format.rShift == _format.rShift && + buf._format.gShift == _format.gShift && + buf._format.bShift == _format.bShift && + buf._format.rLoss == _format.rLoss && + buf._format.gLoss == _format.gLoss && + buf._format.bLoss == _format.bLoss && ( + _format.aLoss = 8 || + buf._format.aLoss == _format.aLoss + ) + ) { memcpy(_buffer + thisFrom * _format.bytesPerPixel, buf._buffer + otherFrom * _format.bytesPerPixel, length * _format.bytesPerPixel); } else { uint8 r, g, b, a;