22 #include <freerdp/config.h>
24 #include <freerdp/types.h>
25 #include <freerdp/primitives.h>
27 #include "prim_internal.h"
28 #include "prim_alphaComp.h"
30 #define ALPHA(_k_) (((_k_)&0xFF000000U) >> 24)
33 static pstatus_t general_alphaComp_argb(
const BYTE* pSrc1, UINT32 src1Step,
const BYTE* pSrc2,
34 UINT32 src2Step, BYTE* pDst, UINT32 dstStep, UINT32 width,
37 for (
size_t y = 0; y < height; y++)
39 const UINT32* sptr1 = (
const UINT32*)(pSrc1 + y * src1Step);
40 const UINT32* sptr2 = (
const UINT32*)(pSrc2 + y * src2Step);
41 UINT32* dptr = (UINT32*)(pDst + y * dstStep);
43 for (
size_t x = 0; x < width; x++)
45 const UINT32 src1 = *sptr1++;
46 const UINT32 src2 = *sptr2++;
47 UINT32 alpha = ALPHA(src1) + 1;
69 UINT32 s2rb = src2 & 0x00FF00FFU;
70 UINT32 s2ag = (src2 >> 8) & 0x00FF00FFU;
71 UINT32 s1rb = src1 & 0x00FF00FFU;
72 UINT32 s1ag = (src1 >> 8) & 0x00FF00FFU;
73 UINT32 drb = s1rb - s2rb;
74 UINT32 dag = s1ag - s2ag;
77 rb = ((drb >> 8) + s2rb) & 0x00FF00FFU;
78 ag = (((dag >> 8) + s2ag) << 8) & 0xFF00FF00U;
84 return PRIMITIVES_SUCCESS;
88 void primitives_init_alphaComp(
primitives_t* WINPR_RESTRICT prims)
90 prims->alphaComp_argb = general_alphaComp_argb;
93 void primitives_init_alphaComp_opt(
primitives_t* WINPR_RESTRICT prims)
95 primitives_init_alphaComp_sse3(prims);