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.

1400 lines
44 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: dcobj.cxx *
  3. * *
  4. * Non inline methods for DC user object. These are in a separate module *
  5. * to save other modules from having to do more includes. *
  6. * *
  7. * Created: 09-Aug-1989 13:57:58 *
  8. * Author: Donald Sidoroff [donalds] *
  9. * *
  10. * Copyright (c) 1989-1999 Microsoft Corporation *
  11. \**************************************************************************/
  12. #include "precomp.hxx"
  13. extern RECTL rclEmpty;
  14. /******************************Public*Routine******************************\
  15. *
  16. * VOID XDCOBJ::vSetDefaultFont(BOOL bDisplay)
  17. *
  18. *
  19. * Effects: called from bCleanDC and CreateDC
  20. *
  21. * History:
  22. * 21-Mar-1996 -by- Bodin Dresevic [BodinD]
  23. * Wrote it.
  24. \**************************************************************************/
  25. VOID XDCOBJ::vSetDefaultFont(BOOL bDisplay)
  26. {
  27. // If display PDEV, then select System stock font.
  28. HLFONT hlfntNew;
  29. if (bDisplay)
  30. {
  31. ulDirty(ulDirty() | DISPLAY_DC );
  32. hlfntNew = STOCKOBJ_SYSFONT;
  33. }
  34. else
  35. {
  36. hlfntNew = STOCKOBJ_DEFAULTDEVFONT;
  37. }
  38. // this can not fail with the stock fonts, also increments ref count
  39. PLFONT plfnt = (PLFONT)HmgShareCheckLock((HOBJ)hlfntNew, LFONT_TYPE);
  40. ASSERTGDI(plfnt, "vSetDefaultFont: plfnt == NULL\n");
  41. pdc->hlfntNew(hlfntNew);
  42. pdc->plfntNew(plfnt);
  43. }
  44. /******************************Member*Function*****************************\
  45. * DCSAVE::bDelete()
  46. *
  47. * Attempt to delete the DC.
  48. *
  49. * History:
  50. * Sat 19-Aug-1989 00:32:58 -by- Charles Whitmer [chuckwh]
  51. * Wrote it.
  52. \**************************************************************************/
  53. BOOL XDCOBJ::bDeleteDC(BOOL bProcessCleanup)
  54. {
  55. PFFLIST *pPFFList;
  56. BOOL bIsPrivate;
  57. RFONTOBJ rfDeadMeat(pdc->prfnt()); // deletion constructor, see rfntobj.cxx
  58. // Nuke the brushes (unreference count to brush realization)
  59. peboFill()->vNuke();
  60. peboLine()->vNuke();
  61. peboText()->vNuke();
  62. peboBackground()->vNuke();
  63. // remove any colortransform in this DC.
  64. vCleanupColorTransform(bProcessCleanup);
  65. // remove any remote fonts
  66. if(pPFFList = pdc->pPFFList)
  67. {
  68. while( pPFFList )
  69. {
  70. PFFLIST *pTmp;
  71. pTmp = pPFFList;
  72. pPFFList = pPFFList->pNext;
  73. GreAcquireSemaphoreEx(ghsemPublicPFT, SEMORDER_PUBLICPFT, NULL);
  74. // this list is also used for local printing with embed fonts
  75. bIsPrivate = (pTmp->pPFF->pPFT == gpPFTPrivate) ? TRUE : FALSE;
  76. PUBLIC_PFTOBJ pfto(pTmp->pPFF->pPFT);
  77. //pPFFList != NULL only if the PFFs have been added to the DC for remote printing.
  78. // bUnloadWorkhorse should release the ghsemPublicPFT
  79. if (!pfto.bUnloadWorkhorse( pTmp->pPFF, 0, ghsemPublicPFT, bIsPrivate ? FR_PRINT_EMB_FONT : FR_NOT_ENUM))
  80. {
  81. WARNING("XDCOBJ::bDelete unable to delete remote font.\n");
  82. }
  83. VFREEMEM( pTmp );
  84. }
  85. }
  86. // remove this from handle manager.
  87. HmgFree((HOBJ)pdc->hGet());
  88. pdc = (PDC) NULL; // Prevents ~DCOBJ from doing anything.
  89. return(TRUE);
  90. }
  91. /******************************Data*Structure******************************\
  92. * dclevelDefault
  93. *
  94. * Defines the default DC image for use by DCMEMOBJ.
  95. *
  96. * History:
  97. * Thu 09-Aug-1990 20:54:02 -by- Charles Whitmer [chuckwh]
  98. * Wrote the nearly bare bones version. We'll build it back up with the
  99. * DC structure as we add components.
  100. \**************************************************************************/
  101. DC_ATTR DcAttrDefault =
  102. {
  103. {0}, // PVOID pvLDC;
  104. (ULONG)DIRTY_CHARSET, // ULONG ulDirty_;
  105. (HBRUSH)0, // HBRUSH hbrush
  106. (HPEN)0, // HPEN hpen
  107. (COLORREF)0x00ffffff, // COLORREF crBackgroundClr;
  108. (COLORREF)0x00ffffff, // ULONG ulBackgroundClr;
  109. (COLORREF)0, // COLORREF crForegroundClr;
  110. (COLORREF)0, // ULONG ulForegroundClr;
  111. (COLORREF)0x00ffffff, // COLORREF crDCBrushClr;
  112. (COLORREF)0x00ffffff, // ULONG ulDCBrushClr;
  113. (COLORREF)0, // COLORREF crDCPenClr;
  114. (COLORREF)0, // ULONG ulDCPenClr;
  115. (ULONG)0, // ULONG iCS_CP;
  116. GM_COMPATIBLE, // ULONG iGraphicsMode;
  117. R2_COPYPEN, // BYTE jROP2;
  118. OPAQUE, // BYTE jBkMode;
  119. ALTERNATE, // BYTE jFillMode;
  120. BLACKONWHITE, // BYTE jStretchBltMode;
  121. {0}, // POINTL ptlCurrent
  122. {0}, // POINTL ptfxCurrent
  123. OPAQUE, // LONG lBkMode;
  124. ALTERNATE, // ULONG lFillMode;
  125. BLACKONWHITE, // LONG lStretchBltMode;
  126. 0, // FLONG flFontMapper;
  127. //
  128. DC_ICM_OFF, // LONG lIcmMode;
  129. (HANDLE)0, // HANDLE hcmXform;
  130. (HCOLORSPACE)0, // HCOLORSPACE hColorSpace;
  131. (DWORD)0, // DWORD dwDIBColorSpace;
  132. (COLORREF)CLR_INVALID, // COLORREF IcmBrushColor;
  133. (COLORREF)CLR_INVALID, // COLORREF IcmPenColor;
  134. {0}, // PVOID pvICM;
  135. //
  136. TA_LEFT|TA_TOP|TA_NOUPDATECP, // FLONG flTextAlign;
  137. TA_LEFT|TA_TOP|TA_NOUPDATECP, // LONG lTextAlign;
  138. (LONG)0, // LONG lTextExtra;
  139. (LONG)ABSOLUTE, // LONG lRelAbs;
  140. (LONG)0, // LONG lBreakExtra;
  141. (LONG)0, // LONG cBreak;
  142. (HLFONT)0, // HLFONT hlfntNew;
  143. { // MATRIX mxWorldToDevice
  144. EFLOAT_16, // EFLOAT efM11
  145. EFLOAT_0, // EFLOAT efM12
  146. EFLOAT_0, // EFLOAT efM21
  147. EFLOAT_16, // EFLOAT efM22
  148. EFLOAT_0, // EFLOAT efDx
  149. EFLOAT_0, // EFLOAT efDy
  150. 0, // FIX fxDx
  151. 0, // FIX fxDy
  152. XFORM_SCALE | // FLONG flAccel
  153. XFORM_UNITY |
  154. XFORM_NO_TRANSLATION |
  155. XFORM_FORMAT_LTOFX
  156. },
  157. { // MATRIX mxDeviceToWorld
  158. EFLOAT_1Over16, // EFLOAT efM11
  159. EFLOAT_0, // EFLOAT efM12
  160. EFLOAT_0, // EFLOAT efM21
  161. EFLOAT_1Over16, // EFLOAT efM22
  162. EFLOAT_0, // EFLOAT efDx
  163. EFLOAT_0, // EFLOAT efDy
  164. 0, // FIX fxDx
  165. 0, // FIX fxDy
  166. XFORM_SCALE | // FLONG flAccel
  167. XFORM_UNITY |
  168. XFORM_NO_TRANSLATION |
  169. XFORM_FORMAT_FXTOL
  170. },
  171. { // MATRIX mxWorldToPage
  172. EFLOAT_1, // EFLOAT efM11
  173. EFLOAT_0, // EFLOAT efM12
  174. EFLOAT_0, // EFLOAT efM21
  175. EFLOAT_1, // EFLOAT efM22
  176. EFLOAT_0, // EFLOAT efDx
  177. EFLOAT_0, // EFLOAT efDy
  178. 0, // FIX fxDx
  179. 0, // FIX fxDy
  180. XFORM_SCALE | // FLONG flAccel
  181. XFORM_UNITY |
  182. XFORM_NO_TRANSLATION |
  183. XFORM_FORMAT_LTOL
  184. },
  185. EFLOAT_16, // EFLOAT efM11PtoD
  186. EFLOAT_16, // EFLOAT efM22PtoD
  187. EFLOAT_0, // EFLOAT efDxPtoD
  188. EFLOAT_0, // EFLOAT efDyPtoD
  189. MM_TEXT, // ULONG iMapMode;
  190. 0, // DWORD dwLayout;
  191. 0, // LONG lWindowOrgx;
  192. {0,0}, // POINTL ptlWindowOrg;
  193. {1,1}, // SIZEL szlWindowExt;
  194. {0,0}, // POINTL ptlViewPortOrg;
  195. {1,1}, // SIZEL szlViewPortExt;
  196. WORLD_TO_PAGE_IDENTITY | // flXform
  197. PAGE_TO_DEVICE_SCALE_IDENTITY |
  198. PAGE_TO_DEVICE_IDENTITY,
  199. {0,0}, // SIZEL szlVirtualDevicePixel;
  200. {0,0}, // SIZEL szlVirtualDeviceMm;
  201. {0,0}, // POINTL ptlBrushOrigin;
  202. {0} // RECTREGION VisRectRegion;
  203. };
  204. DCLEVEL dclevelDefault =
  205. {
  206. 0, // HPAL hpal;
  207. 0, // PPALETTE ppal;
  208. 0, // PVOID pColorSpace;
  209. DC_ICM_OFF, // ULONG lIcmMode;
  210. 1, // LONG lSaveDepth;
  211. 0, // LONG lSaveDepthStartDoc;
  212. (HDC) 0, // HDC hdcSave;
  213. {0,0}, // POINTL ptlKmBrushOrigin;
  214. (PBRUSH)NULL, // PBRUSH pbrFill;
  215. (PBRUSH)NULL, // PBRUSH pbrLine;
  216. (PLFONT)NULL, // PLFONT plfntNew_;
  217. HPATH_INVALID, // HPATH hpath;
  218. 0, // FLONG flPath;
  219. { // LINEATTRS laPath;
  220. 0, // FLONG fl;
  221. 0, // ULONG iJoin;
  222. 0, // ULONG iEndCap;
  223. {IEEE_0_0F}, // FLOAT_LONG elWidth;
  224. IEEE_10_0F, // FLOAT eMiterLimit;
  225. 0, // ULONG cstyle;
  226. (PFLOAT_LONG) NULL, // PFLOAT_LONG pstyle;
  227. {IEEE_0_0F} // FLOAT_LONG elStyleState;
  228. },
  229. NULL, // HRGN prgnClip;
  230. NULL, // HRGN prgnMeta;
  231. { // COLORADJUSTMENT ca
  232. sizeof(COLORADJUSTMENT), // WORD caSize
  233. CA_DEFAULT, // WORD caFlags
  234. ILLUMINANT_DEFAULT, // WORD caIlluminantIndex
  235. HT_DEF_RGB_GAMMA, // WORD caRedPowerGamma
  236. HT_DEF_RGB_GAMMA, // WORD caGreenPowerGamma
  237. HT_DEF_RGB_GAMMA, // WORD caBluePowerGamma
  238. REFERENCE_BLACK_DEFAULT, // WORD caReferenceBlack
  239. REFERENCE_WHITE_DEFAULT, // WORD caReferenceWhite
  240. CONTRAST_ADJ_DEFAULT, // SHORT caContrast
  241. BRIGHTNESS_ADJ_DEFAULT, // SHORT caBrightness
  242. COLORFULNESS_ADJ_DEFAULT, // SHORT caColorfulness
  243. REDGREENTINT_ADJ_DEFAULT, // SHORT caRedGreenTint
  244. },
  245. 0, // FLONG flFontState;
  246. {0,0}, // UNIVERSAL_FONT_ID ufi;
  247. {{0,0},{0,0},{0,0},{0,0}}, // UNIVERSAL_FON_ID aQuickLinks[QUICK_UFI_LINKS]
  248. 0, // PUNIVERSAL_FONT_ID pufi
  249. 0, // UINT uNumLinkedFonts
  250. 0, // BOOL bTurnOffLinking
  251. 0, // FLONG flFlags;
  252. 0, // FLONG flbrush;
  253. { // MATRIX mxWorldToDevice
  254. EFLOAT_16, // EFLOAT efM11
  255. EFLOAT_0, // EFLOAT efM12
  256. EFLOAT_0, // EFLOAT efM21
  257. EFLOAT_16, // EFLOAT efM22
  258. EFLOAT_0, // EFLOAT efDx
  259. EFLOAT_0, // EFLOAT efDy
  260. 0, // FIX fxDx
  261. 0, // FIX fxDy
  262. XFORM_SCALE | // FLONG flAccel
  263. XFORM_UNITY |
  264. XFORM_NO_TRANSLATION |
  265. XFORM_FORMAT_LTOFX
  266. },
  267. { // MATRIX mxDeviceToWorld
  268. EFLOAT_1Over16, // EFLOAT efM11
  269. EFLOAT_0, // EFLOAT efM12
  270. EFLOAT_0, // EFLOAT efM21
  271. EFLOAT_1Over16, // EFLOAT efM22
  272. EFLOAT_0, // EFLOAT efDx
  273. EFLOAT_0, // EFLOAT efDy
  274. 0, // FIX fxDx
  275. 0, // FIX fxDy
  276. XFORM_SCALE | // FLONG flAccel
  277. XFORM_UNITY |
  278. XFORM_NO_TRANSLATION |
  279. XFORM_FORMAT_FXTOL
  280. },
  281. { // MATRIX mxWorldToPage
  282. EFLOAT_1, // EFLOAT efM11
  283. EFLOAT_0, // EFLOAT efM12
  284. EFLOAT_0, // EFLOAT efM21
  285. EFLOAT_1, // EFLOAT efM22
  286. EFLOAT_0, // EFLOAT efDx
  287. EFLOAT_0, // EFLOAT efDy
  288. 0, // FIX fxDx
  289. 0, // FIX fxDy
  290. XFORM_SCALE | // FLONG flAccel
  291. XFORM_UNITY |
  292. XFORM_NO_TRANSLATION |
  293. XFORM_FORMAT_LTOL
  294. },
  295. EFLOAT_16, // EFLOAT efM11PtoD
  296. EFLOAT_16, // EFLOAT efM22PtoD
  297. EFLOAT_0, // EFLOAT efDxPtoD
  298. EFLOAT_0, // EFLOAT efDyPtoD
  299. EFLOAT_0, // EFLOAT efM11_TWIPS
  300. EFLOAT_0, // EFLOAT efM22_TWIPS
  301. EFLOAT_0, // efPr11
  302. EFLOAT_0, // efPr22
  303. 0, // SURFACE *pSurface;
  304. {0,0}, // SIZEL sizl;
  305. };
  306. /******************************Public*Routine******************************\
  307. * BOOL DCOBJ::bCleanDC ()
  308. *
  309. * Restores the DCLEVEL to the same as when DC was created via CreateDC (i.e,
  310. * resets it back to dclevelDefault). Also used to clean the DC before
  311. * deletion.
  312. *
  313. * Returns:
  314. * TRUE if successful, FALSE if an error occurs.
  315. *
  316. * History:
  317. * 21-May-1991 -by- Gilman Wong [gilmanw]
  318. * Wrote it.
  319. \**************************************************************************/
  320. BOOL XDCOBJ::bCleanDC ()
  321. {
  322. // Set TRUE if cleaning the DC invalidates the prfnt with respect to
  323. // the DC's transform.
  324. BOOL bFontXformDirty;
  325. // Sync the brush
  326. SYNC_DRAWING_ATTRS(pdc);
  327. // If the current map mode is MM_TEXT and the current prfnt is NOT dirty
  328. // with respect to the transform, then after we scrub the DC clean, the
  329. // pfrnt is still clean with respect to transform. Otherwise, the font
  330. // is dirty with respect to transform.
  331. if ((ulMapMode() == MM_TEXT) && !this->pdc->bXFormChange())
  332. bFontXformDirty = FALSE;
  333. else
  334. bFontXformDirty = TRUE;
  335. // Restore DC to lowest level.
  336. if (1 < lSaveDepth())
  337. GreRestoreDC(hdc(), 1);
  338. // Restore the palette.
  339. if (ppal() != ppalDefault)
  340. GreSelectPalette(hdc(), (HPALETTE)dclevelDefault.hpal, TRUE);
  341. if (dctp() == DCTYPE_MEMORY)
  342. {
  343. // Restore the bitmap if necessary.
  344. hbmSelectBitmap(hdc(), STOCKOBJ_BITMAP, TRUE);
  345. // Watch out that DirectDraw sometimes marks DCTYPE_MEMORY
  346. // surfaces as being 'full-screen'. Consequently, we have
  347. // to reset that here.
  348. //
  349. // (Note that we don't reset the flag for DCTYPE_DIRECT
  350. // surfaces, because that flag is automatically updated by
  351. // PDEVOBJ::bDisabled() for all DCTYPE_DIRECT surfaces when
  352. // the mode changes.)
  353. bInFullScreen(FALSE);
  354. }
  355. // Reset pixel format.
  356. ipfdDevMax(-1);
  357. // If any regions exist, delete them.
  358. if (pdc->dclevel.prgnClip != NULL)
  359. {
  360. RGNOBJ ro1(pdc->dclevel.prgnClip);
  361. // Note: GreRestoreDC(1) should guarantee regions' reference
  362. // counts are 1
  363. ASSERTGDI (ro1.cGet_cRefs() == 1,
  364. "DCOBJ::bCleanDC(): bad ref count, deleting prgnClip\n");
  365. ro1.bDeleteRGNOBJ();
  366. pdc->dclevel.prgnClip = NULL;
  367. }
  368. if (pdc->dclevel.prgnMeta != NULL)
  369. {
  370. RGNOBJ ro2(pdc->dclevel.prgnMeta);
  371. // Note: GreRestoreDC(1) should guarantee regions' reference
  372. // counts are 1
  373. ASSERTGDI (ro2.cGet_cRefs() == 1,
  374. "DCOBJ::bCleanDC(): bad ref count, deleting prgnMeta\n");
  375. ro2.bDeleteRGNOBJ();
  376. pdc->dclevel.prgnMeta = NULL;
  377. }
  378. // delete the path
  379. if (pdc->dclevel.hpath != HPATH_INVALID)
  380. {
  381. XEPATHOBJ epath(pdc->dclevel.hpath);
  382. ASSERTGDI(epath.bValid(), "Invalid DC path");
  383. epath.vDelete();
  384. }
  385. // Undo the locks from when the fill and line brushes were selected.
  386. // (Un-reference-count the brushes.)
  387. DEC_SHARE_REF_CNT_LAZY0(pdc->dclevel.pbrFill);
  388. DEC_SHARE_REF_CNT_LAZY0(pdc->dclevel.pbrLine);
  389. // make sure to delete the old logfont object if it is marked for deletion
  390. DEC_SHARE_REF_CNT_LAZY_DEL_LOGFONT(pdc->plfntNew());
  391. // decrement ref count for the colorspace selected in DC.
  392. DEC_SHARE_REF_CNT_LAZY_DEL_COLORSPACE(pdc->dclevel.pColorSpace);
  393. // Make sure everything else is set to default.
  394. //
  395. // Preserve 'pSurface' and 'sizl' in the DCLEVEL -- it may asynchronously
  396. // be updated by dynamic mode changing.
  397. RtlCopyMemory(&pdc->dclevel, &dclevelDefault, offsetof(DCLEVEL, pSurface));
  398. RtlCopyMemory(pdc->pDCAttr, &DcAttrDefault, sizeof(DC_ATTR));
  399. // Mark brush, charset, color space and color transform as dirty.
  400. ulDirtyAdd(DIRTY_BRUSHES|DIRTY_CHARSET|DIRTY_COLORSPACE|DIRTY_COLORTRANSFORM);
  401. // Lock the fill and line brushes we just selected in.
  402. // (Reference-count the brushes.)
  403. // These locks can't fail.
  404. INC_SHARE_REF_CNT(pdc->dclevel.pbrFill);
  405. INC_SHARE_REF_CNT(pdc->dclevel.pbrLine);
  406. // Clean up the font stuff. (This must be done after copying the default
  407. // dclevel).
  408. {
  409. PDEVOBJ pdo(hdev());
  410. // If display PDEV, then select System stock font.
  411. vSetDefaultFont(pdo.bDisplayPDEV());
  412. // if primary display dc, set the DC_PRIMARY_DISPLAY flag on
  413. if (hdev() == UserGetHDEV())
  414. {
  415. ulDirtyAdd(DC_PRIMARY_DISPLAY);
  416. }
  417. // OK, set the dclevel's font xfrom dirty flag from the value computed
  418. // BEFORE the GreRestoreDC.
  419. this->pdc->vXformChange(bFontXformDirty);
  420. }
  421. // Lock color space we just selected in.
  422. INC_SHARE_REF_CNT(pdc->dclevel.pColorSpace);
  423. RFONTOBJ rfoDead(pdc->prfnt()); // special constructor deactivates
  424. pdc->prfnt(0); // this RFONT
  425. // free up linked UFIs if not allocated pointing to fast buffer
  426. if(pdc->dclevel.pufi && (pdc->dclevel.pufi != pdc->dclevel.aQuickLinks))
  427. {
  428. VFREEMEM(pdc->dclevel.pufi);
  429. pdc->dclevel.pufi = NULL;
  430. }
  431. // Set the filling origin to whatever the DC origin is.
  432. pdc->ptlFillOrigin(pdc->eptlOrigin().x,pdc->eptlOrigin().y);
  433. // Assume Rao has been made dirty by the above work.
  434. pdc->vReleaseRao();
  435. return(TRUE);
  436. }
  437. /******************************Member*Function*****************************\
  438. * XDCOBJ::bSetLinkedUFIs( PFF *ppff );
  439. *
  440. * Add the list of linked UFIs to tDC
  441. *
  442. * History:
  443. * Mon 15-Dec-1996 -by- Gerrit van Wingerden [gerritv]
  444. * Wrote it.
  445. \**************************************************************************/
  446. BOOL XDCOBJ::bSetLinkedUFIs(PUNIVERSAL_FONT_ID pufis, UINT uNumUFIs)
  447. {
  448. pdc->dclevel.bTurnOffLinking = (uNumUFIs) ? FALSE : TRUE;
  449. // If pufi hasn't been initialized or it is too small, reinitialize it.
  450. if(!pdc->dclevel.pufi || (uNumUFIs > pdc->dclevel.uNumLinkedFonts))
  451. {
  452. if(pdc->dclevel.pufi && (pdc->dclevel.pufi != pdc->dclevel.aQuickLinks))
  453. {
  454. VFREEMEM(pdc->dclevel.pufi);
  455. pdc->dclevel.pufi = NULL;
  456. }
  457. if(uNumUFIs <= QUICK_UFI_LINKS)
  458. {
  459. pdc->dclevel.pufi = pdc->dclevel.aQuickLinks;
  460. }
  461. else
  462. {
  463. if(!(pdc->dclevel.pufi = (PUNIVERSAL_FONT_ID)
  464. PALLOCMEM(sizeof(UNIVERSAL_FONT_ID) * uNumUFIs,'ddaG')))
  465. {
  466. WARNING("GDI: XDCOBJ::bSetLinkedUFIs of of memory\n");
  467. pdc->dclevel.uNumLinkedFonts = 0;
  468. return(FALSE);
  469. }
  470. }
  471. pdc->dclevel.uNumLinkedFonts = uNumUFIs;
  472. }
  473. memcpy(pdc->dclevel.pufi, pufis, sizeof(UNIVERSAL_FONT_ID) * uNumUFIs);
  474. return(TRUE);
  475. }
  476. /******************************Member*Function*****************************\
  477. * XDCOBJ::bAddRemoteFont( PFF *ppff );
  478. *
  479. * Add the PFF of a remote font to this DC.
  480. *
  481. * History:
  482. * Mon 06-Feb-1995 -by- Gerrit van Wingerden [gerritv]
  483. * Wrote it.
  484. \**************************************************************************/
  485. BOOL XDCOBJ::bAddRemoteFont( PFF *ppff )
  486. {
  487. BOOL bRet = FALSE;
  488. PFFLIST *pPFFList;
  489. pPFFList = (PFFLIST*) PALLOCMEM( sizeof(PFFLIST),'ddaG' );
  490. if( pPFFList == NULL )
  491. {
  492. WARNING("XDCOBJ::bAddRemoteFont unable to allocate memory\n");
  493. }
  494. else
  495. {
  496. pPFFList->pNext = pdc->pPFFList;
  497. pdc->pPFFList = pPFFList;
  498. pPFFList->pPFF = ppff;
  499. bRet = TRUE;
  500. }
  501. return(bRet);
  502. }
  503. /****************************Member*Function*****************************\
  504. * XDCOBJ::bRemoveMergeFont(UNIVERSAL_FONT_ID ufi);
  505. *
  506. * Remove a merged font from the public font table and pPFFList in the dc.
  507. *
  508. * History:
  509. * Jan-27-1997 Xudong Wu [tessiew]
  510. * Wrote it.
  511. \************************************************************************/
  512. BOOL XDCOBJ::bRemoveMergeFont(UNIVERSAL_FONT_ID ufi)
  513. {
  514. GDIFunctionID(XDCOBJ::bRemoveMergeFont);
  515. PFFLIST *pPFFCur, *pPFFPrev;
  516. BOOL bRet = FALSE;
  517. pPFFPrev = pPFFCur = pdc->pPFFList;
  518. while(pPFFCur && !bRet)
  519. {
  520. PFFOBJ pffo(pPFFCur->pPFF);
  521. if (pffo.ulCheckSum() == ufi.CheckSum)
  522. {
  523. UINT iFont;
  524. // check whether the Index field also match
  525. for (iFont = 0; iFont < pffo.cFonts(); iFont++ )
  526. {
  527. ASSERTGDI(pffo.ppfe(iFont), "Invalid ppfe\n");
  528. if (pffo.ppfe(iFont)->ufi.Index == ufi.Index)
  529. {
  530. bRet = TRUE;
  531. break;
  532. }
  533. }
  534. }
  535. if (!bRet)
  536. {
  537. pPFFPrev = pPFFCur;
  538. pPFFCur = pPFFCur->pNext;
  539. }
  540. }
  541. if (bRet)
  542. {
  543. GreAcquireSemaphoreEx(ghsemPublicPFT, SEMORDER_PUBLICPFT, NULL);
  544. PUBLIC_PFTOBJ pfto;
  545. // bUnloadWorkhorse should release gpsemPublicePFT
  546. if (!(bRet = pfto.bUnloadWorkhorse(pPFFCur->pPFF, 0, ghsemPublicPFT, FR_NOT_ENUM)))
  547. {
  548. WARNING("Unable to delete the font.\n");
  549. }
  550. else
  551. {
  552. if (pPFFCur == pdc->pPFFList)
  553. {
  554. pdc->pPFFList = pPFFCur->pNext;
  555. }
  556. else
  557. {
  558. pPFFPrev->pNext = pPFFCur->pNext;
  559. }
  560. VFREEMEM(pPFFCur);
  561. }
  562. }
  563. return bRet;
  564. }
  565. /******************************Member*Function*****************************\
  566. * DCMEMOBJ::DCMEMOBJ()
  567. *
  568. * Allocates RAM for a new DC. Fills the RAM with default values.
  569. *
  570. * History:
  571. *
  572. * Fri 07-Dec-1990 -by- Patrick Haluptzok [patrickh]
  573. * Adding palette support
  574. *
  575. * Thu 09-Aug-1990 17:29:25 -by- Charles Whitmer [chuckwh]
  576. * Changed a little for NT DDI.
  577. *
  578. * Fri 01-Sep-1989 04:36:19 -by- Charles Whitmer [chuckwh]
  579. * Wrote it.
  580. \**************************************************************************/
  581. DCMEMOBJ::DCMEMOBJ(
  582. ULONG iType,
  583. BOOL bAltType)
  584. {
  585. pdc = (PDC) NULL;
  586. bKeep = FALSE;
  587. //
  588. // Check the type.
  589. //
  590. ASSERTGDI((iType == DCTYPE_INFO) ||
  591. (iType == DCTYPE_MEMORY) ||
  592. (iType == DCTYPE_DIRECT), "Invalid DC type");
  593. //
  594. // Allocate the DC 0 initialized
  595. //
  596. PDC pdcTemp = pdc = (PDC)HmgAlloc(sizeof(DC), DC_TYPE, HMGR_ALLOC_LOCK);
  597. if (pdcTemp != (PDC)NULL)
  598. {
  599. //
  600. // if this is an alternate DC (may need special attention on the client side
  601. // due to printing or metafiling) set the type to LO_ALTDC_TYPE from LO_TYPE
  602. //
  603. if (bAltType)
  604. {
  605. HmgModifyHandleType((HOBJ)MODIFY_HMGR_TYPE(pdcTemp->hGet(),LO_ALTDC_TYPE));
  606. }
  607. pdcTemp->dcattr = DcAttrDefault;
  608. pdcTemp->pDCAttr = &pdcTemp->dcattr;
  609. pdcTemp->dclevel = dclevelDefault;
  610. //
  611. // Lock the fill and line brushes we just selected in as part of the
  612. // default DC.
  613. // (Reference-count the brushes.)
  614. // These locks can't fail.
  615. //
  616. INC_SHARE_REF_CNT(pdc->dclevel.pbrFill);
  617. INC_SHARE_REF_CNT(pdc->dclevel.pbrLine);
  618. INC_SHARE_REF_CNT(pdc->dclevel.pColorSpace);
  619. pdcTemp->dctp((DCTYPE) iType);
  620. pdcTemp->fs(0);
  621. ASSERTGDI(pdcTemp->hpal() == STOCKOBJ_PAL, "Bad initial hpal for DCMEMOBJ");
  622. ASSERTGDI(pdcTemp->hdcNext() == (HDC) 0, "ERROR this is baddfd343dc");
  623. ASSERTGDI(pdcTemp->hdcPrev() == (HDC) 0, "ERROR this is e43-99crok4");
  624. pdcTemp->ptlFillOrigin(0,0);
  625. ulDirty(DIRTY_BRUSHES|DIRTY_CHARSET|DIRTY_COLORSPACE|DIRTY_COLORTRANSFORM);
  626. //
  627. // Update the pointer to the COLORADJUSTMENT structure for
  628. // the 4 EBRUSHOBJ.
  629. //
  630. COLORADJUSTMENT *pca = pColorAdjustment();
  631. pdcTemp->peboFill()->pColorAdjustment(pca);
  632. pdcTemp->peboLine()->pColorAdjustment(pca);
  633. pdcTemp->peboText()->pColorAdjustment(pca);
  634. pdcTemp->peboBackground()->pColorAdjustment(pca);
  635. pdcTemp->prfnt(PRFNTNULL);
  636. pdcTemp->hlfntCur(HLFONT_INVALID);
  637. pdcTemp->flSimulationFlags(0);
  638. ulCopyCount((ULONG)-1);
  639. ipfdDevMax(-1); // also reset in bCleanDC
  640. pdcTemp->prgnVis(NULL);
  641. pdcTemp->vPFFListSet(NULL);
  642. pdcTemp->vCXFListSet(NULL);
  643. }
  644. }
  645. /******************************Member*Function*****************************\
  646. * DCMEMOBJ::DCMEMOBJ(&dcobjs)
  647. *
  648. * Create a new DC and copy in the DC passed to us. This is used by
  649. * SaveDC.
  650. *
  651. * History:
  652. * 06-Jan-1990 -by- Donald Sidoroff [donalds]
  653. * Wrote it.
  654. \**************************************************************************/
  655. DCMEMOBJ::DCMEMOBJ(DCOBJ& dco)
  656. {
  657. //
  658. // Assume failure.
  659. //
  660. bKeep = FALSE;
  661. //
  662. // Allocate the DC,
  663. //
  664. pdc = (PDC)HmgAlloc(sizeof(DC), DC_TYPE, HMGR_ALLOC_LOCK);
  665. if (pdc != (PDC)NULL)
  666. {
  667. pdc->fs(0);
  668. pdc->prgnVis(NULL);
  669. pdc->ppdev(dco.pdc->ppdev());
  670. //
  671. // shared attrs point to self
  672. //
  673. pdc->pDCAttr = &pdc->dcattr;
  674. dco.pdc->vCopyTo(*this);
  675. }
  676. }
  677. /******************************Member*Function*****************************\
  678. * DCSAVE::vCopyTo
  679. *
  680. * Carbon copy the DCOBJ
  681. *
  682. * History:
  683. * 24-Apr-1991 -by- Donald Sidoroff [donalds]
  684. * Moved it out-of-line.
  685. \**************************************************************************/
  686. VOID DC::vCopyTo(XDCOBJ& dco)
  687. {
  688. //
  689. // The dynamic mode changing code needs to be able to dynamically update
  690. // some fields in the DCLEVEL, and consequently needs to be able to track
  691. // all DCLEVELs. So this routine should be used carefully and under
  692. // the appropriate lock to ensure that the dynamic mode change code does
  693. // not fall over. We do both because one or the other might not have
  694. // set DC_SYNCHRONIZE.
  695. //
  696. vAssertDynaLock(TRUE);
  697. dco.pdc->vAssertDynaLock(TRUE);
  698. //
  699. // copy dc level and dcattr
  700. //
  701. *dco.pdc->pDCAttr = *pDCAttr;
  702. dco.pdc->dclevel = dclevel;
  703. if (dclevel.pufi == dclevel.aQuickLinks)
  704. {
  705. dco.pdc->dclevel.pufi = dco.pdc->dclevel.aQuickLinks;
  706. }
  707. else if (dclevel.pufi)
  708. {
  709. if(dco.pdc->dclevel.pufi = (PUNIVERSAL_FONT_ID)
  710. PALLOCMEM(sizeof(UNIVERSAL_FONT_ID) * dclevel.uNumLinkedFonts,'ddaG'))
  711. {
  712. memcpy(dco.pdc->dclevel.pufi, dclevel.pufi, sizeof(UNIVERSAL_FONT_ID) * dclevel.uNumLinkedFonts);
  713. }
  714. else
  715. {
  716. WARNING("GDI: DC::vCopyTo out of memory\n");
  717. dco.pdc->dclevel.uNumLinkedFonts = 0;
  718. }
  719. }
  720. }
  721. /******************************Member*Function*****************************\
  722. * DCMEMOBJ::~DCMEMOBJ()
  723. *
  724. * Frees a DC unless told to keep it.
  725. *
  726. * History:
  727. * Sat 19-Aug-1989 00:30:53 -by- Charles Whitmer [chuckwh]
  728. * Wrote it.
  729. \**************************************************************************/
  730. DCMEMOBJ::~DCMEMOBJ()
  731. {
  732. if (pdc != (PDC) NULL)
  733. {
  734. if (bKeep)
  735. {
  736. DEC_EXCLUSIVE_REF_CNT(pdc);
  737. }
  738. else
  739. {
  740. if (pdc->pDCAttr != &pdc->dcattr)
  741. {
  742. RIP("ERROR,~DCMEMOBJ on DC with client attrs\n");
  743. }
  744. //
  745. // shouldn't free DC with client attrs
  746. //
  747. HmgFree((HOBJ)pdc->hGet());
  748. }
  749. pdc = (PDC) NULL;
  750. }
  751. }
  752. /******************************Member*Function*****************************\
  753. * DC::vUpdate_VisRect
  754. *
  755. * update user-mode vis region bounding rectangle if dirty
  756. *
  757. * History:
  758. * 2/18/99 LingyunW [Lingyun Wang]
  759. * Wrote it.
  760. \**************************************************************************/
  761. VOID DC::vUpdate_VisRect(REGION *prgn)
  762. {
  763. //
  764. // update user-mode vis region bounding rectangle if dirty
  765. //
  766. if ((PENTRY_FROM_POBJ(this)->Flags & HMGR_ENTRY_INVALID_VIS))
  767. {
  768. if (prgn)
  769. {
  770. //
  771. // setup user-mode region info
  772. //
  773. RGNOBJ roVis(prgn);
  774. pDCAttr->VisRectRegion.Flags = roVis.iComplexity();
  775. if (roVis.iComplexity() == NULLREGION)
  776. {
  777. //
  778. // set pdcatrr vis rgn to NULLRGN
  779. //
  780. pDCAttr->VisRectRegion.Rect = rclEmpty;
  781. }
  782. else
  783. {
  784. PPOINTL pptlWindow = (PPOINTL)prclWindow();
  785. RECTL rcl;
  786. roVis.vGet_rcl(&rcl);
  787. //
  788. // subtract window offset from user-mode region
  789. //
  790. rcl.left -= pptlWindow->x;
  791. rcl.top -= pptlWindow->y;
  792. rcl.right -= pptlWindow->x;
  793. rcl.bottom -= pptlWindow->y;
  794. pDCAttr->VisRectRegion.Rect = rcl;
  795. }
  796. //
  797. // mark DCATTR VIS region as valid
  798. //
  799. }
  800. else
  801. {
  802. pDCAttr->VisRectRegion.Rect = rclEmpty;
  803. }
  804. PENTRY_FROM_POBJ(this)->Flags &= ~HMGR_ENTRY_INVALID_VIS;
  805. }
  806. }
  807. /******************************Public*Routine******************************\
  808. * DCREGION::bSetDefaultRegion(x, y)
  809. *
  810. * Set the default region and erclWindow for bitmaps and surfaces
  811. *
  812. * History:
  813. * 11-Dec-1990 -by- Patrick Haluptzok patrickh
  814. * Wrote it.
  815. \**************************************************************************/
  816. BOOL DC::bSetDefaultRegion()
  817. {
  818. // Release the old RaoRgn
  819. vReleaseRao();
  820. // Get the extents
  821. SIZEL sizl;
  822. vGet_sizlWindow(&sizl);
  823. // Get a rectangle matching the device extents
  824. ERECTL ercl(0, 0, sizl.cx, sizl.cy);
  825. //
  826. // Bug #310012: Under multimon, the rectangle isn't necessarily
  827. // based at 0,0. See dcrgn.cxx.
  828. //
  829. ERECTL erclSurface = ercl;
  830. PDEVOBJ pdo(hdev());
  831. ASSERTGDI(pdo.bValid(), "Invalid pdev\n");
  832. {
  833. DEVLOCKOBJ dl(pdo);
  834. if (pdo.bMetaDriver() && bHasSurface() && pSurface()->bPDEVSurface())
  835. {
  836. erclSurface += *pdo.pptlOrigin();
  837. }
  838. }
  839. // If a VisRgn exists, initialize it, else create a new one
  840. if ((prgnVis() != (REGION *) NULL) &&
  841. (prgnVis() != prgnDefault))
  842. {
  843. RGNOBJ ro(prgnVis());
  844. ro.vSet((RECTL *) &erclSurface);
  845. }
  846. else
  847. {
  848. RGNMEMOBJ rmoRect;
  849. if (!rmoRect.bValid())
  850. {
  851. prgnVis(prgnDefault);
  852. return(FALSE);
  853. }
  854. // Set the region to the rectangle
  855. rmoRect.vSet((RECTL *) &erclSurface);
  856. // Make it long lived
  857. prgnVis(rmoRect.prgnGet());
  858. }
  859. prgnVis()->vStamp();
  860. eptlOrigin((EPOINTL*) &ercl);
  861. //
  862. // Note that we don't use erclSurface to set erclWindow.
  863. // erclWindow's value is a complete hack, and User won't fix it.
  864. // Their code requires that the top left point of erclWindow is equal
  865. // to the DC origin. On top of that, they overload the DC origin: e.g. in a
  866. // monitor-specific DC for an 800x600 monitor
  867. // based at (1024,0), erclWindow is (-1024, 0, -224, 600). Go figure.
  868. //
  869. erclWindow(&ercl);
  870. erclClip(&erclSurface);
  871. // Whenever DC origin changes, it affects ptlFillOrigin. Since the origin
  872. // was set to zero, we can just copy the brush origin in as the fill origin.
  873. // set by user using a DC not owned by the current process
  874. ptlFillOrigin(&dcattr.ptlBrushOrigin);
  875. return(TRUE);
  876. }
  877. /******************************Public*Routine******************************\
  878. * BOOL DCPATH::bOldPenNominal(exo, lPenWidth)
  879. *
  880. * Decides if the old-style (created with CreatePen) pen is a nominal
  881. * width pen or a wide line, depending on the current transform.
  882. *
  883. * History:
  884. * 27-Jan-1992 -by- J. Andrew Goossen [andrewgo]
  885. * Wrote it.
  886. \**************************************************************************/
  887. #define FX_THREE_HALVES (LTOFX(1) + (LTOFX(1) >> 1))
  888. #define FX_THREE_HALVES_SQUARED (FX_THREE_HALVES * FX_THREE_HALVES)
  889. BOOL DC::bOldPenNominal(
  890. EXFORMOBJ& exo, // Current world-to-device transform
  891. LONG lPenWidth) // Pen's width
  892. {
  893. BOOL bRet = FALSE;
  894. if (!(pDCAttr->flXform & WORLD_TRANSFORM_SET))
  895. {
  896. // If no world transform set, use the same criteria as does Win3 (namely,
  897. // the pen is nominal if the transformed x-value is less than 1.5)
  898. EVECTORL evtl(lPenWidth, 0);
  899. if (exo.bXform(&evtl, (PVECTORFX) &evtl, 1))
  900. if (ABS(evtl.x) < FX_THREE_HALVES)
  901. bRet = TRUE;
  902. }
  903. else
  904. {
  905. // A world transform has been set.
  906. VECTORL avtl[2];
  907. avtl[0].x = lPenWidth;
  908. avtl[0].y = 0;
  909. avtl[1].x = 0;
  910. avtl[1].y = lPenWidth;
  911. // We want to be consistent under rotation when using the
  912. // intellectually challenged CreatePen pens, so we go to the trouble
  913. // of ensuring that the transformed axes of the pen lie within
  914. // a circle of radius 1.5:
  915. if (exo.bXform(avtl, (PVECTORFX) avtl, 2))
  916. {
  917. // We can kick out most pens with this simple test:
  918. if ((MAX(ABS(avtl[0].x), ABS(avtl[0].y)) < FX_THREE_HALVES) &&
  919. (MAX(ABS(avtl[1].x), ABS(avtl[1].y)) < FX_THREE_HALVES))
  920. // We now know it's safe to compute the square of the
  921. // Euclidean lengths in 32-bits without overflow:
  922. if (((avtl[0].x * avtl[0].x + avtl[0].y * avtl[0].y)
  923. < FX_THREE_HALVES_SQUARED) &&
  924. ((avtl[1].x * avtl[1].x + avtl[1].y * avtl[1].y)
  925. < FX_THREE_HALVES_SQUARED))
  926. bRet = TRUE;
  927. }
  928. }
  929. return(bRet);
  930. }
  931. /******************************Public*Routine******************************\
  932. * VOID DC::vRealizeLineAttrs(exo)
  933. *
  934. * Initializes the given LINEATTRS structure. Uses fields from the DC
  935. * and the current brush.
  936. *
  937. * This function will be called as a result of a change in current pen,
  938. * or a change in current transform. As a result, we reset the style
  939. * state.
  940. *
  941. * History:
  942. * 23-Sep-1992 -by- Donald Sidoroff [donalds]
  943. * Added failure case
  944. *
  945. * 27-Jan-1992 -by- J. Andrew Goossen [andrewgo]
  946. * Wrote it.
  947. \**************************************************************************/
  948. VOID DC::vRealizeLineAttrs(EXFORMOBJ& exo)
  949. {
  950. PPEN ppen = (PPEN) dclevel.pbrLine;
  951. LINEATTRS *pla = &dclevel.laPath;
  952. // Remember that we've realized the LINEATTRS for this pen:
  953. if (ppen->bIsOldStylePen())
  954. {
  955. // A pen of width zero is always nominal, regardless of the transform:
  956. if ((exo.bIdentity() && ppen->lWidthPen() <= 1) ||
  957. (ppen->lWidthPen() == 0) ||
  958. bOldPenNominal(exo, ppen->lWidthPen()))
  959. {
  960. pla->elWidth.l = 1; // Nominal width line
  961. if (ppen->pstyle() != (PFLOAT_LONG) NULL)
  962. {
  963. pla->cstyle = ppen->cstyle(); // Size of style array
  964. pla->pstyle = ppen->pstyle();
  965. pla->fl = LA_STYLED; // Cosmetic, styled
  966. }
  967. else
  968. {
  969. pla->cstyle = 0;
  970. pla->pstyle = (PFLOAT_LONG) NULL;
  971. pla->fl = 0; // Cosmetic, no style
  972. }
  973. pla->elStyleState.l = 0; // Reset style state
  974. }
  975. else
  976. {
  977. pla->fl = LA_GEOMETRIC; // Geometric
  978. pla->elWidth.e = ppen->l_eWidthPen(); // Need float value of width
  979. pla->cstyle = 0;
  980. pla->pstyle = (PFLOAT_LONG) NULL; // Old wide pens are un-styled
  981. pla->elStyleState.e = IEEE_0_0F;
  982. }
  983. }
  984. else
  985. {
  986. // New-style ExtCreatePen pen:
  987. if (ppen->bIsCosmetic())
  988. {
  989. pla->fl = ppen->bIsAlternate() ? LA_ALTERNATE : 0;
  990. pla->elWidth.l = ppen->lWidthPen();
  991. pla->elStyleState.l = 0;
  992. }
  993. else
  994. {
  995. pla->fl = LA_GEOMETRIC;
  996. pla->elWidth.e = ppen->l_eWidthPen();
  997. pla->elStyleState.e = IEEE_0_0F;
  998. }
  999. pla->cstyle = ppen->cstyle();
  1000. pla->pstyle = ppen->pstyle();
  1001. if (pla->pstyle != NULL)
  1002. {
  1003. pla->fl |= LA_STYLED;
  1004. }
  1005. }
  1006. pla->iJoin = ppen->iJoin();
  1007. pla->iEndCap = ppen->iEndCap();
  1008. }
  1009. /******************************Public*Routine******************************\
  1010. * VOID DCOBJ::vAccumulate(ercl)
  1011. *
  1012. * Accumulate bounds
  1013. *
  1014. * History:
  1015. * 08-Dec-1992 -by- Donald Sidoroff [donalds]
  1016. * Wrote it.
  1017. \**************************************************************************/
  1018. VOID XDCOBJ::vAccumulate(ERECTL& ercl)
  1019. {
  1020. if (bAccum())
  1021. {
  1022. erclBounds() |= ercl;
  1023. }
  1024. if (bAccumApp())
  1025. {
  1026. erclBoundsApp() |= ercl;
  1027. }
  1028. }
  1029. /******************************Member*Function*****************************\
  1030. * DC::bMakeInfoDC
  1031. *
  1032. * This routine is used to take a printer DC and temporarily make it a
  1033. * Metafile DC for spooled printing. This way it can be associated with
  1034. * an enhanced metafile. During this period, it should look and act just
  1035. * like an info DC.
  1036. *
  1037. * bSet determines if it should be set into the INFO DC state or restored
  1038. * to the Direct state.
  1039. *
  1040. * History:
  1041. * 06-Jan-1995 -by- Eric Kutter [erick]
  1042. * Wrote it.
  1043. \**************************************************************************/
  1044. BOOL DC::bMakeInfoDC(
  1045. BOOL bSet)
  1046. {
  1047. BOOL bRet = FALSE;
  1048. if (!bDisplay())
  1049. {
  1050. if (bSet)
  1051. {
  1052. if (!bTempInfoDC() && (dctp() == DCTYPE_DIRECT))
  1053. {
  1054. vSetTempInfoDC();
  1055. dctp(DCTYPE_INFO);
  1056. vSavePsurfInfo();
  1057. // now that this is an info dc, we want it to be the size of
  1058. // the entire surface
  1059. PDEVOBJ pdo(hdev());
  1060. if ((pdo.sizl().cx != sizl().cx) ||
  1061. (pdo.sizl().cy != sizl().cy))
  1062. {
  1063. sizl(pdo.sizl());
  1064. bSetDefaultRegion();
  1065. }
  1066. bRet = TRUE;
  1067. }
  1068. else
  1069. {
  1070. WARNING("GreMakeInfoDC(TRUE) - already infoDC\n");
  1071. }
  1072. }
  1073. else
  1074. {
  1075. if (bTempInfoDC() && (dctp() == DCTYPE_INFO))
  1076. {
  1077. vClearTempInfoDC();
  1078. dctp(DCTYPE_DIRECT);
  1079. vRestorePsurfInfo();
  1080. // back to an direct DC. It needs to be reset to the size of
  1081. // the surface. (band)
  1082. if (bHasSurface())
  1083. {
  1084. if ((pSurface()->sizl().cx != sizl().cx) ||
  1085. (pSurface()->sizl().cy != sizl().cy))
  1086. {
  1087. sizl(pSurface()->sizl());
  1088. bSetDefaultRegion();
  1089. }
  1090. }
  1091. bRet = TRUE;
  1092. }
  1093. else
  1094. {
  1095. WARNING("GreMakeInfoDC(FALSE) - not infoDC\n");
  1096. }
  1097. }
  1098. }
  1099. else
  1100. {
  1101. WARNING("GreMakeInfoDC - on display dc\n");
  1102. }
  1103. return(bRet);
  1104. }
  1105. /******************************Member*Function*****************************\
  1106. * DC::vAssertDynaLock()
  1107. *
  1108. * This routine verifies that appropriate locks are held before accessing
  1109. * DC fields that may otherwise be changed asynchronously by the dynamic
  1110. * mode-change code.
  1111. *
  1112. * History:
  1113. * 06-Feb-1996 -by- J. Andrew Goossen [andrewgo]
  1114. * Wrote it.
  1115. \**************************************************************************/
  1116. #if DBG
  1117. VOID DC::vAssertDynaLock(BOOL bDcLevelField)
  1118. {
  1119. //
  1120. // One of the following conditions is enough to allow the thread
  1121. // to safely access fields that may be modified by the dyanmic
  1122. // mode changing:
  1123. //
  1124. // 1. It's an info DC, or a DC with the default bitmap selected in --
  1125. // these will not change modes;
  1126. // 2. It's a DCLEVEL specific field and a DIB is selected in that
  1127. // doesn't require DevLock locking;
  1128. // 3. Direct DC's that aren't the display, such as printers --
  1129. // these will not dynamically change modes;
  1130. // 4. That the DEVLOCK is held;
  1131. // 5. That the Palette semaphore is held;
  1132. // 6. That the Handle Manager semaphore is held;
  1133. // 7. That the USER semaphore is held.
  1134. //
  1135. #if !defined(_GDIPLUS_)
  1136. ASSERTGDI(!bHasSurface() ||
  1137. ((bDcLevelField) && !(fs() & DC_SYNCHRONIZEACCESS)) ||
  1138. ((dctp() == DCTYPE_DIRECT) && !bDisplay()) ||
  1139. (GreIsSemaphoreOwnedByCurrentThread(hsemDcDevLock_)) ||
  1140. (GreIsSemaphoreSharedByCurrentThread(ghsemShareDevLock)) ||
  1141. (GreIsSemaphoreOwnedByCurrentThread(ghsemPalette)) ||
  1142. (GreIsSemaphoreOwnedByCurrentThread(ghsemHmgr)) ||
  1143. UserIsUserCritSecIn(),
  1144. "A dynamic mode change lock must be held to access this field");
  1145. #endif
  1146. }
  1147. #endif