ReactOS  r75385
bitblt.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for bitblt.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Typedefs

typedef BOOLEAN(APIENTRYPBLTRECTFUNC )(SURFOBJ *OutputObj, SURFOBJ *InputObj, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *OutputRect, POINTL *InputPoint, POINTL *MaskOrigin, BRUSHOBJ *pbo, POINTL *BrushOrigin, ROP4 Rop4)
 

Functions

static BOOLEAN APIENTRY BltMask (SURFOBJ *psoDest, SURFOBJ *psoSource, SURFOBJ *psoMask, XLATEOBJ *ColorTranslation, RECTL *prclDest, POINTL *pptlSource, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
 
static BOOLEAN APIENTRY BltPatCopy (SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *DestRect, POINTL *SourcePoint, POINTL *MaskPoint, BRUSHOBJ *pbo, POINTL *BrushPoint, DWORD Rop4)
 
static BOOLEAN APIENTRY CallDibBitBlt (SURFOBJ *OutputObj, SURFOBJ *InputObj, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *OutputRect, POINTL *InputPoint, POINTL *MaskOrigin, BRUSHOBJ *pbo, POINTL *BrushOrigin, ROP4 Rop4)
 
INT __cdecl abs (INT nm)
 
BOOL APIENTRY NtGdiEngBitBlt (IN SURFOBJ *psoTrg, IN SURFOBJ *psoSrc, IN SURFOBJ *psoMask, IN CLIPOBJ *pco, IN XLATEOBJ *pxlo, IN RECTL *prclTrg, IN POINTL *pptlSrc, IN POINTL *pptlMask, IN BRUSHOBJ *pbo, IN POINTL *pptlBrush, IN ROP4 Rop4)
 
BOOL APIENTRY EngBitBlt (_Inout_ SURFOBJ *psoTrg, _In_opt_ SURFOBJ *psoSrc, _In_opt_ SURFOBJ *psoMask, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ RECTL *prclTrg, _In_opt_ POINTL *pptlSrc, _In_opt_ POINTL *pptlMask, _In_opt_ BRUSHOBJ *pbo, _In_opt_ POINTL *pptlBrush, _In_ ROP4 rop4)
 
BOOL APIENTRY IntEngBitBlt (SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
 
static BOOLEAN APIENTRY AlphaBltMask (SURFOBJ *psoDest, SURFOBJ *psoSource, SURFOBJ *psoMask, XLATEOBJ *pxloRGB2Dest, XLATEOBJ *pxloBrush, RECTL *prclDest, POINTL *pptlSource, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush)
 
static BOOL APIENTRY EngMaskBitBlt (SURFOBJ *psoDest, SURFOBJ *psoMask, CLIPOBJ *ClipRegion, XLATEOBJ *DestColorTranslation, XLATEOBJ *SourceColorTranslation, RECTL *DestRect, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *BrushOrigin)
 
BOOL APIENTRY IntEngMaskBlt (_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoMask, _In_ CLIPOBJ *pco, _In_ XLATEOBJ *pxloDest, _In_ XLATEOBJ *pxloSource, _In_ RECTL *prclDest, _In_ POINTL *pptlMask, _In_ BRUSHOBJ *pbo, _In_ POINTL *pptlBrushOrg)
 

Variables

XCLIPOBJ gxcoTrivial
 

Macro Definition Documentation

#define NDEBUG

Definition at line 12 of file bitblt.c.

Typedef Documentation

typedef BOOLEAN(APIENTRY * PBLTRECTFUNC)(SURFOBJ *OutputObj, SURFOBJ *InputObj, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *OutputRect, POINTL *InputPoint, POINTL *MaskOrigin, BRUSHOBJ *pbo, POINTL *BrushOrigin, ROP4 Rop4)

Definition at line 30 of file bitblt.c.

Function Documentation

INT __cdecl abs ( INT  nm)
static BOOLEAN APIENTRY AlphaBltMask ( SURFOBJ psoDest,
SURFOBJ psoSource,
SURFOBJ psoMask,
XLATEOBJ pxloRGB2Dest,
XLATEOBJ pxloBrush,
RECTL prclDest,
POINTL pptlSource,
POINTL pptlMask,
BRUSHOBJ pbo,
POINTL pptlBrush 
)
static

Definition at line 727 of file bitblt.c.

Referenced by EngMaskBitBlt().

737 {
738  LONG i, j, dx, dy;
739  int r, g, b;
740  ULONG Background, BrushColor, NewColor;
741  BYTE *tMask, *lMask;
742 
743  ASSERT(psoSource == NULL);
744  ASSERT(pptlSource == NULL);
745 
746  dx = prclDest->right - prclDest->left;
747  dy = prclDest->bottom - prclDest->top;
748 
749  if (psoMask != NULL)
750  {
751  BrushColor = XLATEOBJ_iXlate(pxloBrush, pbo ? pbo->iSolidColor : 0);
752  r = (int)GetRValue(BrushColor);
753  g = (int)GetGValue(BrushColor);
754  b = (int)GetBValue(BrushColor);
755 
756  tMask = (PBYTE)psoMask->pvScan0 + (pptlMask->y * psoMask->lDelta) + pptlMask->x;
757  for (j = 0; j < dy; j++)
758  {
759  lMask = tMask;
760  for (i = 0; i < dx; i++)
761  {
762  if (*lMask > 0)
763  {
764  if (*lMask == 0xff)
765  {
767  psoDest, prclDest->left + i, prclDest->top + j, pbo ? pbo->iSolidColor : 0);
768  }
769  else
770  {
771  Background = DIB_GetSource(psoDest, prclDest->left + i, prclDest->top + j,
772  pxloBrush);
773 
774  NewColor =
775  RGB((*lMask * (r - GetRValue(Background)) >> 8) + GetRValue(Background),
776  (*lMask * (g - GetGValue(Background)) >> 8) + GetGValue(Background),
777  (*lMask * (b - GetBValue(Background)) >> 8) + GetBValue(Background));
778 
779  Background = XLATEOBJ_iXlate(pxloRGB2Dest, NewColor);
781  psoDest, prclDest->left + i, prclDest->top + j, Background);
782  }
783  }
784  lMask++;
785  }
786  tMask += psoMask->lDelta;
787  }
788  return TRUE;
789  }
790  else
791  {
792  return FALSE;
793  }
794 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TRUE
Definition: types.h:120
LONG lDelta
Definition: winddi.h:1213
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2912
long bottom
Definition: polytest.cpp:53
ULONG iBitmapFormat
Definition: winddi.h:1215
LONG y
Definition: windef.h:343
#define GetGValue(rgb)
Definition: wingdi.h:2913
long right
Definition: polytest.cpp:53
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define DIB_GetSource(SourceSurf, sx, sy, ColorTranslation)
Definition: dib.h:136
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
long top
Definition: polytest.cpp:53
PFN_DIB_PutPixel DIB_PutPixel
Definition: dib.h:45
smooth NULL
Definition: ftsmooth.c:513
long left
Definition: polytest.cpp:53
#define b
Definition: ke_i.h:79
GLboolean GLboolean g
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2917
LONG x
Definition: windef.h:342
ULONG iSolidColor
Definition: winddi.h:234
unsigned char BYTE
Definition: ntddk_ex.h:96
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
INT INT dy
Definition: msvc.h:65
unsigned int ULONG
Definition: retypes.h:1
#define GetBValue(rgb)
Definition: wingdi.h:2914
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:664
BYTE * PBYTE
Definition: pedump.c:66
PVOID pvScan0
Definition: winddi.h:1212
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
INT dx
Definition: msvc.h:65
static BOOLEAN APIENTRY BltMask ( SURFOBJ psoDest,
SURFOBJ psoSource,
SURFOBJ psoMask,
XLATEOBJ ColorTranslation,
RECTL prclDest,
POINTL pptlSource,
POINTL pptlMask,
BRUSHOBJ pbo,
POINTL pptlBrush,
ROP4  Rop4 
)
static

Definition at line 42 of file bitblt.c.

Referenced by EngBitBlt(), and EngMaskBitBlt().

52 {
53  LONG x, y, cx, cy;
54  BYTE *pjMskLine, *pjMskCurrent;
55  BYTE fjMaskBit0, fjMaskBit;
56  /* Pattern brushes */
58  ULONG PatternWidth = 0, PatternHeight = 0;
59  LONG PatternX0 = 0, PatternX = 0, PatternY = 0;
60  LONG SrcX = 0, SrcY = 0;
61  PFN_DIB_PutPixel fnDest_PutPixel = NULL;
62  PFN_DIB_GetPixel fnPattern_GetPixel = NULL, fnSrc_GetPixel = NULL, fnDest_GetPixel;
63  ULONG Pattern = 0, Source = 0, Dest = 0;
64  DWORD fgndRop, bkgndRop;
65 
66  ASSERT(IS_VALID_ROP4(Rop4));
67  ASSERT(psoMask->iBitmapFormat == BMF_1BPP);
68 
69  fgndRop = ROP4_FGND(Rop4);
70  bkgndRop = ROP4_BKGND(Rop4);
71 
72  //DPRINT1("Rop4 : 0x%08x\n", Rop4);
73 
74  /* Determine pattern */
75  if (pbo && pbo->iSolidColor == 0xFFFFFFFF)
76  {
77  psoPattern = BRUSHOBJ_psoPattern(pbo);
78  if (psoPattern)
79  {
80  PatternWidth = psoPattern->sizlBitmap.cx;
81  PatternHeight = psoPattern->sizlBitmap.cy;
82  fnPattern_GetPixel = DibFunctionsForBitmapFormat[psoPattern->iBitmapFormat].DIB_GetPixel;
83  }
84  }
85  else
86  psoPattern = NULL;
87 
88  cx = prclDest->right - prclDest->left;
89  cy = prclDest->bottom - prclDest->top;
90  if ((pptlMask->x + cx > psoMask->sizlBitmap.cx) ||
91  (pptlMask->y + cy > psoMask->sizlBitmap.cy))
92  {
93  return FALSE;
94  }
95 
96  pjMskLine = (PBYTE)psoMask->pvScan0 + pptlMask->y * psoMask->lDelta + (pptlMask->x >> 3);
97  fjMaskBit0 = 0x80 >> (pptlMask->x & 0x07);
98 
99  fnDest_PutPixel = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_PutPixel;
100  fnDest_GetPixel = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_GetPixel;
101 
102  /* Do we have a source */
103  if(psoSource)
104  {
105  /* Sanity check */
106  ASSERT(ROP4_USES_SOURCE(Rop4));
107  fnSrc_GetPixel = DibFunctionsForBitmapFormat[psoSource->iBitmapFormat].DIB_GetPixel;
108  SrcY = pptlSource->y;
109  SrcX = pptlSource->x;
110  }
111 
112  if (psoPattern)
113  {
114  PatternY = (prclDest->top - pptlBrush->y) % PatternHeight;
115  if (PatternY < 0)
116  {
117  PatternY += PatternHeight;
118  }
119  PatternX0 = (prclDest->left - pptlBrush->x) % PatternWidth;
120  if (PatternX0 < 0)
121  {
122  PatternX0 += PatternWidth;
123  }
124  PatternX = PatternX0;
125  }
126  else
127  {
128  Pattern = pbo ? pbo->iSolidColor : 0;
129  }
130 
131  for (y = prclDest->top; y < prclDest->bottom; y++)
132  {
133  pjMskCurrent = pjMskLine;
134  fjMaskBit = fjMaskBit0;
135 
136  for (x = prclDest->left; x < prclDest->right; x++)
137  {
138  Rop4 = (*pjMskCurrent & fjMaskBit) ? fgndRop : bkgndRop;
139 
140  if(psoPattern)
141  {
142  if(ROP4_USES_PATTERN(Rop4))
143  Pattern = fnPattern_GetPixel(psoPattern, PatternX, PatternY);
144  PatternX++;
145  PatternX %= PatternWidth;
146  }
147 
148  if(psoSource)
149  {
150  if(ROP4_USES_SOURCE(Rop4))
151  {
152  Source = XLATEOBJ_iXlate(ColorTranslation,
153  fnSrc_GetPixel(psoSource, SrcX, SrcY));
154  }
155  SrcX++;
156  }
157 
158  if(ROP4_USES_DEST(Rop4))
159  Dest = fnDest_GetPixel(psoDest, x, y);
160 
161  fnDest_PutPixel(psoDest,
162  x,
163  y,
164  DIB_DoRop(Rop4,
165  Dest,
166  Source,
167  Pattern));
168  fjMaskBit = _rotr8(fjMaskBit, 1);
169  pjMskCurrent += (fjMaskBit >> 7);
170  }
171  pjMskLine += psoMask->lDelta;
172  if(psoPattern)
173  {
174  PatternY++;
175  PatternY %= PatternHeight;
176  PatternX = PatternX0;
177  }
178  if(psoSource)
179  {
180  SrcY++;
181  SrcX = pptlSource->x;
182  }
183  }
184 
185  return TRUE;
186 }
#define TRUE
Definition: types.h:120
SIZEL sizlBitmap
Definition: winddi.h:1209
LONG lDelta
Definition: winddi.h:1213
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define ROP4_USES_DEST(Rop4)
Definition: inteng.h:44
long bottom
Definition: polytest.cpp:53
ULONG iBitmapFormat
Definition: winddi.h:1215
#define IS_VALID_ROP4(rop)
Definition: inteng.h:49
DWORD DWORD
Definition: winlogon.h:75
ULONG(* PFN_DIB_GetPixel)(SURFOBJ *, LONG, LONG)
Definition: dib.h:34
LONG y
Definition: windef.h:343
long right
Definition: polytest.cpp:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
unsigned char _rotr8(unsigned char _Value, unsigned char _Shift)
Definition: intrin_ppc.h:500
long top
Definition: polytest.cpp:53
PFN_DIB_PutPixel DIB_PutPixel
Definition: dib.h:45
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
smooth NULL
Definition: ftsmooth.c:513
LONG cx
Definition: windef.h:347
GLint GLint bottom
Definition: glext.h:7726
#define ROP4_USES_SOURCE(Rop4)
Definition: inteng.h:45
#define BRUSHOBJ_psoPattern(pbo)
Definition: brush.h:171
ULONG DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern)
Definition: dib.c:92
long left
Definition: polytest.cpp:53
#define ROP4_FGND(Rop4)
Definition: inteng.h:51
VOID(* PFN_DIB_PutPixel)(SURFOBJ *, LONG, LONG, ULONG)
Definition: dib.h:33
LONG x
Definition: windef.h:342
Definition: xlate.c:8
GLdouble GLdouble right
Definition: glext.h:10859
PFN_DIB_GetPixel DIB_GetPixel
Definition: dib.h:46
ULONG iSolidColor
Definition: winddi.h:234
#define ROP4_BKGND(Rop4)
Definition: inteng.h:52
unsigned char BYTE
Definition: ntddk_ex.h:96
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
#define ROP4_USES_PATTERN(Rop4)
Definition: inteng.h:46
_Out_opt_ int * cx
Definition: commctrl.h:570
_Inout_ SURFOBJ _In_opt_ SURFOBJ * psoPattern
Definition: winddi.h:3959
unsigned int ULONG
Definition: retypes.h:1
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:664
INT INT y
Definition: msvc.h:62
LONG cy
Definition: windef.h:348
BYTE * PBYTE
Definition: pedump.c:66
PVOID pvScan0
Definition: winddi.h:1212
INT x
Definition: msvc.h:62
static BOOLEAN APIENTRY BltPatCopy ( SURFOBJ Dest,
SURFOBJ Source,
SURFOBJ Mask,
XLATEOBJ ColorTranslation,
RECTL DestRect,
POINTL SourcePoint,
POINTL MaskPoint,
BRUSHOBJ pbo,
POINTL BrushPoint,
DWORD  Rop4 
)
static

Definition at line 191 of file bitblt.c.

Referenced by EngBitBlt().

201 {
202  // These functions are assigned if we're working with a DIB
203  // The assigned functions depend on the bitsPerPixel of the DIB
204 
205  DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_ColorFill(Dest, DestRect, pbo ? pbo->iSolidColor : 0);
206 
207  return TRUE;
208 }
#define TRUE
Definition: types.h:120
ULONG iBitmapFormat
Definition: winddi.h:1215
ULONG iSolidColor
Definition: winddi.h:234
PFN_DIB_ColorFill DIB_ColorFill
Definition: dib.h:53
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
static BOOLEAN APIENTRY CallDibBitBlt ( SURFOBJ OutputObj,
SURFOBJ InputObj,
SURFOBJ Mask,
XLATEOBJ ColorTranslation,
RECTL OutputRect,
POINTL InputPoint,
POINTL MaskOrigin,
BRUSHOBJ pbo,
POINTL BrushOrigin,
ROP4  Rop4 
)
static

Definition at line 211 of file bitblt.c.

Referenced by EngBitBlt().

221 {
222  BLTINFO BltInfo;
224  BOOLEAN Result;
225 
226  BltInfo.DestSurface = OutputObj;
227  BltInfo.SourceSurface = InputObj;
228  BltInfo.PatternSurface = NULL;
229  BltInfo.XlateSourceToDest = ColorTranslation;
230  BltInfo.DestRect = *OutputRect;
231  BltInfo.SourcePoint = *InputPoint;
232 
233  if ((Rop4 & 0xFF) == R3_OPINDEX_SRCCOPY)
234  return DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
235 
236  BltInfo.Brush = pbo;
237  BltInfo.BrushOrigin = *BrushOrigin;
238  BltInfo.Rop4 = Rop4;
239 
240  /* Pattern brush */
241  if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF)
242  {
243  psoPattern = BRUSHOBJ_psoPattern(pbo);
244  if (psoPattern)
245  {
246  BltInfo.PatternSurface = psoPattern;
247  }
248  else
249  {
250  /* FIXME: What to do here? */
251  }
252  }
253  else
254  {
255  psoPattern = NULL;
256  }
257 
258  Result = DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBlt(&BltInfo);
259 
260  return Result;
261 }
POINTL BrushOrigin
Definition: dib.h:29
ROP4 Rop4
Definition: dib.h:30
XLATEOBJ * XlateSourceToDest
Definition: dib.h:25
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
ULONG iBitmapFormat
Definition: winddi.h:1215
SURFOBJ * PatternSurface
Definition: dib.h:24
smooth NULL
Definition: ftsmooth.c:513
#define BRUSHOBJ_psoPattern(pbo)
Definition: brush.h:171
SURFOBJ * SourceSurface
Definition: dib.h:23
unsigned char BOOLEAN
RECTL DestRect
Definition: dib.h:26
SURFOBJ * DestSurface
Definition: dib.h:22
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ * pbo
Definition: winddi.h:3433
ULONG iSolidColor
Definition: winddi.h:234
BRUSHOBJ * Brush
Definition: dib.h:28
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
#define ROP4_USES_PATTERN(Rop4)
Definition: inteng.h:46
PFN_DIB_BitBlt DIB_BitBlt
Definition: dib.h:49
POINTL SourcePoint
Definition: dib.h:27
_Inout_ SURFOBJ _In_opt_ SURFOBJ * psoPattern
Definition: winddi.h:3959
Definition: dib.h:20
PFN_DIB_BitBlt DIB_BitBltSrcCopy
Definition: dib.h:50
BOOL APIENTRY EngBitBlt ( _Inout_ SURFOBJ psoTrg,
_In_opt_ SURFOBJ psoSrc,
_In_opt_ SURFOBJ psoMask,
_In_opt_ CLIPOBJ pco,
_In_opt_ XLATEOBJ pxlo,
_In_ RECTL prclTrg,
_In_opt_ POINTL pptlSrc,
_In_opt_ POINTL pptlMask,
_In_opt_ BRUSHOBJ pbo,
_In_opt_ POINTL pptlBrush,
_In_ ROP4  rop4 
)

Definition at line 317 of file bitblt.c.

Referenced by IntEngBitBlt(), and NtGdiEngBitBlt().

329 {
330  BYTE clippingType;
331  RECTL CombinedRect;
332  RECT_ENUM RectEnum;
333  BOOL EnumMore;
334  POINTL InputPoint;
335  RECTL InputRect;
336  RECTL OutputRect;
337  SURFOBJ* InputObj = 0;
338  SURFOBJ* OutputObj;
339  PBLTRECTFUNC BltRectFunc;
340  BOOLEAN Ret = TRUE;
341  RECTL ClipRect;
342  ULONG i;
343  POINTL Pt;
345  BOOL UsesSource, UsesMask;
346  POINTL AdjustedBrushOrigin;
347 
348  UsesSource = ROP4_USES_SOURCE(rop4);
349  UsesMask = ROP4_USES_MASK(rop4);
350 
351  if (rop4 == ROP4_NOOP)
352  {
353  /* Copy destination onto itself: nop */
354  return TRUE;
355  }
356 
357  //DPRINT1("rop4 : 0x%08x\n", rop4);
358 
359  OutputRect = *prclTrg;
360  RECTL_vMakeWellOrdered(&OutputRect);
361 
362  if (UsesSource)
363  {
364  if (!psoSrc || !pptlSrc)
365  {
366  return FALSE;
367  }
368 
369  /* Make sure we don't try to copy anything outside the valid source
370  region */
371  InputPoint = *pptlSrc;
372  if (InputPoint.x < 0)
373  {
374  OutputRect.left -= InputPoint.x;
375  InputPoint.x = 0;
376  }
377  if (InputPoint.y < 0)
378  {
379  OutputRect.top -= InputPoint.y;
380  InputPoint.y = 0;
381  }
382  if (psoSrc->sizlBitmap.cx < InputPoint.x +
383  OutputRect.right - OutputRect.left)
384  {
385  OutputRect.right = OutputRect.left +
386  psoSrc->sizlBitmap.cx - InputPoint.x;
387  }
388  if (psoSrc->sizlBitmap.cy < InputPoint.y +
389  OutputRect.bottom - OutputRect.top)
390  {
391  OutputRect.bottom = OutputRect.top +
392  psoSrc->sizlBitmap.cy - InputPoint.y;
393  }
394 
395  InputRect.left = InputPoint.x;
396  InputRect.right = InputPoint.x + (OutputRect.right - OutputRect.left);
397  InputRect.top = InputPoint.y;
398  InputRect.bottom = InputPoint.y + (OutputRect.bottom - OutputRect.top);
399 
400  InputObj = psoSrc;
401  }
402  else
403  {
404  InputPoint.x = InputPoint.y = 0;
405  InputRect.left = 0;
406  InputRect.right = prclTrg->right - prclTrg->left;
407  InputRect.top = 0;
408  InputRect.bottom = prclTrg->bottom - prclTrg->top;
409  }
410 
411  if (NULL != pco)
412  {
413  if (OutputRect.left < pco->rclBounds.left)
414  {
415  InputRect.left += pco->rclBounds.left - OutputRect.left;
416  InputPoint.x += pco->rclBounds.left - OutputRect.left;
417  OutputRect.left = pco->rclBounds.left;
418  }
419  if (pco->rclBounds.right < OutputRect.right)
420  {
421  InputRect.right -= OutputRect.right - pco->rclBounds.right;
422  OutputRect.right = pco->rclBounds.right;
423  }
424  if (OutputRect.top < pco->rclBounds.top)
425  {
426  InputRect.top += pco->rclBounds.top - OutputRect.top;
427  InputPoint.y += pco->rclBounds.top - OutputRect.top;
428  OutputRect.top = pco->rclBounds.top;
429  }
430  if (pco->rclBounds.bottom < OutputRect.bottom)
431  {
432  InputRect.bottom -= OutputRect.bottom - pco->rclBounds.bottom;
433  OutputRect.bottom = pco->rclBounds.bottom;
434  }
435  }
436 
437  /* Check for degenerate case: if height or width of OutputRect is 0 pixels
438  there's nothing to do */
439  if (OutputRect.right <= OutputRect.left ||
440  OutputRect.bottom <= OutputRect.top)
441  {
442  return TRUE;
443  }
444 
445  OutputObj = psoTrg;
446 
447  if (pptlBrush)
448  {
449  AdjustedBrushOrigin.x = pptlBrush->x;
450  AdjustedBrushOrigin.y = pptlBrush->y;
451  }
452  else
453  {
454  AdjustedBrushOrigin.x = 0;
455  AdjustedBrushOrigin.y = 0;
456  }
457 
458  /* Determine clipping type */
459  if (pco == (CLIPOBJ *) NULL)
460  {
461  clippingType = DC_TRIVIAL;
462  }
463  else
464  {
465  clippingType = pco->iDComplexity;
466  }
467 
468  /* Check if we need a mask but have no mask surface */
469  if (UsesMask && (psoMask == NULL))
470  {
471  /* Check if the BRUSHOBJ can provide the mask */
473  if (psoMask == NULL)
474  {
475  /* We have no mask, assume the mask is all foreground */
476  rop4 = (rop4 & 0xFF) | ((rop4 & 0xFF) << 8);
477  UsesMask = FALSE;
478  }
479  }
480 
481  if (UsesMask)
482  {
483  BltRectFunc = BltMask;
484  }
485  else if ((rop4 & 0xFF) == R3_OPINDEX_PATCOPY)
486  {
487  if (pbo && pbo->iSolidColor == 0xFFFFFFFF)
488  BltRectFunc = CallDibBitBlt;
489  else
490  BltRectFunc = BltPatCopy;
491  }
492  else
493  {
494  BltRectFunc = CallDibBitBlt;
495  }
496 
497 
498  switch (clippingType)
499  {
500  case DC_TRIVIAL:
501  Ret = (*BltRectFunc)(OutputObj,
502  InputObj,
503  psoMask,
504  pxlo,
505  &OutputRect,
506  &InputPoint,
507  pptlMask,
508  pbo,
509  &AdjustedBrushOrigin,
510  rop4);
511  break;
512  case DC_RECT:
513  /* Clip the blt to the clip rectangle */
514  ClipRect.left = pco->rclBounds.left;
515  ClipRect.right = pco->rclBounds.right;
516  ClipRect.top = pco->rclBounds.top;
517  ClipRect.bottom = pco->rclBounds.bottom;
518  if (RECTL_bIntersectRect(&CombinedRect, &OutputRect, &ClipRect))
519  {
520 #ifdef _USE_DIBLIB_
521  if (BrushOrigin)
522  {
523  AdjustedBrushOrigin.x = BrushOrigin->x + CombinedRect.left - OutputRect.left;
524  AdjustedBrushOrigin.y = BrushOrigin->y + CombinedRect.top - OutputRect.top;
525  }
526 #endif
527  Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
528  Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
529  Ret = (*BltRectFunc)(OutputObj,
530  InputObj,
531  psoMask,
532  pxlo,
533  &CombinedRect,
534  &Pt,
535  pptlMask,
536  pbo,
537  &AdjustedBrushOrigin,
538  rop4);
539  }
540  break;
541  case DC_COMPLEX:
542  Ret = TRUE;
543  if (OutputObj == InputObj)
544  {
545  if (OutputRect.top < InputPoint.y)
546  {
547  Direction = OutputRect.left < InputPoint.x ?
549  }
550  else
551  {
552  Direction = OutputRect.left < InputPoint.x ?
554  }
555  }
556  else
557  {
558  Direction = CD_ANY;
559  }
560  CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, Direction, 0);
561  do
562  {
563  EnumMore = CLIPOBJ_bEnum(pco, sizeof(RectEnum),
564  (PVOID) &RectEnum);
565 
566  for (i = 0; i < RectEnum.c; i++)
567  {
568  ClipRect.left = RectEnum.arcl[i].left;
569  ClipRect.right = RectEnum.arcl[i].right;
570  ClipRect.top = RectEnum.arcl[i].top;
571  ClipRect.bottom = RectEnum.arcl[i].bottom;
572  if (RECTL_bIntersectRect(&CombinedRect, &OutputRect, &ClipRect))
573  {
574 #ifdef _USE_DIBLIB_
575  if (BrushOrigin)
576  {
577  AdjustedBrushOrigin.x = BrushOrigin->x + CombinedRect.left - OutputRect.left;
578  AdjustedBrushOrigin.y = BrushOrigin->y + CombinedRect.top - OutputRect.top;
579  }
580 #endif
581  Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
582  Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
583  Ret = (*BltRectFunc)(OutputObj,
584  InputObj,
585  psoMask,
586  pxlo,
587  &CombinedRect,
588  &Pt,
589  pptlMask,
590  pbo,
591  &AdjustedBrushOrigin,
592  rop4) && Ret;
593  }
594  }
595  }
596  while (EnumMore);
597  break;
598  }
599 
600  return Ret;
601 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define BRUSHOBJ_psoMask(pbo)
Definition: brush.h:178
#define TRUE
Definition: types.h:120
static BOOLEAN APIENTRY BltMask(SURFOBJ *psoDest, SURFOBJ *psoSource, SURFOBJ *psoMask, XLATEOBJ *ColorTranslation, RECTL *prclDest, POINTL *pptlSource, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:42
#define DC_TRIVIAL
Definition: winddi.h:259
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ _In_opt_ POINTL _In_ ROP4 rop4
Definition: winddi.h:3433
#define ROP4_USES_MASK(Rop4)
Definition: inteng.h:47
long bottom
Definition: polytest.cpp:53
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL * prclTrg
Definition: winddi.h:3433
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
ULONG c
Definition: vgaddi.h:78
LONG y
Definition: windef.h:343
_In_ SURFOBJ * psoSrc
Definition: winddi.h:3414
static BOOLEAN APIENTRY CallDibBitBlt(SURFOBJ *OutputObj, SURFOBJ *InputObj, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *OutputRect, POINTL *InputPoint, POINTL *MaskOrigin, BRUSHOBJ *pbo, POINTL *BrushOrigin, ROP4 Rop4)
Definition: bitblt.c:211
long right
Definition: polytest.cpp:53
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define CD_RIGHTDOWN
Definition: winddi.h:1320
BOOL(APIENTRY * PBLTRECTFUNC)(SURFOBJ *OutputObj, SURFOBJ *InputObj, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *OutputRect, POINTL *InputPoint, POINTL *MaskOrigin, BRUSHOBJ *Brush, POINTL *BrushOrigin, ROP4 Rop4)
Definition: bitblt.c:14
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:513
#define CT_RECTANGLES
Definition: winddi.h:1317
#define ROP4_USES_SOURCE(Rop4)
Definition: inteng.h:45
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ _In_opt_ POINTL * pptlBrush
Definition: winddi.h:3433
long left
Definition: polytest.cpp:53
unsigned char BOOLEAN
#define DC_RECT
Definition: winddi.h:260
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CD_RIGHTUP
Definition: winddi.h:1323
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ * pbo
Definition: winddi.h:3433
ENGAPI ULONG APIENTRY CLIPOBJ_cEnumStart(_Inout_ CLIPOBJ *pco, _In_ BOOL bAll, _In_ ULONG iType, _In_ ULONG iDirection, _In_ ULONG cLimit)
Definition: clip.c:255
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION Direction
Definition: mmfuncs.h:773
LONG x
Definition: windef.h:342
static BOOLEAN APIENTRY BltPatCopy(SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *DestRect, POINTL *SourcePoint, POINTL *MaskPoint, BRUSHOBJ *pbo, POINTL *BrushPoint, DWORD Rop4)
Definition: bitblt.c:191
#define CD_LEFTDOWN
Definition: winddi.h:1321
_In_ SURFOBJ _In_ CLIPOBJ * pco
Definition: winddi.h:3414
#define CD_LEFTUP
Definition: winddi.h:1325
unsigned char BYTE
Definition: ntddk_ex.h:96
RECTL arcl[ENUM_RECT_LIMIT]
Definition: vgaddi.h:79
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL * pptlMask
Definition: winddi.h:3433
#define DC_COMPLEX
Definition: winddi.h:261
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL * pptlSrc
Definition: winddi.h:3433
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoMask
Definition: winddi.h:3433
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
unsigned int ULONG
Definition: retypes.h:1
#define ROP4_NOOP
Definition: inteng.h:54
ENGAPI BOOL APIENTRY CLIPOBJ_bEnum(_In_ CLIPOBJ *pco, _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pul)
Definition: clip.c:319
#define CD_ANY
Definition: winddi.h:1326
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ * pxlo
Definition: winddi.h:3414
static BOOL APIENTRY EngMaskBitBlt ( SURFOBJ psoDest,
SURFOBJ psoMask,
CLIPOBJ ClipRegion,
XLATEOBJ DestColorTranslation,
XLATEOBJ SourceColorTranslation,
RECTL DestRect,
POINTL pptlMask,
BRUSHOBJ pbo,
POINTL BrushOrigin 
)
static

Definition at line 798 of file bitblt.c.

Referenced by IntEngMaskBlt().

807 {
808  BYTE clippingType;
809  RECTL CombinedRect;
810  RECT_ENUM RectEnum;
811  BOOL EnumMore;
812  POINTL InputPoint;
813  RECTL InputRect;
814  RECTL OutputRect;
815  POINTL Translate;
816  INTENG_ENTER_LEAVE EnterLeaveSource;
817  INTENG_ENTER_LEAVE EnterLeaveDest;
818  SURFOBJ* psoInput;
819  SURFOBJ* psoOutput;
820  BOOLEAN Ret = TRUE;
821  RECTL ClipRect;
822  unsigned i;
823  POINTL Pt;
825  POINTL AdjustedBrushOrigin;
826 
827  ASSERT(psoMask);
828 
829  if (pptlMask)
830  {
831  InputRect.left = pptlMask->x;
832  InputRect.right = pptlMask->x + (DestRect->right - DestRect->left);
833  InputRect.top = pptlMask->y;
834  InputRect.bottom = pptlMask->y + (DestRect->bottom - DestRect->top);
835  }
836  else
837  {
838  InputRect.left = 0;
839  InputRect.right = DestRect->right - DestRect->left;
840  InputRect.top = 0;
841  InputRect.bottom = DestRect->bottom - DestRect->top;
842  }
843 
844  OutputRect = *DestRect;
845  if (NULL != ClipRegion)
846  {
847  if (OutputRect.left < ClipRegion->rclBounds.left)
848  {
849  InputRect.left += ClipRegion->rclBounds.left - OutputRect.left;
850  OutputRect.left = ClipRegion->rclBounds.left;
851  }
852  if (ClipRegion->rclBounds.right < OutputRect.right)
853  {
854  InputRect.right -= OutputRect.right - ClipRegion->rclBounds.right;
855  OutputRect.right = ClipRegion->rclBounds.right;
856  }
857  if (OutputRect.top < ClipRegion->rclBounds.top)
858  {
859  InputRect.top += ClipRegion->rclBounds.top - OutputRect.top;
860  OutputRect.top = ClipRegion->rclBounds.top;
861  }
862  if (ClipRegion->rclBounds.bottom < OutputRect.bottom)
863  {
864  InputRect.bottom -= OutputRect.bottom - ClipRegion->rclBounds.bottom;
865  OutputRect.bottom = ClipRegion->rclBounds.bottom;
866  }
867  }
868 
869  if (! IntEngEnter(&EnterLeaveSource, psoMask, &InputRect, TRUE, &Translate, &psoInput))
870  {
871  return FALSE;
872  }
873 
874  InputPoint.x = InputRect.left + Translate.x;
875  InputPoint.y = InputRect.top + Translate.y;
876 
877  /* Check for degenerate case: if height or width of OutputRect is 0 pixels there's
878  nothing to do */
879  if (OutputRect.right <= OutputRect.left || OutputRect.bottom <= OutputRect.top)
880  {
881  IntEngLeave(&EnterLeaveSource);
882  return TRUE;
883  }
884 
885  if (! IntEngEnter(&EnterLeaveDest, psoDest, &OutputRect, FALSE, &Translate, &psoOutput))
886  {
887  IntEngLeave(&EnterLeaveSource);
888  return FALSE;
889  }
890 
891  OutputRect.left = DestRect->left + Translate.x;
892  OutputRect.right = DestRect->right + Translate.x;
893  OutputRect.top = DestRect->top + Translate.y;
894  OutputRect.bottom = DestRect->bottom + Translate.y;
895 
896  if (BrushOrigin)
897  {
898  AdjustedBrushOrigin.x = BrushOrigin->x + Translate.x;
899  AdjustedBrushOrigin.y = BrushOrigin->y + Translate.y;
900  }
901  else
902  AdjustedBrushOrigin = Translate;
903 
904  // Determine clipping type
905  if (ClipRegion == (CLIPOBJ *) NULL)
906  {
907  clippingType = DC_TRIVIAL;
908  } else {
909  clippingType = ClipRegion->iDComplexity;
910  }
911 
912  switch (clippingType)
913  {
914  case DC_TRIVIAL:
915  if (psoMask->iBitmapFormat == BMF_8BPP)
916  Ret = AlphaBltMask(psoOutput, NULL , psoInput, DestColorTranslation, SourceColorTranslation,
917  &OutputRect, NULL, &InputPoint, pbo, &AdjustedBrushOrigin);
918  else
919  Ret = BltMask(psoOutput, NULL, psoInput, DestColorTranslation,
920  &OutputRect, NULL, &InputPoint, pbo, &AdjustedBrushOrigin,
921  ROP4_MASK);
922  break;
923  case DC_RECT:
924  // Clip the blt to the clip rectangle
925  ClipRect.left = ClipRegion->rclBounds.left + Translate.x;
926  ClipRect.right = ClipRegion->rclBounds.right + Translate.x;
927  ClipRect.top = ClipRegion->rclBounds.top + Translate.y;
928  ClipRect.bottom = ClipRegion->rclBounds.bottom + Translate.y;
929  if (RECTL_bIntersectRect(&CombinedRect, &OutputRect, &ClipRect))
930  {
931  Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
932  Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
933  if (psoMask->iBitmapFormat == BMF_8BPP)
934  {
935  Ret = AlphaBltMask(psoOutput, NULL, psoInput, DestColorTranslation, SourceColorTranslation,
936  &CombinedRect, NULL, &Pt, pbo, &AdjustedBrushOrigin);
937  }
938  else
939  {
940  Ret = BltMask(psoOutput, NULL, psoInput, DestColorTranslation,
941  &CombinedRect, NULL, &Pt, pbo, &AdjustedBrushOrigin, ROP4_MASK);
942  }
943  }
944  break;
945  case DC_COMPLEX:
946  Ret = TRUE;
947  if (psoOutput == psoInput)
948  {
949  if (OutputRect.top < InputPoint.y)
950  {
951  Direction = OutputRect.left < InputPoint.x ? CD_RIGHTDOWN : CD_LEFTDOWN;
952  }
953  else
954  {
955  Direction = OutputRect.left < InputPoint.x ? CD_RIGHTUP : CD_LEFTUP;
956  }
957  }
958  else
959  {
960  Direction = CD_ANY;
961  }
962  CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, Direction, 0);
963  do
964  {
965  EnumMore = CLIPOBJ_bEnum(ClipRegion,(ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
966 
967  for (i = 0; i < RectEnum.c; i++)
968  {
969  ClipRect.left = RectEnum.arcl[i].left + Translate.x;
970  ClipRect.right = RectEnum.arcl[i].right + Translate.x;
971  ClipRect.top = RectEnum.arcl[i].top + Translate.y;
972  ClipRect.bottom = RectEnum.arcl[i].bottom + Translate.y;
973  if (RECTL_bIntersectRect(&CombinedRect, &OutputRect, &ClipRect))
974  {
975  Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
976  Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
977  if (psoMask->iBitmapFormat == BMF_8BPP)
978  {
979  Ret = AlphaBltMask(psoOutput, NULL, psoInput,
980  DestColorTranslation,
981  SourceColorTranslation,
982  &CombinedRect, NULL, &Pt, pbo,
983  &AdjustedBrushOrigin) && Ret;
984  }
985  else
986  {
987  Ret = BltMask(psoOutput, NULL, psoInput,
988  DestColorTranslation, &CombinedRect, NULL,
989  &Pt, pbo, &AdjustedBrushOrigin,
990  ROP4_MASK) && Ret;
991  }
992  }
993  }
994  }
995  while (EnumMore);
996  break;
997  }
998 
999 
1000  IntEngLeave(&EnterLeaveDest);
1001  IntEngLeave(&EnterLeaveSource);
1002 
1003  return Ret;
1004 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define TRUE
Definition: types.h:120
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
static BOOLEAN APIENTRY AlphaBltMask(SURFOBJ *psoDest, SURFOBJ *psoSource, SURFOBJ *psoMask, XLATEOBJ *pxloRGB2Dest, XLATEOBJ *pxloBrush, RECTL *prclDest, POINTL *pptlSource, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush)
Definition: bitblt.c:727
static BOOLEAN APIENTRY BltMask(SURFOBJ *psoDest, SURFOBJ *psoSource, SURFOBJ *psoMask, XLATEOBJ *ColorTranslation, RECTL *prclDest, POINTL *pptlSource, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:42
#define DC_TRIVIAL
Definition: winddi.h:259
long bottom
Definition: polytest.cpp:53
#define ROP4_MASK
Definition: inteng.h:55
ULONG iBitmapFormat
Definition: winddi.h:1215
ULONG c
Definition: vgaddi.h:78
LONG y
Definition: windef.h:343
long right
Definition: polytest.cpp:53
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define CD_RIGHTDOWN
Definition: winddi.h:1320
long top
Definition: polytest.cpp:53
RECTL rclBounds
Definition: winddi.h:277
smooth NULL
Definition: ftsmooth.c:513
#define CT_RECTANGLES
Definition: winddi.h:1317
long left
Definition: polytest.cpp:53
unsigned char BOOLEAN
#define DC_RECT
Definition: winddi.h:260
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CD_RIGHTUP
Definition: winddi.h:1323
ENGAPI ULONG APIENTRY CLIPOBJ_cEnumStart(_Inout_ CLIPOBJ *pco, _In_ BOOL bAll, _In_ ULONG iType, _In_ ULONG iDirection, _In_ ULONG cLimit)
Definition: clip.c:255
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION Direction
Definition: mmfuncs.h:773
LONG x
Definition: windef.h:342
BOOL APIENTRY IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave, SURFOBJ *psoDest, RECTL *DestRect, BOOL ReadOnly, POINTL *Translate, SURFOBJ **ppsoOutput)
Definition: engmisc.c:15
#define CD_LEFTDOWN
Definition: winddi.h:1321
#define CD_LEFTUP
Definition: winddi.h:1325
Definition: xlate.c:10
unsigned char BYTE
Definition: ntddk_ex.h:96
RECTL arcl[ENUM_RECT_LIMIT]
Definition: vgaddi.h:79
#define DC_COMPLEX
Definition: winddi.h:261
BYTE iDComplexity
Definition: winddi.h:278
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
unsigned int ULONG
Definition: retypes.h:1
BOOL APIENTRY IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave)
Definition: engmisc.c:162
ENGAPI BOOL APIENTRY CLIPOBJ_bEnum(_In_ CLIPOBJ *pco, _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pul)
Definition: clip.c:319
#define CD_ANY
Definition: winddi.h:1326
BOOL APIENTRY IntEngBitBlt ( SURFOBJ psoTrg,
SURFOBJ psoSrc,
SURFOBJ psoMask,
CLIPOBJ pco,
XLATEOBJ pxlo,
RECTL prclTrg,
POINTL pptlSrc,
POINTL pptlMask,
BRUSHOBJ pbo,
POINTL pptlBrush,
ROP4  Rop4 
)

Definition at line 604 of file bitblt.c.

Referenced by EngCopyBits(), EngPaint(), GreExtTextOutW(), IntEngMaskBlt(), IntEngStretchBlt(), IntFillPolygon(), IntFillRect(), IntGdiBitBltRgn(), IntHideMousePointer(), IntPatBlt(), IntRectangle(), IntShowMousePointer(), NtGdiMaskBlt(), NtGdiSetDIBitsToDeviceInternal(), and UserDrawIconEx().

616 {
617  SURFACE *psurfTrg;
618  SURFACE *psurfSrc = NULL;
619  BOOL bResult;
620  RECTL rclClipped;
621  RECTL rclSrc;
622  POINTL ptlBrush;
623  PFN_DrvBitBlt pfnBitBlt;
624 
625  ASSERT(psoTrg);
626  psurfTrg = CONTAINING_RECORD(psoTrg, SURFACE, SurfObj);
627 
628  /* FIXME: Should we really allow to pass non-well-ordered rects? */
629  rclClipped = *prclTrg;
630  RECTL_vMakeWellOrdered(&rclClipped);
631 
632  //DPRINT1("Rop4 : 0x%08x\n", Rop4);
633 
634  /* Sanity check */
635  ASSERT(IS_VALID_ROP4(Rop4));
636 
637  if (pco)
638  {
639  /* Clip target rect against the bounds of the clipping region */
640  if (!RECTL_bIntersectRect(&rclClipped, &rclClipped, &pco->rclBounds))
641  {
642  /* Nothing left */
643  return TRUE;
644  }
645 
646  /* Don't pass a clipobj with only a single rect */
647  if (pco->iDComplexity == DC_RECT)
648  pco = NULL;
649  }
650  else
651  pco = (CLIPOBJ *)&gxcoTrivial;
652 
653  if (ROP4_USES_SOURCE(Rop4))
654  {
655  ASSERT(psoSrc);
656  psurfSrc = CONTAINING_RECORD(psoSrc, SURFACE, SurfObj);
657 
658  /* Calculate source rect */
659  rclSrc.left = pptlSrc->x + rclClipped.left - prclTrg->left;
660  rclSrc.top = pptlSrc->y + rclClipped.top - prclTrg->top;
661  rclSrc.right = rclSrc.left + rclClipped.right - rclClipped.left;
662  rclSrc.bottom = rclSrc.top + rclClipped.bottom - rclClipped.top;
663  pptlSrc = (PPOINTL)&rclSrc;
664  }
665  else
666  {
667  psoSrc = NULL;
668  psurfSrc = NULL;
669  }
670 
671  if (pptlBrush)
672  {
673 #ifdef _USE_DIBLIB_
674  ptlBrush.x = pptlBrush->x + rclClipped.left - prclTrg->left;
675  ptlBrush.y = pptlBrush->y + rclClipped.top - prclTrg->top;
676 #else
677  ptlBrush = *pptlBrush;
678 #endif
679  }
680 
681  /* Is the target surface device managed? */
682  if (psurfTrg->flags & HOOK_BITBLT)
683  {
684  /* Is the source a different device managed surface? */
685  if (psoSrc && psoSrc->hdev != psoTrg->hdev && psurfSrc->flags & HOOK_BITBLT)
686  {
687  DPRINT1("Need to copy to standard bitmap format!\n");
688  ASSERT(FALSE);
689  }
690 
691  pfnBitBlt = GDIDEVFUNCS(psoTrg).BitBlt;
692  }
693 
694  /* Is the source surface device managed? */
695  else if (psoSrc && psurfSrc->flags & HOOK_BITBLT)
696  {
697  pfnBitBlt = GDIDEVFUNCS(psoSrc).BitBlt;
698  }
699  else
700  {
701  pfnBitBlt = EngBitBlt;
702  }
703 
704  bResult = pfnBitBlt(psoTrg,
705  psoSrc,
706  psoMask,
707  pco,
708  pxlo,
709  &rclClipped,
710  pptlSrc,
711  pptlMask,
712  pbo,
713  pptlBrush ? &ptlBrush : NULL,
714  Rop4);
715 
716  // FIXME: cleanup temp surface!
717 
718  return bResult;
719 }
BOOL APIENTRY EngBitBlt(_Inout_ SURFOBJ *psoTrg, _In_opt_ SURFOBJ *psoSrc, _In_opt_ SURFOBJ *psoMask, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ RECTL *prclTrg, _In_opt_ POINTL *pptlSrc, _In_opt_ POINTL *pptlMask, _In_opt_ BRUSHOBJ *pbo, _In_opt_ POINTL *pptlBrush, _In_ ROP4 rop4)
Definition: bitblt.c:317
#define TRUE
Definition: types.h:120
struct _POINTL * PPOINTL
XCLIPOBJ gxcoTrivial
Definition: bitblt.c:15
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
long bottom
Definition: polytest.cpp:53
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL * prclTrg
Definition: winddi.h:3433
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
#define IS_VALID_ROP4(rop)
Definition: inteng.h:49
LONG y
Definition: windef.h:343
long right
Definition: polytest.cpp:53
#define FALSE
Definition: types.h:117
long top
Definition: polytest.cpp:53
RECTL rclBounds
Definition: winddi.h:277
smooth NULL
Definition: ftsmooth.c:513
#define ROP4_USES_SOURCE(Rop4)
Definition: inteng.h:45
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ _In_opt_ POINTL * pptlBrush
Definition: winddi.h:3433
long left
Definition: polytest.cpp:53
#define DC_RECT
Definition: winddi.h:260
unsigned int BOOL
Definition: ntddk_ex.h:94
#define HOOK_BITBLT
Definition: winddi.h:1420
#define GDIDEVFUNCS(SurfObj)
Definition: surface.h:99
LONG x
Definition: windef.h:342
HDEV hdev
Definition: winddi.h:1208
FN_DrvBitBlt * PFN_DrvBitBlt
Definition: winddi.h:3443
BYTE iDComplexity
Definition: winddi.h:278
FLONG flags
Definition: surface.h:10
#define DPRINT1
Definition: precomp.h:8
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
BOOL APIENTRY IntEngMaskBlt ( _Inout_ SURFOBJ psoDest,
_In_ SURFOBJ psoMask,
_In_ CLIPOBJ pco,
_In_ XLATEOBJ pxloDest,
_In_ XLATEOBJ pxloSource,
_In_ RECTL prclDest,
_In_ POINTL pptlMask,
_In_ BRUSHOBJ pbo,
_In_ POINTL pptlBrushOrg 
)

Definition at line 1008 of file bitblt.c.

Referenced by GreExtTextOutW().

1018 {
1019  BOOLEAN ret;
1020  RECTL rcDest;
1021  POINTL ptMask = {0,0};
1022  PSURFACE psurfTemp;
1023  RECTL rcTemp;
1024 
1025  ASSERT(psoDest);
1026  ASSERT(psoMask);
1027 
1028  /* Is this a 1 BPP mask? */
1029  if (psoMask->iBitmapFormat == BMF_1BPP)
1030  {
1031  /* Use IntEngBitBlt with an appropriate ROP4 */
1032  return IntEngBitBlt(psoDest,
1033  NULL,
1034  psoMask,
1035  pco,
1036  pxloDest,
1037  prclDest,
1038  NULL,
1039  pptlMask,
1040  pbo,
1041  pptlBrushOrg,
1042  ROP4_MASKPAINT);
1043  }
1044 
1045  ASSERT(psoMask->iBitmapFormat == BMF_8BPP);
1046 
1047  if (pptlMask)
1048  {
1049  ptMask = *pptlMask;
1050  }
1051 
1052  /* Clip against the bounds of the clipping region so we won't try to write
1053  * outside the surface */
1054  if (pco != NULL)
1055  {
1056  /* Intersect with the clip bounds and check if everything was clipped */
1057  if (!RECTL_bIntersectRect(&rcDest, prclDest, &pco->rclBounds))
1058  {
1059  return TRUE;
1060  }
1061 
1062  /* Adjust the mask point */
1063  ptMask.x += rcDest.left - prclDest->left;
1064  ptMask.y += rcDest.top - prclDest->top;
1065  }
1066  else
1067  {
1068  rcDest = *prclDest;
1069  }
1070 
1071  /* Check if the target surface is device managed */
1072  if (psoDest->iType != STYPE_BITMAP)
1073  {
1074  rcTemp.left = 0;
1075  rcTemp.top = 0;
1076  rcTemp.right = rcDest.right - rcDest.left;
1077  rcTemp.bottom = rcDest.bottom - rcDest.top;
1078 
1079  /* Allocate a temporary surface */
1080  psurfTemp = SURFACE_AllocSurface(STYPE_BITMAP,
1081  rcTemp.right,
1082  rcTemp.bottom,
1083  psoDest->iBitmapFormat,
1084  0,
1085  0,
1086  0,
1087  NULL);
1088  if (psurfTemp == NULL)
1089  {
1090  return FALSE;
1091  }
1092 
1093  /* Copy the current target surface bits to the temp surface */
1094  ret = EngCopyBits(&psurfTemp->SurfObj,
1095  psoDest,
1096  NULL, // pco
1097  NULL, // pxlo
1098  &rcTemp,
1099  (PPOINTL)&rcDest);
1100 
1101  if (ret)
1102  {
1103  /* Do the operation on the temp surface */
1104  ret = EngMaskBitBlt(&psurfTemp->SurfObj,
1105  psoMask,
1106  NULL,
1107  pxloDest,
1108  pxloSource,
1109  &rcTemp,
1110  &ptMask,
1111  pbo,
1112  pptlBrushOrg);
1113  }
1114 
1115  if (ret)
1116  {
1117  /* Copy the result back to the dest surface */
1118  ret = EngCopyBits(psoDest,
1119  &psurfTemp->SurfObj,
1120  pco,
1121  NULL,
1122  &rcDest,
1123  (PPOINTL)&rcTemp);
1124  }
1125 
1126  /* Delete the temp surface */
1127  GDIOBJ_vDeleteObject(&psurfTemp->BaseObject);
1128  }
1129  else
1130  {
1131  /* Do the operation on the target surface */
1132  ret = EngMaskBitBlt(psoDest,
1133  psoMask,
1134  pco,
1135  pxloDest,
1136  pxloSource,
1137  &rcDest,
1138  &ptMask,
1139  pbo,
1140  pptlBrushOrg);
1141  }
1142 
1143  return ret;
1144 }
#define TRUE
Definition: types.h:120
#define STYPE_BITMAP
Definition: winddi.h:1175
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define ROP4_MASKPAINT
Definition: inteng.h:56
long bottom
Definition: polytest.cpp:53
LONG y
Definition: windef.h:343
long right
Definition: polytest.cpp:53
#define FALSE
Definition: types.h:117
_In_ PATHOBJ _In_ CLIPOBJ _In_ BRUSHOBJ _In_ POINTL * pptlBrushOrg
Definition: winddi.h:3591
long top
Definition: polytest.cpp:53
SURFOBJ SurfObj
Definition: surface.h:8
smooth NULL
Definition: ftsmooth.c:513
long left
Definition: polytest.cpp:53
BASEOBJECT BaseObject
Definition: surface.h:6
unsigned char BOOLEAN
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1106
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ * pbo
Definition: winddi.h:3433
LONG x
Definition: windef.h:342
Definition: xlate.c:8
static BOOL APIENTRY EngMaskBitBlt(SURFOBJ *psoDest, SURFOBJ *psoMask, CLIPOBJ *ClipRegion, XLATEOBJ *DestColorTranslation, XLATEOBJ *SourceColorTranslation, RECTL *DestRect, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *BrushOrigin)
Definition: bitblt.c:798
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL * prclDest
Definition: winddi.h:3414
PSURFACE NTAPI SURFACE_AllocSurface(_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
Definition: surface.c:116
int ret
_In_ SURFOBJ _In_ CLIPOBJ * pco
Definition: winddi.h:3414
ENGAPI BOOL APIENTRY EngCopyBits(_In_ SURFOBJ *psoDest, _In_ SURFOBJ *psoSrc, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ __in_data_source(USER_MODE) RECTL *prclDest, _In_ __in_data_source(USER_MODE) POINTL *pptlSrc)
Definition: xlate.c:10
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL * pptlMask
Definition: winddi.h:3433
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoMask
Definition: winddi.h:3433
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
BOOL APIENTRY IntEngBitBlt(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:604
BOOL APIENTRY NtGdiEngBitBlt ( IN SURFOBJ psoTrg,
IN SURFOBJ psoSrc,
IN SURFOBJ psoMask,
IN CLIPOBJ pco,
IN XLATEOBJ pxlo,
IN RECTL prclTrg,
IN POINTL pptlSrc,
IN POINTL pptlMask,
IN BRUSHOBJ pbo,
IN POINTL pptlBrush,
IN ROP4  Rop4 
)

Definition at line 270 of file bitblt.c.

282 {
283  RECTL rclTrg;
284  POINTL ptlSrc;
285  POINTL ptlMask;
286  POINTL ptlBrush;
287 
288  _SEH2_TRY
289  {
290  ProbeForRead(prclTrg, sizeof(RECTL), 1);
291  RtlCopyMemory(&rclTrg,prclTrg, sizeof(RECTL));
292 
293  ProbeForRead(pptlSrc, sizeof(POINTL), 1);
294  RtlCopyMemory(&ptlSrc, pptlSrc, sizeof(POINTL));
295 
296  ProbeForRead(pptlMask, sizeof(POINTL), 1);
297  RtlCopyMemory(&ptlMask, pptlMask, sizeof(POINTL));
298 
299  ProbeForRead(pptlBrush, sizeof(POINTL), 1);
300  RtlCopyMemory(&ptlBrush, pptlBrush, sizeof(POINTL));
301 
302  }
304  {
305  _SEH2_YIELD(return FALSE);
306  }
307  _SEH2_END;
308 
309  return EngBitBlt(psoTrg, psoSrc, psoMask, pco, pxlo, &rclTrg, &ptlSrc, &ptlMask, pbo, &ptlBrush, Rop4);
310 }
BOOL APIENTRY EngBitBlt(_Inout_ SURFOBJ *psoTrg, _In_opt_ SURFOBJ *psoSrc, _In_opt_ SURFOBJ *psoMask, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ RECTL *prclTrg, _In_opt_ POINTL *pptlSrc, _In_opt_ POINTL *pptlMask, _In_opt_ BRUSHOBJ *pbo, _In_opt_ POINTL *pptlBrush, _In_ ROP4 rop4)
Definition: bitblt.c:317
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL * prclTrg
Definition: winddi.h:3433
_In_ SURFOBJ * psoSrc
Definition: winddi.h:3414
#define FALSE
Definition: types.h:117
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ _In_opt_ POINTL * pptlBrush
Definition: winddi.h:3433
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ * pbo
Definition: winddi.h:3433
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
_In_ SURFOBJ _In_ CLIPOBJ * pco
Definition: winddi.h:3414
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL * pptlMask
Definition: winddi.h:3433
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL * pptlSrc
Definition: winddi.h:3433
#define _SEH2_TRY
Definition: pseh2_64.h:5
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoMask
Definition: winddi.h:3433
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ * pxlo
Definition: winddi.h:3414

Variable Documentation

XCLIPOBJ gxcoTrivial
Initial value:
=
{
{
0,
{LONG_MIN, LONG_MIN, LONG_MAX, LONG_MAX},
0
},
{ 0, {0,0,0,0}, 0},
0, {0,0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
#define TC_RECTANGLES
Definition: winddi.h:269
#define DC_TRIVIAL
Definition: winddi.h:259
#define LONG_MAX
Definition: limits.h:43
#define FC_RECT
Definition: winddi.h:264
#define LONG_MIN
Definition: limits.h:42

Definition at line 15 of file bitblt.c.

Referenced by DC_vInitDc(), EngGradientFill(), IntEngAlphaBlend(), IntEngStretchBlt(), and IntEngTransparentBlt().