ReactOS 0.4.15-dev-6049-ge54b32b
PatBlt.c File Reference
#include "precomp.h"
Include dependency graph for PatBlt.c:

Go to the source code of this file.

Functions

void Test_PatBlt_Params ()
 
void Test_BrushOrigin ()
 
 START_TEST (PatBlt)
 

Variables

HBITMAP ghbmpTarget
 
PULONG gpulTargetBits
 
HDC hdcTarget
 

Function Documentation

◆ START_TEST()

START_TEST ( PatBlt  )

Definition at line 126 of file PatBlt.c.

127{
128 BITMAPINFO bmi;
129
130 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
131 bmi.bmiHeader.biWidth = 16;
132 bmi.bmiHeader.biHeight = -16;
133 bmi.bmiHeader.biPlanes = 1;
134 bmi.bmiHeader.biBitCount = 32;
136 bmi.bmiHeader.biSizeImage = 0;
139 bmi.bmiHeader.biClrUsed = 0;
142 &bmi,
145 NULL,
146 0);
147 if (!ghbmpTarget)
148 {
149 printf("Couln not create target bitmap\n");
150 return;
151 }
152
154 if (!hdcTarget)
155 {
156 printf("Couln not create target dc\n");
157 return;
158 }
159
160
162 {
163 printf("Failed to select bitmap\n");
164 return;
165 }
166
168
170
171
172}
PULONG gpulTargetBits
Definition: PatBlt.c:11
HDC hdcTarget
Definition: PatBlt.c:12
HBITMAP ghbmpTarget
Definition: PatBlt.c:10
void Test_PatBlt_Params()
Definition: PatBlt.c:14
void Test_BrushOrigin()
Definition: PatBlt.c:80
#define NULL
Definition: types.h:112
#define BI_RGB
Definition: precomp.h:47
#define printf
Definition: freeldr.h:94
ULONG biClrImportant
Definition: precomp.h:43
USHORT biBitCount
Definition: precomp.h:37
LONG biYPelsPerMeter
Definition: precomp.h:41
ULONG biCompression
Definition: precomp.h:38
LONG biXPelsPerMeter
Definition: precomp.h:40
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)

◆ Test_BrushOrigin()

void Test_BrushOrigin ( )

Definition at line 80 of file PatBlt.c.

81{
82 ULONG aulBits[2] = {0x5555AAAA, 0};
84 HBRUSH hbr;
85 BOOL ret;
86
87 hbmp = CreateBitmap(2, 2, 1, 1, aulBits);
88 if (!hbmp)
89 {
90 printf("Couln not create a bitmap\n");
91 return;
92 }
93
95 if (!hbr)
96 {
97 printf("Couln not create a bitmap\n");
98 return;
99 }
100
101 if (!SelectObject(hdcTarget, hbr))
102 {
103 printf("failed to select pattern brush\n");
104 return;
105 }
106
107 ret = PatBlt(hdcTarget, 0, 0, 2, 2, PATCOPY);
108 ok_long(ret, 1);
109 ok_long(gpulTargetBits[0], 0xffffff);
110 ok_long(gpulTargetBits[1], 0);
111 ok_long(gpulTargetBits[16], 0);
112 ok_long(gpulTargetBits[17], 0xffffff);
113 //printf("0x%lx, 0x%lx\n", gpulTargetBits[0], gpulTargetBits[1]);
114
115 ret = PatBlt(hdcTarget, 1, 0, 2, 2, PATCOPY);
116 ok_long(ret, 1);
117 ok_long(gpulTargetBits[0], 0xffffff);
118 ok_long(gpulTargetBits[1], 0);
119 ok_long(gpulTargetBits[2], 0xffffff);
120 ok_long(gpulTargetBits[16], 0);
121 ok_long(gpulTargetBits[17], 0xffffff);
122 ok_long(gpulTargetBits[18], 0);
123
124}
#define ok_long(expression, result)
Definition: atltest.h:133
HBITMAP hbmp
unsigned int BOOL
Definition: ntddk_ex.h:94
static HBITMAP
Definition: button.c:44
uint32_t ULONG
Definition: typedefs.h:59
int ret
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)

Referenced by START_TEST().

◆ Test_PatBlt_Params()

void Test_PatBlt_Params ( )

Definition at line 14 of file PatBlt.c.

15{
16 BOOL ret;
17 ULONG i, rop;
18 HDC hdc;
19
20 /* Test a rop that contains only the operation index */
21 ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
22 ok_long(ret, 1);
23
24 /* Test a rop that contains arbitrary values outside the operation index */
25 ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
26 ok_long(ret, 1);
27
28 /* Test an invalid rop */
29 SetLastError(0);
30 ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
31 ok_err(0);
32
33 /* Test all rops */
34 for (i = 0; i < 256; i++)
35 {
36 rop = i << 16;
37 ret = PatBlt(hdcTarget, 0, 0, 1, 1, rop);
38
39 /* Only these should succeed (they use no source) */
40 if ((i == 0) || (i == 5) || (i == 10) || (i == 15) || (i == 80) ||
41 (i == 85) || (i == 90) || (i == 95) || (i == 160) || (i == 165) ||
42 (i == 170) || (i == 175) || (i == 240) || (i == 245) ||
43 (i == 250) || (i == 255))
44 {
45 ok(ret == 1, "index %ld failed, but should succeed\n", i);
46 }
47 else
48 {
49 ok(ret == 0, "index %ld succeeded, but should fail\n", i);
50 }
51 }
52
53 /* Test quaternary rop, the background part is simply ignored */
54 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, PATINVERT));
55 ok_long(ret, 1);
56 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, SRCCOPY));
57 ok_long(ret, 1);
58 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(SRCCOPY, PATCOPY));
59 ok_long(ret, 0);
60
61 /* Test an info DC */
62 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
63 ok(hdc != 0, "\n");
64 SetLastError(0);
65 ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
66 ok_err(0);
68
69 /* Test a mem DC without selecting a bitmap */
71 ok(hdc != 0, "\n");
72 ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
73 ok_err(0);
75
76
77
78}
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define SetLastError(x)
Definition: compat.h:752
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
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
#define PATINVERT
Definition: wingdi.h:328
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
#define MAKEROP4(f, b)
Definition: wingdi.h:2946

Referenced by START_TEST().

Variable Documentation

◆ ghbmpTarget

HBITMAP ghbmpTarget

Definition at line 10 of file PatBlt.c.

Referenced by START_TEST().

◆ gpulTargetBits

PULONG gpulTargetBits

Definition at line 11 of file PatBlt.c.

Referenced by START_TEST(), and Test_BrushOrigin().

◆ hdcTarget