| 1 | /* | 
|---|
| 2 | * GDI object statistics | 
|---|
| 3 | * | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 2002-2003 Innotek Systemberatung GmbH (sandervl@innotek.de) | 
|---|
| 6 | * | 
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 8 | * | 
|---|
| 9 | */ | 
|---|
| 10 |  | 
|---|
| 11 | #include <os2win.h> | 
|---|
| 12 | #include <stats.h> | 
|---|
| 13 | #include <objhandle.h> | 
|---|
| 14 |  | 
|---|
| 15 | #ifdef RAS | 
|---|
| 16 |  | 
|---|
| 17 | RAS_TRACK_HANDLE rthFont; | 
|---|
| 18 | RAS_TRACK_HANDLE rthDC; | 
|---|
| 19 | RAS_TRACK_HANDLE rthPen; | 
|---|
| 20 | RAS_TRACK_HANDLE rthBrush; | 
|---|
| 21 | RAS_TRACK_HANDLE rthRgn; | 
|---|
| 22 | RAS_TRACK_HANDLE rthBmp; | 
|---|
| 23 |  | 
|---|
| 24 | void STATS_CreateFontIndirect(HFONT hFont, LOGFONTA* lplf) | 
|---|
| 25 | { | 
|---|
| 26 | if (!rthFont) STATS_InitializeGDI32 (); | 
|---|
| 27 | RasAddObject (rthFont, hFont, lplf, sizeof (LOGFONTA)); | 
|---|
| 28 | } | 
|---|
| 29 | void STATS_DeleteFont(HFONT hFont) | 
|---|
| 30 | { | 
|---|
| 31 | RasRemoveObject (rthFont, hFont); | 
|---|
| 32 | } | 
|---|
| 33 | void STATS_CreateCompatibleDC(HDC hdc, HDC hdcCreated) | 
|---|
| 34 | { | 
|---|
| 35 | if (!rthDC) STATS_InitializeGDI32 (); | 
|---|
| 36 | RasAddObject (rthDC, hdcCreated, &hdc, sizeof (hdc)); | 
|---|
| 37 | } | 
|---|
| 38 | void STATS_CreateICA(HDC hdc, LPCSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszOutput, | 
|---|
| 39 | const DEVMODEA *lpdvmInit) | 
|---|
| 40 | { | 
|---|
| 41 | if (!rthDC) STATS_InitializeGDI32 (); | 
|---|
| 42 | RasAddObject (rthDC, hdc, NULL, 0); | 
|---|
| 43 | } | 
|---|
| 44 | void STATS_CreateDCA(HDC hdc, LPCSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszOutput, | 
|---|
| 45 | const DEVMODEA *lpdvmInit) | 
|---|
| 46 | { | 
|---|
| 47 | if (!rthDC) STATS_InitializeGDI32 (); | 
|---|
| 48 | RasAddObject (rthDC, hdc, NULL, 0); | 
|---|
| 49 | } | 
|---|
| 50 | void STATS_DeleteDC(HDC hdc) | 
|---|
| 51 | { | 
|---|
| 52 | RasRemoveObject (rthDC, hdc); | 
|---|
| 53 | } | 
|---|
| 54 | void STATS_CreatePatternBrush(HBRUSH hBrush, HBITMAP hBitmap) | 
|---|
| 55 | { | 
|---|
| 56 | if (!rthBrush) STATS_InitializeGDI32 (); | 
|---|
| 57 | RasAddObject (rthBrush, hBrush, &hBitmap, sizeof (hBitmap)); | 
|---|
| 58 | } | 
|---|
| 59 | void STATS_CreateDIBPatternBrushPt(HBRUSH hBrush, LPCVOID buffer, DWORD usage) | 
|---|
| 60 | { | 
|---|
| 61 | if (!rthBrush) STATS_InitializeGDI32 (); | 
|---|
| 62 | RasAddObject (rthBrush, hBrush, &buffer, sizeof (buffer)); | 
|---|
| 63 | } | 
|---|
| 64 | void STATS_CreateBrushIndirect(HBRUSH hBrush, LPLOGBRUSH pLogBrush) | 
|---|
| 65 | { | 
|---|
| 66 | if (!rthBrush) STATS_InitializeGDI32 (); | 
|---|
| 67 | RasAddObject (rthBrush, hBrush, pLogBrush, sizeof (LOGBRUSH)); | 
|---|
| 68 | } | 
|---|
| 69 | void STATS_CreateHatchBrush(HBRUSH hBrush, int fnStyle, COLORREF clrref) | 
|---|
| 70 | { | 
|---|
| 71 | struct Parms | 
|---|
| 72 | { | 
|---|
| 73 | int fnStyle; | 
|---|
| 74 | COLORREF clrref; | 
|---|
| 75 | } parms = {fnStyle, clrref}; | 
|---|
| 76 | if (!rthBrush) STATS_InitializeGDI32 (); | 
|---|
| 77 | RasAddObject (rthBrush, hBrush, &parms, sizeof (parms)); | 
|---|
| 78 | } | 
|---|
| 79 | void STATS_CreateSolidBrush(HBRUSH hBrush, COLORREF color) | 
|---|
| 80 | { | 
|---|
| 81 | if (!rthBrush) STATS_InitializeGDI32 (); | 
|---|
| 82 | RasAddObject (rthBrush, hBrush, &color, sizeof (COLORREF)); | 
|---|
| 83 | } | 
|---|
| 84 | void STATS_DeleteBrush(HBRUSH hBrush) | 
|---|
| 85 | { | 
|---|
| 86 | RasRemoveObject (rthBrush, hBrush); | 
|---|
| 87 | } | 
|---|
| 88 | void STATS_CreatePenIndirect(HPEN hPen, const LOGPEN *lplgpn) | 
|---|
| 89 | { | 
|---|
| 90 | if (!rthPen) STATS_InitializeGDI32 (); | 
|---|
| 91 | RasAddObject (rthPen, hPen, (void *)lplgpn, sizeof (LOGPEN)); | 
|---|
| 92 | } | 
|---|
| 93 | void STATS_CreatePen(HPEN hPen, int fnPenStyle, int nWidth, COLORREF crColor) | 
|---|
| 94 | { | 
|---|
| 95 | struct Parms | 
|---|
| 96 | { | 
|---|
| 97 | int fnPenStyle; | 
|---|
| 98 | int nWidth; | 
|---|
| 99 | COLORREF crColor; | 
|---|
| 100 | } parms = {fnPenStyle, nWidth, crColor}; | 
|---|
| 101 |  | 
|---|
| 102 | if (!rthPen) STATS_InitializeGDI32 (); | 
|---|
| 103 | RasAddObject (rthPen, hPen, &parms, sizeof (parms)); | 
|---|
| 104 | } | 
|---|
| 105 | void STATS_ExtCreatePen(HPEN hPen, DWORD dwPenStyle, DWORD dwWidth, const LOGBRUSH *lplb, | 
|---|
| 106 | DWORD dwStyleCount, const DWORD *lpStyle) | 
|---|
| 107 | { | 
|---|
| 108 | struct Parms | 
|---|
| 109 | { | 
|---|
| 110 | DWORD dwPenStyle; | 
|---|
| 111 | DWORD dwWidth; | 
|---|
| 112 | const LOGBRUSH *lplb; | 
|---|
| 113 | DWORD dwStyleCount; | 
|---|
| 114 | const DWORD *lpStyle; | 
|---|
| 115 | } parms = {dwPenStyle, dwWidth, lplb, | 
|---|
| 116 | dwStyleCount, lpStyle}; | 
|---|
| 117 |  | 
|---|
| 118 | if (!rthPen) STATS_InitializeGDI32 (); | 
|---|
| 119 | RasAddObject (rthPen, hPen, &parms, sizeof (parms)); | 
|---|
| 120 | } | 
|---|
| 121 | void STATS_DeletePen(HPEN hPen) | 
|---|
| 122 | { | 
|---|
| 123 | RasRemoveObject (rthPen, hPen); | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 | void STATS_CreatePolyPolygonRgn(HRGN hRgn, const POINT *lppt, const int *pPolyCount, int nCount, int fnPolyFillMode) | 
|---|
| 127 | { | 
|---|
| 128 | if (!rthRgn) STATS_InitializeGDI32 (); | 
|---|
| 129 | RasAddObject (rthRgn, hRgn, NULL, 0); | 
|---|
| 130 | } | 
|---|
| 131 | void STATS_CreateRectRgn(HRGN hRgn, int left, int top, int right, int bottom) | 
|---|
| 132 | { | 
|---|
| 133 | if (!rthRgn) STATS_InitializeGDI32 (); | 
|---|
| 134 | RasAddObject (rthRgn, hRgn, NULL, 0); | 
|---|
| 135 | } | 
|---|
| 136 | void STATS_CreateRoundRectRgn(HRGN hRgn, int left, int top, int right, int bottom, int nWidthEllipse, int nHeightEllipse) | 
|---|
| 137 | { | 
|---|
| 138 | if (!rthRgn) STATS_InitializeGDI32 (); | 
|---|
| 139 | RasAddObject (rthRgn, hRgn, NULL, 0); | 
|---|
| 140 | } | 
|---|
| 141 | void STATS_ExtCreateRegion(HRGN hRgn, PVOID pXform, DWORD count, const RGNDATA * pData) | 
|---|
| 142 | { | 
|---|
| 143 | if (!rthRgn) STATS_InitializeGDI32 (); | 
|---|
| 144 | RasAddObject (rthRgn, hRgn, NULL, 0); | 
|---|
| 145 | } | 
|---|
| 146 | void STATS_CreateEllipticRgn(HRGN hRgn, int left, int top, int right, int bottom) | 
|---|
| 147 | { | 
|---|
| 148 | if (!rthRgn) STATS_InitializeGDI32 (); | 
|---|
| 149 | RasAddObject (rthRgn, hRgn, NULL, 0); | 
|---|
| 150 | } | 
|---|
| 151 | void STATS_CreatePolygonRgn(HRGN hRgn, const POINT * lppt, int cPoints, int fnPolyFillMode) | 
|---|
| 152 | { | 
|---|
| 153 | if (!rthRgn) STATS_InitializeGDI32 (); | 
|---|
| 154 | RasAddObject (rthRgn, hRgn, NULL, 0); | 
|---|
| 155 | } | 
|---|
| 156 | void STATS_DeleteRgn(HRGN hRgn) | 
|---|
| 157 | { | 
|---|
| 158 | RasRemoveObject (rthRgn, hRgn); | 
|---|
| 159 | } | 
|---|
| 160 |  | 
|---|
| 161 | void STATS_CreateDIBitmap(HBITMAP hBitmap,HDC hdc, const BITMAPINFOHEADER *lpbmih, | 
|---|
| 162 | DWORD fdwInit, const void *lpbInit, | 
|---|
| 163 | const BITMAPINFO *lpbmi, UINT fuUsage) | 
|---|
| 164 | { | 
|---|
| 165 | if (!rthBmp) STATS_InitializeGDI32 (); | 
|---|
| 166 | RasAddObject (rthBmp, hBitmap, NULL, 0); | 
|---|
| 167 | } | 
|---|
| 168 | void STATS_CreateCompatibleBitmap(HBITMAP hBitmap,HDC hdc, int nWidth, int nHeight) | 
|---|
| 169 | { | 
|---|
| 170 | if (!rthBmp) STATS_InitializeGDI32 (); | 
|---|
| 171 | RasAddObject (rthBmp, hBitmap, NULL, 0); | 
|---|
| 172 | } | 
|---|
| 173 | void STATS_CreateBitmap(HBITMAP hBitmap,int nWidth, int nHeight, UINT cPlanes, | 
|---|
| 174 | UINT cBitsPerPel, const void *lpvBits) | 
|---|
| 175 | { | 
|---|
| 176 | if (!rthBmp) STATS_InitializeGDI32 (); | 
|---|
| 177 | RasAddObject (rthBmp, hBitmap, NULL, 0); | 
|---|
| 178 | } | 
|---|
| 179 | void STATS_CreateDIBSection(HBITMAP hBitmap,HDC hdc, BITMAPINFO *pbmi, UINT iUsage, | 
|---|
| 180 | VOID **ppvBits, HANDLE hSection, DWORD dwOffset) | 
|---|
| 181 | { | 
|---|
| 182 | if (!rthBmp) STATS_InitializeGDI32 (); | 
|---|
| 183 | RasAddObject (rthBmp, hBitmap, NULL, 0); | 
|---|
| 184 | } | 
|---|
| 185 | void STATS_CreateBitmapIndirect(HBITMAP hBitmap, const BITMAP *pBitmap) | 
|---|
| 186 | { | 
|---|
| 187 | if (!rthBmp) STATS_InitializeGDI32 (); | 
|---|
| 188 | RasAddObject (rthBmp, hBitmap, NULL, 0); | 
|---|
| 189 | } | 
|---|
| 190 | void STATS_DeleteBitmap(HBITMAP hBitmap) | 
|---|
| 191 | { | 
|---|
| 192 | RasRemoveObject (rthBmp, hBitmap); | 
|---|
| 193 | } | 
|---|
| 194 |  | 
|---|
| 195 | void STATS_DeleteObject(HANDLE hObj, DWORD objtype) | 
|---|
| 196 | { | 
|---|
| 197 | switch(objtype) { | 
|---|
| 198 | case OBJ_PEN: | 
|---|
| 199 | case OBJ_EXTPEN: | 
|---|
| 200 | STATS_DeletePen(hObj); | 
|---|
| 201 | break; | 
|---|
| 202 | case OBJ_BRUSH: | 
|---|
| 203 | STATS_DeleteBrush(hObj); | 
|---|
| 204 | break; | 
|---|
| 205 | case OBJ_FONT: | 
|---|
| 206 | STATS_DeleteFont(hObj); | 
|---|
| 207 | break; | 
|---|
| 208 | case OBJ_REGION: | 
|---|
| 209 | STATS_DeleteRgn(hObj); | 
|---|
| 210 | break; | 
|---|
| 211 | case OBJ_BITMAP: | 
|---|
| 212 | STATS_DeleteBitmap(hObj); | 
|---|
| 213 | break; | 
|---|
| 214 |  | 
|---|
| 215 | case OBJ_MEMDC: | 
|---|
| 216 | case OBJ_DC: | 
|---|
| 217 | STATS_DeleteDC(hObj); | 
|---|
| 218 | break; | 
|---|
| 219 |  | 
|---|
| 220 | case OBJ_PAL: | 
|---|
| 221 | case OBJ_METAFILE: | 
|---|
| 222 | case OBJ_ENHMETADC: | 
|---|
| 223 | case OBJ_ENHMETAFILE: | 
|---|
| 224 | case OBJ_METADC: | 
|---|
| 225 | break; | 
|---|
| 226 | default: | 
|---|
| 227 | RasLog ("!ERROR! Unknown object %x of type %d", hObj, objtype); | 
|---|
| 228 | break; | 
|---|
| 229 | } | 
|---|
| 230 | } | 
|---|
| 231 |  | 
|---|
| 232 | void STATS_DumpStatsGDI32() | 
|---|
| 233 | { | 
|---|
| 234 | RasLogObjects(rthDC, RAS_FLAG_LOG_OBJECTS); | 
|---|
| 235 | RasLogObjects(rthPen, RAS_FLAG_LOG_OBJECTS); | 
|---|
| 236 | RasLogObjects(rthBrush, RAS_FLAG_LOG_OBJECTS); | 
|---|
| 237 | RasLogObjects(rthRgn, RAS_FLAG_LOG_OBJECTS); | 
|---|
| 238 | RasLogObjects(rthBmp, RAS_FLAG_LOG_OBJECTS); | 
|---|
| 239 | } | 
|---|
| 240 |  | 
|---|
| 241 | void STATS_InitializeGDI32(void) | 
|---|
| 242 | { | 
|---|
| 243 | RasEnterSerialize (); | 
|---|
| 244 | if (!rthDC) | 
|---|
| 245 | { | 
|---|
| 246 | RasRegisterObjectTracking(&rthDC, "DC", 0, 0, NULL, NULL); | 
|---|
| 247 | } | 
|---|
| 248 | if (!rthPen) | 
|---|
| 249 | { | 
|---|
| 250 | RasRegisterObjectTracking(&rthPen, "Pen", 0, 0, NULL, NULL); | 
|---|
| 251 | } | 
|---|
| 252 | if (!rthBrush) | 
|---|
| 253 | { | 
|---|
| 254 | RasRegisterObjectTracking(&rthBrush, "Brush", 0, 0, NULL, NULL); | 
|---|
| 255 | } | 
|---|
| 256 | if (!rthRgn) | 
|---|
| 257 | { | 
|---|
| 258 | RasRegisterObjectTracking(&rthRgn, "Region", 0, 0, NULL, NULL); | 
|---|
| 259 | } | 
|---|
| 260 | if (!rthBmp) | 
|---|
| 261 | { | 
|---|
| 262 | RasRegisterObjectTracking(&rthBmp, "Bitmap", 0, 0, NULL, NULL); | 
|---|
| 263 | } | 
|---|
| 264 | RasExitSerialize (); | 
|---|
| 265 | } | 
|---|
| 266 |  | 
|---|
| 267 | void STATS_UninitializeGDI32(void) | 
|---|
| 268 | { | 
|---|
| 269 | // done in RAS kernel | 
|---|
| 270 | //    RasDeregisterObjectTracking(rthDC); | 
|---|
| 271 | //    RasDeregisterObjectTracking(rthPen); | 
|---|
| 272 | //    RasDeregisterObjectTracking(rthBrush); | 
|---|
| 273 | //    RasDeregisterObjectTracking(rthRgn); | 
|---|
| 274 | //    RasDeregisterObjectTracking(rthBmp); | 
|---|
| 275 | } | 
|---|
| 276 |  | 
|---|
| 277 | #else | 
|---|
| 278 | #ifdef DEBUG | 
|---|
| 279 |  | 
|---|
| 280 | #define STATS_MAX_OBJECTS        1024 | 
|---|
| 281 |  | 
|---|
| 282 | static DWORD createddc[STATS_MAX_OBJECTS]     = {0}; | 
|---|
| 283 | static DWORD createdfont[STATS_MAX_OBJECTS]   = {0}; | 
|---|
| 284 | static DWORD createdpen[STATS_MAX_OBJECTS]    = {0}; | 
|---|
| 285 | static DWORD createdbrush[STATS_MAX_OBJECTS]  = {0}; | 
|---|
| 286 | static DWORD createdregion[STATS_MAX_OBJECTS] = {0}; | 
|---|
| 287 | static DWORD createdbitmap[STATS_MAX_OBJECTS] = {0}; | 
|---|
| 288 |  | 
|---|
| 289 | static DWORD nrdcscreated        = 0; | 
|---|
| 290 | static DWORD nrfontscreated      = 0; | 
|---|
| 291 | static DWORD nrpenscreated       = 0; | 
|---|
| 292 | static DWORD nrbrushescreated    = 0; | 
|---|
| 293 | static DWORD nrregionscreated    = 0; | 
|---|
| 294 | static DWORD nrbitmapscreated    = 0; | 
|---|
| 295 |  | 
|---|
| 296 |  | 
|---|
| 297 | //****************************************************************************** | 
|---|
| 298 | //****************************************************************************** | 
|---|
| 299 | static void STAT_InsertObject(HANDLE hObject, DWORD *pdwObjects) | 
|---|
| 300 | { | 
|---|
| 301 | for(int i=0;i<STATS_MAX_OBJECTS;i++) { | 
|---|
| 302 | if(pdwObjects[i] == 0) { | 
|---|
| 303 | pdwObjects[i] = hObject; | 
|---|
| 304 | break; | 
|---|
| 305 | } | 
|---|
| 306 | } | 
|---|
| 307 | if(i == STATS_MAX_OBJECTS) { | 
|---|
| 308 | dprintf(("!WARNING! STAT_InsertObject: no room left!!")); | 
|---|
| 309 | } | 
|---|
| 310 | } | 
|---|
| 311 | //****************************************************************************** | 
|---|
| 312 | //****************************************************************************** | 
|---|
| 313 | static void STAT_DeleteObject(HANDLE hObject, DWORD *pdwObjects) | 
|---|
| 314 | { | 
|---|
| 315 | for(int i=0;i<STATS_MAX_OBJECTS;i++) { | 
|---|
| 316 | if(LOWORD(pdwObjects[i]) == LOWORD(hObject)) { | 
|---|
| 317 | pdwObjects[i] = 0; | 
|---|
| 318 | break; | 
|---|
| 319 | } | 
|---|
| 320 | } | 
|---|
| 321 | if(i == STATS_MAX_OBJECTS) { | 
|---|
| 322 | dprintf(("!WARNING! STAT_DeleteObject: %x not found!!", hObject)); | 
|---|
| 323 | } | 
|---|
| 324 | } | 
|---|
| 325 | //****************************************************************************** | 
|---|
| 326 | //****************************************************************************** | 
|---|
| 327 | static void STAT_PrintLeakedObjects(char *szMessage, DWORD *pdwObjects) | 
|---|
| 328 | { | 
|---|
| 329 | for(int i=0;i<STATS_MAX_OBJECTS;i++) { | 
|---|
| 330 | if(pdwObjects[i] != 0) { | 
|---|
| 331 | dprintf(("%s %x", szMessage, pdwObjects[i])); | 
|---|
| 332 | } | 
|---|
| 333 | } | 
|---|
| 334 | } | 
|---|
| 335 | //****************************************************************************** | 
|---|
| 336 | //****************************************************************************** | 
|---|
| 337 | void STATS_CreateFontIndirect(HFONT hFont, LOGFONTA* lplf) | 
|---|
| 338 | { | 
|---|
| 339 | nrfontscreated++; | 
|---|
| 340 | STAT_InsertObject(hFont, createdfont); | 
|---|
| 341 | } | 
|---|
| 342 | //****************************************************************************** | 
|---|
| 343 | //****************************************************************************** | 
|---|
| 344 | void STATS_CreateCompatibleDC(HDC hdc, HDC newHdc) | 
|---|
| 345 | { | 
|---|
| 346 | nrdcscreated++; | 
|---|
| 347 | STAT_InsertObject(newHdc, createddc); | 
|---|
| 348 | } | 
|---|
| 349 | //****************************************************************************** | 
|---|
| 350 | //****************************************************************************** | 
|---|
| 351 | void STATS_DeleteDC(HDC hdc) | 
|---|
| 352 | { | 
|---|
| 353 | nrdcscreated--; | 
|---|
| 354 | STAT_DeleteObject(hdc, createddc); | 
|---|
| 355 | } | 
|---|
| 356 | //****************************************************************************** | 
|---|
| 357 | //****************************************************************************** | 
|---|
| 358 | void STATS_CreatePatternBrush(HBRUSH hBrush, HBITMAP hBitmap) | 
|---|
| 359 | { | 
|---|
| 360 | nrbrushescreated++; | 
|---|
| 361 | STAT_InsertObject(hBrush, createdbrush); | 
|---|
| 362 | } | 
|---|
| 363 | //****************************************************************************** | 
|---|
| 364 | //****************************************************************************** | 
|---|
| 365 | void STATS_CreateDIBPatternBrushPt(HBRUSH hBrush, LPCVOID buffer, DWORD usage) | 
|---|
| 366 | { | 
|---|
| 367 | nrbrushescreated++; | 
|---|
| 368 | STAT_InsertObject(hBrush, createdbrush); | 
|---|
| 369 | } | 
|---|
| 370 | //****************************************************************************** | 
|---|
| 371 | //****************************************************************************** | 
|---|
| 372 | void STATS_CreatePenIndirect(HPEN hPen, const LOGPEN *lplgpn) | 
|---|
| 373 | { | 
|---|
| 374 | nrpenscreated++; | 
|---|
| 375 | STAT_InsertObject(hPen, createdpen); | 
|---|
| 376 | } | 
|---|
| 377 | //****************************************************************************** | 
|---|
| 378 | //****************************************************************************** | 
|---|
| 379 | void STATS_CreatePen(HPEN hPen, int fnPenStyle, int nWidth, COLORREF crColor) | 
|---|
| 380 | { | 
|---|
| 381 | nrpenscreated++; | 
|---|
| 382 | STAT_InsertObject(hPen, createdpen); | 
|---|
| 383 | } | 
|---|
| 384 | //****************************************************************************** | 
|---|
| 385 | //****************************************************************************** | 
|---|
| 386 | void STATS_ExtCreatePen(HPEN hPen, DWORD dwPenStyle, DWORD dwWidth, const LOGBRUSH *lplb, | 
|---|
| 387 | DWORD dwStyleCount, const DWORD *lpStyle) | 
|---|
| 388 | { | 
|---|
| 389 | nrpenscreated++; | 
|---|
| 390 | STAT_InsertObject(hPen, createdpen); | 
|---|
| 391 | } | 
|---|
| 392 | //****************************************************************************** | 
|---|
| 393 | //****************************************************************************** | 
|---|
| 394 | void STATS_CreateBrushIndirect(HBRUSH hBrush, LPLOGBRUSH pLogBrush) | 
|---|
| 395 | { | 
|---|
| 396 | nrbrushescreated++; | 
|---|
| 397 | STAT_InsertObject(hBrush, createdbrush); | 
|---|
| 398 | } | 
|---|
| 399 | //****************************************************************************** | 
|---|
| 400 | //****************************************************************************** | 
|---|
| 401 | void STATS_CreateHatchBrush(HBRUSH hBrush, int fnStyle, COLORREF clrref) | 
|---|
| 402 | { | 
|---|
| 403 | nrbrushescreated++; | 
|---|
| 404 | STAT_InsertObject(hBrush, createdbrush); | 
|---|
| 405 | } | 
|---|
| 406 | //****************************************************************************** | 
|---|
| 407 | //****************************************************************************** | 
|---|
| 408 | void STATS_CreateSolidBrush(HBRUSH hBrush, COLORREF color) | 
|---|
| 409 | { | 
|---|
| 410 | nrbrushescreated++; | 
|---|
| 411 | STAT_InsertObject(hBrush, createdbrush); | 
|---|
| 412 | } | 
|---|
| 413 | //****************************************************************************** | 
|---|
| 414 | //****************************************************************************** | 
|---|
| 415 | void STATS_CreateICA(HDC hdc, LPCSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszOutput, | 
|---|
| 416 | const DEVMODEA *lpdvmInit) | 
|---|
| 417 | { | 
|---|
| 418 | nrdcscreated++; | 
|---|
| 419 | STAT_InsertObject(hdc, createddc); | 
|---|
| 420 | } | 
|---|
| 421 | //****************************************************************************** | 
|---|
| 422 | //****************************************************************************** | 
|---|
| 423 | void STATS_CreateDCA(HDC hdc, LPCSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszOutput, | 
|---|
| 424 | const DEVMODEA *lpdvmInit) | 
|---|
| 425 | { | 
|---|
| 426 | nrdcscreated++; | 
|---|
| 427 | STAT_InsertObject(hdc, createddc); | 
|---|
| 428 | } | 
|---|
| 429 | //****************************************************************************** | 
|---|
| 430 | //****************************************************************************** | 
|---|
| 431 | void STATS_CreatePolyPolygonRgn(HRGN hRgn, const POINT *lppt, const int *pPolyCount, int nCount, int fnPolyFillMode) | 
|---|
| 432 | { | 
|---|
| 433 | nrregionscreated++; | 
|---|
| 434 | STAT_InsertObject(hRgn, createdregion); | 
|---|
| 435 | } | 
|---|
| 436 | //****************************************************************************** | 
|---|
| 437 | //****************************************************************************** | 
|---|
| 438 | void STATS_CreateRectRgn(HRGN hRgn, int left, int top, int right, int bottom) | 
|---|
| 439 | { | 
|---|
| 440 | nrregionscreated++; | 
|---|
| 441 | STAT_InsertObject(hRgn, createdregion); | 
|---|
| 442 | } | 
|---|
| 443 | //****************************************************************************** | 
|---|
| 444 | //****************************************************************************** | 
|---|
| 445 | void STATS_CreateRoundRectRgn(HRGN hRgn, int left, int top, int right, int bottom, int nWidthEllipse, int nHeightEllipse) | 
|---|
| 446 | { | 
|---|
| 447 | nrregionscreated++; | 
|---|
| 448 | STAT_InsertObject(hRgn, createdregion); | 
|---|
| 449 | } | 
|---|
| 450 | //****************************************************************************** | 
|---|
| 451 | //****************************************************************************** | 
|---|
| 452 | void STATS_ExtCreateRegion(HRGN hRgn, PVOID pXform, DWORD count, const RGNDATA * pData) | 
|---|
| 453 | { | 
|---|
| 454 | nrregionscreated++; | 
|---|
| 455 | STAT_InsertObject(hRgn, createdregion); | 
|---|
| 456 | } | 
|---|
| 457 | //****************************************************************************** | 
|---|
| 458 | //****************************************************************************** | 
|---|
| 459 | void STATS_CreateEllipticRgn(HRGN hRgn, int left, int top, int right, int bottom) | 
|---|
| 460 | { | 
|---|
| 461 | nrregionscreated++; | 
|---|
| 462 | STAT_InsertObject(hRgn, createdregion); | 
|---|
| 463 | } | 
|---|
| 464 | //****************************************************************************** | 
|---|
| 465 | //****************************************************************************** | 
|---|
| 466 | void STATS_CreatePolygonRgn(HRGN hRgn, const POINT * lppt, int cPoints, int fnPolyFillMode) | 
|---|
| 467 | { | 
|---|
| 468 | nrregionscreated++; | 
|---|
| 469 | STAT_InsertObject(hRgn, createdregion); | 
|---|
| 470 | } | 
|---|
| 471 | //****************************************************************************** | 
|---|
| 472 | //****************************************************************************** | 
|---|
| 473 | void STATS_CreateDIBitmap(HBITMAP hBitmap,HDC hdc, const BITMAPINFOHEADER *lpbmih, | 
|---|
| 474 | DWORD fdwInit, const void *lpbInit, | 
|---|
| 475 | const BITMAPINFO *lpbmi, UINT fuUsage) | 
|---|
| 476 | { | 
|---|
| 477 | nrbitmapscreated++; | 
|---|
| 478 | STAT_InsertObject(hBitmap, createdbitmap); | 
|---|
| 479 | } | 
|---|
| 480 | //****************************************************************************** | 
|---|
| 481 | //****************************************************************************** | 
|---|
| 482 | void STATS_CreateCompatibleBitmap(HBITMAP hBitmap,HDC hdc, int nWidth, int nHeight) | 
|---|
| 483 | { | 
|---|
| 484 | nrbitmapscreated++; | 
|---|
| 485 | STAT_InsertObject(hBitmap, createdbitmap); | 
|---|
| 486 | } | 
|---|
| 487 | //****************************************************************************** | 
|---|
| 488 | //****************************************************************************** | 
|---|
| 489 | void STATS_CreateBitmap(HBITMAP hBitmap,int nWidth, int nHeight, UINT cPlanes, | 
|---|
| 490 | UINT cBitsPerPel, const void *lpvBits) | 
|---|
| 491 | { | 
|---|
| 492 | nrbitmapscreated++; | 
|---|
| 493 | STAT_InsertObject(hBitmap, createdbitmap); | 
|---|
| 494 | } | 
|---|
| 495 | //****************************************************************************** | 
|---|
| 496 | //****************************************************************************** | 
|---|
| 497 | void STATS_CreateDIBSection(HBITMAP hBitmap,HDC hdc, BITMAPINFO *pbmi, UINT iUsage, | 
|---|
| 498 | VOID **ppvBits, HANDLE hSection, DWORD dwOffset) | 
|---|
| 499 | { | 
|---|
| 500 | nrbitmapscreated++; | 
|---|
| 501 | STAT_InsertObject(hBitmap, createdbitmap); | 
|---|
| 502 | } | 
|---|
| 503 | //****************************************************************************** | 
|---|
| 504 | //****************************************************************************** | 
|---|
| 505 | void STATS_CreateBitmapIndirect(HBITMAP hBitmap, const BITMAP *pBitmap) | 
|---|
| 506 | { | 
|---|
| 507 | nrbitmapscreated++; | 
|---|
| 508 | STAT_InsertObject(hBitmap, createdbitmap); | 
|---|
| 509 | } | 
|---|
| 510 | //****************************************************************************** | 
|---|
| 511 | //****************************************************************************** | 
|---|
| 512 | void STATS_DeleteObject(HANDLE hObj, DWORD objtype) | 
|---|
| 513 | { | 
|---|
| 514 | switch(objtype) { | 
|---|
| 515 | case OBJ_PEN: | 
|---|
| 516 | case OBJ_EXTPEN: | 
|---|
| 517 | nrpenscreated--; | 
|---|
| 518 | STAT_DeleteObject(hObj, createdpen); | 
|---|
| 519 | break; | 
|---|
| 520 | case OBJ_BRUSH: | 
|---|
| 521 | nrbrushescreated--; | 
|---|
| 522 | STAT_DeleteObject(hObj, createdbrush); | 
|---|
| 523 | break; | 
|---|
| 524 | case OBJ_FONT: | 
|---|
| 525 | nrfontscreated--; | 
|---|
| 526 | STAT_DeleteObject(hObj, createdfont); | 
|---|
| 527 | break; | 
|---|
| 528 | case OBJ_REGION: | 
|---|
| 529 | nrregionscreated--; | 
|---|
| 530 | STAT_DeleteObject(hObj, createdregion); | 
|---|
| 531 | break; | 
|---|
| 532 | case OBJ_BITMAP: | 
|---|
| 533 | nrbitmapscreated--; | 
|---|
| 534 | STAT_DeleteObject(hObj, createdbitmap); | 
|---|
| 535 | break; | 
|---|
| 536 |  | 
|---|
| 537 | case OBJ_MEMDC: | 
|---|
| 538 | case OBJ_DC: | 
|---|
| 539 | nrdcscreated--; | 
|---|
| 540 | STAT_DeleteObject(hObj, createddc); | 
|---|
| 541 | break; | 
|---|
| 542 |  | 
|---|
| 543 | case OBJ_PAL: | 
|---|
| 544 | case OBJ_METAFILE: | 
|---|
| 545 | case OBJ_ENHMETADC: | 
|---|
| 546 | case OBJ_ENHMETAFILE: | 
|---|
| 547 | case OBJ_METADC: | 
|---|
| 548 | break; | 
|---|
| 549 | default: | 
|---|
| 550 | dprintf(("!ERROR! Unknown object %x of type %d", hObj, objtype)); | 
|---|
| 551 | break; | 
|---|
| 552 | } | 
|---|
| 553 | } | 
|---|
| 554 | //****************************************************************************** | 
|---|
| 555 | //****************************************************************************** | 
|---|
| 556 | void STATS_DumpStatsGDI32() | 
|---|
| 557 | { | 
|---|
| 558 | dprintf(("*************  GDI32 STATISTICS BEGIN *****************")); | 
|---|
| 559 | dprintf(("Leaked dcs            %d", nrdcscreated)); | 
|---|
| 560 | STAT_PrintLeakedObjects("Leaked DC", createddc); | 
|---|
| 561 | dprintf(("*************  ********************** *****************")); | 
|---|
| 562 | dprintf(("Leaked font objects   %d", nrfontscreated)); | 
|---|
| 563 | STAT_PrintLeakedObjects("Leaked Font", createdfont); | 
|---|
| 564 | dprintf(("*************  ********************** *****************")); | 
|---|
| 565 | dprintf(("Leaked pen objects    %d", nrpenscreated)); | 
|---|
| 566 | STAT_PrintLeakedObjects("Leaked Pen", createdpen); | 
|---|
| 567 | dprintf(("*************  ********************** *****************")); | 
|---|
| 568 | dprintf(("Leaked brush objects  %d", nrbrushescreated)); | 
|---|
| 569 | STAT_PrintLeakedObjects("Leaked Brush", createdbrush); | 
|---|
| 570 | dprintf(("*************  ********************** *****************")); | 
|---|
| 571 | dprintf(("Leaked region objects %d", nrregionscreated)); | 
|---|
| 572 | STAT_PrintLeakedObjects("Leaked Region", createdregion); | 
|---|
| 573 | dprintf(("*************  ********************** *****************")); | 
|---|
| 574 | dprintf(("Leaked bitmap objects %d", nrbitmapscreated)); | 
|---|
| 575 | STAT_PrintLeakedObjects("Leaked Bitmap", createdbitmap); | 
|---|
| 576 | ObjDumpObjects(); | 
|---|
| 577 | dprintf(("*************  GDI32 STATISTICS END   *****************")); | 
|---|
| 578 | } | 
|---|
| 579 | //****************************************************************************** | 
|---|
| 580 | //****************************************************************************** | 
|---|
| 581 | void STATS_InitializeGDI32(void) | 
|---|
| 582 | { | 
|---|
| 583 | return; | 
|---|
| 584 | } | 
|---|
| 585 |  | 
|---|
| 586 | void STATS_UninitializeGDI32(void) | 
|---|
| 587 | { | 
|---|
| 588 | return; | 
|---|
| 589 | } | 
|---|
| 590 |  | 
|---|
| 591 |  | 
|---|
| 592 | #endif //DEBUG | 
|---|
| 593 | #endif //RAS | 
|---|