mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 23:08:39 +09: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:
parent
8b4b6f8ebd
commit
9b4c0ef4e9
1 changed files with 6 additions and 0 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue