ReactOS 0.4.15-dev-8219-ge8b88cf
alphablend.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for alphablend.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL APIENTRY EngAlphaBlend (_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoSource, _In_opt_ CLIPOBJ *ClipRegion, _In_opt_ XLATEOBJ *ColorTranslation, _In_ RECTL *DestRect, _In_ RECTL *SourceRect, _In_ BLENDOBJ *BlendObj)
 
BOOL APIENTRY IntEngAlphaBlend (_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoSource, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ RECTL *prclDest, _In_ RECTL *prclSrc, _In_ BLENDOBJ *pBlendObj)
 
BOOL APIENTRY NtGdiEngAlphaBlend (IN SURFOBJ *psoDest, IN SURFOBJ *psoSource, IN CLIPOBJ *ClipRegion, IN XLATEOBJ *ColorTranslation, IN PRECTL upDestRect, IN PRECTL upSourceRect, IN BLENDOBJ *BlendObj)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file alphablend.c.

Function Documentation

◆ EngAlphaBlend()

BOOL APIENTRY EngAlphaBlend ( _Inout_ SURFOBJ psoDest,
_In_ SURFOBJ psoSource,
_In_opt_ CLIPOBJ ClipRegion,
_In_opt_ XLATEOBJ ColorTranslation,
_In_ RECTL DestRect,
_In_ RECTL SourceRect,
_In_ BLENDOBJ BlendObj 
)

Definition at line 20 of file alphablend.c.

