Skip to content

Commit

Permalink
APNG support
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Sep 14, 2023
1 parent bafaf13 commit 3b5cd6e
Show file tree
Hide file tree
Showing 5 changed files with 774 additions and 35 deletions.
16 changes: 9 additions & 7 deletions src/common/textures/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ static const CopyFunc copyfuncs[][12]={
COPY_FUNCS(bCopyAlpha),
COPY_FUNCS(bCopyNewAlpha),
COPY_FUNCS(bOverlay),
COPY_FUNCS(bOverwrite)
COPY_FUNCS(bOverwrite),
COPY_FUNCS(bComposeAlpha)
};
#undef COPY_FUNCS

Expand Down Expand Up @@ -257,21 +258,21 @@ bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
step_y = pstep_y;
break;

case 1: // rotate 90° right
case 1: // rotate 90 right
pixxoffset = 0;
pixyoffset = srcheight - 1;
step_x = -pstep_y;
step_y = pstep_x;
break;

case 2: // rotate 180°
case 2: // rotate 180
pixxoffset = srcwidth - 1;
pixyoffset = srcheight - 1;
step_x = -pstep_x;
step_y = -pstep_y;
break;

case 3: // rotate 90° left
case 3: // rotate 90 left
pixxoffset = srcwidth - 1;
pixyoffset = 0;
step_x = pstep_y;
Expand All @@ -285,7 +286,7 @@ bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
step_y = pstep_y;
break;

case 5: // flip horizontally and rotate 90° right
case 5: // flip horizontally and rotate 90 right
pixxoffset = srcwidth - 1;
pixyoffset = srcheight - 1;
step_x = -pstep_y;
Expand All @@ -299,7 +300,7 @@ bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
step_y = -pstep_y;
break;

case 7: // flip horizontally and rotate 90° left
case 7: // flip horizontally and rotate 90 left
pixxoffset = 0;
pixyoffset = 0;
step_x = pstep_y;
Expand Down Expand Up @@ -443,7 +444,8 @@ static const CopyPalettedFunc copypalettedfuncs[]=
iCopyPaletted<cBGRA, bCopyAlpha>,
iCopyPaletted<cBGRA, bCopyNewAlpha>,
iCopyPaletted<cBGRA, bOverlay>,
iCopyPaletted<cBGRA, bOverwrite>
iCopyPaletted<cBGRA, bOverwrite>,
iCopyPaletted<cBGRA, bComposeAlpha>
};

//===========================================================================
Expand Down
9 changes: 8 additions & 1 deletion src/common/textures/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ enum ECopyOp
OP_COPYALPHA,
OP_COPYNEWALPHA,
OP_OVERLAY,
OP_OVERWRITE
OP_OVERWRITE,
OP_COMPOSEALPHA // Only intended for internal use.
};

struct FCopyInfo
Expand Down Expand Up @@ -507,5 +508,11 @@ struct bModulate
static __forceinline bool ProcessAlpha0() { return false; }
};

struct bComposeAlpha
{
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = (s*255 + d*(255-s))/255; }
static __forceinline bool ProcessAlpha0() { return false; }
};

#endif
Loading

0 comments on commit 3b5cd6e

Please sign in to comment.