ReactOS 0.4.15-dev-7928-g68a8619
SetLayout.c File Reference
#include "precomp.h"
Include dependency graph for SetLayout.c:

Go to the source code of this file.

Macros

#define BLACK_PIXEL   0x000000
 
#define BLUE_PIXEL   0x0000FF
 
#define GREEN_PIXEL   0x00FF00
 
#define RED_PIXEL   0xFF0000
 
#define WHITE_PIXEL   0xFFFFFF
 
#define WIDTH   10
 

Functions

static void copy (PUINT32 buffer, UINT32 value, int width, int start_x, int start_y, int end_x, int end_y)
 
static void nomirror_test (PUINT32 dstBuffer, PUINT32 srcBuffer, int width, int line)
 
 START_TEST (SetLayout)
 

Macro Definition Documentation

◆ BLACK_PIXEL

#define BLACK_PIXEL   0x000000

Definition at line 21 of file SetLayout.c.

◆ BLUE_PIXEL

#define BLUE_PIXEL   0x0000FF

Definition at line 22 of file SetLayout.c.

◆ GREEN_PIXEL

#define GREEN_PIXEL   0x00FF00

Definition at line 23 of file SetLayout.c.

◆ RED_PIXEL

#define RED_PIXEL   0xFF0000

Definition at line 24 of file SetLayout.c.

◆ WHITE_PIXEL

#define WHITE_PIXEL   0xFFFFFF

Definition at line 25 of file SetLayout.c.

◆ WIDTH

#define WIDTH   10

Definition at line 112 of file SetLayout.c.

Function Documentation

◆ copy()

