Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

353 lines
9.6 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: Main.cpp
  3. *
  4. * This file contains the code to support the functionality test harness
  5. * for GDI+. This includes menu options and calling the appropriate
  6. * functions for execution.
  7. *
  8. * Created: 28-Apr-2000 - Jeff Vezina [t-jfvez]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. *
  12. \**************************************************************************/
  13. #undef UNICODE
  14. #undef _UNICODE
  15. #include <windows.h>
  16. #include <commctrl.h>
  17. #include <objbase.h>
  18. #include <gdiplus.h>
  19. #include "CFuncTest.h"
  20. #include "resource.h"
  21. CFuncTest g_FuncTest; // FuncTest (handles test runs)
  22. HBRUSH g_hbrBackground=NULL; // Main window background color
  23. HWND g_hWndMain=NULL; // Main window
  24. int g_nResult=0; // Result of test run
  25. // Include all the outputs (classes derived from COutput)
  26. #include "CHWND.h"
  27. #include "CHDC.h"
  28. #include "CFile.h"
  29. #include "CBitmap.h"
  30. #include "CDIB.h"
  31. #include "CDirect3D.h"
  32. #include "CPrinter.h"
  33. #include "CMetafile.h"
  34. // Include all the primitives (classes derived from CPrimitive)
  35. #include "CPolygons.h"
  36. #include "CBitmaps.h"
  37. #include "CCachedBitmap.h"
  38. #include "CCompoundLines.h"
  39. #include "CContainer.h"
  40. #include "CContainerClip.h"
  41. #include "CDashes.h"
  42. #include "CPathGradient.hpp"
  43. #include "CDash.hpp"
  44. #include "CLines.hpp"
  45. #include "CGradients.h"
  46. #include "CHatch.h"
  47. #include "CImaging.h"
  48. #include "CRecolor.h"
  49. #include "CInsetLines.h"
  50. #include "CMixedObjects.h"
  51. #include "CPaths.h"
  52. #include "CPrimitives.h"
  53. #include "CRegions.h"
  54. #include "CText.h"
  55. #include "CRegression.h"
  56. #include "CSourceCopy.h"
  57. #include "CExtra.h"
  58. // Include all the settings (classes derived from CSetting)
  59. #include "CAntialias.h"
  60. #include "CHalfPixel.h"
  61. #include "CQuality.h"
  62. #include "CHalftone.h"
  63. #include "CChecker.h"
  64. #include "CRotate.h"
  65. #include "CBKGradient.h"
  66. #include "CHatch.h"
  67. #include "../gpinit.inc"
  68. // Create global objects for each individual output
  69. // First constructor param is the regression flag
  70. // If true, the test will take part of the regression suite
  71. CHWND g_HWND(true);
  72. CHDC g_HDC(true);
  73. CDirect3D g_Direct3D(false);
  74. CPrinter g_Printer(false);
  75. CDIB g_DIB1(true,1);
  76. CDIB g_DIB2(false,2);
  77. CDIB g_DIB4(true,4);
  78. CDIB g_DIB8(true,8);
  79. CDIB g_DIB16(true,16);
  80. CDIB g_DIB24(true,24);
  81. CDIB g_DIB32(true,32);
  82. CFile g_File1(false,1);
  83. CFile g_File2(false,2);
  84. CFile g_File4(false,4);
  85. CFile g_File8(false,8);
  86. CFile g_File16(false,16);
  87. CFile g_File24(false,24);
  88. CFile g_File32(false,32);
  89. CBitmap g_Bitmap1(false, PixelFormat1bppIndexed);
  90. CBitmap g_Bitmap4(false, PixelFormat4bppIndexed);
  91. CBitmap g_Bitmap8(false, PixelFormat8bppIndexed);
  92. CBitmap g_Bitmap16Gray(false, PixelFormat16bppGrayScale);
  93. CBitmap g_Bitmap16555(false, PixelFormat16bppRGB555);
  94. CBitmap g_Bitmap16565(false, PixelFormat16bppRGB565);
  95. CBitmap g_Bitmap161555(false, PixelFormat16bppARGB1555);
  96. CBitmap g_Bitmap24(false, PixelFormat24bppRGB);
  97. CBitmap g_Bitmap32RGB(false, PixelFormat32bppRGB);
  98. CBitmap g_Bitmap32ARGB(false, PixelFormat32bppARGB);
  99. CBitmap g_Bitmap32PARGB(false, PixelFormat32bppPARGB);
  100. CBitmap g_Bitmap48RGB(false, PixelFormat48bppRGB);
  101. CBitmap g_Bitmap64ARGB(false, PixelFormat64bppARGB);
  102. CBitmap g_Bitmap64PARGB(false, PixelFormat64bppPARGB);
  103. CMetafile g_MetafileEMF(false, MetafileTypeEmf);
  104. CMetafile g_MetafileEMFPlus(false, MetafileTypeEmfPlusOnly);
  105. CMetafile g_MetafileEMFPlusDual(true, MetafileTypeEmfPlusDual);
  106. CMetafile g_MetafileEMFF(false, MetafileTypeEmf, true);
  107. CMetafile g_MetafileEMFPlusF(false, MetafileTypeEmfPlusOnly, true);
  108. CMetafile g_MetafileEMFPlusDualF(true, MetafileTypeEmfPlusDual, true);
  109. CRegression g_Regression(true);
  110. // Create global objects for each individual setting
  111. // First constructor param is the regression flag
  112. // If true, the test will take part of the regression suite
  113. CAntialias g_Antialias(true);
  114. CHalfPixel g_HalfPixel(true);
  115. CQuality g_Quality(true);
  116. CCompositingMode g_CompositingMode(true);
  117. CHalftone g_Halftone(true);
  118. CChecker g_Checker(true);
  119. CRotate g_Rotate13(true,13);
  120. CRotate g_Rotate45(true,45);
  121. CBKGradient g_BKGradient(true);
  122. CHatch g_Hatch(true);
  123. LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
  124. // Main window proc
  125. {
  126. switch (Msg)
  127. {
  128. case WM_COMMAND: // Process menu buttons
  129. switch(LOWORD(wParam))
  130. {
  131. case IDM_RUN:
  132. g_FuncTest.Run();
  133. break;
  134. case IDM_REGRESSION:
  135. g_FuncTest.RunRegression();
  136. break;
  137. case IDM_OPTIONS:
  138. g_FuncTest.RunOptions();
  139. break;
  140. case IDM_QUIT:
  141. {
  142. HWND hwnd = g_hWndMain;
  143. g_hWndMain = NULL;
  144. DestroyWindow(hwnd);
  145. }
  146. break;
  147. }
  148. break;
  149. case WM_DESTROY:
  150. PostQuitMessage(0);
  151. break;
  152. }
  153. return DefWindowProcA(hWnd,Msg,wParam,lParam);
  154. }
  155. void WindowUninit()
  156. // Uninitializes window
  157. {
  158. if (g_hbrBackground!=NULL) // Destroy background brush
  159. {
  160. DeleteObject((HGDIOBJ)g_hbrBackground);
  161. g_hbrBackground=NULL;
  162. }
  163. if (g_hWndMain!=NULL) // Destroy main window
  164. {
  165. DestroyWindow(g_hWndMain);
  166. g_hWndMain=NULL;
  167. }
  168. }
  169. BOOL WindowInit()
  170. // Creates window and starts up app
  171. {
  172. WNDCLASSA wc;
  173. HINSTANCE hInst=GetModuleHandleA(NULL);
  174. // Create white background brush
  175. g_hbrBackground=CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
  176. wc.style = 0;
  177. wc.lpfnWndProc = WndProc;
  178. wc.cbClsExtra = 0;
  179. wc.cbWndExtra = 0;
  180. wc.hInstance = hInst;
  181. wc.hIcon = LoadIconA(GetModuleHandle(NULL),MAKEINTRESOURCEA(ID_APP));
  182. wc.hCursor = LoadCursorA(NULL,MAKEINTRESOURCEA(32512));
  183. wc.hbrBackground = g_hbrBackground;
  184. wc.lpszMenuName = MAKEINTRESOURCEA(IDR_MENU1);
  185. wc.lpszClassName = "Functest";
  186. if (!RegisterClassA(&wc))
  187. return false;
  188. g_hWndMain=CreateWindowExA(
  189. 0,
  190. "Functest",
  191. "GDI+ Functionality Test",
  192. WS_OVERLAPPED|WS_CAPTION|WS_BORDER|WS_THICKFRAME|WS_MAXIMIZEBOX|
  193. WS_MINIMIZEBOX|WS_CLIPCHILDREN|WS_VISIBLE|WS_MAXIMIZE|WS_SYSMENU,
  194. CW_USEDEFAULT,
  195. CW_USEDEFAULT,
  196. 800,
  197. 600,
  198. NULL,
  199. NULL,
  200. hInst,
  201. NULL
  202. );
  203. HRESULT h=GetLastError();
  204. if (g_hWndMain==NULL)
  205. return false;
  206. UpdateWindow(g_hWndMain);
  207. ShowWindow(g_hWndMain,SW_SHOW);
  208. return true;
  209. }
  210. /***************************************************************************\
  211. * main(argc, argv[])
  212. *
  213. * Sets up the message loop.
  214. *
  215. * History:
  216. * 04-07-91 - Created - KentD
  217. * 04-28-00 - Modified - Jeff Vezina (t-jfvez)
  218. *
  219. \***************************************************************************/
  220. __cdecl main(int argc,PCHAR argv[])
  221. {
  222. MSG msg;
  223. if (!gGdiplusInitHelper.IsValid())
  224. {
  225. return 0;
  226. }
  227. CoInitialize(NULL);
  228. if (!WindowInit())
  229. return 0;
  230. if (!g_FuncTest.Init(g_hWndMain))
  231. return 0;
  232. // Init all primitives, graphics types, and graphics settings
  233. g_HWND.Init();
  234. g_HDC.Init();
  235. g_Direct3D.Init();
  236. g_Printer.Init();
  237. g_DIB1.Init();
  238. g_DIB2.Init();
  239. g_DIB4.Init();
  240. g_DIB8.Init();
  241. g_DIB16.Init();
  242. g_DIB24.Init();
  243. g_DIB32.Init();
  244. g_File1.Init();
  245. g_File2.Init();
  246. g_File4.Init();
  247. g_File8.Init();
  248. g_File16.Init();
  249. g_File24.Init();
  250. g_File32.Init();
  251. g_Bitmap1.Init();
  252. g_Bitmap4.Init();
  253. g_Bitmap8.Init();
  254. g_Bitmap16Gray.Init();
  255. g_Bitmap16555.Init();
  256. g_Bitmap16565.Init();
  257. g_Bitmap161555.Init();
  258. g_Bitmap24.Init();
  259. g_Bitmap32RGB.Init();
  260. g_Bitmap32ARGB.Init();
  261. g_Bitmap32PARGB.Init();
  262. g_Bitmap48RGB.Init();
  263. g_Bitmap64ARGB.Init();
  264. g_Bitmap64PARGB.Init();
  265. g_MetafileEMF.Init();
  266. g_MetafileEMFPlus.Init();
  267. g_MetafileEMFPlusDual.Init();
  268. g_MetafileEMFF.Init();
  269. g_MetafileEMFPlusF.Init();
  270. g_MetafileEMFPlusDualF.Init();
  271. g_Regression.Init();
  272. g_Antialias.Init();
  273. g_Quality.Init();
  274. g_CompositingMode.Init();
  275. g_HalfPixel.Init();
  276. g_Halftone.Init();
  277. g_Checker.Init();
  278. g_Rotate13.Init();
  279. g_Rotate45.Init();
  280. g_BKGradient.Init();
  281. g_Hatch.Init();
  282. // Put initializations into cextra.cpp, so that individual
  283. // developers can implement their own file for private usage.
  284. ExtraInitializations();
  285. for (int i=1;i<argc;i++)
  286. {
  287. if ((_stricmp(argv[i],"/?")==0) || (_stricmp(argv[i],"?")==0) || (_stricmp(argv[i],"-?")==0))
  288. {
  289. printf("Functest command line parameters:\n");
  290. printf("/? - Show the command line parameters\n");
  291. printf("/regression - Run the regression test immediately\n");
  292. return 1;
  293. }
  294. else if (_stricmp(argv[i],"/regression")==0)
  295. {
  296. g_FuncTest.RunRegression();
  297. SendMessageA(g_FuncTest.m_hWndMain,WM_CLOSE,0,0);
  298. return g_nResult;
  299. }
  300. }
  301. while (GetMessageA(&msg,NULL,0,0)) {
  302. TranslateMessage(&msg);
  303. DispatchMessageA(&msg);
  304. }
  305. WindowUninit();
  306. CoUninitialize();
  307. return g_nResult;
  308. }
  309. #define UNICODE
  310. #define _UNICODE