mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 13:58:49 +00:00
Issue #2040 - Pre-multiply the alpha values in our JXL decode buffer.
Using selective calculation (only if not opaque) and fast integer math here should optimize well in compilers.
This commit is contained in:
@@ -145,6 +145,12 @@ nsJXLDecoder::ReadJXLData(const char* aData, size_t aLength)
|
||||
// We currently have a channel ordering mis-match here.
|
||||
for (uint8_t* pixPtr = rowPtr; pixPtr < rowPtr + mInfo.xsize * 4; pixPtr+=4){
|
||||
std::swap(pixPtr[0], pixPtr[2]);
|
||||
// Pre-multiply, too
|
||||
if (pixPtr[3] < 255) {
|
||||
pixPtr[0]=((uint16_t)pixPtr[0]*(uint16_t)pixPtr[3]) >> 8;
|
||||
pixPtr[1]=((uint16_t)pixPtr[1]*(uint16_t)pixPtr[3]) >> 8;
|
||||
pixPtr[2]=((uint16_t)pixPtr[2]*(uint16_t)pixPtr[3]) >> 8;
|
||||
}
|
||||
}
|
||||
pipe->WriteBuffer(reinterpret_cast<uint32_t*>(rowPtr));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user