1 | #include <os2win.h>
|
---|
2 | #include <stats.h>
|
---|
3 |
|
---|
4 | #ifdef RAS
|
---|
5 |
|
---|
6 | RAS_TRACK_HANDLE rthDCCalls = 0;
|
---|
7 |
|
---|
8 | //******************************************************************************
|
---|
9 | //******************************************************************************
|
---|
10 | void STATS_GetDCEx(HWND hwnd, HDC hdc, HRGN hrgn, ULONG flags)
|
---|
11 | {
|
---|
12 | if (!rthDCCalls) STATS_InitializeUSER32 ();
|
---|
13 | RasAddObject (rthDCCalls, hdc, NULL, 0);
|
---|
14 | }
|
---|
15 | //******************************************************************************
|
---|
16 | //******************************************************************************
|
---|
17 | void STATS_ReleaseDC(HWND hwnd, HDC hdc)
|
---|
18 | {
|
---|
19 | if (!rthDCCalls) STATS_InitializeUSER32 ();
|
---|
20 | RasRemoveObject (rthDCCalls, hdc);
|
---|
21 | }
|
---|
22 | //******************************************************************************
|
---|
23 | //******************************************************************************
|
---|
24 | void STATS_DumpStatsUSER32()
|
---|
25 | {
|
---|
26 | RasLogObjects (rthDCCalls, RAS_FLAG_LOG_OBJECTS);
|
---|
27 | }
|
---|
28 | void STATS_InitializeUSER32 (void)
|
---|
29 | {
|
---|
30 | RasEnterSerialize ();
|
---|
31 | if (!rthDCCalls)
|
---|
32 | {
|
---|
33 | RasRegisterObjectTracking(&rthDCCalls, "DCCalls", 0, 0, NULL, NULL);
|
---|
34 | }
|
---|
35 | RasExitSerialize ();
|
---|
36 | }
|
---|
37 |
|
---|
38 | void STATS_UninitializeUSER32(void)
|
---|
39 | {
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | #else
|
---|
44 |
|
---|
45 | #ifdef DEBUG
|
---|
46 |
|
---|
47 | static DWORD nrwindowdcsallocated = 0;
|
---|
48 | static DWORD nrcalls_GetDCEx = 0;
|
---|
49 | static DWORD nrcalls_ReleaseDC = 0;
|
---|
50 |
|
---|
51 | //******************************************************************************
|
---|
52 | //******************************************************************************
|
---|
53 | void STATS_GetDCEx(HWND hwnd, HDC hdc, HRGN hrgn, ULONG flags)
|
---|
54 | {
|
---|
55 | nrwindowdcsallocated++;
|
---|
56 | nrcalls_GetDCEx++;
|
---|
57 | }
|
---|
58 | //******************************************************************************
|
---|
59 | //******************************************************************************
|
---|
60 | void STATS_ReleaseDC(HWND hwnd, HDC hdc)
|
---|
61 | {
|
---|
62 | nrwindowdcsallocated--;
|
---|
63 | nrcalls_ReleaseDC++;
|
---|
64 | }
|
---|
65 | //******************************************************************************
|
---|
66 | //******************************************************************************
|
---|
67 | void STATS_DumpStatsUSER32()
|
---|
68 | {
|
---|
69 | dprintf(("************* USER32 STATISTICS BEGIN *****************"));
|
---|
70 | dprintf(("Total nr of GetDCEx calls %d", nrcalls_GetDCEx));
|
---|
71 | dprintf(("Total nr of ReleaseDC calls %d", nrcalls_ReleaseDC));
|
---|
72 | dprintf(("Leaked DCs: %d", nrwindowdcsallocated));
|
---|
73 | dprintf(("************* USER STATISTICS END *****************"));
|
---|
74 | }
|
---|
75 | //******************************************************************************
|
---|
76 | //******************************************************************************
|
---|
77 |
|
---|
78 |
|
---|
79 | #endif //DEBUG
|
---|
80 | #endif //RAS
|
---|