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.

1510 lines
25 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. gstate.cpp
  5. Abstract:
  6. PCL XL Graphics state manager
  7. Environment:
  8. Windows Whistler
  9. Revision History:
  10. 08/23/99
  11. Created it.
  12. --*/
  13. #include "xlpdev.h"
  14. #include "xldebug.h"
  15. #include "pclxle.h"
  16. #include "xlgstate.h"
  17. //
  18. // XLLine
  19. //
  20. //
  21. // Default setting of LineAttrs
  22. //
  23. const LINEATTRS gLineAttrs =
  24. {
  25. LA_GEOMETRIC, // fl
  26. JOIN_ROUND, // iJoin
  27. ENDCAP_ROUND, // iEndCap
  28. {FLOATL_IEEE_0_0F}, // elWidth
  29. FLOATL_IEEE_0_0F, // eMiterLimit
  30. 0, // cstyle
  31. (FLOAT_LONG*) NULL, // pstyle
  32. {FLOATL_IEEE_0_0F} // elStyleState
  33. };
  34. const LINEATTRS *pgLineAttrs = &gLineAttrs;
  35. XLLine::
  36. XLLine(
  37. VOID):
  38. /*++
  39. Routine Description:
  40. XLLine constructor
  41. Arguments:
  42. Return Value:
  43. Note:
  44. --*/
  45. m_dwGenFlags(0),
  46. m_LineAttrs(gLineAttrs)
  47. {
  48. #if DBG
  49. SetDbgLevel(GSTATEDBG);
  50. #endif
  51. XL_VERBOSE(("XLLine::CTor\n"));
  52. }
  53. XLLine::
  54. ~XLLine(
  55. VOID)
  56. /*++
  57. Routine Description:
  58. XLLine destructor
  59. Arguments:
  60. Return Value:
  61. Note:
  62. --*/
  63. {
  64. XL_VERBOSE(("XLLine::DTor\n"));
  65. if ( NULL != m_LineAttrs.pstyle)
  66. {
  67. //
  68. // Free memory
  69. //
  70. MemFree(m_LineAttrs.pstyle);
  71. }
  72. }
  73. #if DBG
  74. VOID
  75. XLLine::
  76. SetDbgLevel(
  77. DWORD dwLevel)
  78. /*++
  79. Routine Description:
  80. Arguments:
  81. Return Value:
  82. Note:
  83. --*/
  84. {
  85. m_dbglevel = dwLevel;
  86. }
  87. #endif
  88. VOID
  89. XLLine::
  90. ResetLine(
  91. VOID)
  92. /*++
  93. Routine Description:
  94. Arguments:
  95. Return Value:
  96. Note:
  97. --*/
  98. {
  99. m_LineAttrs = gLineAttrs;
  100. }
  101. DWORD
  102. XLLine::
  103. GetDifferentAttribute(
  104. IN LINEATTRS *plineattrs)
  105. /*++
  106. Routine Description:
  107. Arguments:
  108. Return Value:
  109. Note:
  110. --*/
  111. {
  112. DWORD dwRet;
  113. XL_VERBOSE(("XLLine::GetDifferentAttribute\n"));
  114. dwRet = XLLINE_NONE;
  115. if (NULL == plineattrs)
  116. {
  117. XL_ERR(("XLLine::GetDifferentAttribute: plineattrs == NULL.\n"));
  118. return dwRet;
  119. }
  120. if ( m_LineAttrs.fl != plineattrs->fl )
  121. dwRet |= XLLINE_LINETYPE;
  122. if ( m_LineAttrs.iJoin != plineattrs->iJoin )
  123. dwRet |= XLLINE_JOIN;
  124. if ( m_LineAttrs.iEndCap != plineattrs->iEndCap )
  125. dwRet |= XLLINE_ENDCAP;
  126. if ( m_LineAttrs.elWidth.l != plineattrs->elWidth.l)
  127. dwRet |= XLLINE_WIDTH;
  128. if ( m_LineAttrs.eMiterLimit != plineattrs->eMiterLimit )
  129. dwRet |= XLLINE_MITERLIMIT;
  130. if ( m_LineAttrs.cstyle != plineattrs->cstyle ||
  131. plineattrs->cstyle != 0 &&
  132. memcmp(m_LineAttrs.pstyle,
  133. plineattrs->pstyle,
  134. sizeof(FLOAT_LONG) * m_LineAttrs.cstyle) ||
  135. m_LineAttrs.elStyleState.l != plineattrs->elStyleState.l )
  136. dwRet |= XLLINE_STYLE;
  137. XL_VERBOSE(("XLLine::GetDifferentAttribute returns %08x.\n", dwRet));
  138. return dwRet;
  139. }
  140. HRESULT
  141. XLLine::
  142. SetLineType(
  143. IN XLLineType LineType )
  144. /*++
  145. Routine Description:
  146. Arguments:
  147. Return Value:
  148. None
  149. --*/
  150. {
  151. XL_VERBOSE(("XLLine::SetLineType\n"));
  152. m_LineAttrs.fl = (FLONG)LineType;
  153. return S_OK;
  154. }
  155. HRESULT
  156. XLLine::
  157. SetLineJoin(
  158. IN XLLineJoin LineJoin )
  159. /*++
  160. Routine Description:
  161. Arguments:
  162. Return Value:
  163. None
  164. --*/
  165. {
  166. XL_VERBOSE(("XLLine::SetLineJoin\n"));
  167. m_LineAttrs.iJoin = (ULONG)LineJoin;
  168. return S_OK;
  169. }
  170. HRESULT
  171. XLLine::
  172. SetLineEndCap(
  173. IN XLLineEndCap LineEndCap )
  174. /*++
  175. Routine Description:
  176. Arguments:
  177. Return Value:
  178. None
  179. --*/
  180. {
  181. XL_VERBOSE(("XLLine::SetLineEndCap\n"));
  182. m_LineAttrs.iEndCap = (ULONG)LineEndCap;
  183. return S_OK;
  184. }
  185. HRESULT
  186. XLLine::
  187. SetLineWidth(
  188. IN FLOAT_LONG elWidth )
  189. /*++
  190. Routine Description:
  191. Arguments:
  192. Return Value:
  193. Note:
  194. --*/
  195. {
  196. XL_VERBOSE(("XLLine::SetLineWidth\n"));
  197. m_LineAttrs.elWidth = elWidth;
  198. return S_OK;
  199. }
  200. HRESULT
  201. XLLine::
  202. SetMiterLimit(
  203. IN FLOATL eMiterLimit )
  204. /*++
  205. Routine Description:
  206. Arguments:
  207. Return Value:
  208. None
  209. --*/
  210. {
  211. XL_VERBOSE(("XLLine::SetMiterLimit\n"));
  212. m_LineAttrs.eMiterLimit = eMiterLimit;
  213. return S_OK;
  214. }
  215. HRESULT
  216. XLLine::
  217. SetLineStyle(
  218. IN ULONG ulCStyle,
  219. IN PFLOAT_LONG pStyle,
  220. IN FLOAT_LONG elStyleState )
  221. /*++
  222. Routine Description:
  223. Arguments:
  224. Return Value:
  225. None
  226. --*/
  227. {
  228. XL_VERBOSE(("XLLine::SetLineStyle\n"));
  229. m_LineAttrs.elStyleState = elStyleState;
  230. //
  231. // Error check
  232. // Make sure the pointer is valid.
  233. // Make sure the the ulCStyle is valid, not ZERO.
  234. //
  235. if ( NULL == pStyle || 0 == ulCStyle )
  236. {
  237. XL_VERBOSE(("XLLine::SetLineStyle: pStyle == NULL.\n"));
  238. if (NULL != m_LineAttrs.pstyle)
  239. {
  240. MemFree(m_LineAttrs.pstyle);
  241. }
  242. m_LineAttrs.pstyle = NULL;
  243. m_LineAttrs.cstyle = 0;
  244. return S_OK;
  245. }
  246. if ( m_LineAttrs.cstyle > 0 && NULL != m_LineAttrs.pstyle)
  247. {
  248. //
  249. // Free memory and reset.
  250. //
  251. MemFree(m_LineAttrs.pstyle);
  252. m_LineAttrs.pstyle = NULL;
  253. m_LineAttrs.cstyle = 0;
  254. }
  255. m_LineAttrs.pstyle = (PFLOAT_LONG) MemAlloc(ulCStyle * sizeof(FLOAT_LONG));
  256. if ( NULL == m_LineAttrs.pstyle )
  257. {
  258. m_LineAttrs.cstyle = 0;
  259. XL_ERR(("XLLine::SetLineStyle: Out of memory.\n"));
  260. return E_OUTOFMEMORY;
  261. }
  262. m_LineAttrs.cstyle = ulCStyle;
  263. memcpy( m_LineAttrs.pstyle, pStyle, ulCStyle * sizeof(FLOAT_LONG));
  264. return S_OK;
  265. }
  266. //
  267. // Common Brush
  268. //
  269. Brush::
  270. Brush(
  271. VOID)
  272. /*++
  273. Routine Description:
  274. Arguments:
  275. Return Value:
  276. Note:
  277. --*/
  278. {
  279. #if DBG
  280. SetDbgLevel(GSTATEDBG);
  281. #endif
  282. m_Brush.dwSig = BRUSH_SIGNATURE;
  283. m_Brush.BrushType = kNotInitialized;
  284. XL_VERBOSE(("Brush:: Ctor\n"));
  285. }
  286. Brush::
  287. ~Brush(
  288. IN VOID)
  289. /*++
  290. Routine Description:
  291. Arguments:
  292. Return Value:
  293. Note:
  294. --*/
  295. {
  296. XL_VERBOSE(("Brush:: Dtor\n"));
  297. }
  298. #if DBG
  299. VOID
  300. Brush::
  301. SetDbgLevel(
  302. DWORD dwLevel)
  303. /*++
  304. Routine Description:
  305. Arguments:
  306. Return Value:
  307. Note:
  308. --*/
  309. {
  310. m_dbglevel = dwLevel;
  311. }
  312. #endif
  313. VOID
  314. Brush::
  315. ResetBrush(
  316. VOID)
  317. /*++
  318. Routine Description:
  319. Arguments:
  320. Return Value:
  321. Note:
  322. --*/
  323. {
  324. m_Brush.BrushType = kNotInitialized;
  325. }
  326. HRESULT
  327. Brush::
  328. CheckCurrentBrush(
  329. IN BRUSHOBJ *pbo)
  330. /*+++
  331. Routine Description
  332. This function checks if the current selected brush is same as
  333. the one specified in the parameter.
  334. Note
  335. pbo->iSolidColor == NOT_SOLID_COLOR
  336. {
  337. iHatch < HS_DDI_MAX
  338. CMNBRUSH (solid color, hatch pattern)
  339. --> kBrushTypeHatch
  340. iHatch >= HS_DDI_MAX
  341. CMNBRUSH pattern Brush
  342. --> kBrushTypePattern
  343. }
  344. pbo->iSolidColor != NOT_SOLID_COLOR
  345. {
  346. Solid color, solid pattern fill
  347. --> kBrushTypeSolid
  348. }
  349. List of members to check
  350. pbo->iSolidColor (Solid color ID or NOT_SOLID_COLOR)
  351. lHatch (HS_XXX or >= HS_MAX_ID)
  352. dwColor (BRUSHOBJ_ulGetBrushColor(pbo))
  353. psoPattern bitmap
  354. Return value
  355. S_FALSE if the specified brush is different from the current selected.
  356. S_OK if the specified brush is same as the curren one.
  357. ---*/
  358. {
  359. HRESULT lrRet;
  360. XL_VERBOSE(("Brush::CheckCurrentBrush\n"));
  361. //
  362. // Error check: parameter
  363. //
  364. if (NULL == pbo && m_Brush.BrushType != kNoBrush ||
  365. m_Brush.BrushType == kNotInitialized )
  366. {
  367. XL_VERBOSE(("Brush::CheckCurrentBrush: Set NULL Brush (pbo==NULL)\n"));
  368. return S_FALSE;
  369. }
  370. lrRet = S_OK;
  371. switch ( m_Brush.BrushType )
  372. {
  373. case kNoBrush:
  374. if (pbo != NULL)
  375. lrRet = S_FALSE;
  376. XL_VERBOSE(("Brush::CheckCurrentBrush: kNoBrush:%d\n", lrRet));
  377. break;
  378. case kBrushTypeSolid:
  379. //
  380. // 1. Check the brush type.
  381. // 2. Check solid color.
  382. //
  383. if ( pbo->iSolidColor != m_Brush.ulSolidColor ||
  384. BRUSHOBJ_ulGetBrushColor(pbo) != m_Brush.dwColor )
  385. lrRet = S_FALSE;
  386. XL_VERBOSE(("Brush::CheckCurrentBrush: kBrushTyepSolid:%d\n", lrRet));
  387. break;
  388. case kBrushTypeHatch:
  389. //
  390. // 1. Check the brush type.
  391. // 2. Check hatch type.
  392. // 3. Check color.
  393. //
  394. if (pbo->iSolidColor == NOT_SOLID_COLOR)
  395. {
  396. XLBRUSH *pBrush = (XLBRUSH*)BRUSHOBJ_pvGetRbrush(pbo);
  397. ULONG ulHatch = 0;
  398. if (NULL != pBrush)
  399. {
  400. if (pBrush->dwSig != XLBRUSH_SIG)
  401. {
  402. lrRet = E_UNEXPECTED;
  403. XL_ERR(("Brush::CheckCurrentBrush: BRUSHOBJ_pvGetRbrush returned invalid BRUSH.\n"));
  404. break;
  405. }
  406. ulHatch = pBrush->dwHatch;
  407. if ( NOT_SOLID_COLOR != m_Brush.ulSolidColor ||
  408. ulHatch != m_Brush.ulHatch ||
  409. pbo->iSolidColor != m_Brush.ulSolidColor ||
  410. pBrush->dwColor != m_Brush.dwColor )
  411. {
  412. lrRet = S_FALSE;
  413. }
  414. }
  415. else
  416. {
  417. //
  418. // GDI requests to set solid color or NULL brush.
  419. //
  420. XL_ERR(("Brush::CheckCurrentBrush: BRUSHOBJ_pvGetRbrush returned NULL.\n"));
  421. lrRet = S_FALSE;
  422. }
  423. XL_VERBOSE(("Brush::CheckCurrentBrush: kBrushTypeHatch:ID(%d),%d\n", ulHatch, lrRet));
  424. }
  425. else
  426. lrRet = S_FALSE;
  427. break;
  428. case kBrushTypePattern:
  429. //
  430. // 1. Check brush type.
  431. // 2. Check pattern brush.
  432. //
  433. if (pbo->iSolidColor == NOT_SOLID_COLOR)
  434. {
  435. XLBRUSH *pBrush = (XLBRUSH*)BRUSHOBJ_pvGetRbrush(pbo);
  436. if (NULL != pBrush)
  437. {
  438. if (pBrush->dwSig != XLBRUSH_SIG)
  439. {
  440. lrRet = E_UNEXPECTED;
  441. XL_ERR(("Brush::CheckCurrentBrush: BRUSHOBJ_pvGetRbrush returned invalid BRUSH.\n"));
  442. break;
  443. }
  444. if ( NOT_SOLID_COLOR == m_Brush.ulSolidColor ||
  445. m_Brush.dwPatternBrushID != pBrush->dwPatternID)
  446. {
  447. lrRet = S_FALSE;
  448. }
  449. }
  450. else
  451. {
  452. //
  453. // GDI requests to set solid color or NULL brush.
  454. //
  455. lrRet = S_FALSE;
  456. }
  457. }
  458. else
  459. {
  460. lrRet = S_FALSE;
  461. }
  462. XL_VERBOSE(("Brush::CheckCurrentBrush: kBrushTypePattern:%d\n", lrRet));
  463. break;
  464. }
  465. return lrRet;
  466. }
  467. HRESULT
  468. Brush::
  469. SetBrush(
  470. IN CMNBRUSH *pBrush)
  471. /*+++
  472. Routine Description
  473. This function sets if the current selected brush is same as
  474. the one specified in the parameter.
  475. ---*/
  476. {
  477. HRESULT lrRet;
  478. XL_VERBOSE(("Brush::SetBrush\n"));
  479. //
  480. // Error check: Parameter
  481. //
  482. if ( NULL == pBrush )
  483. {
  484. XL_ERR(("Brush::SetBrush: pBrush is NULL.\n"));
  485. return E_UNEXPECTED;
  486. }
  487. m_Brush.BrushType = pBrush->BrushType;
  488. m_Brush.ulSolidColor = pBrush->ulSolidColor;
  489. m_Brush.ulHatch = pBrush->ulHatch;
  490. m_Brush.dwCEntries = pBrush->dwCEntries;
  491. m_Brush.dwColor = pBrush->dwColor;
  492. m_Brush.dwPatternBrushID = pBrush->dwPatternBrushID;
  493. return S_OK;
  494. }
  495. //
  496. // XLClip
  497. //
  498. XLClip::
  499. XLClip(
  500. VOID):
  501. /*++
  502. Routine Description:
  503. Arguments:
  504. Return Value:
  505. Note:
  506. --*/
  507. m_ClipType(kNoClip)
  508. {
  509. #if DBG
  510. SetDbgLevel(GSTATEDBG);
  511. #endif
  512. m_XLClip.dwSig = CLIP_SIGNATURE;
  513. XL_VERBOSE(("XLClip:: Ctor\n"));
  514. }
  515. XLClip::
  516. ~XLClip(
  517. VOID)
  518. /*++
  519. Routine Description:
  520. Arguments:
  521. Return Value:
  522. Note:
  523. --*/
  524. {
  525. XL_VERBOSE(("XLClip:: Dtor\n"));
  526. }
  527. #if DBG
  528. VOID
  529. XLClip::
  530. SetDbgLevel(
  531. DWORD dwLevel)
  532. /*++
  533. Routine Description:
  534. Arguments:
  535. Return Value:
  536. Note:
  537. --*/
  538. {
  539. m_dbglevel = dwLevel;
  540. }
  541. #endif
  542. HRESULT
  543. XLClip::
  544. ClearClip(
  545. VOID)
  546. /*++
  547. Routine Description:
  548. Arguments:
  549. Return Value:
  550. Note:
  551. --*/
  552. {
  553. XL_VERBOSE(("XLClip::ClearClip\n"));
  554. m_ClipType = kNoClip;
  555. return S_OK;
  556. }
  557. HRESULT
  558. XLClip::
  559. CheckClip(
  560. IN CLIPOBJ *pco)
  561. /*++
  562. Routine Description:
  563. Arguments:
  564. Return Value:
  565. Note:
  566. --*/
  567. {
  568. HRESULT lrRet = S_OK;
  569. XL_VERBOSE(("XLClip::CheckClip\n"));
  570. //
  571. // Error check: Parameter
  572. //
  573. if (!pco)
  574. {
  575. //
  576. // It is not necessary to clip if pco is NULL.
  577. //
  578. XL_VERBOSE(("XLClip::CheckClip: pco == NULL.\n"));
  579. if (kNoClip != m_ClipType)
  580. lrRet = S_FALSE;
  581. }
  582. else
  583. {
  584. switch (pco->iDComplexity)
  585. {
  586. case DC_TRIVIAL:
  587. if ( m_ClipType != kNoClip )
  588. lrRet = S_FALSE;
  589. XL_VERBOSE(("XLClip::Type: DC_TRIVIAL:%d\n", lrRet));
  590. break;
  591. case DC_RECT:
  592. if ( m_ClipType != kClipTypeRectangle ||
  593. m_XLClip.rclClipRect.left != pco->rclBounds.left ||
  594. m_XLClip.rclClipRect.right != pco->rclBounds.right ||
  595. m_XLClip.rclClipRect.top != pco->rclBounds.top ||
  596. m_XLClip.rclClipRect.bottom != pco->rclBounds.bottom )
  597. lrRet = S_FALSE;
  598. XL_VERBOSE(("XLClip::Type: DC_RECT:%d\n", lrRet));
  599. break;
  600. case DC_COMPLEX:
  601. #if 0 // It seems like we can't rely on iUniq.
  602. // Always sends complex clip path.
  603. if ( m_ClipType != kClipTypeComplex ||
  604. m_XLClip.ulUniq == 0 ||
  605. pco->iUniq == 0 ||
  606. m_XLClip.ulUniq != pco->iUniq )
  607. lrRet = S_FALSE;
  608. #else
  609. lrRet = S_FALSE;
  610. #endif
  611. XL_VERBOSE(("XLClip::Type: DC_COMPLEX\n", lrRet));
  612. break;
  613. default:
  614. if ( m_ClipType != kNoClip )
  615. lrRet = S_FALSE;
  616. XL_VERBOSE(("XLClip::Type: DC_TRIVIAL:%d\n", lrRet));
  617. }
  618. }
  619. return lrRet;
  620. }
  621. HRESULT
  622. XLClip::
  623. SetClip(
  624. IN CLIPOBJ *pco)
  625. /*++
  626. Routine Description:
  627. Arguments:
  628. Return Value:
  629. Note:
  630. --*/
  631. {
  632. HRESULT lrRet;
  633. XL_VERBOSE(("XLClip::SetClip\n"));
  634. //
  635. // Error check: Parameter
  636. //
  637. if (!pco)
  638. {
  639. //
  640. // It is not necessary to clip if pco is NULL.
  641. //
  642. XL_VERBOSE(("XLClip::SetClip: pco == NULL.\n"));
  643. return E_UNEXPECTED;
  644. }
  645. switch (pco->iDComplexity)
  646. {
  647. case DC_TRIVIAL:
  648. XL_VERBOSE(("XLClip::SetClip Type: DC_TRIVIAL\n"));
  649. m_ClipType = kNoClip;
  650. lrRet = S_OK;
  651. break;
  652. case DC_RECT:
  653. XL_VERBOSE(("XLClip::SetClip Type: DC_RECT\n"));
  654. m_ClipType = kClipTypeRectangle;
  655. m_XLClip.rclClipRect.left = pco->rclBounds.left;
  656. m_XLClip.rclClipRect.right = pco->rclBounds.right;
  657. m_XLClip.rclClipRect.top = pco->rclBounds.top;
  658. m_XLClip.rclClipRect.bottom = pco->rclBounds.bottom;
  659. lrRet = S_OK;
  660. break;
  661. case DC_COMPLEX:
  662. XL_VERBOSE(("XLClip::SetClip Type: DC_COMPLEX\n"));
  663. m_ClipType = kClipTypeComplex;
  664. m_XLClip.ulUniq = pco->iUniq;
  665. lrRet = S_OK;
  666. break;
  667. default:
  668. XL_ERR(("XLClip::SetClip: Unexpected iDCompelxity\n"));
  669. m_ClipType = kNoClip;
  670. lrRet = E_UNEXPECTED;
  671. }
  672. return lrRet;
  673. }
  674. //
  675. // XLRop
  676. //
  677. XLRop::
  678. XLRop(
  679. VOID):
  680. /*++
  681. Routine Description:
  682. Arguments:
  683. Return Value:
  684. Note:
  685. --*/
  686. m_rop3(0xCC) // SRCCPY
  687. {
  688. #if DBG
  689. SetDbgLevel(GSTATEDBG);
  690. #endif
  691. XL_VERBOSE(("XLRop:: Ctor\n"));
  692. }
  693. XLRop::
  694. ~XLRop(
  695. VOID)
  696. /*++
  697. Routine Description:
  698. Arguments:
  699. Return Value:
  700. Note:
  701. --*/
  702. {
  703. XL_VERBOSE(("XLRop:: Dtor\n"));
  704. }
  705. #if DBG
  706. VOID
  707. XLRop::
  708. SetDbgLevel(
  709. DWORD dwLevel)
  710. /*++
  711. Routine Description:
  712. Arguments:
  713. Return Value:
  714. Note:
  715. --*/
  716. {
  717. m_dbglevel = dwLevel;
  718. }
  719. #endif
  720. HRESULT
  721. XLRop::
  722. CheckROP3(
  723. IN ROP3 rop3 )
  724. /*++
  725. Routine Description:
  726. Arguments:
  727. Return Value:
  728. Note:
  729. --*/
  730. {
  731. HRESULT lrRet;
  732. XL_VERBOSE(("XLRop::CheckROP3\n"));
  733. if (rop3 != m_rop3)
  734. lrRet = S_FALSE;
  735. else
  736. lrRet = S_OK;
  737. return lrRet;
  738. }
  739. HRESULT
  740. XLRop::
  741. SetROP3(
  742. IN ROP3 rop3 )
  743. /*++
  744. Routine Description:
  745. Arguments:
  746. Return Value:
  747. Note:
  748. --*/
  749. {
  750. XL_VERBOSE(("XLRop::SetROP3\n"));
  751. m_rop3 = rop3;
  752. return S_OK;
  753. }
  754. XLFont::
  755. XLFont(
  756. VOID)
  757. /*++
  758. Routine Description:
  759. Arguments:
  760. Return Value:
  761. Note:
  762. --*/
  763. {
  764. #if DBG
  765. SetDbgLevel(GSTATEDBG);
  766. #endif
  767. XL_VERBOSE(("XLFont::CTor\n"));
  768. ResetFont();
  769. }
  770. XLFont::
  771. ~XLFont(
  772. VOID)
  773. /*++
  774. Routine Description:
  775. Arguments:
  776. Return Value:
  777. Note:
  778. --*/
  779. {
  780. XL_VERBOSE(("XLFont::DTor\n"));
  781. }
  782. #if DBG
  783. VOID
  784. XLFont::
  785. SetDbgLevel(
  786. DWORD dwLevel)
  787. /*++
  788. Routine Description:
  789. Arguments:
  790. Return Value:
  791. Note:
  792. --*/
  793. {
  794. m_dbglevel = dwLevel;
  795. }
  796. #endif
  797. VOID
  798. XLFont::
  799. ResetFont(
  800. VOID)
  801. /*++
  802. Routine Description:
  803. Arguments:
  804. Return Value:
  805. Note:
  806. --*/
  807. {
  808. m_XLFontType = kFontNone;
  809. m_aubFontName[0] = (BYTE) NULL;
  810. m_dwFontHeight = 0;
  811. m_dwFontWidth = 0;
  812. m_dwFontSymbolSet = 0;
  813. m_dwFontSimulation = 0;
  814. }
  815. HRESULT
  816. XLFont::
  817. CheckCurrentFont(
  818. FontType XLFontType,
  819. PBYTE pPCLXLFontName,
  820. DWORD dwFontHeight,
  821. DWORD dwFontWidth,
  822. DWORD dwFontSymbolSet,
  823. DWORD dwFontSimulation)
  824. /*++
  825. Routine Description:
  826. Arguments:
  827. Return Value:
  828. Note:
  829. --*/
  830. {
  831. HRESULT lrRet = S_OK;
  832. XL_VERBOSE(("XLFont::CheckCurrentFont\n"));
  833. switch (XLFontType)
  834. {
  835. case kFontNone:
  836. lrRet = S_FALSE;
  837. break;
  838. case kFontTypeDevice:
  839. ASSERT((pPCLXLFontName));
  840. if (m_XLFontType == kFontTypeDevice ||
  841. strcmp((CHAR*)pPCLXLFontName, (CHAR*)m_aubFontName) ||
  842. dwFontHeight != m_dwFontHeight ||
  843. dwFontWidth != m_dwFontWidth ||
  844. dwFontSymbolSet != m_dwFontSymbolSet)
  845. lrRet = S_FALSE;
  846. break;
  847. case kFontTypeTTBitmap:
  848. ASSERT((pPCLXLFontName));
  849. if (m_XLFontType == kFontTypeTTBitmap ||
  850. strcmp((CHAR*)pPCLXLFontName, (CHAR*)m_aubFontName))
  851. lrRet = S_FALSE;
  852. break;
  853. case kFontTypeTTOutline:
  854. ASSERT((pPCLXLFontName));
  855. if (m_XLFontType == kFontTypeTTOutline ||
  856. strcmp((CHAR*)pPCLXLFontName, (CHAR*)m_aubFontName) ||
  857. dwFontHeight != m_dwFontHeight ||
  858. dwFontWidth != m_dwFontWidth ||
  859. dwFontSymbolSet != m_dwFontSymbolSet ||
  860. dwFontSimulation != m_dwFontSimulation )
  861. lrRet = S_FALSE;
  862. break;
  863. default:
  864. XL_ERR(("XLFont::CheckCurrentFont: Invalid font type.\n"));
  865. lrRet = E_UNEXPECTED;
  866. break;
  867. }
  868. return lrRet;
  869. }
  870. HRESULT
  871. XLFont::
  872. SetFont(
  873. FontType XLFontType,
  874. PBYTE pPCLXLFontName,
  875. DWORD dwFontHeight,
  876. DWORD dwFontWidth,
  877. DWORD dwFontSymbolSet,
  878. DWORD dwFontSimulation)
  879. /*++
  880. Routine Description:
  881. Set font in GState.
  882. Arguments:
  883. XLFontType - FontType enum, Font type (Device/TTBitmap/TTOutline)
  884. pPCLXLFontName - XL font name (base name + attributes)
  885. dwFontHeight - Font height
  886. dwFontWidth - Font width
  887. dwFontSymbolSet - Font's symbol set
  888. dwFontSimulation - Font attributes (Bold/Italic)
  889. Return Value:
  890. Note:
  891. --*/
  892. {
  893. HRESULT lrRet;
  894. XL_VERBOSE(("XLFont::SetFont\n"));
  895. switch (XLFontType)
  896. {
  897. case kFontTypeDevice:
  898. case kFontTypeTTOutline:
  899. case kFontTypeTTBitmap:
  900. ASSERT(pPCLXLFontName);
  901. m_XLFontType = XLFontType;
  902. CopyMemory(m_aubFontName, pPCLXLFontName, PCLXL_FONTNAME_SIZE);
  903. m_aubFontName[PCLXL_FONTNAME_SIZE] = NULL;
  904. m_dwFontHeight = dwFontHeight;
  905. m_dwFontWidth = dwFontWidth;
  906. m_dwFontSymbolSet = dwFontSymbolSet;
  907. m_dwFontSimulation = dwFontSimulation;
  908. lrRet = S_OK;
  909. break;
  910. default:
  911. XL_ERR(("XLFont::CheckCurrentFont: Invalid font type.\n"));
  912. lrRet = E_UNEXPECTED;
  913. break;
  914. }
  915. return lrRet;
  916. }
  917. HRESULT
  918. XLFont::
  919. GetFontName(
  920. PBYTE paubFontName)
  921. /*++
  922. Routine Description:
  923. Returns current selected font base name.
  924. Arguments:
  925. Return Value:
  926. Note:
  927. --*/
  928. {
  929. XL_VERBOSE(("XLFont::GetFontName\n"));
  930. if (NULL == paubFontName)
  931. {
  932. XL_ERR(("GetFontName: Invalid fontname pointer\n"));
  933. return E_UNEXPECTED;
  934. }
  935. //
  936. // Assumption: paubFontName is an array of 16 + 1 bytes.
  937. //
  938. CopyMemory(paubFontName, m_aubFontName, PCLXL_FONTNAME_SIZE);
  939. paubFontName[PCLXL_FONTNAME_SIZE] = NULL;
  940. return S_OK;
  941. }
  942. FontType
  943. XLFont::
  944. GetFontType(VOID)
  945. /*++
  946. Routine Description:
  947. Returns current font's type.
  948. Arguments:
  949. Return Value:
  950. Note:
  951. --*/
  952. {
  953. XL_VERBOSE(("XLFont::GetFontType\n"));
  954. return m_XLFontType;
  955. }
  956. DWORD
  957. XLFont::
  958. GetFontHeight(VOID)
  959. /*++
  960. Routine Description:
  961. Returns current font's height.
  962. Arguments:
  963. Return Value:
  964. Note:
  965. --*/
  966. {
  967. XL_VERBOSE(("XLFont::GetFontHeight\n"));
  968. return m_dwFontHeight;
  969. }
  970. DWORD
  971. XLFont::
  972. GetFontWidth(VOID)
  973. /*++
  974. Routine Description:
  975. Arguments:
  976. Return Value:
  977. Note:
  978. --*/
  979. {
  980. XL_VERBOSE(("XLFont::GetFontWidth\n"));
  981. return m_dwFontWidth;
  982. }
  983. DWORD
  984. XLFont::
  985. GetFontSymbolSet(VOID)
  986. /*++
  987. Routine Description:
  988. Return font symbol set.
  989. Arguments:
  990. Return Value:
  991. Note:
  992. --*/
  993. {
  994. XL_VERBOSE(("XLFont::GetFontSymbolSet\n"));
  995. return m_dwFontSymbolSet;
  996. }
  997. DWORD
  998. XLFont::
  999. GetFontSimulation(VOID)
  1000. /*++
  1001. Routine Description:
  1002. Return current font simulation.
  1003. Arguments:
  1004. Return Value:
  1005. Note:
  1006. --*/
  1007. {
  1008. XL_VERBOSE(("XLFont::GetFontSimulation\n"));
  1009. return m_dwFontSimulation;
  1010. }
  1011. //
  1012. // XLTxMode
  1013. //
  1014. XLTxMode::
  1015. XLTxMode()
  1016. :m_SourceTxMode(eNotSet),
  1017. m_PaintTxMode(eNotSet)
  1018. {
  1019. #if DBG
  1020. SetDbgLevel(GSTATEDBG);
  1021. #endif
  1022. XL_VERBOSE(("XLTxMode::CTor\n"));
  1023. }
  1024. XLTxMode::
  1025. ~XLTxMode()
  1026. {
  1027. XL_VERBOSE(("XLTxMode::DTor\n"));
  1028. }
  1029. HRESULT
  1030. XLTxMode::
  1031. SetSourceTxMode(
  1032. TxMode SrcTxMode)
  1033. {
  1034. XL_VERBOSE(("XLTxMode::SetSourceTxMode\n"));
  1035. m_SourceTxMode = SrcTxMode;
  1036. return S_OK;
  1037. }
  1038. HRESULT
  1039. XLTxMode::
  1040. SetPaintTxMode(
  1041. TxMode PaintTxMode)
  1042. {
  1043. XL_VERBOSE(("XLTxMode::SetPaintTxMode\n"));
  1044. m_PaintTxMode = PaintTxMode;
  1045. return S_OK;
  1046. }
  1047. TxMode
  1048. XLTxMode::
  1049. GetSourceTxMode()
  1050. {
  1051. XL_VERBOSE(("XLTxMode::GetSourceTxMode\n"));
  1052. return m_SourceTxMode;
  1053. }
  1054. TxMode
  1055. XLTxMode::
  1056. GetPaintTxMode()
  1057. {
  1058. XL_VERBOSE(("XLTxMode::GetPaintTxMode\n"));
  1059. return m_PaintTxMode;
  1060. }
  1061. #if DBG
  1062. VOID
  1063. XLTxMode::
  1064. SetDbgLevel(
  1065. DWORD dwLevel)
  1066. /*++
  1067. Routine Description:
  1068. Arguments:
  1069. Return Value:
  1070. Note:
  1071. --*/
  1072. {
  1073. m_dbglevel = dwLevel;
  1074. }
  1075. #endif
  1076. //
  1077. // XLGState
  1078. //
  1079. VOID
  1080. XLGState::
  1081. ResetGState(
  1082. VOID)
  1083. /*++
  1084. Routine Description:
  1085. Reset Graphics State.
  1086. Arguments:
  1087. Return Value:
  1088. Note:
  1089. ROP3 is set to SRCPY(0xCC)
  1090. --*/
  1091. {
  1092. XLLine *pXLine = this;
  1093. pXLine->ResetLine();
  1094. XLBrush *pXBrush = this;
  1095. pXBrush->ResetBrush();
  1096. XLPen *pXPen = this;
  1097. pXPen->ResetBrush();
  1098. XLClip *pXClip = this;
  1099. pXClip->ClearClip();
  1100. //
  1101. // Set CC (SrcCopy)
  1102. //
  1103. XLRop *pXRop = this;
  1104. pXRop->SetROP3(0xCC);
  1105. XLFont *pXFont = this;
  1106. pXFont->ResetFont();
  1107. XLTxMode *pXLTxMode = this;
  1108. pXLTxMode->SetSourceTxMode(eNotSet);
  1109. pXLTxMode->SetPaintTxMode(eNotSet);
  1110. }
  1111. #if DBG
  1112. VOID
  1113. XLGState::
  1114. SetAllDbgLevel(
  1115. DWORD dwLevel)
  1116. /*++
  1117. Routine Description:
  1118. Set debug level in all classes.
  1119. Arguments:
  1120. Return Value:
  1121. Note:
  1122. --*/
  1123. {
  1124. XLLine *pXLine = this;
  1125. pXLine->SetDbgLevel(dwLevel);
  1126. XLBrush *pXBrush = this;
  1127. pXBrush->SetDbgLevel(dwLevel);
  1128. XLPen *pXPen = this;
  1129. pXPen->SetDbgLevel(dwLevel);
  1130. XLClip *pXClip = this;
  1131. pXClip->SetDbgLevel(dwLevel);
  1132. XLRop *pXRop = this;
  1133. pXRop->SetDbgLevel(dwLevel);
  1134. XLFont *pXFont = this;
  1135. pXFont->SetDbgLevel(dwLevel);
  1136. XLTxMode *pTxMode = this;
  1137. pTxMode->SetDbgLevel(dwLevel);
  1138. }
  1139. #endif