28{
29 RECTL InputRect;
30 RECTL OutputRect;
31 RECTL ClipRect;
32 RECTL CombinedRect;
33 RECTL Rect;
34 POINTL Translate;
35 INTENG_ENTER_LEAVE EnterLeaveSource;
36 INTENG_ENTER_LEAVE EnterLeaveDest;
37 SURFOBJ* InputObj;
38 SURFOBJ* OutputObj;
39 LONG ClippingType;
40 RECT_ENUM RectEnum;
41 BOOL EnumMore;
42 ULONG i;
43 BOOLEAN Ret;
44
45 DPRINT("EngAlphaBlend(psoDest:0x%p, psoSource:0x%p, ClipRegion:0x%p, ColorTranslation:0x%p,\n", psoDest, psoSource, ClipRegion, ColorTranslation);
46 DPRINT(" DestRect:{0x%x, 0x%x, 0x%x, 0x%x}, SourceRect:{0x%x, 0x%x, 0x%x, 0x%x},\n",
47 DestRect->left, DestRect->top, DestRect->right, DestRect->bottom,
48 SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom);
49 DPRINT(" BlendObj:{0x%x, 0x%x, 0x%x, 0x%x}\n", BlendObj->BlendFunction.BlendOp,
50 BlendObj->BlendFunction.BlendFlags, BlendObj->BlendFunction.SourceConstantAlpha,
51 BlendObj->BlendFunction.AlphaFormat);
52
53 /* Validate output */
54 OutputRect = *DestRect;
55 RECTL_vMakeWellOrdered(&OutputRect);
56
57 /* Validate input */
58 InputRect = *SourceRect;
59 RECTL_vMakeWellOrdered(&InputRect);
60 if ( (InputRect.top < 0) || (InputRect.bottom < 0) ||
61 (InputRect.left < 0) || (InputRect.right < 0) ||
62 InputRect.right > psoSource->sizlBitmap.cx ||
63 InputRect.bottom > psoSource->sizlBitmap.cy )
64 {
66 return FALSE;
67 }
68
69 if (psoDest == psoSource &&
70 !(OutputRect.left >= SourceRect->right || InputRect.left >= OutputRect.right ||
71 OutputRect.top >= SourceRect->bottom || InputRect.top >= OutputRect.bottom))
72 {
73 DPRINT1("Source and destination rectangles overlap!\n");
74 return FALSE;
75 }
76
77 if (BlendObj->BlendFunction.BlendOp != AC_SRC_OVER)
78 {
79 DPRINT1("BlendOp != AC_SRC_OVER (0x%x)\n", BlendObj->BlendFunction.BlendOp);
80 return FALSE;
81 }
82 if (BlendObj->BlendFunction.BlendFlags != 0)
83 {
84 DPRINT1("BlendFlags != 0 (0x%x)\n", BlendObj->BlendFunction.BlendFlags);
85 return FALSE;
86 }
87 if ((BlendObj->BlendFunction.AlphaFormat & ~AC_SRC_ALPHA) != 0)
88 {
89 DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendObj->BlendFunction.AlphaFormat);
90 return FALSE;
91 }
92
93 /* Check if there is anything to draw */
94 if (ClipRegion != NULL &&
95 (ClipRegion->rclBounds.left >= ClipRegion->rclBounds.right ||
96 ClipRegion->rclBounds.top >= ClipRegion->rclBounds.bottom))
97 {
98 /* Nothing to do */
99 return TRUE;
100 }
101
102 /* Now call the DIB function */
103 if (!IntEngEnter(&EnterLeaveSource, psoSource, &InputRect, TRUE, &Translate, &InputObj))
104 {
105 return FALSE;
106 }
107 InputRect.left += Translate.x;
108 InputRect.right += Translate.x;
109 InputRect.top += Translate.y;
110 InputRect.bottom += Translate.y;
111
112 if (!IntEngEnter(&EnterLeaveDest, psoDest, &OutputRect, FALSE, &Translate, &OutputObj))
113 {
114 IntEngLeave(&EnterLeaveSource);
115 return FALSE;
116 }
117 OutputRect.left += Translate.x;
118 OutputRect.right += Translate.x;
119 OutputRect.top += Translate.y;
120 OutputRect.bottom += Translate.y;
121
122 ASSERT(InputRect.left <= InputRect.right && InputRect.top <= InputRect.bottom);
123
124 Ret = FALSE;
125 ClippingType = (ClipRegion == NULL) ? DC_TRIVIAL : ClipRegion->iDComplexity;
126 switch (ClippingType)
127 {
128 case DC_TRIVIAL:
130 OutputObj, InputObj, &OutputRect, &InputRect, ClipRegion, ColorTranslation, BlendObj);
131 break;
132
133 case DC_RECT:
134 ClipRect.left = ClipRegion->rclBounds.left + Translate.x;
135 ClipRect.right = ClipRegion->rclBounds.right + Translate.x;
136 ClipRect.top = ClipRegion->rclBounds.top + Translate.y;
137 ClipRect.bottom = ClipRegion->rclBounds.bottom + Translate.y;
138 if (RECTL_bIntersectRect(&CombinedRect, &OutputRect, &ClipRect))
139 {
140 /* take into acount clipping results when calculating new input rect (scaled to input rect size) */
141 Rect.left = InputRect.left + (CombinedRect.left - OutputRect.left) * (InputRect.right - InputRect.left) / (OutputRect.right - OutputRect.left);
142 Rect.right = InputRect.right + (CombinedRect.right - OutputRect.right) * (InputRect.right - InputRect.left) / (OutputRect.right - OutputRect.left);
143 Rect.top = InputRect.top + (CombinedRect.top - OutputRect.top) * (InputRect.bottom - InputRect.top) / (OutputRect.bottom - OutputRect.top);
144 Rect.bottom = InputRect.bottom + (CombinedRect.bottom - OutputRect.bottom) * (InputRect.bottom - InputRect.top) / (OutputRect.bottom - OutputRect.top);
145
146 /* Aplha blend one rect */
148 OutputObj, InputObj, &CombinedRect, &Rect, ClipRegion, ColorTranslation, BlendObj);
149 }
150 break;
151
152 case DC_COMPLEX:
153 Ret = TRUE;
155 do
156 {
157 EnumMore = CLIPOBJ_bEnum(ClipRegion,(ULONG) sizeof(RectEnum),
158 (PVOID) &RectEnum);
159
160 for (i = 0; i < RectEnum.c; i++)
161 {
162 ClipRect.left = RectEnum.arcl[i].left + Translate.x;
163 ClipRect.right = RectEnum.arcl[i].right + Translate.x;
164 ClipRect.top = RectEnum.arcl[i].top + Translate.y;
165 ClipRect.bottom = RectEnum.arcl[i].bottom + Translate.y;
166 if (RECTL_bIntersectRect(&CombinedRect, &OutputRect, &ClipRect))
167 {
168 /* take into acount clipping results when calculating new input rect (scaled to input rect size) */
169 Rect.left = InputRect.left + (CombinedRect.left - OutputRect.left) * (InputRect.right - InputRect.left) / (OutputRect.right - OutputRect.left);
170 Rect.right = InputRect.right + (CombinedRect.right - OutputRect.right) * (InputRect.right - InputRect.left) / (OutputRect.right - OutputRect.left);
171 Rect.top = InputRect.top + (CombinedRect.top - OutputRect.top) * (InputRect.bottom - InputRect.top) / (OutputRect.bottom - OutputRect.top);
172 Rect.bottom = InputRect.bottom + (CombinedRect.bottom - OutputRect.bottom) * (InputRect.bottom - InputRect.top) / (OutputRect.bottom - OutputRect.top);
173
174 /* Alpha blend one rect */
176 OutputObj, InputObj, &CombinedRect, &Rect, ClipRegion, ColorTranslation, BlendObj) && Ret;
177 }
178 }
179 }
180 while (EnumMore);
181 break;
182
183 default:
185 ASSERT(FALSE);
186 break;
187 }
188
189 IntEngLeave(&EnterLeaveDest);
190 IntEngLeave(&EnterLeaveSource);
191
192 return Ret;
193}
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:118
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
switch(r->id)
Definition: btrfs.c:3046
BOOL APIENTRY IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave, SURFOBJ *psoDest, RECTL *DestRect, BOOL ReadOnly, POINTL *Translate, SURFOBJ **ppsoOutput)
Definition: engmisc.c:15
BOOL APIENTRY IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave)
Definition: engmisc.c:162
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
#define AC_SRC_ALPHA
Definition: alphablend.c:9
long LONG
Definition: pedump.c:60
#define DPRINT
Definition: sndvol32.h:73
PFN_DIB_AlphaBlend DIB_AlphaBlend
Definition: dib.h:54
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
ULONG c
Definition: vgaddi.h:78
RECTL arcl[ENUM_RECT_LIMIT]
Definition: vgaddi.h:79
ULONG iBitmapFormat
Definition: winddi.h:1215
uint32_t ULONG
Definition: typedefs.h:59
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
#define DC_TRIVIAL
Definition: winddi.h:259
#define CT_RECTANGLES
Definition: winddi.h:1317
ENGAPI BOOL APIENTRY CLIPOBJ_bEnum(_In_ CLIPOBJ *pco, _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pul)
Definition: clip.c:319
#define DC_COMPLEX
Definition: winddi.h:261
ENGAPI ULONG APIENTRY CLIPOBJ_cEnumStart(_Inout_ CLIPOBJ *pco, _In_ BOOL bAll, _In_ ULONG iType, _In_ ULONG iDirection, _In_ ULONG cLimit)
Definition: clip.c:255
#define DC_RECT
Definition: winddi.h:260
#define CD_ANY
Definition: winddi.h:1326
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define AC_SRC_OVER
Definition: wingdi.h:1369

