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.

1737 lines
42 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. Draw.c
  5. Abstract:
  6. Win32 application to display performance statictics. This routine implements
  7. graphics output for display windows.
  8. Author:
  9. Mark Enstrom (marke)
  10. Environment:
  11. Win32
  12. Revision History:
  13. 10-07-92 Initial version
  14. --*/
  15. //
  16. // set variable to define global variables
  17. //
  18. #include <nt.h>
  19. #include <ntrtl.h>
  20. #include <nturtl.h>
  21. #include <windows.h>
  22. #include <math.h>
  23. #include <errno.h>
  24. #include "Wperf.h"
  25. extern DISPLAY_ITEM PerfDataList[SAVE_SUBJECTS];
  26. extern WINPERF_INFO WinperfInfo;
  27. extern PUCHAR PerfNames[];
  28. BOOLEAN
  29. FitPerfWindows(
  30. IN HWND hWnd,
  31. IN HDC hDC,
  32. IN PDISPLAY_ITEM DisplayItems,
  33. IN ULONG NumberOfWindows
  34. )
  35. /*++
  36. Routine Description:
  37. Calculate all parameters to fit the given number of
  38. windows into the app window. Fill out the data structure
  39. for each sub-window
  40. Arguments:
  41. hDC - Screen context
  42. DisplayItems - List of display structures
  43. NumberOfWindows - Number of sub-windows
  44. Return Value:
  45. Status
  46. Revision History:
  47. 02-17-91 Initial code
  48. --*/
  49. {
  50. RECT ClientRect;
  51. int cx,cy;
  52. UINT Index;
  53. int ActiveWindows,IndexX,IndexY;
  54. int WindowsX,WindowsY,WindowWidth,WindowHeight;
  55. int LastRowWidth,LoopWidth;
  56. double fWindowsX,fActiveWindows,fcx,fcy;
  57. //
  58. // Find out the client area bounds
  59. //
  60. GetClientRect(hWnd,&ClientRect);
  61. cx = ClientRect.right;
  62. cy = ClientRect.bottom - 2; // subtract 2 to give a little more border
  63. //
  64. // Find out how many perf windows are active
  65. //
  66. ActiveWindows = 0;
  67. for (Index=0;Index<NumberOfWindows;Index++) {
  68. if (DisplayItems[Index].Display == TRUE) {
  69. ActiveWindows++;
  70. }
  71. }
  72. //
  73. // Return if there are no active windows to display
  74. //
  75. if (ActiveWindows == 0) {
  76. return(TRUE);
  77. }
  78. //
  79. // Now convert the window dimensions to floating point and
  80. // then take the square root of the window dimension to find
  81. // out the number of windows in the x direction
  82. //
  83. fActiveWindows = 1.0 * ActiveWindows;
  84. fcx = 1.0 * cx;
  85. fcy = 1.0 * cy;
  86. if (fcy != 0.0) {
  87. fWindowsX = sqrt((fcx * fActiveWindows) / fcy);
  88. } else {
  89. //
  90. // If fcy = 0 then return since this is an error condition that
  91. // would cause a divide by zero.
  92. //
  93. return(FALSE);
  94. }
  95. //
  96. // convert back to integer
  97. //
  98. WindowsX = (int)fWindowsX;
  99. if (WindowsX == 0) {
  100. WindowsX = 1;
  101. } else if (WindowsX > ActiveWindows) {
  102. WindowsX = ActiveWindows;
  103. }
  104. WindowsY = ActiveWindows / WindowsX;
  105. //
  106. // Add on extra line to Y to take care of the left over windows ie:
  107. // if there are 15 active windows and the x number = 7 then y = 2 with 1
  108. // left over.
  109. //
  110. Index = ActiveWindows - (WindowsX * WindowsY);
  111. if (Index > 0) {
  112. WindowsY++;
  113. LastRowWidth = cx / Index;
  114. } else {
  115. LastRowWidth = cx / WindowsX;
  116. }
  117. WindowWidth = cx / WindowsX;
  118. WindowHeight = cy / WindowsY;
  119. //
  120. // Assign positions for each active window
  121. //
  122. Index = 0;
  123. for (IndexY=0;IndexY<WindowsY;IndexY++) {
  124. for (IndexX=0;IndexX<WindowsX;IndexX++) {
  125. //
  126. // Find the next active display item
  127. //
  128. while ((DisplayItems[Index].Display != TRUE) && (Index < NumberOfWindows)) {
  129. Index++;
  130. }
  131. //
  132. // Add y fixup for last row
  133. //
  134. if (IndexY == WindowsY - 1) {
  135. LoopWidth = LastRowWidth;
  136. } else {
  137. LoopWidth = WindowWidth;
  138. }
  139. DisplayItems[Index].PositionX = LoopWidth * IndexX;
  140. DisplayItems[Index].PositionY = WindowHeight * IndexY + 1; // +1 for more top border
  141. DisplayItems[Index].Width = LoopWidth - 1;
  142. DisplayItems[Index].Height = WindowHeight - 1;
  143. //
  144. // Last Column fix-up to use all of window.
  145. //
  146. if (IndexX == WindowsX - 1) {
  147. DisplayItems[Index].Width = cx - DisplayItems[Index].PositionX - 1;
  148. }
  149. //
  150. //
  151. //
  152. Index++;
  153. if (Index >= NumberOfWindows) {
  154. break;
  155. }
  156. }
  157. if (Index >= NumberOfWindows) {
  158. break;
  159. }
  160. }
  161. return(TRUE);
  162. }
  163. VOID
  164. CalcDrawFrame(
  165. PDISPLAY_ITEM DisplayItem
  166. )
  167. /*++
  168. Routine Description:
  169. Calculate all borders for graphics windows
  170. Arguments:
  171. DisplayItem - Data structure with all perf window info
  172. Return Value:
  173. status of operation
  174. Revision History:
  175. 03-21-91 Initial code
  176. --*/
  177. {
  178. LONG x1,x2,y1,y2;
  179. LONG gx1,gx2,gy1,gy2;
  180. LONG tx1,tx2,ty1,ty2;
  181. LONG GraphHeight,TextHeight;
  182. BOOLEAN TextWindow;
  183. double fx1,fx2,fy1;
  184. //
  185. // Draw a 3-d stand out box around item window
  186. //
  187. x1 = DisplayItem->PositionX + 2;
  188. x2 = DisplayItem->PositionX + DisplayItem->Width - 2;
  189. y1 = DisplayItem->PositionY + 2;
  190. y2 = DisplayItem->PositionY + DisplayItem->Height - 2;
  191. //
  192. // find out in there is enough space for a text window
  193. //
  194. if ((y2 - y1 - 12) > 30) {
  195. TextWindow = TRUE;
  196. //
  197. // Calculate dimensions for a text window and a graphics window
  198. //
  199. // fx1 = portion of the window - bordres and free space
  200. //
  201. // fx2 = fraction of window used for graphics
  202. //
  203. // fy1 = fraction of winddow used for text
  204. //
  205. fx1 = (y2 - y1 - 10);
  206. fx2 = fx1 * 0.6666;
  207. fy1 = fx1 * 0.3333;
  208. GraphHeight = (LONG)fx2;
  209. TextHeight = (LONG)fy1;
  210. if (TextHeight > 20) {
  211. GraphHeight += TextHeight-20;
  212. TextHeight = 20;
  213. }
  214. //
  215. // Calculate window boundaries
  216. //
  217. gx1 = x1 + 4;
  218. gx2 = x2 - 4;
  219. gy1 = y1 + 4;
  220. gy2 = y1 + 4 + GraphHeight + 1;
  221. tx1 = x1 + 4;
  222. tx2 = x2 - 4;
  223. ty1 = gy2 + 1 + 2 + 1; // border,free space,border
  224. ty2 = gy2 + TextHeight + 1;
  225. } else {
  226. TextWindow = FALSE;
  227. GraphHeight = y2 - y1 - 10;
  228. gx1 = x1 + 4;
  229. gx2 = x2 - 4;
  230. gy1 = y1 + 4;
  231. gy2 = y2 - 4;
  232. tx1 = tx2 = ty1 = ty2 = 0;
  233. }
  234. //
  235. // Fill in structures for drawing text and graphics
  236. //
  237. DisplayItem->Border.left = x1;
  238. DisplayItem->Border.right = x2;
  239. DisplayItem->Border.top = y1;
  240. DisplayItem->Border.bottom = y2;
  241. DisplayItem->GraphBorder.left = gx1;
  242. DisplayItem->GraphBorder.right = gx2;
  243. DisplayItem->GraphBorder.top = gy1;
  244. DisplayItem->GraphBorder.bottom = gy2;
  245. DisplayItem->TextBorder.left = tx1;
  246. DisplayItem->TextBorder.right = tx2;
  247. DisplayItem->TextBorder.top = ty1;
  248. DisplayItem->TextBorder.bottom = ty2;
  249. }
  250. VOID
  251. DrawFrame(
  252. HDC hDC,
  253. PDISPLAY_ITEM DisplayItem
  254. )
  255. /*++
  256. Routine Description:
  257. Draw the window frame for a performance window
  258. Arguments:
  259. hDC - Device Context for window
  260. DisplayItem - Data structure with all perf window info
  261. Return Value:
  262. status of operation
  263. Revision History:
  264. 03-21-91 Initial code
  265. --*/
  266. {
  267. RECT DrawRect;
  268. LONG x1,x2,y1,y2;
  269. LONG gx1,gx2,gy1,gy2;
  270. LONG tx1,tx2,ty1,ty2;
  271. //
  272. // Draw a 3-d stand out box around item window
  273. //
  274. x1 = DisplayItem->Border.left;
  275. x2 = DisplayItem->Border.right;
  276. y1 = DisplayItem->Border.top;
  277. y2 = DisplayItem->Border.bottom;
  278. gx1 = DisplayItem->GraphBorder.left;
  279. gx2 = DisplayItem->GraphBorder.right;
  280. gy1 = DisplayItem->GraphBorder.top;
  281. gy2 = DisplayItem->GraphBorder.bottom;
  282. tx1 = DisplayItem->TextBorder.left;
  283. tx2 = DisplayItem->TextBorder.right;
  284. ty1 = DisplayItem->TextBorder.top;
  285. ty2 = DisplayItem->TextBorder.bottom;
  286. //
  287. // Draw top border in light shade
  288. //
  289. DrawRect.left = x1;
  290. DrawRect.right = x2;
  291. DrawRect.top = y1;
  292. DrawRect.bottom = y1 + 2;
  293. FillRect(hDC,&DrawRect,WinperfInfo.hLightBrush);
  294. //
  295. // Draw Left border in light shade
  296. //
  297. DrawRect.left = x1;
  298. DrawRect.right = x1 + 2;
  299. DrawRect.top = y1;
  300. DrawRect.bottom = y2;
  301. FillRect(hDC,&DrawRect,WinperfInfo.hLightBrush);
  302. //
  303. // Draw right border in dark shade
  304. //
  305. DrawRect.left = x2 - 2;
  306. DrawRect.right = x2;
  307. DrawRect.top = y1;
  308. DrawRect.bottom = y2;
  309. FillRect(hDC,&DrawRect,WinperfInfo.hDarkBrush);
  310. //
  311. // draw bottom in dark shade
  312. //
  313. DrawRect.left = x1;
  314. DrawRect.right = x2;
  315. DrawRect.top = y2-2;
  316. DrawRect.bottom = y2;
  317. FillRect(hDC,&DrawRect,WinperfInfo.hDarkBrush);
  318. //
  319. // Draw graphics area single border
  320. //
  321. //
  322. // Draw top border in dark shade
  323. //
  324. DrawRect.left = gx1;
  325. DrawRect.right = gx2;
  326. DrawRect.top = gy1;
  327. DrawRect.bottom = gy1+1;
  328. FillRect(hDC,&DrawRect,WinperfInfo.hDarkBrush);
  329. //
  330. // Draw Left border in Dark shade
  331. //
  332. DrawRect.left = gx1;
  333. DrawRect.right = gx1 + 1;
  334. DrawRect.top = gy1;
  335. DrawRect.bottom = gy2;
  336. FillRect(hDC,&DrawRect,WinperfInfo.hDarkBrush);
  337. //
  338. // Draw right border in Light shade
  339. //
  340. DrawRect.left = gx2 - 1;
  341. DrawRect.right = gx2;
  342. DrawRect.top = gy1;
  343. DrawRect.bottom = gy2;
  344. FillRect(hDC,&DrawRect,WinperfInfo.hLightBrush);
  345. //
  346. // draw bottom in Light shade
  347. //
  348. DrawRect.left = gx1;
  349. DrawRect.right = gx2;
  350. DrawRect.top = gy2-1;
  351. DrawRect.bottom = gy2;
  352. FillRect(hDC,&DrawRect,WinperfInfo.hLightBrush);
  353. if (tx2 > 0) {
  354. //
  355. // Draw top border in Dark shade
  356. //
  357. DrawRect.left = tx1;
  358. DrawRect.right = tx2;
  359. DrawRect.top = ty1;
  360. DrawRect.bottom = ty1 + 1;
  361. FillRect(hDC,&DrawRect,WinperfInfo.hDarkBrush);
  362. //
  363. // Draw Left border in Dark shade
  364. //
  365. DrawRect.left = tx1;
  366. DrawRect.right = tx1 + 1;
  367. DrawRect.top = ty1;
  368. DrawRect.bottom = ty2;
  369. FillRect(hDC,&DrawRect,WinperfInfo.hDarkBrush);
  370. //
  371. // Draw right border in Light shade
  372. //
  373. DrawRect.left = tx2 - 1;
  374. DrawRect.right = tx2;
  375. DrawRect.top = ty1;
  376. DrawRect.bottom = ty2;
  377. FillRect(hDC,&DrawRect,WinperfInfo.hLightBrush);
  378. //
  379. // draw bottom in Light shade
  380. //
  381. DrawRect.left = tx1;
  382. DrawRect.right = tx2;
  383. DrawRect.top = ty2-1;
  384. DrawRect.bottom = ty2;
  385. FillRect(hDC,&DrawRect,WinperfInfo.hLightBrush);
  386. }
  387. }
  388. VOID
  389. DrawPerfText(
  390. HDC hDC,
  391. PDISPLAY_ITEM DisplayItem,
  392. UINT Item
  393. )
  394. /*++
  395. Routine Description:
  396. Draw text into the perf window
  397. Arguments:
  398. hDC - Device Context for window
  399. DisplayItem - Data structure with all perf window info
  400. Return Value:
  401. status of operation
  402. Revision History:
  403. 03-21-91 Initial code
  404. --*/
  405. {
  406. RECT TextRect;
  407. UCHAR TextStr[50];
  408. UINT FontSize;
  409. //
  410. // Check that text display is enabled
  411. //
  412. if (DisplayItem->TextBorder.right == 0) {
  413. return;
  414. }
  415. TextRect.left = DisplayItem->TextBorder.left +1;
  416. TextRect.right = DisplayItem->TextBorder.right -1;
  417. TextRect.top = DisplayItem->TextBorder.top +1;
  418. TextRect.bottom = DisplayItem->TextBorder.bottom -1;
  419. FillRect(hDC,&TextRect,WinperfInfo.hBackground);
  420. SetBkColor(hDC,RGB(192,192,192));
  421. //
  422. // Decide which font to draw with
  423. //
  424. FontSize = TextRect.bottom - TextRect.top;
  425. if (FontSize >= 15) {
  426. WinperfInfo.hOldFont = SelectObject(hDC,WinperfInfo.LargeFont);
  427. } else if (FontSize > 10) {
  428. WinperfInfo.hOldFont = SelectObject(hDC,WinperfInfo.MediumFont);
  429. } else {
  430. WinperfInfo.hOldFont = SelectObject(hDC,WinperfInfo.SmallFont);
  431. }
  432. DrawText(
  433. hDC,
  434. PerfNames[Item],
  435. strlen(PerfNames[Item]),
  436. &TextRect,
  437. DT_LEFT | DT_VCENTER | DT_SINGLELINE
  438. );
  439. //
  440. // Build the numeric value
  441. //
  442. wsprintf(TextStr," %li",DisplayItem->TotalTime[0]);
  443. DrawText(
  444. hDC,
  445. TextStr,
  446. strlen(TextStr),
  447. &TextRect,
  448. DT_RIGHT | DT_VCENTER | DT_SINGLELINE
  449. );
  450. SelectObject(hDC,WinperfInfo.hOldFont);
  451. }
  452. VOID
  453. DrawPerfGraph(
  454. HDC hDC,
  455. PDISPLAY_ITEM DisplayItem
  456. )
  457. /*++
  458. Routine Description:
  459. Draw graphics into the perf window
  460. Arguments:
  461. hDC - Device Context for window
  462. DisplayItem - Data structure with all perf window info
  463. Return Value:
  464. status of operation
  465. Revision History:
  466. 03-21-91 Initial code
  467. --*/
  468. {
  469. RECT GraphRect,MemGraphRect;
  470. ULONG Scale,i,GraphWidth,GraphHeight;
  471. GraphRect.left = DisplayItem->GraphBorder.left + 1;
  472. GraphRect.right = DisplayItem->GraphBorder.right - 1;
  473. GraphRect.top = DisplayItem->GraphBorder.top + 1;
  474. GraphRect.bottom = DisplayItem->GraphBorder.bottom - 1;
  475. GraphWidth = GraphRect.right - GraphRect.left -1;
  476. GraphHeight = GraphRect.bottom - GraphRect.top -1;
  477. //
  478. // Memory bitmap is zero-offset for all windows, add 1 to make fillrect fill out
  479. // to right and bottom edge
  480. //
  481. MemGraphRect.left = 0;
  482. MemGraphRect.right = GraphWidth +1;
  483. MemGraphRect.top = 0;
  484. MemGraphRect.bottom = GraphHeight +1;
  485. FillRect(DisplayItem->MemoryDC,&MemGraphRect,WinperfInfo.hBackground);
  486. MemGraphRect.right = GraphWidth;
  487. MemGraphRect.bottom = GraphHeight;
  488. if (DisplayItem->Max == 0) {
  489. DisplayItem->Max = 1;
  490. }
  491. //
  492. // calculate scale from data to perf window
  493. //
  494. //
  495. // X scale factor (100 items in x space). Scale can not be less than 1
  496. //
  497. Scale = (GraphWidth -1)/ DATA_LIST_LENGTH;
  498. if (Scale == 0) {
  499. Scale = 1;
  500. }
  501. //
  502. // Draw UserTime if needed
  503. //
  504. if (DisplayItem->NumberOfElements>1) {
  505. //
  506. // Select kernel pen
  507. //
  508. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hRedPen);
  509. MoveToEx(DisplayItem->MemoryDC,
  510. MemGraphRect.right,
  511. MemGraphRect.bottom - (DisplayItem->KernelTime[0] * GraphHeight)/ DisplayItem->Max,
  512. (LPPOINT)NULL);
  513. for (i=1;((i<DATA_LIST_LENGTH) && i*Scale < GraphWidth);i++) {
  514. LineTo(DisplayItem->MemoryDC,
  515. MemGraphRect.right - Scale * i,
  516. MemGraphRect.bottom - (DisplayItem->KernelTime[i] * GraphHeight)/DisplayItem->Max
  517. );
  518. }
  519. //
  520. // Select User Pen
  521. //
  522. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hGreenPen);
  523. MoveToEx(DisplayItem->MemoryDC,
  524. MemGraphRect.right,
  525. MemGraphRect.bottom - (DisplayItem->UserTime[0] * GraphHeight)/ DisplayItem->Max,
  526. (LPPOINT)NULL);
  527. for (i=1;((i<DATA_LIST_LENGTH) && i * Scale < GraphWidth);i++) {
  528. LineTo(DisplayItem->MemoryDC,
  529. MemGraphRect.right - Scale * i,
  530. MemGraphRect.bottom - (DisplayItem->UserTime[i] * GraphHeight)/DisplayItem->Max);
  531. }
  532. //
  533. // Select DPC Pen
  534. //
  535. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hYellowPen);
  536. MoveToEx(DisplayItem->MemoryDC,
  537. MemGraphRect.right,
  538. MemGraphRect.bottom - (DisplayItem->UserTime[0] * GraphHeight)/ DisplayItem->Max,
  539. (LPPOINT)NULL);
  540. for (i=1;((i<DATA_LIST_LENGTH) && i * Scale < GraphWidth);i++) {
  541. LineTo(DisplayItem->MemoryDC,
  542. MemGraphRect.right - Scale * i,
  543. MemGraphRect.bottom - (DisplayItem->DpcTime[i] * GraphHeight)/DisplayItem->Max);
  544. }
  545. //
  546. // Select Interrupt Pen
  547. //
  548. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hMagentaPen);
  549. MoveToEx(DisplayItem->MemoryDC,
  550. MemGraphRect.right,
  551. MemGraphRect.bottom - (DisplayItem->InterruptTime[0] * GraphHeight)/ DisplayItem->Max,
  552. (LPPOINT)NULL);
  553. for (i=1;((i<DATA_LIST_LENGTH) && i * Scale < GraphWidth);i++) {
  554. LineTo(DisplayItem->MemoryDC,
  555. MemGraphRect.right - Scale * i,
  556. MemGraphRect.bottom - (DisplayItem->InterruptTime[i] * GraphHeight)/DisplayItem->Max);
  557. }
  558. }
  559. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hBluePen);
  560. MoveToEx(DisplayItem->MemoryDC,
  561. MemGraphRect.right,
  562. MemGraphRect.bottom - (DisplayItem->TotalTime[0] * GraphHeight)/ DisplayItem->Max,
  563. (LPPOINT)NULL);
  564. for (i=1;((i<DATA_LIST_LENGTH) && i*Scale < GraphWidth);i++) {
  565. LineTo(DisplayItem->MemoryDC,
  566. MemGraphRect.right - Scale * i,
  567. MemGraphRect.bottom - (DisplayItem->TotalTime[i] * GraphHeight)/DisplayItem->Max);
  568. }
  569. BitBlt(
  570. hDC,
  571. GraphRect.left,
  572. GraphRect.top,
  573. GraphWidth+1,
  574. GraphHeight+1,
  575. DisplayItem->MemoryDC,
  576. 0,
  577. 0,
  578. SRCCOPY);
  579. }
  580. VOID
  581. ShiftPerfGraph(
  582. HDC hDC,
  583. PDISPLAY_ITEM DisplayItem
  584. )
  585. /*++
  586. Routine Description:
  587. Shift memory bitmap 1 location left then draw the 1 new data point.
  588. BitBlt this to the screen.
  589. Arguments:
  590. hDC - Device Context for window
  591. DisplayItem - Data structure with all perf window info
  592. Return Value:
  593. status of operation
  594. Revision History:
  595. 03-21-91 Initial code
  596. --*/
  597. {
  598. RECT GraphRect,MemGraphRect,FillArea;
  599. ULONG Scale,GraphWidth,GraphHeight;
  600. GraphRect.left = DisplayItem->GraphBorder.left + 1;
  601. GraphRect.right = DisplayItem->GraphBorder.right - 1;
  602. GraphRect.top = DisplayItem->GraphBorder.top + 1;
  603. GraphRect.bottom = DisplayItem->GraphBorder.bottom - 1;
  604. GraphWidth = GraphRect.right - GraphRect.left -1;
  605. GraphHeight = GraphRect.bottom - GraphRect.top -1;
  606. //
  607. // Memory bitmap is zero-offset for all windows, add 1 to make fillrect fill out
  608. // to right and bottom edge
  609. //
  610. MemGraphRect.left = 0;
  611. MemGraphRect.right = GraphWidth;
  612. MemGraphRect.top = 0;
  613. MemGraphRect.bottom = GraphHeight;
  614. if (DisplayItem->Max == 0) {
  615. DisplayItem->Max = 1;
  616. }
  617. //
  618. // calculate scale from data to perf window
  619. //
  620. // X scale factor (100 items in x space). Scale can not be less than 1
  621. //
  622. Scale = (GraphWidth -1)/ DATA_LIST_LENGTH;
  623. if (Scale == 0) {
  624. Scale = 1;
  625. }
  626. //
  627. // Shift memory image left by scale
  628. //
  629. BitBlt( DisplayItem->MemoryDC,
  630. 0,
  631. 0,
  632. GraphWidth+1 - Scale,
  633. GraphHeight+1,
  634. DisplayItem->MemoryDC,
  635. Scale,
  636. 0,
  637. SRCCOPY);
  638. //
  639. // Fill The new area on the right of the screen
  640. //
  641. FillArea.left = GraphWidth +1 - Scale;
  642. FillArea.right = GraphWidth +1;
  643. FillArea.top = 0;
  644. FillArea.bottom = GraphHeight +1;
  645. FillRect(DisplayItem->MemoryDC,&FillArea,WinperfInfo.hBackground);
  646. //
  647. // Draw the 1 new data point
  648. //
  649. //
  650. // Draw UserTime if needed
  651. //
  652. if (DisplayItem->NumberOfElements>1) {
  653. //
  654. // Select kernel pen
  655. //
  656. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hRedPen);
  657. MoveToEx(DisplayItem->MemoryDC,
  658. MemGraphRect.right,
  659. MemGraphRect.bottom - (DisplayItem->KernelTime[0] * GraphHeight)/ DisplayItem->Max,
  660. (LPPOINT)NULL);
  661. LineTo(
  662. DisplayItem->MemoryDC,
  663. MemGraphRect.right - Scale,
  664. MemGraphRect.bottom - (DisplayItem->KernelTime[1] * GraphHeight)/DisplayItem->Max
  665. );
  666. //
  667. // Select User Pen
  668. //
  669. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hGreenPen);
  670. MoveToEx(
  671. DisplayItem->MemoryDC,
  672. MemGraphRect.right,
  673. MemGraphRect.bottom - (DisplayItem->UserTime[0] * GraphHeight)/ DisplayItem->Max,
  674. (LPPOINT)NULL
  675. );
  676. LineTo(
  677. DisplayItem->MemoryDC,
  678. MemGraphRect.right - Scale,
  679. MemGraphRect.bottom - (DisplayItem->UserTime[1] * GraphHeight)/DisplayItem->Max
  680. );
  681. //
  682. // Select DPC Pen
  683. //
  684. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hYellowPen);
  685. MoveToEx(
  686. DisplayItem->MemoryDC,
  687. MemGraphRect.right,
  688. MemGraphRect.bottom - (DisplayItem->DpcTime[0] * GraphHeight)/ DisplayItem->Max,
  689. (LPPOINT)NULL
  690. );
  691. LineTo(
  692. DisplayItem->MemoryDC,
  693. MemGraphRect.right - Scale,
  694. MemGraphRect.bottom - (DisplayItem->DpcTime[1] * GraphHeight)/DisplayItem->Max
  695. );
  696. //
  697. // Select Interrupt Pen
  698. //
  699. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hMagentaPen);
  700. MoveToEx(
  701. DisplayItem->MemoryDC,
  702. MemGraphRect.right,
  703. MemGraphRect.bottom - (DisplayItem->InterruptTime[0] * GraphHeight)/ DisplayItem->Max,
  704. (LPPOINT)NULL
  705. );
  706. LineTo(
  707. DisplayItem->MemoryDC,
  708. MemGraphRect.right - Scale,
  709. MemGraphRect.bottom - (DisplayItem->InterruptTime[1] * GraphHeight)/DisplayItem->Max
  710. );
  711. }
  712. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hBluePen);
  713. MoveToEx(DisplayItem->MemoryDC,
  714. MemGraphRect.right,
  715. MemGraphRect.bottom - (DisplayItem->TotalTime[0] * GraphHeight)/ DisplayItem->Max,
  716. (LPPOINT)NULL);
  717. LineTo(DisplayItem->MemoryDC,
  718. MemGraphRect.right - Scale,
  719. MemGraphRect.bottom - (DisplayItem->TotalTime[1] * GraphHeight)/DisplayItem->Max);
  720. BitBlt(
  721. hDC,
  722. GraphRect.left,
  723. GraphRect.top,
  724. GraphWidth+1,
  725. GraphHeight+1,
  726. DisplayItem->MemoryDC,
  727. 0,
  728. 0,
  729. SRCCOPY);
  730. }
  731. BOOLEAN
  732. CreateMemoryContext(
  733. HDC hDC,
  734. PDISPLAY_ITEM DisplayItem
  735. )
  736. /*++
  737. Routine Description:
  738. Create a memory context and a memory bitmap for each perf window
  739. Arguments:
  740. hDC - Device Context for window
  741. DisplayItem - Data structure with all perf window info
  742. Return Value:
  743. status of operation
  744. Revision History:
  745. 03-21-91 Initial code
  746. --*/
  747. {
  748. int Width;
  749. int Height;
  750. if (DisplayItem->Display == TRUE) {
  751. //
  752. // Calculate width of memory bitmap needed
  753. //
  754. Width = DisplayItem->GraphBorder.right - DisplayItem->GraphBorder.left;
  755. Height = DisplayItem->GraphBorder.bottom - DisplayItem->GraphBorder.top;
  756. if ((Width<=0) || (Height <= 0)) {
  757. //
  758. // Disable this window that is to small to be seen
  759. //
  760. //DisplayItem->Display = FALSE;
  761. //return(TRUE);
  762. //
  763. // make a fake width and height
  764. //
  765. Width = 1;
  766. Height = 1;
  767. }
  768. //
  769. // Create DC and Bitmap
  770. //
  771. DisplayItem->MemoryDC = CreateCompatibleDC(hDC);
  772. if (DisplayItem->MemoryDC == NULL) {
  773. return(FALSE);
  774. }
  775. DisplayItem->MemoryBitmap = CreateCompatibleBitmap(hDC,Width,Height);
  776. if (DisplayItem->MemoryBitmap == 0) {
  777. return(FALSE);
  778. }
  779. SelectObject(DisplayItem->MemoryDC,DisplayItem->MemoryBitmap);
  780. }
  781. return(TRUE);
  782. }
  783. VOID
  784. DeleteMemoryContext(
  785. PDISPLAY_ITEM DisplayItem
  786. )
  787. /*++
  788. Routine Description:
  789. Delete memory bitmap and context
  790. Arguments:
  791. hDC - Device Context for window
  792. DisplayItem - Data structure with all perf window info
  793. Return Value:
  794. status of operation
  795. Revision History:
  796. 03-21-91 Initial code
  797. --*/
  798. {
  799. if (DisplayItem->MemoryDC != NULL) {
  800. DeleteDC(DisplayItem->MemoryDC);
  801. }
  802. if (DisplayItem->MemoryBitmap != NULL) {
  803. DeleteObject(DisplayItem->MemoryBitmap);
  804. }
  805. }
  806. #define BOX_DEPTH 3
  807. VOID
  808. DrawCpuBarGraph(
  809. HDC hDC,
  810. PDISPLAY_ITEM DisplayItem,
  811. UINT Item
  812. )
  813. /*++
  814. Routine Description:
  815. Draw a 3-d like CPU bar graph into the perf window
  816. Arguments:
  817. hDC - Device Context for window
  818. DisplayItem - Data structure with all perf window info
  819. Return Value:
  820. status of operation
  821. Revision History:
  822. 03-21-91 Initial code
  823. --*/
  824. {
  825. RECT GraphRect,DrawRect;
  826. ULONG i,GraphWidth,GraphHeight,CpuGraphHeight;
  827. ULONG BarWidth,BarHeight,tHeight,kHeight,uHeight,dHeight,iHeight;
  828. POINT PolyPoint[4];
  829. HPEN hOldPen;
  830. UINT FontSize;
  831. UCHAR TextStr[100];
  832. ULONG nItems,UserBase, KerBase, DPCbase, TotBase, IntBase;
  833. nItems = 5;
  834. GraphRect.left = DisplayItem->GraphBorder.left + 1;
  835. GraphRect.right = DisplayItem->GraphBorder.right - 1;
  836. GraphRect.top = DisplayItem->GraphBorder.top + 1;
  837. GraphRect.bottom = DisplayItem->GraphBorder.bottom - 1;
  838. GraphWidth = GraphRect.right - GraphRect.left;
  839. GraphHeight = GraphRect.bottom - GraphRect.top;
  840. BarWidth = GraphWidth/((nItems*4)+4);
  841. BarHeight = GraphHeight/((nItems*4)+4);
  842. CpuGraphHeight = GraphHeight - 2 * BarHeight;
  843. //
  844. // Jump Out if window is too small
  845. //
  846. if (BarWidth == 0) {
  847. return;
  848. }
  849. //
  850. // Calculate Heights
  851. //
  852. uHeight = (DisplayItem->UserTime[0] * CpuGraphHeight)/ DisplayItem->Max;
  853. UserBase = 2;
  854. kHeight = (DisplayItem->KernelTime[0] * CpuGraphHeight)/ DisplayItem->Max;
  855. KerBase = 6;
  856. dHeight = (DisplayItem->DpcTime[0] * CpuGraphHeight)/ DisplayItem->Max;
  857. DPCbase = 10;
  858. iHeight = (DisplayItem->InterruptTime[0] * CpuGraphHeight)/ DisplayItem->Max;
  859. IntBase = 14;
  860. tHeight = (DisplayItem->TotalTime[0] * CpuGraphHeight)/ DisplayItem->Max;
  861. TotBase = 18;
  862. DrawRect.left = 0;
  863. DrawRect.right = GraphWidth;
  864. DrawRect.top = 0;
  865. DrawRect.bottom = GraphHeight;
  866. FillRect(DisplayItem->MemoryDC,&DrawRect,WinperfInfo.hBackground);
  867. SelectObject(DisplayItem->MemoryDC,GetStockObject(GRAY_BRUSH));
  868. //
  869. // Draw Background, face 1 (left side)
  870. //
  871. PolyPoint[0].x = DrawRect.left + BarWidth;
  872. PolyPoint[0].y = DrawRect.bottom - (BarHeight/2);
  873. PolyPoint[1].x = DrawRect.left + BOX_DEPTH*BarWidth;
  874. PolyPoint[1].y = DrawRect.bottom - (BOX_DEPTH*BarHeight/2);
  875. PolyPoint[2].x = DrawRect.left + BOX_DEPTH*BarWidth;
  876. PolyPoint[2].y = DrawRect.bottom - (GraphHeight - BarHeight/2);
  877. PolyPoint[3].x = DrawRect.left + BarWidth;
  878. PolyPoint[3].y = DrawRect.bottom - (GraphHeight - BOX_DEPTH*BarHeight/2);
  879. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  880. //
  881. // Draw Background, face 2 (bottom)
  882. //
  883. PolyPoint[0].x = DrawRect.left + BarWidth;
  884. PolyPoint[0].y = DrawRect.bottom - (BarHeight/2);
  885. // Left line
  886. PolyPoint[1].x = DrawRect.left + BOX_DEPTH*BarWidth;
  887. PolyPoint[1].y = DrawRect.bottom - (BOX_DEPTH*BarHeight/2);
  888. // Back line
  889. PolyPoint[2].x = DrawRect.left + (nItems*4+2)*BarWidth;
  890. PolyPoint[2].y = DrawRect.bottom - (BOX_DEPTH*BarHeight/2);
  891. // Bottom line.
  892. PolyPoint[3].x = DrawRect.left + (nItems*4)*BarWidth;
  893. PolyPoint[3].y = DrawRect.bottom - (BarHeight/2);
  894. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  895. //
  896. // Draw Background, face 3 (Back Side)
  897. //
  898. PolyPoint[0].x = DrawRect.left + BOX_DEPTH*BarWidth;
  899. PolyPoint[0].y = DrawRect.bottom - (BOX_DEPTH*BarHeight/2);
  900. PolyPoint[1].x = DrawRect.left + BOX_DEPTH*BarWidth;
  901. PolyPoint[1].y = DrawRect.bottom - (GraphHeight - BarHeight/2);
  902. PolyPoint[2].x = DrawRect.left + (nItems*4+2)*BarWidth;
  903. PolyPoint[2].y = DrawRect.bottom - (GraphHeight - BarHeight/2);
  904. PolyPoint[3].x = DrawRect.left + (nItems*4+2)*BarWidth;
  905. PolyPoint[3].y = DrawRect.bottom - ((BOX_DEPTH*BarHeight)/2);
  906. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  907. //
  908. // Draw Scale Lines if the window height is large ( > 200)
  909. //
  910. if ((DrawRect.bottom - DrawRect.top) > 200) {
  911. hOldPen = SelectObject(DisplayItem->MemoryDC,WinperfInfo.hDotPen);
  912. SetBkMode(DisplayItem->MemoryDC,TRANSPARENT);
  913. //
  914. // Back
  915. //
  916. for (i=1;i<10;i++) {
  917. MoveToEx(DisplayItem->MemoryDC,
  918. BOX_DEPTH*BarWidth,
  919. DrawRect.bottom - (BOX_DEPTH*BarHeight/2 + (i*CpuGraphHeight/10)),
  920. NULL
  921. );
  922. LineTo(DisplayItem->MemoryDC,
  923. (nItems*4+2)*BarWidth,
  924. DrawRect.bottom - (BOX_DEPTH*BarHeight/2 + (i*CpuGraphHeight/10))
  925. );
  926. }
  927. //
  928. // Left Side
  929. //
  930. for (i=1;i<10;i++) {
  931. MoveToEx(DisplayItem->MemoryDC,
  932. BarWidth,
  933. DrawRect.bottom - (BarHeight/2 + (i*CpuGraphHeight/10)),
  934. NULL
  935. );
  936. LineTo(DisplayItem->MemoryDC,
  937. BOX_DEPTH*BarWidth,
  938. DrawRect.bottom - (BOX_DEPTH*BarHeight/2 + (i*CpuGraphHeight/10))
  939. );
  940. }
  941. SelectObject(DisplayItem->MemoryDC,hOldPen);
  942. }
  943. //
  944. // Draw CPU User time BOX, face
  945. //
  946. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hGreenBrush);
  947. PolyPoint[0].x = DrawRect.left + (UserBase)*BarWidth;
  948. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  949. PolyPoint[1].x = DrawRect.left + (UserBase+2)*BarWidth;
  950. PolyPoint[1].y = DrawRect.bottom - (BarHeight);
  951. PolyPoint[2].x = DrawRect.left + (UserBase+2)*BarWidth;
  952. PolyPoint[2].y = DrawRect.bottom - (uHeight + BarHeight);
  953. PolyPoint[3].x = DrawRect.left + (UserBase)*BarWidth;
  954. PolyPoint[3].y = DrawRect.bottom - (uHeight + BarHeight);
  955. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  956. //
  957. // Draw User Box Side
  958. //
  959. PolyPoint[0].x = DrawRect.left + (UserBase+2)*BarWidth;
  960. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  961. PolyPoint[1].x = DrawRect.left + (UserBase+BOX_DEPTH)*BarWidth;
  962. PolyPoint[1].y = DrawRect.bottom - (3*BarHeight/2);
  963. PolyPoint[2].x = DrawRect.left + (UserBase+BOX_DEPTH)*BarWidth;
  964. PolyPoint[2].y = DrawRect.bottom - (3*BarHeight/2 + uHeight);
  965. PolyPoint[3].x = DrawRect.left + (UserBase+2)*BarWidth;
  966. PolyPoint[3].y = DrawRect.bottom - (BarHeight + uHeight);
  967. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  968. //
  969. // Draw User Box Top
  970. //
  971. PolyPoint[0].x = DrawRect.left + (UserBase)*BarWidth;
  972. PolyPoint[0].y = DrawRect.bottom - (uHeight + BarHeight);
  973. PolyPoint[1].x = DrawRect.left + (UserBase+2)*BarWidth;
  974. PolyPoint[1].y = DrawRect.bottom - (uHeight + BarHeight);
  975. PolyPoint[2].x = DrawRect.left + (UserBase+BOX_DEPTH)*BarWidth;
  976. PolyPoint[2].y = DrawRect.bottom - (uHeight + 3*BarHeight/2);
  977. PolyPoint[3].x = DrawRect.left + (UserBase+1)*BarWidth;
  978. PolyPoint[3].y = DrawRect.bottom - (uHeight + 3*BarHeight/2);
  979. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  980. //
  981. // Draw CPU Kernel time BOX, face
  982. //
  983. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hRedBrush);
  984. PolyPoint[0].x = DrawRect.left + (KerBase)*BarWidth;
  985. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  986. PolyPoint[1].x = DrawRect.left + (KerBase+2)*BarWidth;
  987. PolyPoint[1].y = DrawRect.bottom - (BarHeight);
  988. PolyPoint[2].x = DrawRect.left + (KerBase+2)*BarWidth;
  989. PolyPoint[2].y = DrawRect.bottom - ( kHeight + BarHeight);
  990. PolyPoint[3].x = DrawRect.left + (KerBase)*BarWidth;
  991. PolyPoint[3].y = DrawRect.bottom - (kHeight + BarHeight);
  992. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  993. //
  994. // Draw Kernel Box Side
  995. //
  996. PolyPoint[0].x = DrawRect.left + (KerBase+2)*BarWidth;
  997. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  998. PolyPoint[1].x = DrawRect.left + (KerBase+3)*BarWidth;
  999. PolyPoint[1].y = DrawRect.bottom - (3*BarHeight/2);
  1000. PolyPoint[2].x = DrawRect.left + (KerBase+3)*BarWidth;
  1001. PolyPoint[2].y = DrawRect.bottom - (3*BarHeight/2 +kHeight);
  1002. PolyPoint[3].x = DrawRect.left + (KerBase+2)*BarWidth;
  1003. PolyPoint[3].y = DrawRect.bottom - (kHeight + BarHeight);
  1004. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1005. //
  1006. // Draw Kernel Box Top
  1007. //
  1008. PolyPoint[0].x = DrawRect.left + (KerBase)*BarWidth;
  1009. PolyPoint[0].y = DrawRect.bottom - (kHeight + BarHeight);
  1010. PolyPoint[1].x = DrawRect.left + (KerBase+2)*BarWidth;
  1011. PolyPoint[1].y = DrawRect.bottom - (kHeight + BarHeight);
  1012. PolyPoint[2].x = DrawRect.left + (KerBase+3)*BarWidth;
  1013. PolyPoint[2].y = DrawRect.bottom - (kHeight + 3*BarHeight/2);
  1014. PolyPoint[3].x = DrawRect.left + (KerBase+1)*BarWidth;
  1015. PolyPoint[3].y = DrawRect.bottom - (kHeight + 3*BarHeight/2);
  1016. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1017. //
  1018. // Draw CPU DPC time BOX, face
  1019. //
  1020. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hYellowBrush);
  1021. PolyPoint[0].x = DrawRect.left + (DPCbase)*BarWidth;
  1022. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  1023. PolyPoint[1].x = DrawRect.left + (DPCbase+2)*BarWidth;
  1024. PolyPoint[1].y = DrawRect.bottom - (BarHeight);
  1025. PolyPoint[2].x = DrawRect.left + (DPCbase+2)*BarWidth;
  1026. PolyPoint[2].y = DrawRect.bottom - ( dHeight + BarHeight);
  1027. PolyPoint[3].x = DrawRect.left + (DPCbase)*BarWidth;
  1028. PolyPoint[3].y = DrawRect.bottom - (dHeight + BarHeight);
  1029. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1030. //
  1031. // Draw DPC Box Side
  1032. //
  1033. PolyPoint[0].x = DrawRect.left + (DPCbase+2)*BarWidth;
  1034. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  1035. PolyPoint[1].x = DrawRect.left + (DPCbase+3)*BarWidth;
  1036. PolyPoint[1].y = DrawRect.bottom - (3*BarHeight/2);
  1037. PolyPoint[2].x = DrawRect.left + (DPCbase+3)*BarWidth;
  1038. PolyPoint[2].y = DrawRect.bottom - (3*BarHeight/2 +dHeight);
  1039. PolyPoint[3].x = DrawRect.left + (DPCbase+2)*BarWidth;
  1040. PolyPoint[3].y = DrawRect.bottom - (dHeight + BarHeight);
  1041. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1042. //
  1043. // Draw DPC Box Top
  1044. //
  1045. PolyPoint[0].x = DrawRect.left + (DPCbase)*BarWidth;
  1046. PolyPoint[0].y = DrawRect.bottom - (dHeight + BarHeight);
  1047. PolyPoint[1].x = DrawRect.left + (DPCbase+2)*BarWidth;
  1048. PolyPoint[1].y = DrawRect.bottom - (dHeight + BarHeight);
  1049. PolyPoint[2].x = DrawRect.left + (DPCbase+3)*BarWidth;
  1050. PolyPoint[2].y = DrawRect.bottom - (dHeight + 3*BarHeight/2);
  1051. PolyPoint[3].x = DrawRect.left + (DPCbase+1)*BarWidth;
  1052. PolyPoint[3].y = DrawRect.bottom - (dHeight + 3*BarHeight/2);
  1053. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1054. //
  1055. // Draw CPU Interrupt time BOX, face
  1056. //
  1057. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hMagentaBrush);
  1058. PolyPoint[0].x = DrawRect.left + (IntBase)*BarWidth;
  1059. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  1060. PolyPoint[1].x = DrawRect.left + (IntBase+2)*BarWidth;
  1061. PolyPoint[1].y = DrawRect.bottom - (BarHeight);
  1062. PolyPoint[2].x = DrawRect.left + (IntBase+2)*BarWidth;
  1063. PolyPoint[2].y = DrawRect.bottom - ( iHeight + BarHeight);
  1064. PolyPoint[3].x = DrawRect.left + (IntBase)*BarWidth;
  1065. PolyPoint[3].y = DrawRect.bottom - (iHeight + BarHeight);
  1066. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1067. //
  1068. // Draw Interrupt Box Side
  1069. //
  1070. PolyPoint[0].x = DrawRect.left + (IntBase+2)*BarWidth;
  1071. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  1072. PolyPoint[1].x = DrawRect.left + (IntBase+3)*BarWidth;
  1073. PolyPoint[1].y = DrawRect.bottom - (3*BarHeight/2);
  1074. PolyPoint[2].x = DrawRect.left + (IntBase+3)*BarWidth;
  1075. PolyPoint[2].y = DrawRect.bottom - (3*BarHeight/2 +iHeight);
  1076. PolyPoint[3].x = DrawRect.left + (IntBase+2)*BarWidth;
  1077. PolyPoint[3].y = DrawRect.bottom - (iHeight + BarHeight);
  1078. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1079. //
  1080. // Draw Interrupt Box Top
  1081. //
  1082. PolyPoint[0].x = DrawRect.left + (IntBase)*BarWidth;
  1083. PolyPoint[0].y = DrawRect.bottom - (iHeight + BarHeight);
  1084. PolyPoint[1].x = DrawRect.left + (IntBase+2)*BarWidth;
  1085. PolyPoint[1].y = DrawRect.bottom - (iHeight + BarHeight);
  1086. PolyPoint[2].x = DrawRect.left + (IntBase+3)*BarWidth;
  1087. PolyPoint[2].y = DrawRect.bottom - (iHeight + 3*BarHeight/2);
  1088. PolyPoint[3].x = DrawRect.left + (IntBase+1)*BarWidth;
  1089. PolyPoint[3].y = DrawRect.bottom - (iHeight + 3*BarHeight/2);
  1090. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1091. //
  1092. // Draw CPU Total time BOX, face
  1093. //
  1094. SelectObject(DisplayItem->MemoryDC,WinperfInfo.hBlueBrush);
  1095. PolyPoint[0].x = DrawRect.left + (TotBase)*BarWidth;
  1096. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  1097. PolyPoint[1].x = DrawRect.left + (TotBase+2)*BarWidth;
  1098. PolyPoint[1].y = DrawRect.bottom - (BarHeight);
  1099. PolyPoint[2].x = DrawRect.left + (TotBase+2)*BarWidth;
  1100. PolyPoint[2].y = DrawRect.bottom - ( tHeight + BarHeight);
  1101. PolyPoint[3].x = DrawRect.left + (TotBase)*BarWidth;
  1102. PolyPoint[3].y = DrawRect.bottom - (tHeight + BarHeight);
  1103. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1104. //
  1105. // Draw CPU Total Box Side
  1106. //
  1107. PolyPoint[0].x = DrawRect.left + (TotBase+2)*BarWidth;
  1108. PolyPoint[0].y = DrawRect.bottom - (BarHeight);
  1109. PolyPoint[1].x = DrawRect.left + (TotBase+3)*BarWidth;
  1110. PolyPoint[1].y = DrawRect.bottom - (3*BarHeight/2);
  1111. PolyPoint[2].x = DrawRect.left + (TotBase+3)*BarWidth;
  1112. PolyPoint[2].y = DrawRect.bottom - (3*BarHeight/2 + tHeight);
  1113. PolyPoint[3].x = DrawRect.left + (TotBase+2)*BarWidth;
  1114. PolyPoint[3].y = DrawRect.bottom - (tHeight + BarHeight);
  1115. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1116. //
  1117. // Draw Kernel Box Top
  1118. //
  1119. PolyPoint[0].x = DrawRect.left + (TotBase)*BarWidth;
  1120. PolyPoint[0].y = DrawRect.bottom - (tHeight + BarHeight);
  1121. PolyPoint[1].x = DrawRect.left + (TotBase+2)*BarWidth;
  1122. PolyPoint[1].y = DrawRect.bottom - (tHeight + BarHeight);
  1123. PolyPoint[2].x = DrawRect.left + (TotBase+3)*BarWidth;
  1124. PolyPoint[2].y = DrawRect.bottom - (tHeight + 3*BarHeight/2);
  1125. PolyPoint[3].x = DrawRect.left + (TotBase+1)*BarWidth;
  1126. PolyPoint[3].y = DrawRect.bottom - (tHeight + 3*BarHeight/2);
  1127. Polygon(DisplayItem->MemoryDC,&PolyPoint[0],4);
  1128. //
  1129. // Update screen with memory image
  1130. //
  1131. BitBlt(
  1132. hDC,
  1133. GraphRect.left,
  1134. GraphRect.top,
  1135. GraphWidth,
  1136. GraphHeight,
  1137. DisplayItem->MemoryDC,
  1138. 0,
  1139. 0,
  1140. SRCCOPY);
  1141. //
  1142. // Draw Text output for CPU bar-graph window
  1143. //
  1144. DrawRect.left = DisplayItem->TextBorder.left +2;
  1145. DrawRect.right = DisplayItem->TextBorder.right -2;
  1146. DrawRect.top = DisplayItem->TextBorder.top +1;
  1147. DrawRect.bottom = DisplayItem->TextBorder.bottom -1;
  1148. FillRect(hDC,&DrawRect,WinperfInfo.hBackground);
  1149. SetBkColor(hDC,RGB(192,192,192));
  1150. //
  1151. // Decide which font to draw with
  1152. //
  1153. FontSize = DrawRect.bottom - DrawRect.top;
  1154. if (FontSize >= 15) {
  1155. WinperfInfo.hOldFont = SelectObject(hDC,WinperfInfo.LargeFont);
  1156. } else if (FontSize > 10) {
  1157. WinperfInfo.hOldFont = SelectObject(hDC,WinperfInfo.MediumFont);
  1158. } else {
  1159. WinperfInfo.hOldFont = SelectObject(hDC,WinperfInfo.SmallFont);
  1160. }
  1161. strcpy(TextStr,PerfNames[Item]);
  1162. if ((DrawRect.right - DrawRect.left) > 120) {
  1163. strcat(TextStr," User,Kernel,Dpc,Int,Total");
  1164. } else {
  1165. strcat(TextStr," U K D I T");
  1166. }
  1167. DrawText(
  1168. hDC,
  1169. TextStr,
  1170. strlen(TextStr),
  1171. &DrawRect,
  1172. DT_LEFT | DT_VCENTER | DT_SINGLELINE
  1173. );
  1174. }