static void copy ( PUINT32  buffer,
UINT32  value,
int  width,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
static

Definition at line 12 of file SetLayout.c.

13{
14 for (int y = start_y; y < end_y; y++)
15 {
16 for (int x = start_x; x < end_x; x++)
17 buffer[y * width + x] = value;
18 }
19}
static int start_x
Definition: maze.c:118
static int start_y
Definition: maze.c:118
static int end_x
Definition: maze.c:118
static int end_y
Definition: maze.c:118
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
Definition: pdh_main.c:94

Referenced by START_TEST().

◆ nomirror_test()

static void nomirror_test ( PUINT32  dstBuffer,
PUINT32  srcBuffer,
int  width,
int  line 
)
static

Definition at line 90 of file SetLayout.c.

91{
92 for (int y = 0; y < width; y++)
93 {
94 for (int x = 0; x < width; x++)
95 {
96 if (x == width - 1)
97 {
98 ok(dstBuffer[y * width + x] == BLACK_PIXEL,
99 "Expected blank (black) pixel (0x0), got (%06X), coordinates (%d, %d). line: %d\n",
100 dstBuffer[y * width + x], x, y, line);
101 }
102 else
103 {
104 ok(dstBuffer[y * width + x] == srcBuffer[y * width + x + 1],
105 "Coordinates: (%d, %d), expected (%06X), got (%06X). line: %d\n",
106 x, y, srcBuffer[y * width + x + 1], dstBuffer[y * width + x], line);
107 }
108 }
109 }
110}
#define BLACK_PIXEL
Definition: SetLayout.c:21
#define ok(value,...)
Definition: atltest.h:57
Definition: parser.c:49

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( SetLayout  )

Definition at line 113 of file SetLayout.c.

114{
115 HBITMAP bmpDst, bmpSrc, oldDst, oldSrc;
117 PUINT32 dstBuffer, srcBuffer;
118 BITMAPINFO info = { 0 };
119 size_t nBuf = WIDTH * WIDTH * sizeof(UINT32);
120
124
125 info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
126 info.bmiHeader.biWidth = WIDTH;
127 info.bmiHeader.biHeight = -WIDTH;
128 info.bmiHeader.biPlanes = 1;
129 info.bmiHeader.biBitCount = 32;
130 info.bmiHeader.biCompression = BI_RGB;
131
132 /* Create bitmaps to test with */
133 bmpSrc = CreateDIBSection(hdcSrc, &info, DIB_RGB_COLORS, (PVOID*)&srcBuffer, NULL, 0);
134 bmpDst = CreateDIBSection(hdcDst, &info, DIB_RGB_COLORS, (PVOID*)&dstBuffer, NULL, 0);
135
136 if (!bmpSrc || !bmpDst)
137 {
138 skip("Failed to create bitmaps");
139 goto cleanup;
140 }
141
142 oldSrc = SelectObject(hdcSrc, bmpSrc);
143 oldDst = SelectObject(hdcDst, bmpDst);
144
145 /* Create base "image" for use in the tests */
146 copy(srcBuffer, WHITE_PIXEL, WIDTH, 0, 0, WIDTH / 2, WIDTH / 2);
147 copy(srcBuffer, BLUE_PIXEL, WIDTH, 0, WIDTH / 2, WIDTH / 2, WIDTH);
148 copy(srcBuffer, GREEN_PIXEL, WIDTH, WIDTH / 2, 0, WIDTH, WIDTH / 2);
149 copy(srcBuffer, RED_PIXEL, WIDTH, WIDTH / 2, WIDTH / 2, WIDTH, WIDTH);
150
151 /* Mirror destination DC */
153 ok(GetLayout(hdcDst) == LAYOUT_RTL, "DC layout is not RTL\n");
154 ok(GetMapMode(hdcDst) == MM_ANISOTROPIC, "DC Map mode is not MM_ANISOTROPIC\n");
155
156 /* Test RTL transform (using LPtoDP) and the inverse transform (DPtoLP) */
157 for (int y = 0; y < WIDTH; y++)
158 {
159 for (int x = 0; x < WIDTH; x++)
160 {
161 POINT pt = { x, y };
162 POINT mirrored = { WIDTH - 1 - x, y }; /* Expected results */
163
164 LPtoDP(hdcDst, &pt, 1);
165 /* Test LPtoDP */
166 ok(pt.x == mirrored.x && pt.y == mirrored.y,
167 "Coodinates: (%d, %d), expected (%ld, %ld), got (%ld, %ld)\n",
168 x, y, mirrored.x, mirrored.y, pt.x, pt.y);
169
170 pt = mirrored;
171
172 /* Test DPtoLP */
173 DPtoLP(hdcDst, &pt, 1);
174 ok(pt.x == x && pt.y == y,
175 "Mirrored Coodinates: (%ld, %ld), expected (%d, %d), got (%ld, %ld)\n",
176 mirrored.x, mirrored.y, x, y, pt.x, pt.y);
177 }
178 }
179
180 ZeroMemory(dstBuffer, nBuf);
182 for (int y = 0; y < WIDTH; y++)
183 {
184 for (int x = 0; x < WIDTH; x++)
185 {
186 /* Test if the image is mirrored using the assumed RTL transform results */
187 ok(dstBuffer[y * WIDTH + (WIDTH - 1 - x)] == srcBuffer[y * WIDTH + x],
188 "Coordinates: (%d, %d), expected (%06X), got (%06X)\n",
189 x, y, srcBuffer[y * WIDTH + x], dstBuffer[y * WIDTH + (WIDTH - 1 - x)]);
190 }
191 }
192
193 ZeroMemory(dstBuffer, nBuf);
195 nomirror_test(dstBuffer, srcBuffer, WIDTH, __LINE__);
196
197 ZeroMemory(dstBuffer, nBuf);
198 BitBlt(hdcDst, 0, 0, WIDTH, WIDTH, hdcSrc, 0, 0, SRCCOPY);
199 for (int y = 0; y < WIDTH; y++)
200 {
201 for (int x = 0; x < WIDTH; x++)
202 {
203 /* Test if the image is mirrored using the assumed RTL transform results */
204 ok(dstBuffer[y * WIDTH + (WIDTH - 1 - x)] == srcBuffer[y * WIDTH + x],
205 "Coordinates: (%d, %d), expected (%06X), got (%06X)\n",
206 x, y, srcBuffer[y * WIDTH + x], dstBuffer[y * WIDTH + (WIDTH - 1 - x)]);
207 }
208 }
209
210 ZeroMemory(dstBuffer, nBuf);
212 nomirror_test(dstBuffer, srcBuffer, WIDTH, __LINE__);
213
215
217 "DC Layout is not LAYOUT_RTL | LAYOUT_BITMAPORIENTATIONPRESERVED\n");
218 ok(GetMapMode(hdcDst) == MM_ANISOTROPIC, "DC Map mode is not MM_ANISOTROPIC\n");
219
220 ZeroMemory(dstBuffer, nBuf);
222 nomirror_test(dstBuffer, srcBuffer, WIDTH, __LINE__);
223
224 ZeroMemory(dstBuffer, nBuf);
226 nomirror_test(dstBuffer, srcBuffer, WIDTH, __LINE__);
227
228 ZeroMemory(dstBuffer, nBuf);
229 BitBlt(hdcDst, 0, 0, WIDTH, WIDTH, hdcSrc, 0, 0, SRCCOPY);
230 nomirror_test(dstBuffer, srcBuffer, WIDTH, __LINE__);
231
232 ZeroMemory(dstBuffer, nBuf);
234 nomirror_test(dstBuffer, srcBuffer, WIDTH, __LINE__);
235
236 /* Reset DC layout to default (LTR) */
238 ok(GetLayout(hdcDst) == LAYOUT_LTR, "DC layout is not LAYOUT_LTR");
239
240 for (int y = 0; y < WIDTH; y++)
241 {
242 for (int x = 0; x < WIDTH; x++)
243 {
244 POINT pt = { x, y };
245
246 LPtoDP(hdcDst, &pt, 1);
247 /* Confirm that RTL transform is not the current one */
248 ok(pt.x == x && pt.y == y,
249 "Expected (%d, %d) got (%ld, %ld)\n", x, y, pt.x, pt.y);
250 }
251 }
252
253 ZeroMemory(dstBuffer, nBuf);
255 ok(memcmp(dstBuffer, srcBuffer, nBuf) == 0, "Bitmaps are not identical\n");
256
258 ok(GetLayout(hdcDst) == LAYOUT_BITMAPORIENTATIONPRESERVED, "DC Layout is not LAYOUT_BITMAPORIENTATIONPRESERVED");
259
260 SelectObject(hdcSrc, oldSrc);
261 SelectObject(hdcDst, oldDst);
262 DeleteObject(bmpSrc);
263 DeleteObject(bmpDst);
264cleanup:
267 DeleteDC(hdc);
268}
unsigned int UINT32
#define WHITE_PIXEL
Definition: SetLayout.c:25
#define WIDTH
Definition: SetLayout.c:112
#define BLUE_PIXEL
Definition: SetLayout.c:22
static void copy(PUINT32 buffer, UINT32 value, int width, int start_x, int start_y, int end_x, int end_y)
Definition: SetLayout.c:12
#define RED_PIXEL
Definition: SetLayout.c:24
#define GREEN_PIXEL
Definition: SetLayout.c:23
static void nomirror_test(PUINT32 dstBuffer, PUINT32 srcBuffer, int width, int line)
Definition: SetLayout.c:90
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define skip(...)
Definition: atltest.h:64
unsigned int * PUINT32
Definition: basetsd.h:125
#define NULL
Definition: types.h:112
static void cleanup(void)
Definition: main.c:1335
#define pt(x, y)
Definition: drawing.c:79
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define BI_RGB
Definition: precomp.h:56
pKey DeleteObject()
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
DWORD WINAPI SetLayout(_In_ HDC hdc, _In_ DWORD dwLayout)
Definition: coord.c:780
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define LAYOUT_LTR
Definition: dc.c:36
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define ZeroMemory
Definition: winbase.h:1712
#define NOMIRRORBITMAP
Definition: wingdi.h:1377
#define DIB_RGB_COLORS
Definition: wingdi.h:367
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
BOOL WINAPI LPtoDP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
#define LAYOUT_RTL
Definition: wingdi.h:1371
int WINAPI GetMapMode(_In_ HDC)
Definition: coord.c:114
BOOL WINAPI DeleteDC(_In_ HDC)
#define LAYOUT_BITMAPORIENTATIONPRESERVED
Definition: wingdi.h:1375
static HDC hdcSrc
Definition: xlate.c:32
static HDC hdcDst
Definition: xlate.c:32