Referenced by IntEngAlphaBlend(), NtGdiEngAlphaBlend(), and PanAlphaBlend().

◆ IntEngAlphaBlend()

BOOL APIENTRY IntEngAlphaBlend ( _Inout_ SURFOBJ psoDest,
_In_ SURFOBJ psoSource,
_In_opt_ CLIPOBJ pco,
_In_opt_ XLATEOBJ pxlo,
_In_ RECTL prclDest,
_In_ RECTL prclSrc,
_In_ BLENDOBJ pBlendObj 
)

Definition at line 197 of file alphablend.c.

205{
206 BOOL ret = FALSE;
207 SURFACE *psurfDest;
208
209 ASSERT(psoDest);
210 ASSERT(psoSource);
213 //ASSERT(pBlendObj);
214
215 /* If no clip object is given, use trivial one */
216 if (!pco) pco = (CLIPOBJ *)&gxcoTrivial;
217
218 /* Check if there is anything to draw */
219 if ((pco->rclBounds.left >= pco->rclBounds.right) ||
220 (pco->rclBounds.top >= pco->rclBounds.bottom))
221 {
222 /* Nothing to do */
223 return TRUE;
224 }
225
226 psurfDest = CONTAINING_RECORD(psoDest, SURFACE, SurfObj);
227
228 /* Call the driver's DrvAlphaBlend if available */
229 if (psurfDest->flags & HOOK_ALPHABLEND)
230 {
231 ret = GDIDEVFUNCS(psoDest).AlphaBlend(
232 psoDest, psoSource, pco, pxlo,
234 }
235
236 if (!ret)
237 {
238 ret = EngAlphaBlend(psoDest, psoSource, pco, pxlo,
240 }
241
242 return ret;
243}
FLONG flags
Definition: surface.h:10
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
int ret
BOOL APIENTRY EngAlphaBlend(_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoSource, _In_opt_ CLIPOBJ *ClipRegion, _In_opt_ XLATEOBJ *ColorTranslation, _In_ RECTL *DestRect, _In_ RECTL *SourceRect, _In_ BLENDOBJ *BlendObj)
Definition: alphablend.c:20
XCLIPOBJ gxcoTrivial
Definition: bitblt.c:20
#define GDIDEVFUNCS(SurfObj)
Definition: surface.h:106
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_ RECTL * prclSrc
Definition: winddi.h:3418
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ * pxlo
Definition: winddi.h:3416
#define HOOK_ALPHABLEND
Definition: winddi.h:1435
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_ RECTL _In_ BLENDOBJ * pBlendObj
Definition: winddi.h:3419
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL * prclDest
Definition: winddi.h:3417
_In_ SURFOBJ _In_ CLIPOBJ * pco
Definition: winddi.h:3415

Referenced by IntShowMousePointer(), NtGdiAlphaBlend(), and UserDrawIconEx().

◆ NtGdiEngAlphaBlend()

BOOL APIENTRY NtGdiEngAlphaBlend ( IN SURFOBJ psoDest,
IN SURFOBJ psoSource,
IN CLIPOBJ ClipRegion,
IN XLATEOBJ ColorTranslation,
IN PRECTL  upDestRect,
IN PRECTL  upSourceRect,
IN BLENDOBJ BlendObj 
)

Definition at line 250 of file alphablend.c.

257{
258 RECTL DestRect;
259 RECTL SourceRect;
260
262 {
263 ProbeForRead(upDestRect, sizeof(RECTL), 1);
264 RtlCopyMemory(&DestRect,upDestRect, sizeof(RECTL));
265
266 ProbeForRead(upSourceRect, sizeof(RECTL), 1);
267 RtlCopyMemory(&SourceRect, upSourceRect, sizeof(RECTL));
268
269 }
271 {
272 _SEH2_YIELD(return FALSE);
273 }
274 _SEH2_END;
275
276 return EngAlphaBlend(psoDest, psoSource, ClipRegion, ColorTranslation, &DestRect, &SourceRect, BlendObj);
277}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263