Source code of Windows XP (NT5)
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.

2575 lines
75 KiB

  1. #include "precomp.h"
  2. //
  3. // OD.CPP
  4. // Order Decoding
  5. //
  6. // Copyright(c) Microsoft 1997-
  7. //
  8. #define MLZ_FILE_ZONE ZONE_ORDER
  9. //
  10. // OD_ViewStarting()
  11. //
  12. // Sets up the odLast... vars
  13. //
  14. BOOL ASShare::OD_ViewStarting(ASPerson * pasPerson)
  15. {
  16. BOOL rc = FALSE;
  17. TSHR_COLOR colorWhite = {0xFF,0xFF,0xFF};
  18. BYTE brushExtra[7] = {0,0,0,0,0,0,0};
  19. DebugEntry(ASShare::OD_ViewStarting);
  20. ValidateView(pasPerson);
  21. //
  22. // Invalidate OD results
  23. //
  24. pasPerson->m_pView->m_odInvalRgnTotal = CreateRectRgn(0, 0, 0, 0);
  25. if (pasPerson->m_pView->m_odInvalRgnTotal == NULL)
  26. {
  27. ERROR_OUT(("OD_PartyStartingHosting: Couldn't create total invalid OD region"));
  28. DC_QUIT;
  29. }
  30. pasPerson->m_pView->m_odInvalRgnOrder = CreateRectRgn(0, 0, 0, 0);
  31. if (pasPerson->m_pView->m_odInvalRgnOrder == NULL)
  32. {
  33. ERROR_OUT(("OD_PartyStartingHosting: Couldn't create order invalid OD region"));
  34. DC_QUIT;
  35. }
  36. //
  37. // Back color.
  38. //
  39. pasPerson->m_pView->m_odLastBkColor = 0;
  40. ODUseBkColor(pasPerson, TRUE, colorWhite);
  41. //
  42. // Text color.
  43. //
  44. pasPerson->m_pView->m_odLastTextColor = 0;
  45. ODUseTextColor(pasPerson, TRUE, colorWhite);
  46. //
  47. // Background mode.
  48. //
  49. pasPerson->m_pView->m_odLastBkMode = TRANSPARENT;
  50. ODUseBkMode(pasPerson, OPAQUE);
  51. //
  52. // ROP2.
  53. //
  54. pasPerson->m_pView->m_odLastROP2 = R2_BLACK;
  55. ODUseROP2(pasPerson, R2_COPYPEN);
  56. //
  57. // Fill Mode. It's zero, we don't need to do anything since 0 isn't
  58. // a valid mode, so we'll change it the first order we get that uses
  59. // one.
  60. //
  61. ASSERT(pasPerson->m_pView->m_odLastFillMode == 0);
  62. //
  63. // Arc Direction. It's zero, we don't need to do anything since 0
  64. // isn't a valid dir, so we'll change it the first order we get that
  65. // uses one.
  66. //
  67. ASSERT(pasPerson->m_pView->m_odLastArcDirection == 0);
  68. //
  69. // Pen.
  70. //
  71. pasPerson->m_pView->m_odLastPenStyle = PS_DASH;
  72. pasPerson->m_pView->m_odLastPenWidth = 2;
  73. pasPerson->m_pView->m_odLastPenColor = 0;
  74. ODUsePen(pasPerson, TRUE, PS_SOLID, 1, colorWhite);
  75. //
  76. // Brush.
  77. //
  78. pasPerson->m_pView->m_odLastBrushOrgX = 1;
  79. pasPerson->m_pView->m_odLastBrushOrgY = 1;
  80. pasPerson->m_pView->m_odLastBrushBkColor = 0;
  81. pasPerson->m_pView->m_odLastBrushTextColor = 0;
  82. pasPerson->m_pView->m_odLastLogBrushStyle = BS_NULL;
  83. pasPerson->m_pView->m_odLastLogBrushHatch = HS_VERTICAL;
  84. pasPerson->m_pView->m_odLastLogBrushColor.red = 0;
  85. pasPerson->m_pView->m_odLastLogBrushColor.green = 0;
  86. pasPerson->m_pView->m_odLastLogBrushColor.blue = 0;
  87. ODUseBrush(pasPerson, TRUE, 0, 0, BS_SOLID, HS_HORIZONTAL,
  88. colorWhite, brushExtra);
  89. //
  90. // Char extra.
  91. //
  92. pasPerson->m_pView->m_odLastCharExtra = 1;
  93. ODUseTextCharacterExtra(pasPerson, 0);
  94. //
  95. // Text justification.
  96. //
  97. pasPerson->m_pView->m_odLastJustExtra = 1;
  98. pasPerson->m_pView->m_odLastJustCount = 1;
  99. ODUseTextJustification(pasPerson, 0, 0);
  100. // odLastBaselineOffset. This is zero, which is the default in the DC
  101. // right now so need to change anything.
  102. //
  103. // Font.
  104. //
  105. // We don't call ODUseFont because we know that the following values
  106. // are invalid. The first valid font to arrive will be selected.
  107. //
  108. ASSERT(pasPerson->m_pView->m_odLastFontID == NULL);
  109. pasPerson->m_pView->m_odLastFontCodePage = 0;
  110. pasPerson->m_pView->m_odLastFontWidth = 0;
  111. pasPerson->m_pView->m_odLastFontHeight = 0;
  112. pasPerson->m_pView->m_odLastFontWeight = 0;
  113. pasPerson->m_pView->m_odLastFontFlags = 0;
  114. pasPerson->m_pView->m_odLastFontFaceLen = 0;
  115. ZeroMemory(pasPerson->m_pView->m_odLastFaceName, sizeof(pasPerson->m_pView->m_odLastFaceName));
  116. //
  117. // These next 4 variables which describe the current clip rectangle are
  118. // only valid if fRectReset is FALSE. If fRectReset is true then no
  119. // clipping is in force.
  120. //
  121. pasPerson->m_pView->m_odRectReset = TRUE;
  122. pasPerson->m_pView->m_odLastLeft = 0x12345678;
  123. pasPerson->m_pView->m_odLastTop = 0x12345678;
  124. pasPerson->m_pView->m_odLastRight = 0x12345678;
  125. pasPerson->m_pView->m_odLastBottom = 0x12345678;
  126. // odLastVGAColor?
  127. // odLastVGAResult?
  128. rc = TRUE;
  129. DC_EXIT_POINT:
  130. DebugExitBOOL(ASShare::OD_ViewStarting, rc);
  131. return(rc);
  132. }
  133. //
  134. // OD_ViewEnded()
  135. // Cleans up any created objects
  136. //
  137. void ASShare::OD_ViewEnded(ASPerson * pasPerson)
  138. {
  139. DebugEntry(ASShare::OD_ViewEnded);
  140. ValidateView(pasPerson);
  141. //
  142. // We may create and select in a font and a pen for our drawing decode.
  143. // Select them out and delete them. Since we can't delete stock objects,
  144. // if we didn't actually create one, there's no harm in it.
  145. //
  146. if (pasPerson->m_pView->m_usrDC != NULL)
  147. {
  148. DeleteBrush(SelectBrush(pasPerson->m_pView->m_usrDC, (HBRUSH)GetStockObject(BLACK_BRUSH)));
  149. DeletePen(SelectPen(pasPerson->m_pView->m_usrDC, (HPEN)GetStockObject(BLACK_PEN)));
  150. }
  151. //
  152. // Destroy the brush patern
  153. //
  154. if (pasPerson->m_pView->m_odLastBrushPattern != NULL)
  155. {
  156. DeleteBitmap(pasPerson->m_pView->m_odLastBrushPattern);
  157. pasPerson->m_pView->m_odLastBrushPattern = NULL;
  158. }
  159. //
  160. // Destroy the font -- but in this case we don't know that our font is
  161. // actually the one in the DC. od2 also selects in fonts.
  162. //
  163. if (pasPerson->m_pView->m_odLastFontID != NULL)
  164. {
  165. // Make sure this isn't selected in to usrDC
  166. SelectFont(pasPerson->m_pView->m_usrDC, (HFONT)GetStockObject(SYSTEM_FONT));
  167. DeleteFont(pasPerson->m_pView->m_odLastFontID);
  168. pasPerson->m_pView->m_odLastFontID = NULL;
  169. }
  170. if (pasPerson->m_pView->m_odInvalRgnTotal != NULL)
  171. {
  172. DeleteRgn(pasPerson->m_pView->m_odInvalRgnTotal);
  173. pasPerson->m_pView->m_odInvalRgnTotal = NULL;
  174. }
  175. if (pasPerson->m_pView->m_odInvalRgnOrder != NULL)
  176. {
  177. DeleteRgn(pasPerson->m_pView->m_odInvalRgnOrder);
  178. pasPerson->m_pView->m_odInvalRgnOrder = NULL;
  179. }
  180. DebugExitVOID(ASShare::OD_ViewEnded);
  181. }
  182. //
  183. // OD_ReceivedPacket()
  184. //
  185. // Handles incoming orders packet from a host. Replays the drawing orders
  186. // into the screen bitmap for the host, then repaints the view with the
  187. // results.
  188. //
  189. void ASShare::OD_ReceivedPacket
  190. (
  191. ASPerson * pasPerson,
  192. PS20DATAPACKET pPacket
  193. )
  194. {
  195. PORDPACKET pOrders;
  196. HPALETTE hOldPalette;
  197. HPALETTE hOldSavePalette;
  198. UINT cOrders;
  199. UINT cUpdates;
  200. UINT i;
  201. LPCOM_ORDER_UA pOrder;
  202. UINT decodedLength;
  203. LPBYTE pEncodedOrder;
  204. TSHR_INT32 xOrigin;
  205. TSHR_INT32 yOrigin;
  206. BOOL fPalRGB;
  207. DebugEntry(ASShare::OD_ReceivedPacket);
  208. ValidateView(pasPerson);
  209. pOrders = (PORDPACKET)pPacket;
  210. //
  211. // The color type is RGB if we or they are < 256 colors
  212. // Else it's PALETTE if they are old, or new and not sending 24bpp
  213. //
  214. fPalRGB = TRUE;
  215. if ((g_usrScreenBPP < 8) || (pasPerson->cpcCaps.screen.capsBPP < 8))
  216. {
  217. TRACE_OUT(("OD_ReceivedPacket: no PALRGB"));
  218. fPalRGB = FALSE;
  219. }
  220. else
  221. {
  222. // At 24bpp, no palette matching for RGB values unless we're <= 8
  223. if ((g_usrScreenBPP > 8) && (pOrders->sendBPP > 8))
  224. {
  225. TRACE_OUT(("OD_ReceivedPacket: no PALRGB"));
  226. fPalRGB = FALSE;
  227. }
  228. }
  229. if (g_usrPalettized)
  230. {
  231. //
  232. // Select and realize the current remote palette into the device
  233. // context.
  234. //
  235. hOldPalette = SelectPalette(pasPerson->m_pView->m_usrDC, pasPerson->pmPalette, FALSE);
  236. RealizePalette(pasPerson->m_pView->m_usrDC);
  237. //
  238. // We must select the same palette into the Save Bitmap DC so that
  239. // no color conversion occurs during save and restore operations.
  240. //
  241. if (pasPerson->m_pView->m_ssiDC != NULL)
  242. {
  243. hOldSavePalette = SelectPalette(pasPerson->m_pView->m_ssiDC,
  244. pasPerson->pmPalette, FALSE);
  245. RealizePalette(pasPerson->m_pView->m_ssiDC);
  246. }
  247. }
  248. //
  249. // Extract the number of orders supplied.
  250. //
  251. cOrders = pOrders->cOrders;
  252. if (m_oefOE2EncodingOn)
  253. {
  254. pEncodedOrder = (LPBYTE)(&pOrders->data);
  255. pOrder = NULL;
  256. }
  257. else
  258. {
  259. pOrder = (LPCOM_ORDER_UA)(&pOrders->data);
  260. pEncodedOrder = NULL;
  261. }
  262. //
  263. // Get the desktop origin for this person.
  264. //
  265. TRACE_OUT(( "Begin replaying %u orders ((", cOrders));
  266. //
  267. // This should be empty, we should have reset it when we invalidated
  268. // the view of the host the last time we got a packet.
  269. //
  270. #ifdef _DEBUG
  271. {
  272. RECT rcBounds;
  273. ASSERT(pasPerson->m_pView->m_odInvalTotal == 0);
  274. GetRgnBox(pasPerson->m_pView->m_odInvalRgnTotal, &rcBounds);
  275. ASSERT(IsRectEmpty(&rcBounds));
  276. }
  277. #endif // _DEBUG
  278. //
  279. // Repeat for each of the received orders.
  280. //
  281. for (i = 0; i < cOrders; i++)
  282. {
  283. if (m_oefOE2EncodingOn)
  284. {
  285. //
  286. // Decode the first order. The pOrder returned by
  287. // OD2_DecodeOrder should have all fields in local byte order
  288. //
  289. pOrder = OD2_DecodeOrder( (PDCEO2ORDER)pEncodedOrder,
  290. &decodedLength,
  291. pasPerson );
  292. if (pOrder == NULL)
  293. {
  294. ERROR_OUT(( "Failed to decode order from pasPerson %u", pasPerson));
  295. DC_QUIT;
  296. }
  297. }
  298. else
  299. {
  300. //
  301. // Convert any font ids to be local ids.
  302. //
  303. //
  304. // BOGUS LAURABU
  305. // pOrder is unaligned, FH_Convert... takes an aligned order
  306. //
  307. FH_ConvertAnyFontIDToLocal((LPCOM_ORDER)pOrder, pasPerson);
  308. decodedLength = pOrder->OrderHeader.cbOrderDataLength +
  309. sizeof(COM_ORDER_HEADER);
  310. }
  311. //
  312. // If the order is a Private Order then it is dealt with by
  313. // the Bitmap Cache Controller.
  314. //
  315. if (EXTRACT_TSHR_UINT16_UA(&(pOrder->OrderHeader.fOrderFlags)) &
  316. OF_PRIVATE)
  317. {
  318. RBC_ProcessCacheOrder(pasPerson, pOrder);
  319. }
  320. else if ( EXTRACT_TSHR_UINT16_UA(
  321. &(((LPPATBLT_ORDER)pOrder->abOrderData)->type)) ==
  322. LOWORD(ORD_DESKSCROLL))
  323. {
  324. ERROR_OUT(("Received DESKSCROLL order, obsolete, from 3.0 node [%d]",
  325. pasPerson->mcsID));
  326. }
  327. else
  328. {
  329. //
  330. // Replay the received order. This will also add the
  331. // bounds to the invalidate region.
  332. //
  333. //
  334. OD_ReplayOrder(pasPerson, (LPCOM_ORDER)pOrder, fPalRGB);
  335. }
  336. if (m_oefOE2EncodingOn)
  337. {
  338. pEncodedOrder += decodedLength;
  339. }
  340. else
  341. {
  342. pOrder = (LPCOM_ORDER_UA)((LPBYTE)pOrder + decodedLength);
  343. }
  344. }
  345. TRACE_OUT(( "End replaying orders ))"));
  346. //
  347. // Pass the Update Region to the Shadow Window Presenter.
  348. //
  349. OD_UpdateView(pasPerson);
  350. DC_EXIT_POINT:
  351. if (g_usrPalettized)
  352. {
  353. //
  354. // Reinstate the old palette(s).
  355. //
  356. SelectPalette(pasPerson->m_pView->m_usrDC, hOldPalette, FALSE);
  357. if (pasPerson->m_pView->m_ssiDC != NULL)
  358. {
  359. SelectPalette(pasPerson->m_pView->m_ssiDC, hOldSavePalette, FALSE);
  360. }
  361. }
  362. DebugExitVOID(ASShare::OD_ReceivedPacket);
  363. }
  364. //
  365. // OD_UpdateView()
  366. //
  367. // This is called after we've processed an order packet and replayed the
  368. // drawing into our bitmap for the host.
  369. //
  370. // Replaying the drawing keeps a running tally of the area changed. This
  371. // function invalidates the changed area in the view of the host, so it
  372. // will repaint and show the updates.
  373. //
  374. void ASShare::OD_UpdateView(ASPerson * pasHost)
  375. {
  376. RECT rcBounds;
  377. DebugEntry(ASShare::OD_UpdateView);
  378. ValidateView(pasHost);
  379. //
  380. // Do nothing if there are no updates.
  381. //
  382. if (pasHost->m_pView->m_odInvalTotal == 0)
  383. {
  384. // Nothing got played back, nothing to repaint
  385. }
  386. else if (pasHost->m_pView->m_odInvalTotal <= MAX_UPDATE_REGION_ORDERS)
  387. {
  388. VIEW_InvalidateRgn(pasHost, pasHost->m_pView->m_odInvalRgnTotal);
  389. }
  390. else
  391. {
  392. //
  393. // Rather than invalidating a very complex region, which will
  394. // chew up a lot of memory, just invalidate the bounding box.
  395. //
  396. GetRgnBox(pasHost->m_pView->m_odInvalRgnTotal, &rcBounds);
  397. TRACE_OUT(("OD_UpdateView: Update region too complex; use bounds {%04d, %04d, %04d, %04d}",
  398. rcBounds.left, rcBounds.top, rcBounds.right, rcBounds.bottom));
  399. //
  400. // BOGUS LAURABU!
  401. // This code used to add one to the right & bottom, which was
  402. // bogus EXCLUSIVE coordinate confusion. I fixed this--the bound
  403. // box is the right area.
  404. //
  405. SetRectRgn(pasHost->m_pView->m_odInvalRgnTotal, rcBounds.left, rcBounds.top,
  406. rcBounds.right, rcBounds.bottom);
  407. VIEW_InvalidateRgn(pasHost, pasHost->m_pView->m_odInvalRgnTotal);
  408. }
  409. // Now reset the update region to empty
  410. SetRectRgn(pasHost->m_pView->m_odInvalRgnTotal, 0, 0, 0, 0);
  411. pasHost->m_pView->m_odInvalTotal = 0;
  412. DebugExitVOID(ASShare::OD_UpdateView);
  413. }
  414. //
  415. // OD_ReplayOrder()
  416. //
  417. // Replays one drawing operation, the next one, in the packet of orders
  418. // we received from a host.
  419. //
  420. void ASShare::OD_ReplayOrder
  421. (
  422. ASPerson * pasPerson,
  423. LPCOM_ORDER pOrder,
  424. BOOL fPalRGB
  425. )
  426. {
  427. LPPATBLT_ORDER pDrawing;
  428. LPSTR faceName;
  429. UINT faceNameLength;
  430. UINT trueFontWidth;
  431. UINT maxFontHeight;
  432. TSHR_UINT16 nFontFlags;
  433. TSHR_UINT16 nCodePage;
  434. UINT i;
  435. RECT rcDst;
  436. DebugEntry(ASShare::OD_ReplayOrder);
  437. ValidateView(pasPerson);
  438. pDrawing = (LPPATBLT_ORDER)pOrder->abOrderData;
  439. //
  440. // These are VD coords.
  441. // WHEN 2.X INTEROP IS GONE, GET RID OF m_pView->m_dsScreenOrigin
  442. //
  443. RECT_FROM_TSHR_RECT16(&rcDst, pOrder->OrderHeader.rcsDst);
  444. //
  445. // The host bitmap is in screen, not VD, coords
  446. //
  447. if (pOrder->OrderHeader.fOrderFlags & OF_NOTCLIPPED)
  448. {
  449. //
  450. // The rectangle associated with this order is the bounding
  451. // rectangle of the order and does not clip it. We optimise this
  452. // case by passing in a large rectangle that will not result in
  453. // clipping to ODUseRectRegion. ODUseRectRegion will spot if this
  454. // is the same as the last clip region we set and take a fast exit
  455. // path. This improves performance substantially.
  456. //
  457. ODUseRectRegion(pasPerson, 0, 0, 10000, 10000);
  458. }
  459. else
  460. {
  461. ODUseRectRegion(pasPerson, rcDst.left, rcDst.top, rcDst.right, rcDst.bottom);
  462. }
  463. switch (pDrawing->type)
  464. {
  465. case ORD_DSTBLT_TYPE:
  466. ODReplayDSTBLT(pasPerson, (LPDSTBLT_ORDER)pDrawing, fPalRGB);
  467. break;
  468. case ORD_PATBLT_TYPE:
  469. ODReplayPATBLT(pasPerson, (LPPATBLT_ORDER)pDrawing, fPalRGB);
  470. break;
  471. case ORD_SCRBLT_TYPE:
  472. ODReplaySCRBLT(pasPerson, (LPSCRBLT_ORDER)pDrawing, fPalRGB);
  473. break;
  474. case ORD_MEMBLT_TYPE:
  475. case ORD_MEMBLT_R2_TYPE:
  476. ODReplayMEMBLT(pasPerson, (LPMEMBLT_ORDER)pDrawing, fPalRGB);
  477. break;
  478. case ORD_MEM3BLT_TYPE:
  479. case ORD_MEM3BLT_R2_TYPE:
  480. ODReplayMEM3BLT(pasPerson, (LPMEM3BLT_ORDER)pDrawing, fPalRGB);
  481. break;
  482. case ORD_RECTANGLE_TYPE:
  483. ODReplayRECTANGLE(pasPerson, (LPRECTANGLE_ORDER)pDrawing, fPalRGB);
  484. break;
  485. case ORD_POLYGON_TYPE:
  486. ODReplayPOLYGON(pasPerson, (LPPOLYGON_ORDER)pDrawing, fPalRGB);
  487. break;
  488. case ORD_PIE_TYPE:
  489. ODReplayPIE(pasPerson, (LPPIE_ORDER)pDrawing, fPalRGB);
  490. break;
  491. case ORD_ELLIPSE_TYPE:
  492. ODReplayELLIPSE(pasPerson, (LPELLIPSE_ORDER)pDrawing, fPalRGB);
  493. break;
  494. case ORD_ARC_TYPE:
  495. ODReplayARC(pasPerson, (LPARC_ORDER)pDrawing, fPalRGB);
  496. break;
  497. case ORD_CHORD_TYPE:
  498. ODReplayCHORD(pasPerson, (LPCHORD_ORDER)pDrawing, fPalRGB);
  499. break;
  500. case ORD_POLYBEZIER_TYPE:
  501. ODReplayPOLYBEZIER(pasPerson, (LPPOLYBEZIER_ORDER)pDrawing, fPalRGB);
  502. break;
  503. case ORD_ROUNDRECT_TYPE:
  504. ODReplayROUNDRECT(pasPerson, (LPROUNDRECT_ORDER)pDrawing, fPalRGB);
  505. break;
  506. case ORD_LINETO_TYPE:
  507. ODReplayLINETO(pasPerson, (LPLINETO_ORDER)pDrawing, fPalRGB);
  508. break;
  509. case ORD_EXTTEXTOUT_TYPE:
  510. ODReplayEXTTEXTOUT(pasPerson, (LPEXTTEXTOUT_ORDER)pDrawing, fPalRGB);
  511. break;
  512. case ORD_TEXTOUT_TYPE:
  513. ODReplayTEXTOUT(pasPerson, (LPTEXTOUT_ORDER)pDrawing, fPalRGB);
  514. break;
  515. case ORD_OPAQUERECT_TYPE:
  516. ODReplayOPAQUERECT(pasPerson, (LPOPAQUERECT_ORDER)pDrawing, fPalRGB);
  517. break;
  518. case ORD_SAVEBITMAP_TYPE:
  519. SSI_SaveBitmap(pasPerson, (LPSAVEBITMAP_ORDER)pDrawing);
  520. break;
  521. default:
  522. ERROR_OUT(( "ORDER: Unrecognised order %d from [%d]",
  523. (int)pDrawing->type, pasPerson->mcsID));
  524. break;
  525. }
  526. //
  527. // rcDst is INCLUSIVE coords still
  528. //
  529. if ((rcDst.left <= rcDst.right) && (rcDst.top <= rcDst.bottom))
  530. {
  531. SetRectRgn(pasPerson->m_pView->m_odInvalRgnOrder, rcDst.left, rcDst.top,
  532. rcDst.right+1, rcDst.bottom+1);
  533. //
  534. // Combine the rectangle region with the update region.
  535. //
  536. if (UnionRgn(pasPerson->m_pView->m_odInvalRgnTotal, pasPerson->m_pView->m_odInvalRgnTotal, pasPerson->m_pView->m_odInvalRgnOrder) <= ERROR)
  537. {
  538. RECT rcCur;
  539. //
  540. // Union failed; so simplyify the current region
  541. //
  542. WARNING_OUT(("OD_ReplayOrder: UnionRgn failed"));
  543. //
  544. // BOGUS LAURABU!
  545. // This code used to add one to the right & bottom, which is
  546. // bogus exclusive coord confusion. The bound box is the right
  547. // area.
  548. //
  549. GetRgnBox(pasPerson->m_pView->m_odInvalRgnTotal, &rcCur);
  550. SetRectRgn(pasPerson->m_pView->m_odInvalRgnTotal, rcCur.left, rcCur.top, rcCur.right,
  551. rcCur.bottom);
  552. //
  553. // Reset odInvalTotal count -- this is really a # of bounds rects
  554. // count, and now we have just one.
  555. //
  556. pasPerson->m_pView->m_odInvalTotal = 1;
  557. if (UnionRgn(pasPerson->m_pView->m_odInvalRgnTotal, pasPerson->m_pView->m_odInvalRgnTotal, pasPerson->m_pView->m_odInvalRgnOrder) <= ERROR)
  558. {
  559. ERROR_OUT(("OD_ReplayOrder: UnionRgn failed after simplification"));
  560. }
  561. }
  562. pasPerson->m_pView->m_odInvalTotal++;
  563. }
  564. DebugExitVOID(ASShare::OD_ReplayOrder);
  565. }
  566. //
  567. // ODReplayDSTBLT()
  568. // Replays a DSTBLT order
  569. //
  570. void ASShare::ODReplayDSTBLT
  571. (
  572. ASPerson * pasPerson,
  573. LPDSTBLT_ORDER pDstBlt,
  574. BOOL fPalRGB
  575. )
  576. {
  577. DebugEntry(ASShare::ODReplayDSTBLT);
  578. TRACE_OUT(("ORDER: DstBlt X %hd Y %hd w %hd h %hd rop %08lX",
  579. pDstBlt->nLeftRect,
  580. pDstBlt->nTopRect,
  581. pDstBlt->nWidth,
  582. pDstBlt->nHeight,
  583. (UINT)ODConvertToWindowsROP(pDstBlt->bRop)));
  584. //
  585. // Apply DS origin offset ourselves (do not use transform)
  586. //
  587. PatBlt(pasPerson->m_pView->m_usrDC,
  588. pDstBlt->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  589. pDstBlt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  590. pDstBlt->nWidth,
  591. pDstBlt->nHeight,
  592. ODConvertToWindowsROP(pDstBlt->bRop));
  593. DebugExitVOID(ASShare::ODReplayDSTBLT);
  594. }
  595. //
  596. // ASShare::ODReplayPATBLT()
  597. // Replays a PATBLT order
  598. //
  599. void ASShare::ODReplayPATBLT
  600. (
  601. ASPerson * pasPerson,
  602. LPPATBLT_ORDER pPatblt,
  603. BOOL fPalRGB
  604. )
  605. {
  606. TSHR_COLOR BackColor;
  607. TSHR_COLOR ForeColor;
  608. DebugEntry(ASShare::ODReplayPATBLT);
  609. TRACE_OUT(("ORDER: PatBlt BC %08lX FC %08lX Brush %02X %02X X %d Y %d w %d h %d rop %08lX",
  610. pPatblt->BackColor,
  611. pPatblt->ForeColor,
  612. pPatblt->BrushStyle,
  613. pPatblt->BrushHatch,
  614. pPatblt->nLeftRect,
  615. pPatblt->nTopRect,
  616. pPatblt->nWidth,
  617. pPatblt->nHeight,
  618. ODConvertToWindowsROP(pPatblt->bRop) ));
  619. ODAdjustColor(pasPerson, &(pPatblt->BackColor), &BackColor, OD_BACK_COLOR);
  620. ODAdjustColor(pasPerson, &(pPatblt->ForeColor), &ForeColor, OD_FORE_COLOR);
  621. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  622. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  623. ODUseBrush(pasPerson, fPalRGB, pPatblt->BrushOrgX, pPatblt->BrushOrgY,
  624. pPatblt->BrushStyle, pPatblt->BrushHatch, ForeColor, pPatblt->BrushExtra);
  625. //
  626. // Apply DS origin offset ourselves (do not use transform)
  627. //
  628. PatBlt(pasPerson->m_pView->m_usrDC,
  629. pPatblt->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  630. pPatblt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  631. pPatblt->nWidth,
  632. pPatblt->nHeight,
  633. ODConvertToWindowsROP(pPatblt->bRop));
  634. DebugExitVOID(ASShare::ODReplayPATBLT);
  635. }
  636. //
  637. // ASShare::ODReplaySCRBLT()
  638. // Replays SCRBLT order
  639. //
  640. void ASShare::ODReplaySCRBLT
  641. (
  642. ASPerson * pasPerson,
  643. LPSCRBLT_ORDER pScrBlt,
  644. BOOL fPalRGB
  645. )
  646. {
  647. DebugEntry(ASShare::ODReplaySCRBLT);
  648. TRACE_OUT(("ORDER: ScrBlt dx %d dy %d w %d h %d sx %d sy %d rop %08lX",
  649. pScrBlt->nLeftRect,
  650. pScrBlt->nTopRect,
  651. pScrBlt->nWidth,
  652. pScrBlt->nHeight,
  653. pScrBlt->nXSrc,
  654. pScrBlt->nYSrc,
  655. ODConvertToWindowsROP(pScrBlt->bRop)));
  656. //
  657. // Apply DS origin offset ourselves (do not use transform)
  658. //
  659. BitBlt(pasPerson->m_pView->m_usrDC,
  660. pScrBlt->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  661. pScrBlt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  662. pScrBlt->nWidth,
  663. pScrBlt->nHeight,
  664. pasPerson->m_pView->m_usrDC,
  665. pScrBlt->nXSrc - pasPerson->m_pView->m_dsScreenOrigin.x,
  666. pScrBlt->nYSrc - pasPerson->m_pView->m_dsScreenOrigin.y,
  667. ODConvertToWindowsROP(pScrBlt->bRop));
  668. DebugExitVOID(ASShare::ODReplaySCRBLT);
  669. }
  670. //
  671. // ASShare::ODReplayMEMBLT()
  672. // Replays MEMBLT and MEMBLT_R2 orders
  673. //
  674. void ASShare::ODReplayMEMBLT
  675. (
  676. ASPerson * pasPerson,
  677. LPMEMBLT_ORDER pMemBlt,
  678. BOOL fPalRGB
  679. )
  680. {
  681. HPALETTE hpalOld;
  682. HPALETTE hpalOld2;
  683. TSHR_UINT16 cacheIndex;
  684. UINT nXSrc;
  685. HBITMAP cacheBitmap;
  686. HBITMAP hOldBitmap;
  687. COLORREF clrBk;
  688. COLORREF clrText;
  689. DebugEntry(ASShare::ODReplayMEMBLT);
  690. ValidateView(pasPerson);
  691. TRACE_OUT(("MEMBLT nXSrc %d",pMemBlt->nXSrc));
  692. hpalOld = SelectPalette(pasPerson->m_pView->m_usrWorkDC, pasPerson->pmPalette, FALSE);
  693. RealizePalette(pasPerson->m_pView->m_usrWorkDC);
  694. hpalOld2 = SelectPalette( pasPerson->m_pView->m_usrDC, pasPerson->pmPalette, FALSE );
  695. RealizePalette(pasPerson->m_pView->m_usrDC);
  696. //
  697. // Now get the source bitmap. The cache is defined by
  698. // hBitmap. For R1 protocols the cache index is indicated
  699. // by the source offset on the order. For R2 it is
  700. // indicated by a separate field in the order.
  701. // The color table index is in the high order of hBitmap
  702. //
  703. cacheIndex = ((LPMEMBLT_R2_ORDER)pMemBlt)->cacheIndex;
  704. nXSrc = pMemBlt->nXSrc;
  705. TRACE_OUT(( "MEMBLT color %d cache %d:%d",
  706. MEMBLT_COLORINDEX(pMemBlt),
  707. MEMBLT_CACHETABLE(pMemBlt),
  708. cacheIndex));
  709. cacheBitmap = RBC_MapCacheIDToBitmapHandle(pasPerson,
  710. MEMBLT_CACHETABLE(pMemBlt), cacheIndex, MEMBLT_COLORINDEX(pMemBlt));
  711. hOldBitmap = SelectBitmap(pasPerson->m_pView->m_usrWorkDC, cacheBitmap);
  712. TRACE_OUT(("ORDER: MemBlt dx %d dy %d w %d h %d sx %d sy %d rop %08lX",
  713. pMemBlt->nLeftRect,
  714. pMemBlt->nTopRect,
  715. pMemBlt->nWidth,
  716. pMemBlt->nHeight,
  717. nXSrc,
  718. pMemBlt->nYSrc,
  719. ODConvertToWindowsROP(pMemBlt->bRop)));
  720. //
  721. // ALWAYS set back/fore color to white/black in case of rops like
  722. // SRCAND or SRCINVERT which will use their values.
  723. //
  724. clrBk = SetBkColor(pasPerson->m_pView->m_usrDC, RGB(255, 255, 255));
  725. clrText = SetTextColor(pasPerson->m_pView->m_usrDC, RGB(0, 0, 0));
  726. //
  727. // Apply DS origin offset ourselves (do not use transform)
  728. //
  729. BitBlt(pasPerson->m_pView->m_usrDC,
  730. pMemBlt->nLeftRect- pasPerson->m_pView->m_dsScreenOrigin.x,
  731. pMemBlt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  732. pMemBlt->nWidth,
  733. pMemBlt->nHeight,
  734. pasPerson->m_pView->m_usrWorkDC,
  735. nXSrc,
  736. pMemBlt->nYSrc,
  737. ODConvertToWindowsROP(pMemBlt->bRop));
  738. //
  739. // If the relevant property is set hatch the area in blue.
  740. //
  741. if (m_usrHatchBitmaps)
  742. {
  743. SDP_DrawHatchedRect(pasPerson->m_pView->m_usrDC,
  744. pMemBlt->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  745. pMemBlt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  746. pMemBlt->nWidth,
  747. pMemBlt->nHeight,
  748. USR_HATCH_COLOR_BLUE);
  749. }
  750. //
  751. // Restore back, text colors
  752. //
  753. SetTextColor(pasPerson->m_pView->m_usrDC, clrText);
  754. SetBkColor(pasPerson->m_pView->m_usrDC, clrBk);
  755. //
  756. // Deselect the bitmap from the DC.
  757. //
  758. SelectBitmap(pasPerson->m_pView->m_usrWorkDC, hOldBitmap);
  759. SelectPalette(pasPerson->m_pView->m_usrWorkDC, hpalOld, FALSE);
  760. SelectPalette(pasPerson->m_pView->m_usrDC, hpalOld2, FALSE);
  761. DebugExitVOID(ASShare::ODReplayMEMBLT);
  762. }
  763. //
  764. // ASShare::ODReplayMEM3BLT()
  765. // Replays MEM3BLT and MEM3BLT_R2 orders
  766. //
  767. void ASShare::ODReplayMEM3BLT
  768. (
  769. ASPerson * pasPerson,
  770. LPMEM3BLT_ORDER pMem3Blt,
  771. BOOL fPalRGB
  772. )
  773. {
  774. HPALETTE hpalOld;
  775. HPALETTE hpalOld2;
  776. TSHR_UINT16 cacheIndex;
  777. int nXSrc;
  778. HBITMAP cacheBitmap;
  779. HBITMAP hOldBitmap;
  780. TSHR_COLOR BackColor;
  781. TSHR_COLOR ForeColor;
  782. DebugEntry(ASShare::ODReplayMEM3BLT);
  783. ValidateView(pasPerson);
  784. TRACE_OUT(("MEM3BLT nXSrc %d",pMem3Blt->nXSrc));
  785. TRACE_OUT(("ORDER: Mem3Blt brush %04lX %04lX dx %d dy %d "\
  786. "w %d h %d sx %d sy %d rop %08lX",
  787. pMem3Blt->BrushStyle,
  788. pMem3Blt->BrushHatch,
  789. pMem3Blt->nLeftRect,
  790. pMem3Blt->nTopRect,
  791. pMem3Blt->nWidth,
  792. pMem3Blt->nHeight,
  793. pMem3Blt->nXSrc,
  794. pMem3Blt->nYSrc,
  795. (UINT)ODConvertToWindowsROP(pMem3Blt->bRop)));
  796. hpalOld = SelectPalette(pasPerson->m_pView->m_usrWorkDC, pasPerson->pmPalette, FALSE);
  797. RealizePalette(pasPerson->m_pView->m_usrWorkDC);
  798. hpalOld2 = SelectPalette( pasPerson->m_pView->m_usrDC, pasPerson->pmPalette, FALSE);
  799. RealizePalette(pasPerson->m_pView->m_usrDC);
  800. //
  801. // Now get the source bitmap. The cache is defined by
  802. // hBitmap. For R1 protocols the cache index is indicated
  803. // by the source offset on the order. For R2 it is
  804. // indicated by a separate field in the order.
  805. // The color table index is in the high order of hBitmap
  806. //
  807. cacheIndex = ((LPMEM3BLT_R2_ORDER)pMem3Blt)->cacheIndex;
  808. nXSrc = pMem3Blt->nXSrc;
  809. TRACE_OUT(("MEM3BLT color %d cache %d:%d",
  810. MEMBLT_COLORINDEX(pMem3Blt),
  811. MEMBLT_CACHETABLE(pMem3Blt),
  812. cacheIndex));
  813. cacheBitmap = RBC_MapCacheIDToBitmapHandle(pasPerson,
  814. MEMBLT_CACHETABLE(pMem3Blt), cacheIndex, MEMBLT_COLORINDEX(pMem3Blt));
  815. hOldBitmap = SelectBitmap(pasPerson->m_pView->m_usrWorkDC, cacheBitmap);
  816. ODAdjustColor(pasPerson, &(pMem3Blt->BackColor), &BackColor, OD_BACK_COLOR);
  817. ODAdjustColor(pasPerson, &(pMem3Blt->ForeColor), &ForeColor, OD_FORE_COLOR);
  818. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  819. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  820. ODUseBrush(pasPerson, fPalRGB, pMem3Blt->BrushOrgX, pMem3Blt->BrushOrgY,
  821. pMem3Blt->BrushStyle, pMem3Blt->BrushHatch, ForeColor,
  822. pMem3Blt->BrushExtra);
  823. //
  824. // Apply DS origin offset ourselves (do not use transform)
  825. //
  826. BitBlt(pasPerson->m_pView->m_usrDC,
  827. pMem3Blt->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  828. pMem3Blt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  829. pMem3Blt->nWidth,
  830. pMem3Blt->nHeight,
  831. pasPerson->m_pView->m_usrWorkDC,
  832. nXSrc,
  833. pMem3Blt->nYSrc,
  834. ODConvertToWindowsROP(pMem3Blt->bRop));
  835. //
  836. // If the relevant property is set hatch the area in blue.
  837. //
  838. if (m_usrHatchBitmaps)
  839. {
  840. SDP_DrawHatchedRect(pasPerson->m_pView->m_usrDC,
  841. pMem3Blt->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  842. pMem3Blt->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  843. pMem3Blt->nWidth,
  844. pMem3Blt->nHeight,
  845. USR_HATCH_COLOR_BLUE);
  846. }
  847. //
  848. // Deselect the bitmap from the DC.
  849. //
  850. SelectBitmap(pasPerson->m_pView->m_usrWorkDC, hOldBitmap);
  851. SelectPalette(pasPerson->m_pView->m_usrWorkDC, hpalOld, FALSE);
  852. SelectPalette(pasPerson->m_pView->m_usrDC, hpalOld2, FALSE);
  853. DebugExitVOID(ASShare::ODReplayMEM3BLT);
  854. }
  855. //
  856. // ASShare::ODReplayRECTANGLE()
  857. // Replays RECTANGLE order
  858. //
  859. void ASShare::ODReplayRECTANGLE
  860. (
  861. ASPerson * pasPerson,
  862. LPRECTANGLE_ORDER pRectangle,
  863. BOOL fPalRGB
  864. )
  865. {
  866. TSHR_COLOR BackColor;
  867. TSHR_COLOR ForeColor;
  868. TSHR_COLOR PenColor;
  869. DebugEntry(ASShare::ODReplayRECTANGLE);
  870. TRACE_OUT(("ORDER: Rectangle BC %08lX FC %08lX BM %04hX brush %02hX " \
  871. "%02hX rop2 %04hX pen %04hX %04hX %08lX rect %d %d %d %d",
  872. pRectangle->BackColor,
  873. pRectangle->ForeColor,
  874. (TSHR_UINT16)pRectangle->BackMode,
  875. (TSHR_UINT16)pRectangle->BrushStyle,
  876. (TSHR_UINT16)pRectangle->BrushHatch,
  877. (TSHR_UINT16)pRectangle->ROP2,
  878. (TSHR_UINT16)pRectangle->PenStyle,
  879. (TSHR_UINT16)pRectangle->PenWidth,
  880. pRectangle->PenColor,
  881. (int)pRectangle->nLeftRect,
  882. (int)pRectangle->nTopRect,
  883. (int)pRectangle->nRightRect + 1,
  884. (int)pRectangle->nBottomRect + 1));
  885. ODAdjustColor(pasPerson, &(pRectangle->BackColor), &BackColor, OD_BACK_COLOR);
  886. ODAdjustColor(pasPerson, &(pRectangle->ForeColor), &ForeColor, OD_FORE_COLOR);
  887. ODAdjustColor(pasPerson, &(pRectangle->PenColor), &PenColor, OD_PEN_COLOR);
  888. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  889. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  890. ODUseBkMode(pasPerson, pRectangle->BackMode);
  891. ODUseBrush(pasPerson, fPalRGB, pRectangle->BrushOrgX, pRectangle->BrushOrgY,
  892. pRectangle->BrushStyle, pRectangle->BrushHatch, ForeColor,
  893. pRectangle->BrushExtra);
  894. ODUseROP2(pasPerson, pRectangle->ROP2);
  895. ODUsePen(pasPerson, fPalRGB, pRectangle->PenStyle, pRectangle->PenWidth,
  896. PenColor);
  897. //
  898. // The rectangle in the order is inclusive but Windows works
  899. // with exclusive rectangles.
  900. //
  901. // Apply DS origin offset ourselves (do not use transform)
  902. //
  903. Rectangle(pasPerson->m_pView->m_usrDC,
  904. pRectangle->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  905. pRectangle->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  906. pRectangle->nRightRect - pasPerson->m_pView->m_dsScreenOrigin.x + 1,
  907. pRectangle->nBottomRect- pasPerson->m_pView->m_dsScreenOrigin.y + 1);
  908. DebugExitVOID(ASShare::ODReplayRECTANGLE);
  909. }
  910. //
  911. // ASShare::ODReplayPOLYGON()
  912. // Replays POLYGON order
  913. //
  914. void ASShare::ODReplayPOLYGON
  915. (
  916. ASPerson * pasPerson,
  917. LPPOLYGON_ORDER pPolygon,
  918. BOOL fPalRGB
  919. )
  920. {
  921. POINT aP[ORD_MAX_POLYGON_POINTS];
  922. UINT i;
  923. UINT cPoints;
  924. TSHR_COLOR BackColor;
  925. TSHR_COLOR ForeColor;
  926. TSHR_COLOR PenColor;
  927. DebugEntry(ASShare::ODReplayPOLYGON);
  928. cPoints = pPolygon->variablePoints.len /
  929. sizeof(pPolygon->variablePoints.aPoints[0]);
  930. TRACE_OUT(("ORDER: Polygon BC %08lX FC %08lX BM %04hX brush %02hX %02hX "
  931. "%02hX %02hX rop2 %04hX pen %04hX %04hX %08lX points %d",
  932. pPolygon->BackColor,
  933. pPolygon->ForeColor,
  934. (TSHR_UINT16)pPolygon->BackMode,
  935. (TSHR_UINT16)pPolygon->BrushStyle,
  936. (TSHR_UINT16)pPolygon->BrushHatch,
  937. (TSHR_UINT16)pPolygon->ROP2,
  938. (TSHR_UINT16)pPolygon->PenStyle,
  939. (TSHR_UINT16)pPolygon->PenWidth,
  940. pPolygon->PenColor,
  941. cPoints));
  942. //
  943. // Apply DS origin offset ourselves (do not use transform)
  944. // while copying to native size point array.
  945. //
  946. for (i = 0; i < cPoints; i++)
  947. {
  948. TRACE_OUT(( "aPoints[%u]: %d,%d", i,
  949. (int)(pPolygon->variablePoints.aPoints[i].x),
  950. (int)(pPolygon->variablePoints.aPoints[i].y)));
  951. aP[i].x = pPolygon->variablePoints.aPoints[i].x -
  952. pasPerson->m_pView->m_dsScreenOrigin.x;
  953. aP[i].y = pPolygon->variablePoints.aPoints[i].y -
  954. pasPerson->m_pView->m_dsScreenOrigin.y;
  955. }
  956. ODAdjustColor(pasPerson, &(pPolygon->BackColor), &BackColor, OD_BACK_COLOR);
  957. ODAdjustColor(pasPerson, &(pPolygon->ForeColor), &ForeColor, OD_FORE_COLOR);
  958. ODAdjustColor(pasPerson, &(pPolygon->PenColor), &PenColor, OD_PEN_COLOR);
  959. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  960. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  961. ODUseBkMode(pasPerson, pPolygon->BackMode);
  962. ODUseBrush(pasPerson, fPalRGB, pPolygon->BrushOrgX, pPolygon->BrushOrgY,
  963. pPolygon->BrushStyle, pPolygon->BrushHatch, ForeColor,
  964. pPolygon->BrushExtra);
  965. ODUseROP2(pasPerson, pPolygon->ROP2);
  966. ODUsePen(pasPerson, fPalRGB, pPolygon->PenStyle, pPolygon->PenWidth,
  967. PenColor);
  968. ODUseFillMode(pasPerson, pPolygon->FillMode);
  969. Polygon(pasPerson->m_pView->m_usrDC, aP, cPoints);
  970. DebugExitVOID(ASShare::ODReplayPOLYGON);
  971. }
  972. //
  973. // ASShare::ODReplayPIE()
  974. // Replays PIE order
  975. //
  976. void ASShare::ODReplayPIE
  977. (
  978. ASPerson * pasPerson,
  979. LPPIE_ORDER pPie,
  980. BOOL fPalRGB
  981. )
  982. {
  983. TSHR_COLOR BackColor;
  984. TSHR_COLOR ForeColor;
  985. TSHR_COLOR PenColor;
  986. DebugEntry(ASShare::ODReplayPIE);
  987. TRACE_OUT(("ORDER: Pie BC %08lX FC %08lX BM %04hX brush %02hX "
  988. " %02hX rop2 %04hX pen %04hX %04hX %08lX rect %d %d %d %d",
  989. pPie->BackColor,
  990. pPie->ForeColor,
  991. (TSHR_UINT16)pPie->BackMode,
  992. (TSHR_UINT16)pPie->BrushStyle,
  993. (TSHR_UINT16)pPie->BrushHatch,
  994. (TSHR_UINT16)pPie->ROP2,
  995. (TSHR_UINT16)pPie->PenStyle,
  996. (TSHR_UINT16)pPie->PenWidth,
  997. pPie->PenColor,
  998. (int)pPie->nLeftRect,
  999. (int)pPie->nTopRect,
  1000. (int)pPie->nRightRect + 1,
  1001. (int)pPie->nBottomRect + 1));
  1002. ODAdjustColor(pasPerson, &(pPie->BackColor), &BackColor, OD_BACK_COLOR);
  1003. ODAdjustColor(pasPerson, &(pPie->ForeColor), &ForeColor, OD_FORE_COLOR);
  1004. ODAdjustColor(pasPerson, &(pPie->PenColor), &PenColor, OD_PEN_COLOR);
  1005. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1006. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  1007. ODUseBkMode(pasPerson, pPie->BackMode);
  1008. ODUseBrush(pasPerson, fPalRGB, pPie->BrushOrgX, pPie->BrushOrgY,
  1009. pPie->BrushStyle, pPie->BrushHatch, ForeColor, pPie->BrushExtra);
  1010. ODUseROP2(pasPerson, pPie->ROP2);
  1011. ODUsePen(pasPerson, fPalRGB, pPie->PenStyle, pPie->PenWidth,
  1012. PenColor);
  1013. ODUseArcDirection(pasPerson, (int)pPie->ArcDirection);
  1014. Pie(pasPerson->m_pView->m_usrDC,
  1015. pPie->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  1016. pPie->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  1017. pPie->nRightRect - pasPerson->m_pView->m_dsScreenOrigin.x + 1,
  1018. pPie->nBottomRect - pasPerson->m_pView->m_dsScreenOrigin.y + 1,
  1019. pPie->nXStart - pasPerson->m_pView->m_dsScreenOrigin.x,
  1020. pPie->nYStart - pasPerson->m_pView->m_dsScreenOrigin.y,
  1021. pPie->nXEnd - pasPerson->m_pView->m_dsScreenOrigin.x,
  1022. pPie->nYEnd - pasPerson->m_pView->m_dsScreenOrigin.y);
  1023. DebugExitVOID(ASShare::ODReplayPIE);
  1024. }
  1025. //
  1026. // ASShare::ODReplayELLIPSE()
  1027. // Replays ELLIPSE order
  1028. //
  1029. void ASShare::ODReplayELLIPSE
  1030. (
  1031. ASPerson * pasPerson,
  1032. LPELLIPSE_ORDER pEllipse,
  1033. BOOL fPalRGB
  1034. )
  1035. {
  1036. TSHR_COLOR BackColor;
  1037. TSHR_COLOR ForeColor;
  1038. TSHR_COLOR PenColor;
  1039. DebugEntry(ASShare::ODReplayELLIPSE);
  1040. TRACE_OUT(("ORDER: Ellipse BC %08lX FC %08lX BM %04hX brush %02hX %02hX "
  1041. "rop2 %04hX pen %04hX %04hX %08lX rect %d %d %d %d",
  1042. pEllipse->BackColor,
  1043. pEllipse->ForeColor,
  1044. (TSHR_UINT16)pEllipse->BackMode,
  1045. (TSHR_UINT16)pEllipse->BrushStyle,
  1046. (TSHR_UINT16)pEllipse->BrushHatch,
  1047. (TSHR_UINT16)pEllipse->ROP2,
  1048. (TSHR_UINT16)pEllipse->PenStyle,
  1049. (TSHR_UINT16)pEllipse->PenWidth,
  1050. pEllipse->PenColor,
  1051. (int)pEllipse->nLeftRect,
  1052. (int)pEllipse->nTopRect,
  1053. (int)pEllipse->nRightRect + 1,
  1054. (int)pEllipse->nBottomRect + 1));
  1055. ODAdjustColor(pasPerson, &(pEllipse->BackColor), &BackColor, OD_BACK_COLOR);
  1056. ODAdjustColor(pasPerson, &(pEllipse->ForeColor), &ForeColor, OD_FORE_COLOR);
  1057. ODAdjustColor(pasPerson, &(pEllipse->PenColor), &PenColor, OD_PEN_COLOR);
  1058. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1059. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  1060. ODUseBkMode(pasPerson, pEllipse->BackMode);
  1061. ODUseBrush(pasPerson, fPalRGB, pEllipse->BrushOrgX, pEllipse->BrushOrgY,
  1062. pEllipse->BrushStyle, pEllipse->BrushHatch, ForeColor,
  1063. pEllipse->BrushExtra);
  1064. ODUseROP2(pasPerson, pEllipse->ROP2);
  1065. ODUsePen(pasPerson, fPalRGB, pEllipse->PenStyle, pEllipse->PenWidth,
  1066. PenColor);
  1067. Ellipse(pasPerson->m_pView->m_usrDC,
  1068. pEllipse->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  1069. pEllipse->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  1070. pEllipse->nRightRect - pasPerson->m_pView->m_dsScreenOrigin.x + 1,
  1071. pEllipse->nBottomRect - pasPerson->m_pView->m_dsScreenOrigin.y + 1);
  1072. DebugExitVOID(ASShare::ODReplayELLIPSE);
  1073. }
  1074. //
  1075. // ASShare::ODReplayARC()
  1076. // Replays ARC order
  1077. //
  1078. void ASShare::ODReplayARC
  1079. (
  1080. ASPerson * pasPerson,
  1081. LPARC_ORDER pArc,
  1082. BOOL fPalRGB
  1083. )
  1084. {
  1085. TSHR_COLOR BackColor;
  1086. TSHR_COLOR PenColor;
  1087. DebugEntry(ASShare::ODReplayARC);
  1088. TRACE_OUT(("ORDER: Arc BC %08lX BM %04hX rop2 %04hX pen %04hX "
  1089. "%04hX %08lX rect %d %d %d %d",
  1090. pArc->BackColor,
  1091. (TSHR_UINT16)pArc->BackMode,
  1092. (TSHR_UINT16)pArc->ROP2,
  1093. (TSHR_UINT16)pArc->PenStyle,
  1094. (TSHR_UINT16)pArc->PenWidth,
  1095. pArc->PenColor,
  1096. (int)pArc->nLeftRect,
  1097. (int)pArc->nTopRect,
  1098. (int)pArc->nRightRect + 1,
  1099. (int)pArc->nBottomRect + 1));
  1100. ODAdjustColor(pasPerson, &(pArc->BackColor), &BackColor, OD_BACK_COLOR);
  1101. ODAdjustColor(pasPerson, &(pArc->PenColor), &PenColor, OD_PEN_COLOR);
  1102. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1103. ODUseBkMode(pasPerson, pArc->BackMode);
  1104. ODUseROP2(pasPerson, pArc->ROP2);
  1105. ODUsePen(pasPerson, fPalRGB, pArc->PenStyle, pArc->PenWidth,
  1106. PenColor);
  1107. ODUseArcDirection(pasPerson, pArc->ArcDirection);
  1108. Arc(pasPerson->m_pView->m_usrDC,
  1109. pArc->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  1110. pArc->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  1111. pArc->nRightRect - pasPerson->m_pView->m_dsScreenOrigin.x + 1,
  1112. pArc->nBottomRect - pasPerson->m_pView->m_dsScreenOrigin.y + 1,
  1113. pArc->nXStart - pasPerson->m_pView->m_dsScreenOrigin.x,
  1114. pArc->nYStart - pasPerson->m_pView->m_dsScreenOrigin.y,
  1115. pArc->nXEnd - pasPerson->m_pView->m_dsScreenOrigin.x,
  1116. pArc->nYEnd - pasPerson->m_pView->m_dsScreenOrigin.y);
  1117. DebugExitVOID(ASShare::ODReplayARC);
  1118. }
  1119. //
  1120. // ASShare::ODReplayCHORD()
  1121. // Replays CHORD order
  1122. //
  1123. void ASShare::ODReplayCHORD
  1124. (
  1125. ASPerson * pasPerson,
  1126. LPCHORD_ORDER pChord,
  1127. BOOL fPalRGB
  1128. )
  1129. {
  1130. TSHR_COLOR BackColor;
  1131. TSHR_COLOR ForeColor;
  1132. TSHR_COLOR PenColor;
  1133. DebugEntry(ASShare::ODReplayCHORD);
  1134. TRACE_OUT(("ORDER: Chord BC %08lX FC %08lX BM %04hX brush "
  1135. "%02hX %02hX rop2 %04hX pen %04hX %04hX %08lX rect "
  1136. "%d %d %d %d",
  1137. pChord->BackColor,
  1138. pChord->ForeColor,
  1139. (TSHR_UINT16)pChord->BackMode,
  1140. (TSHR_UINT16)pChord->BrushStyle,
  1141. (TSHR_UINT16)pChord->BrushHatch,
  1142. (TSHR_UINT16)pChord->ROP2,
  1143. (TSHR_UINT16)pChord->PenStyle,
  1144. (TSHR_UINT16)pChord->PenWidth,
  1145. pChord->PenColor,
  1146. (int)pChord->nLeftRect,
  1147. (int)pChord->nTopRect,
  1148. (int)pChord->nRightRect + 1,
  1149. (int)pChord->nBottomRect + 1));
  1150. ODAdjustColor(pasPerson, &(pChord->BackColor), &BackColor, OD_BACK_COLOR);
  1151. ODAdjustColor(pasPerson, &(pChord->ForeColor), &ForeColor, OD_FORE_COLOR);
  1152. ODAdjustColor(pasPerson, &(pChord->PenColor), &PenColor, OD_PEN_COLOR);
  1153. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1154. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  1155. ODUseBkMode(pasPerson, pChord->BackMode);
  1156. ODUseBrush(pasPerson, fPalRGB, pChord->BrushOrgX, pChord->BrushOrgY,
  1157. pChord->BrushStyle, pChord->BrushHatch, ForeColor,
  1158. pChord->BrushExtra);
  1159. ODUseROP2(pasPerson, pChord->ROP2);
  1160. ODUsePen(pasPerson, fPalRGB, pChord->PenStyle, pChord->PenWidth,
  1161. PenColor);
  1162. ODUseArcDirection(pasPerson, pChord->ArcDirection);
  1163. Chord(pasPerson->m_pView->m_usrDC,
  1164. pChord->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  1165. pChord->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  1166. pChord->nRightRect - pasPerson->m_pView->m_dsScreenOrigin.x + 1,
  1167. pChord->nBottomRect - pasPerson->m_pView->m_dsScreenOrigin.y + 1,
  1168. pChord->nXStart - pasPerson->m_pView->m_dsScreenOrigin.x,
  1169. pChord->nYStart - pasPerson->m_pView->m_dsScreenOrigin.y,
  1170. pChord->nXEnd - pasPerson->m_pView->m_dsScreenOrigin.x,
  1171. pChord->nYEnd - pasPerson->m_pView->m_dsScreenOrigin.y);
  1172. DebugExitVOID(ASShare::ODReplayCHORD);
  1173. }
  1174. //
  1175. // ASShare::ODReplayPOLYBEZIER()
  1176. // Replays POLYBEZIER order
  1177. //
  1178. void ASShare::ODReplayPOLYBEZIER
  1179. (
  1180. ASPerson * pasPerson,
  1181. LPPOLYBEZIER_ORDER pPolyBezier,
  1182. BOOL fPalRGB
  1183. )
  1184. {
  1185. POINT aP[ORD_MAX_POLYBEZIER_POINTS];
  1186. UINT i;
  1187. UINT cPoints;
  1188. TSHR_COLOR BackColor;
  1189. TSHR_COLOR ForeColor;
  1190. TSHR_COLOR PenColor;
  1191. DebugEntry(ASShare::ODReplayPOLYBEZIER);
  1192. cPoints = pPolyBezier->variablePoints.len /
  1193. sizeof(pPolyBezier->variablePoints.aPoints[0]);
  1194. TRACE_OUT(("ORDER: PolyBezier BC %08lX FC %08lX BM %04hX rop2 "
  1195. "%04hX pen %04hX %04hX %08lX points %d",
  1196. pPolyBezier->BackColor,
  1197. pPolyBezier->ForeColor,
  1198. (TSHR_UINT16)pPolyBezier->BackMode,
  1199. (TSHR_UINT16)pPolyBezier->ROP2,
  1200. (TSHR_UINT16)pPolyBezier->PenStyle,
  1201. (TSHR_UINT16)pPolyBezier->PenWidth,
  1202. pPolyBezier->PenColor,
  1203. (int)cPoints));
  1204. //
  1205. // Apply DS origin offset ourselves (do not use transform)
  1206. // while copying to native size point array.
  1207. //
  1208. for (i = 0; i < cPoints; i++)
  1209. {
  1210. TRACE_OUT(("aPoints[%u]: %d,%d",(UINT)i,
  1211. (int)(pPolyBezier->variablePoints.aPoints[i].x),
  1212. (int)(pPolyBezier->variablePoints.aPoints[i].y)));
  1213. aP[i].x = pPolyBezier->variablePoints.aPoints[i].x -
  1214. pasPerson->m_pView->m_dsScreenOrigin.x;
  1215. aP[i].y = pPolyBezier->variablePoints.aPoints[i].y -
  1216. pasPerson->m_pView->m_dsScreenOrigin.y;
  1217. }
  1218. ODAdjustColor(pasPerson, &(pPolyBezier->BackColor), &BackColor, OD_BACK_COLOR);
  1219. ODAdjustColor(pasPerson, &(pPolyBezier->ForeColor), &ForeColor, OD_FORE_COLOR);
  1220. ODAdjustColor(pasPerson, &(pPolyBezier->PenColor), &PenColor, OD_PEN_COLOR);
  1221. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1222. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  1223. ODUseBkMode(pasPerson, pPolyBezier->BackMode);
  1224. ODUseROP2(pasPerson, pPolyBezier->ROP2);
  1225. ODUsePen(pasPerson, fPalRGB, pPolyBezier->PenStyle, pPolyBezier->PenWidth,
  1226. PenColor);
  1227. PolyBezier(pasPerson->m_pView->m_usrDC, aP, cPoints);
  1228. DebugExitVOID(ASShare::ODReplayPOLYBEZIER);
  1229. }
  1230. //
  1231. // ASShare::ODReplayROUNDRECT()
  1232. //
  1233. void ASShare::ODReplayROUNDRECT
  1234. (
  1235. ASPerson * pasPerson,
  1236. LPROUNDRECT_ORDER pRoundRect,
  1237. BOOL fPalRGB
  1238. )
  1239. {
  1240. TSHR_COLOR BackColor;
  1241. TSHR_COLOR ForeColor;
  1242. TSHR_COLOR PenColor;
  1243. DebugEntry(ASShare::ODReplayROUNDRECT);
  1244. TRACE_OUT(("ORDER: RoundRect BC %08lX FC %08lX BM %04hX " \
  1245. "brush %02hX %02hX rop2 %04hX pen %04hX %04hX " \
  1246. "%08lX rect %d %d %d %d ellipse %d %d",
  1247. pRoundRect->BackColor,
  1248. pRoundRect->ForeColor,
  1249. (TSHR_UINT16)pRoundRect->BackMode,
  1250. (TSHR_UINT16)pRoundRect->BrushStyle,
  1251. (TSHR_UINT16)pRoundRect->BrushHatch,
  1252. (TSHR_UINT16)pRoundRect->ROP2,
  1253. (TSHR_UINT16)pRoundRect->PenStyle,
  1254. (TSHR_UINT16)pRoundRect->PenWidth,
  1255. pRoundRect->PenColor,
  1256. (int)pRoundRect->nLeftRect,
  1257. (int)pRoundRect->nTopRect,
  1258. (int)pRoundRect->nRightRect,
  1259. (int)pRoundRect->nBottomRect,
  1260. (int)pRoundRect->nEllipseWidth,
  1261. (int)pRoundRect->nEllipseHeight));
  1262. ODAdjustColor(pasPerson, &(pRoundRect->BackColor), &BackColor, OD_BACK_COLOR);
  1263. ODAdjustColor(pasPerson, &(pRoundRect->ForeColor), &ForeColor, OD_FORE_COLOR);
  1264. ODAdjustColor(pasPerson, &(pRoundRect->PenColor), &PenColor, OD_PEN_COLOR);
  1265. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1266. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  1267. ODUseBkMode(pasPerson, pRoundRect->BackMode);
  1268. ODUseBrush(pasPerson, fPalRGB, pRoundRect->BrushOrgX, pRoundRect->BrushOrgY,
  1269. pRoundRect->BrushStyle, pRoundRect->BrushHatch, ForeColor,
  1270. pRoundRect->BrushExtra);
  1271. ODUseROP2(pasPerson, pRoundRect->ROP2);
  1272. ODUsePen(pasPerson, fPalRGB, pRoundRect->PenStyle, pRoundRect->PenWidth,
  1273. PenColor);
  1274. //
  1275. // Apply DS origin offset ourselves (do not use transform).
  1276. //
  1277. RoundRect(pasPerson->m_pView->m_usrDC,
  1278. pRoundRect->nLeftRect - pasPerson->m_pView->m_dsScreenOrigin.x,
  1279. pRoundRect->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y,
  1280. pRoundRect->nRightRect - pasPerson->m_pView->m_dsScreenOrigin.x + 1,
  1281. pRoundRect->nBottomRect- pasPerson->m_pView->m_dsScreenOrigin.y + 1,
  1282. pRoundRect->nEllipseWidth,
  1283. pRoundRect->nEllipseHeight);
  1284. DebugExitVOID(ASShare::ODReplayROUNDRECT);
  1285. }
  1286. //
  1287. // ASShare::ODReplayLINETO()
  1288. // Replays LINETO order
  1289. //
  1290. void ASShare::ODReplayLINETO
  1291. (
  1292. ASPerson * pasPerson,
  1293. LPLINETO_ORDER pLineTo,
  1294. BOOL fPalRGB
  1295. )
  1296. {
  1297. TSHR_COLOR BackColor;
  1298. TSHR_COLOR PenColor;
  1299. DebugEntry(ASShare::ODReplayLINETO);
  1300. TRACE_OUT(("ORDER: LineTo BC %08lX BM %04X rop2 %04X pen " \
  1301. "%04X %04X %08lX x1 %d y1 %d x2 %d y2 %d",
  1302. pLineTo->BackColor,
  1303. pLineTo->BackMode,
  1304. pLineTo->ROP2,
  1305. pLineTo->PenStyle,
  1306. pLineTo->PenWidth,
  1307. pLineTo->PenColor,
  1308. pLineTo->nXStart,
  1309. pLineTo->nYStart,
  1310. pLineTo->nXEnd,
  1311. pLineTo->nYEnd));
  1312. ODAdjustColor(pasPerson, &(pLineTo->BackColor), &BackColor, OD_BACK_COLOR);
  1313. ODAdjustColor(pasPerson, &(pLineTo->PenColor), &PenColor, OD_PEN_COLOR);
  1314. ODUseBkColor(pasPerson, fPalRGB, BackColor);
  1315. ODUseBkMode(pasPerson, pLineTo->BackMode);
  1316. ODUseROP2(pasPerson, pLineTo->ROP2);
  1317. ODUsePen(pasPerson, fPalRGB, pLineTo->PenStyle, pLineTo->PenWidth,
  1318. PenColor);
  1319. //
  1320. // Apply DS origin offset ourselves (do not use transform)
  1321. //
  1322. MoveToEx(pasPerson->m_pView->m_usrDC,
  1323. pLineTo->nXStart - pasPerson->m_pView->m_dsScreenOrigin.x,
  1324. pLineTo->nYStart - pasPerson->m_pView->m_dsScreenOrigin.y,
  1325. NULL);
  1326. LineTo(pasPerson->m_pView->m_usrDC,
  1327. pLineTo->nXEnd - pasPerson->m_pView->m_dsScreenOrigin.x,
  1328. pLineTo->nYEnd - pasPerson->m_pView->m_dsScreenOrigin.y);
  1329. DebugExitVOID(ASShare::ODReplayLINETO);
  1330. }
  1331. //
  1332. // ASShare::ODReplayEXTTEXTOUT()
  1333. // Replays EXTTEXTOUT order
  1334. //
  1335. void ASShare::ODReplayEXTTEXTOUT
  1336. (
  1337. ASPerson * pasPerson,
  1338. LPEXTTEXTOUT_ORDER pExtTextOut,
  1339. BOOL fPalRGB
  1340. )
  1341. {
  1342. LPINT lpDx;
  1343. RECT rect;
  1344. DebugEntry(ASShare::ODReplayEXTTEXTOUT);
  1345. ValidateView(pasPerson);
  1346. //
  1347. // Convert from TSHR_RECT32 to RECT we can manipulate
  1348. // And convert to screen coords
  1349. //
  1350. rect.left = pExtTextOut->rectangle.left;
  1351. rect.top = pExtTextOut->rectangle.top;
  1352. rect.right = pExtTextOut->rectangle.right;
  1353. rect.bottom = pExtTextOut->rectangle.bottom;
  1354. OffsetRect(&rect, -pasPerson->m_pView->m_dsScreenOrigin.x, -pasPerson->m_pView->m_dsScreenOrigin.y);
  1355. //
  1356. // Get pointers to the optional/variable parameters.
  1357. //
  1358. if (pExtTextOut->fuOptions & ETO_WINDOWS)
  1359. {
  1360. //
  1361. // Make the rectangle exclusive for Windows to use.
  1362. //
  1363. rect.right++;
  1364. rect.bottom++;
  1365. }
  1366. if (pExtTextOut->fuOptions & ETO_LPDX)
  1367. {
  1368. //
  1369. // if OE2 encoding is in use, the 'variable' string is
  1370. // in fact fixed at its maximum possible value, hence
  1371. // deltaX is always in the same place.
  1372. //
  1373. if (m_oefOE2EncodingOn)
  1374. {
  1375. lpDx = (LPINT)(pExtTextOut->variableDeltaX.deltaX);
  1376. }
  1377. else
  1378. {
  1379. //
  1380. // If OE2 encoding is not in use, the variable string is
  1381. // truly variable, hence the position of deltaX depends
  1382. // on the length of the string.
  1383. //
  1384. lpDx = (LPINT)( ((LPBYTE)pExtTextOut) +
  1385. FIELD_OFFSET(EXTTEXTOUT_ORDER, variableString.string) +
  1386. pExtTextOut->variableString.len +
  1387. sizeof(pExtTextOut->variableDeltaX.len) );
  1388. }
  1389. //
  1390. // Note that deltaLen contains the number of bytes used
  1391. // for the deltas, NOT the number of deltas.
  1392. //
  1393. //
  1394. // THERE IS A BUG IN THE ORDER ENCODING - THE DELTA
  1395. // LENGTH FIELD IS NOT ALWAYS SET UP CORRECTLY. USE
  1396. // THE STRING LENGTH INSTEAD.
  1397. //
  1398. }
  1399. else
  1400. {
  1401. lpDx = NULL;
  1402. }
  1403. TRACE_OUT(( "ORDER: ExtTextOut %u %s",
  1404. pExtTextOut->variableString.len,
  1405. pExtTextOut->variableString.string));
  1406. //
  1407. // Call our internal routine to draw the text
  1408. //
  1409. ODDrawTextOrder(pasPerson,
  1410. TRUE, // ExtTextOut
  1411. fPalRGB,
  1412. &pExtTextOut->common,
  1413. pExtTextOut->variableString.string,
  1414. pExtTextOut->variableString.len,
  1415. &rect,
  1416. pExtTextOut->fuOptions,
  1417. lpDx);
  1418. DebugExitVOID(ASShare::ODReplayEXTTEXTOUT);
  1419. }
  1420. //
  1421. // ASShare::ODReplayTEXTOUT()
  1422. // Replays TEXTOUT order
  1423. //
  1424. void ASShare::ODReplayTEXTOUT
  1425. (
  1426. ASPerson * pasPerson,
  1427. LPTEXTOUT_ORDER pTextOut,
  1428. BOOL fPalRGB
  1429. )
  1430. {
  1431. DebugEntry(ASShare::ODReplayTEXTOUT);
  1432. TRACE_OUT(("ORDER: TextOut len %hu '%s' flags %04hx bc %08lX " \
  1433. "fc %08lX bm %04hx",
  1434. (TSHR_UINT16)(pTextOut->variableString.len),
  1435. pTextOut->variableString.string,
  1436. pTextOut->common.FontFlags,
  1437. pTextOut->common.BackColor,
  1438. pTextOut->common.ForeColor,
  1439. pTextOut->common.BackMode));
  1440. //
  1441. // Call our internal routine to draw the text
  1442. //
  1443. ODDrawTextOrder(pasPerson,
  1444. FALSE, // Not ExtTextOut
  1445. fPalRGB,
  1446. &pTextOut->common,
  1447. pTextOut->variableString.string,
  1448. pTextOut->variableString.len,
  1449. NULL, // ExtTextOut specific
  1450. 0, // ExtTextOut specific
  1451. NULL); // ExtTextOut specific
  1452. DebugExitVOID(ASShare::ODReplayTEXTOUT);
  1453. }
  1454. //
  1455. // ASShare::ODReplayOPAQUERECT()
  1456. // Replays OPAQUERECT order
  1457. //
  1458. void ASShare::ODReplayOPAQUERECT
  1459. (
  1460. ASPerson * pasPerson,
  1461. LPOPAQUERECT_ORDER pOpaqueRect,
  1462. BOOL fPalRGB
  1463. )
  1464. {
  1465. RECT rect;
  1466. TSHR_COLOR ForeColor;
  1467. DebugEntry(ASShare::ODReplayOPAQUERECT);
  1468. TRACE_OUT(( "ORDER: OpaqueRect BC %08lX x %d y %d w %x h %d",
  1469. pOpaqueRect->Color,
  1470. (int)pOpaqueRect->nLeftRect,
  1471. (int)pOpaqueRect->nTopRect,
  1472. (int)pOpaqueRect->nWidth,
  1473. (int)pOpaqueRect->nHeight));
  1474. ODAdjustColor(pasPerson, &(pOpaqueRect->Color), &ForeColor, OD_FORE_COLOR);
  1475. ODUseBkColor(pasPerson, fPalRGB, ForeColor);
  1476. //
  1477. // Apply DS origin offset ourselves (do not use transform)
  1478. //
  1479. rect.left = pOpaqueRect->nLeftRect- pasPerson->m_pView->m_dsScreenOrigin.x;
  1480. rect.top = pOpaqueRect->nTopRect - pasPerson->m_pView->m_dsScreenOrigin.y;
  1481. rect.right = rect.left + pOpaqueRect->nWidth;
  1482. rect.bottom = rect.top + pOpaqueRect->nHeight;
  1483. ExtTextOut(pasPerson->m_pView->m_usrDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
  1484. DebugExitVOID(ASShare::ODReplayOPAQUERECT);
  1485. }
  1486. //
  1487. // OD_ResetRectRegion()
  1488. //
  1489. void ASShare::OD_ResetRectRegion(ASPerson * pasPerson)
  1490. {
  1491. DebugEntry(ASShare::OD_ResetRectRegion);
  1492. ValidateView(pasPerson);
  1493. if (!pasPerson->m_pView->m_odRectReset)
  1494. {
  1495. SelectClipRgn(pasPerson->m_pView->m_usrDC, NULL);
  1496. //
  1497. // Indicate that the region is currently reset.
  1498. //
  1499. pasPerson->m_pView->m_odRectReset = TRUE;
  1500. }
  1501. DebugExitVOID(ASShare::OD_ResetRectRegion);
  1502. }
  1503. //
  1504. // ODUseFont()
  1505. //
  1506. void ASShare::ODUseFont
  1507. (
  1508. ASPerson * pasPerson,
  1509. LPSTR pName,
  1510. UINT facelength,
  1511. UINT CodePage,
  1512. UINT MaxHeight,
  1513. UINT Height,
  1514. UINT Width,
  1515. UINT Weight,
  1516. UINT flags
  1517. )
  1518. {
  1519. BOOL rc = TRUE;
  1520. TEXTMETRIC* pfm = NULL;
  1521. UINT textAlign;
  1522. DebugEntry(ASShare::ODUseFont);
  1523. ValidateView(pasPerson);
  1524. //
  1525. // If the baseline alignment flag has been set or cleared, change the
  1526. // alignment in our surface (do this now before we reset the
  1527. // odLastFontFlags variable).
  1528. //
  1529. if ((flags & NF_BASELINE) != (pasPerson->m_pView->m_odLastFontFlags & NF_BASELINE))
  1530. {
  1531. textAlign = GetTextAlign(pasPerson->m_pView->m_usrDC);
  1532. if ((flags & NF_BASELINE) != 0)
  1533. {
  1534. //
  1535. // We are setting the baseline alignment flag. We have to
  1536. // clear the top alignment flag and set the baseline flag (they
  1537. // are mutually exclusive).
  1538. //
  1539. textAlign &= ~TA_TOP;
  1540. textAlign |= TA_BASELINE;
  1541. }
  1542. else
  1543. {
  1544. //
  1545. // We are clearing the baseline alignment flag. We have to set
  1546. // the top alignment flag and clear the baseline flag (they are
  1547. // mutually exclusive).
  1548. //
  1549. textAlign |= TA_TOP;
  1550. textAlign &= ~TA_BASELINE;
  1551. }
  1552. SetTextAlign(pasPerson->m_pView->m_usrDC, textAlign);
  1553. }
  1554. //
  1555. // The font face string is NOT null terminated in the order data so we
  1556. // must use strncmp.
  1557. //
  1558. if ((pasPerson->m_pView->m_odLastFontFaceLen != facelength ) ||
  1559. (memcmp((LPSTR)pasPerson->m_pView->m_odLastFaceName,pName,facelength) != 0 ) ||
  1560. (pasPerson->m_pView->m_odLastFontCodePage != CodePage ) ||
  1561. (pasPerson->m_pView->m_odLastFontHeight != Height ) ||
  1562. (pasPerson->m_pView->m_odLastFontWidth != Width ) ||
  1563. (pasPerson->m_pView->m_odLastFontWeight != Weight ) ||
  1564. (pasPerson->m_pView->m_odLastFontFlags != flags ))
  1565. {
  1566. TRACE_OUT((
  1567. "Change font from %s (CodePage %d height %d width %d " \
  1568. "weight %d flags %04X) to %s (CodePage %d height %d " \
  1569. "width %d weight %u flags %04X)",
  1570. pasPerson->m_pView->m_odLastFaceName,
  1571. pasPerson->m_pView->m_odLastFontCodePage,
  1572. pasPerson->m_pView->m_odLastFontHeight,
  1573. pasPerson->m_pView->m_odLastFontWidth,
  1574. pasPerson->m_pView->m_odLastFontWeight,
  1575. pasPerson->m_pView->m_odLastFontFlags,
  1576. pName,
  1577. CodePage,
  1578. Height,
  1579. Width,
  1580. Weight,
  1581. flags));
  1582. memcpy(pasPerson->m_pView->m_odLastFaceName, pName, facelength);
  1583. pasPerson->m_pView->m_odLastFontFaceLen = facelength;
  1584. pasPerson->m_pView->m_odLastFaceName[facelength] = '\0';
  1585. pasPerson->m_pView->m_odLastFontCodePage = CodePage;
  1586. pasPerson->m_pView->m_odLastFontHeight = Height;
  1587. pasPerson->m_pView->m_odLastFontWidth = Width;
  1588. pasPerson->m_pView->m_odLastFontWeight = Weight;
  1589. pasPerson->m_pView->m_odLastFontFlags = flags;
  1590. rc = USR_UseFont(pasPerson->m_pView->m_usrDC, &pasPerson->m_pView->m_odLastFontID,
  1591. pfm, (LPSTR)pasPerson->m_pView->m_odLastFaceName, CodePage, MaxHeight,
  1592. Height, Width, Weight, flags);
  1593. }
  1594. else
  1595. {
  1596. //
  1597. // The font hasn't changed. But we must still select it in since
  1598. // both OD2 and OD code select in fonts.
  1599. //
  1600. ASSERT(pasPerson->m_pView->m_odLastFontID != NULL);
  1601. SelectFont(pasPerson->m_pView->m_usrDC, pasPerson->m_pView->m_odLastFontID);
  1602. }
  1603. DebugExitVOID(ASShare::ODUseFont);
  1604. }
  1605. //
  1606. // FUNCTION: ASShare::ODUseRectRegion
  1607. //
  1608. // DESCRIPTION:
  1609. //
  1610. // Set the clipping rectangle in the ScreenBitmap to the given rectangle.
  1611. // The values passed are inclusive.
  1612. //
  1613. // PARAMETERS:
  1614. //
  1615. void ASShare::ODUseRectRegion
  1616. (
  1617. ASPerson * pasPerson,
  1618. int left,
  1619. int top,
  1620. int right,
  1621. int bottom
  1622. )
  1623. {
  1624. POINT aPoints[2];
  1625. HRGN hrgnRect;
  1626. DebugEntry(ASShare::ODUseRectRegion);
  1627. ValidateView(pasPerson);
  1628. // Adjust for 2.x desktop scrolling
  1629. left -= pasPerson->m_pView->m_dsScreenOrigin.x;
  1630. top -= pasPerson->m_pView->m_dsScreenOrigin.y;
  1631. right -= pasPerson->m_pView->m_dsScreenOrigin.x;
  1632. bottom -= pasPerson->m_pView->m_dsScreenOrigin.y;
  1633. if ((pasPerson->m_pView->m_odRectReset) ||
  1634. (left != pasPerson->m_pView->m_odLastLeft) ||
  1635. (top != pasPerson->m_pView->m_odLastTop) ||
  1636. (right != pasPerson->m_pView->m_odLastRight) ||
  1637. (bottom != pasPerson->m_pView->m_odLastBottom))
  1638. {
  1639. //
  1640. // The region clip rectangle has changed, so we change the region
  1641. // in the screen bitmap DC.
  1642. //
  1643. aPoints[0].x = left;
  1644. aPoints[0].y = top;
  1645. aPoints[1].x = right;
  1646. aPoints[1].y = bottom;
  1647. //
  1648. // Windows requires that the coordinates are in DEVICE values for
  1649. // its SelectClipRgn call.
  1650. //
  1651. LPtoDP(pasPerson->m_pView->m_usrDC, aPoints, 2);
  1652. if ((left > right) || (top > bottom))
  1653. {
  1654. //
  1655. // We get this for SaveScreenBitmap orders. SFR5292
  1656. //
  1657. TRACE_OUT(( "Null bounds of region rect"));
  1658. hrgnRect = CreateRectRgn(0, 0, 0, 0);
  1659. }
  1660. else
  1661. {
  1662. // We must add one to right & bottom since coords were inclusive
  1663. hrgnRect = CreateRectRgn( aPoints[0].x,
  1664. aPoints[0].y,
  1665. aPoints[1].x+1,
  1666. aPoints[1].y+1);
  1667. }
  1668. SelectClipRgn(pasPerson->m_pView->m_usrDC, hrgnRect);
  1669. pasPerson->m_pView->m_odLastLeft = left;
  1670. pasPerson->m_pView->m_odLastTop = top;
  1671. pasPerson->m_pView->m_odLastRight = right;
  1672. pasPerson->m_pView->m_odLastBottom = bottom;
  1673. pasPerson->m_pView->m_odRectReset = FALSE;
  1674. if (hrgnRect != NULL)
  1675. {
  1676. DeleteRgn(hrgnRect);
  1677. }
  1678. }
  1679. DebugExitVOID(ASShare::ODUseRectRegion);
  1680. }
  1681. //
  1682. // ODUseBrush creates the correct brush to use. NB. We rely on
  1683. // UseTextColor and UseBKColor being called before this routine to set up
  1684. // pasPerson->m_pView->m_odLastTextColor and pasPerson->m_pView->m_odLastBkColor correctly.
  1685. //
  1686. void ASShare::ODUseBrush
  1687. (
  1688. ASPerson * pasPerson,
  1689. BOOL fPalRGB,
  1690. int x,
  1691. int y,
  1692. UINT Style,
  1693. UINT Hatch,
  1694. TSHR_COLOR Color,
  1695. BYTE Extra[7]
  1696. )
  1697. {
  1698. HBRUSH hBrushNew = NULL;
  1699. DebugEntry(ASShare::ODUseBrush);
  1700. // Reset the origin
  1701. if ((x != pasPerson->m_pView->m_odLastBrushOrgX) ||
  1702. (y != pasPerson->m_pView->m_odLastBrushOrgY))
  1703. {
  1704. SetBrushOrgEx(pasPerson->m_pView->m_usrDC, x, y, NULL);
  1705. // Update saved brush org
  1706. pasPerson->m_pView->m_odLastBrushOrgX = x;
  1707. pasPerson->m_pView->m_odLastBrushOrgY = y;
  1708. }
  1709. if ((Style != pasPerson->m_pView->m_odLastLogBrushStyle) ||
  1710. (Hatch != pasPerson->m_pView->m_odLastLogBrushHatch) ||
  1711. (memcmp(&Color, &pasPerson->m_pView->m_odLastLogBrushColor, sizeof(Color))) ||
  1712. (memcmp(Extra,pasPerson->m_pView->m_odLastLogBrushExtra,sizeof(pasPerson->m_pView->m_odLastLogBrushExtra))) ||
  1713. ((pasPerson->m_pView->m_odLastLogBrushStyle == BS_PATTERN) &&
  1714. ((pasPerson->m_pView->m_odLastTextColor != pasPerson->m_pView->m_odLastBrushTextColor) ||
  1715. (pasPerson->m_pView->m_odLastBkColor != pasPerson->m_pView->m_odLastBrushBkColor))))
  1716. {
  1717. pasPerson->m_pView->m_odLastLogBrushStyle = Style;
  1718. pasPerson->m_pView->m_odLastLogBrushHatch = Hatch;
  1719. pasPerson->m_pView->m_odLastLogBrushColor = Color;
  1720. memcpy(pasPerson->m_pView->m_odLastLogBrushExtra, Extra, sizeof(pasPerson->m_pView->m_odLastLogBrushExtra));
  1721. if (pasPerson->m_pView->m_odLastLogBrushStyle == BS_PATTERN)
  1722. {
  1723. //
  1724. // A pattern from a bitmap is required.
  1725. //
  1726. if (pasPerson->m_pView->m_odLastBrushPattern == NULL)
  1727. {
  1728. TRACE_OUT(( "Creating bitmap to use for brush setup"));
  1729. pasPerson->m_pView->m_odLastBrushPattern = CreateBitmap(8,8,1,1,NULL);
  1730. }
  1731. if (pasPerson->m_pView->m_odLastBrushPattern != NULL)
  1732. {
  1733. char lpBits[16];
  1734. //
  1735. // Place the bitmap bits into an array of bytes in the
  1736. // correct form for SetBitmapBits which uses 16 bits per
  1737. // scanline.
  1738. //
  1739. lpBits[14] = (char)Hatch;
  1740. lpBits[12] = Extra[0];
  1741. lpBits[10] = Extra[1];
  1742. lpBits[8] = Extra[2];
  1743. lpBits[6] = Extra[3];
  1744. lpBits[4] = Extra[4];
  1745. lpBits[2] = Extra[5];
  1746. lpBits[0] = Extra[6];
  1747. SetBitmapBits(pasPerson->m_pView->m_odLastBrushPattern,8*2,lpBits);
  1748. hBrushNew = CreatePatternBrush(pasPerson->m_pView->m_odLastBrushPattern);
  1749. if (hBrushNew == NULL)
  1750. {
  1751. ERROR_OUT(( "Failed to create pattern brush"));
  1752. }
  1753. else
  1754. {
  1755. pasPerson->m_pView->m_odLastBrushTextColor = pasPerson->m_pView->m_odLastTextColor;
  1756. pasPerson->m_pView->m_odLastBrushBkColor = pasPerson->m_pView->m_odLastBkColor;
  1757. }
  1758. }
  1759. }
  1760. else
  1761. {
  1762. LOGBRUSH logBrush;
  1763. logBrush.lbStyle = pasPerson->m_pView->m_odLastLogBrushStyle;
  1764. logBrush.lbHatch = pasPerson->m_pView->m_odLastLogBrushHatch;
  1765. logBrush.lbColor = ODCustomRGB(pasPerson->m_pView->m_odLastLogBrushColor.red,
  1766. pasPerson->m_pView->m_odLastLogBrushColor.green,
  1767. pasPerson->m_pView->m_odLastLogBrushColor.blue,
  1768. fPalRGB);
  1769. hBrushNew = CreateBrushIndirect(&logBrush);
  1770. }
  1771. if (hBrushNew == NULL)
  1772. {
  1773. ERROR_OUT(( "Failed to create brush"));
  1774. }
  1775. else
  1776. {
  1777. TRACE_OUT(( "Selecting new brush 0x%08x", hBrushNew));
  1778. DeleteBrush(SelectBrush(pasPerson->m_pView->m_usrDC, hBrushNew));
  1779. }
  1780. }
  1781. DebugExitVOID(ASShare::ODUseBrush);
  1782. }
  1783. //
  1784. // ODDrawTextOrder()
  1785. // Common text order playback code for EXTTEXTOUT and TEXTOUT
  1786. //
  1787. void ASShare::ODDrawTextOrder
  1788. (
  1789. ASPerson * pasPerson,
  1790. BOOL isExtTextOut,
  1791. BOOL fPalRGB,
  1792. LPCOMMON_TEXTORDER pCommon,
  1793. LPSTR pText,
  1794. UINT textLength,
  1795. LPRECT pExtRect,
  1796. UINT extOptions,
  1797. LPINT pExtDx
  1798. )
  1799. {
  1800. LPSTR faceName;
  1801. UINT faceNameLength;
  1802. UINT maxFontHeight;
  1803. TSHR_UINT16 nFontFlags;
  1804. TSHR_UINT16 nCodePage;
  1805. TSHR_COLOR BackColor;
  1806. TSHR_COLOR ForeColor;
  1807. DebugEntry(ASShare::ODDrawTextOrder);
  1808. ODAdjustColor(pasPerson, &(pCommon->BackColor), &BackColor, OD_BACK_COLOR);
  1809. ODAdjustColor(pasPerson, &(pCommon->ForeColor), &ForeColor, OD_FORE_COLOR);
  1810. ODUseTextBkColor(pasPerson, fPalRGB, BackColor);
  1811. ODUseTextColor(pasPerson, fPalRGB, ForeColor);
  1812. ODUseBkMode(pasPerson, pCommon->BackMode);
  1813. ODUseTextCharacterExtra(pasPerson, pCommon->CharExtra);
  1814. ODUseTextJustification(pasPerson, pCommon->BreakExtra, pCommon->BreakCount);
  1815. faceName = FH_GetFaceNameFromLocalHandle(pCommon->FontIndex,
  1816. &faceNameLength);
  1817. maxFontHeight = FH_GetMaxHeightFromLocalHandle(pCommon->FontIndex);
  1818. //
  1819. // Get the local font flags for the font, so that we can merge in any
  1820. // specific local flag information when setting up the font. The prime
  1821. // example of this is whether the local font we matched is TrueType or
  1822. // not, which information is not sent over the wire, but does need to
  1823. // be used when setting up the font - or else we may draw using a local
  1824. // fixed font of the same facename.
  1825. //
  1826. nFontFlags = (TSHR_UINT16)FH_GetFontFlagsFromLocalHandle(pCommon->FontIndex);
  1827. //
  1828. // Get the local CodePage for the font.
  1829. //
  1830. nCodePage = (TSHR_UINT16)FH_GetCodePageFromLocalHandle(pCommon->FontIndex);
  1831. ODUseFont(pasPerson, faceName, faceNameLength, nCodePage,
  1832. maxFontHeight, pCommon->FontHeight, pCommon->FontWidth,
  1833. pCommon->FontWeight, pCommon->FontFlags | (nFontFlags & NF_LOCAL));
  1834. //
  1835. // Make the call.
  1836. //
  1837. if (isExtTextOut)
  1838. {
  1839. //
  1840. // Apply DS origin offset ourselves (do not use transform)
  1841. //
  1842. ExtTextOut(pasPerson->m_pView->m_usrDC,
  1843. pCommon->nXStart - pasPerson->m_pView->m_dsScreenOrigin.x,
  1844. pCommon->nYStart - pasPerson->m_pView->m_dsScreenOrigin.y,
  1845. extOptions & ETO_WINDOWS,
  1846. pExtRect,
  1847. pText,
  1848. textLength,
  1849. pExtDx);
  1850. }
  1851. else
  1852. {
  1853. //
  1854. // Apply DS origin offset ourselves (do not use transform)
  1855. //
  1856. TextOut(pasPerson->m_pView->m_usrDC,
  1857. pCommon->nXStart - pasPerson->m_pView->m_dsScreenOrigin.x,
  1858. pCommon->nYStart - pasPerson->m_pView->m_dsScreenOrigin.y,
  1859. pText,
  1860. textLength);
  1861. }
  1862. DebugExitVOID(ASShare::ODDrawTextOrder);
  1863. }
  1864. //
  1865. // ODAdjustColor()
  1866. //
  1867. // Used for playback on 4bpp devices. We convert colors that are 'close'
  1868. // to VGA to their VGA equivalents.
  1869. //
  1870. // This function tries to find a close match in the VGA color set for a
  1871. // given input color. Close is defined as follows: each color element
  1872. // (red, green, blue) must be within 7 of the corresponding element in a
  1873. // VGA color, without wrapping. For example
  1874. //
  1875. // - 0xc7b8c6 is 'close' to 0xc0c0c0
  1876. //
  1877. // - 0xf8f8f8 is 'close' to 0xffffff
  1878. //
  1879. // - 0xff0102 is not 'close' to 0x000000, but is 'close' to 0xff0000
  1880. //
  1881. // Closeness is determined as follows:
  1882. //
  1883. // - for each entry in the table s_odVGAColors
  1884. // - ADD the addMask to the color
  1885. // - AND the result with the andMask
  1886. // - if the result equals the testMask, this VGA color is close match
  1887. //
  1888. // Think about it. It works.
  1889. //
  1890. //
  1891. void ASShare::ODAdjustColor
  1892. (
  1893. ASPerson * pasPerson,
  1894. const TSHR_COLOR * pColorIn,
  1895. LPTSHR_COLOR pColorOut,
  1896. int type
  1897. )
  1898. {
  1899. int i;
  1900. COLORREF color;
  1901. COLORREF work;
  1902. DebugEntry(ASShare::ODAdjustColor);
  1903. *pColorOut = *pColorIn;
  1904. if (g_usrScreenBPP > 4)
  1905. {
  1906. // Nothing to convert; bail out
  1907. DC_QUIT;
  1908. }
  1909. //
  1910. // Convert the color to a single integer
  1911. //
  1912. color = (pColorOut->red << 16) + (pColorOut->green << 8) + pColorOut->blue;
  1913. //
  1914. // See if this is the same as the last call of this type
  1915. //
  1916. if (color == pasPerson->m_pView->m_odLastVGAColor[type])
  1917. {
  1918. *pColorOut = pasPerson->m_pView->m_odLastVGAResult[type];
  1919. TRACE_OUT(("Same as last %s color",
  1920. (type == OD_BACK_COLOR ? "background" :
  1921. type == OD_FORE_COLOR ? "foreground" : "pen")));
  1922. DC_QUIT;
  1923. }
  1924. //
  1925. // Scan the table for a close match.
  1926. //
  1927. for (i = 0; i < 16; i++)
  1928. {
  1929. //
  1930. // Check for a close match. Don't bother to look for an exact
  1931. // match, as that is caught by this code. The trade off is between
  1932. // - an additional test and jump in non-exact cases
  1933. // - an 'add' and an 'and' in the exact case.
  1934. //
  1935. work = color;
  1936. work += s_odVGAColors[i].addMask;
  1937. work &= s_odVGAColors[i].andMask;
  1938. if (work == s_odVGAColors[i].testMask)
  1939. {
  1940. TRACE_OUT(( "%#6.6lx is close match for %#6.6lx (%s)",
  1941. s_odVGAColors[i].color, color,
  1942. type == OD_BACK_COLOR ? "background" :
  1943. type == OD_FORE_COLOR ? "foreground" : "pen"));
  1944. *pColorOut = s_odVGAColors[i].result;
  1945. break;
  1946. }
  1947. }
  1948. if (i == 16)
  1949. {
  1950. TRACE_OUT(( "No close VGA match found for %#6.6lx (%s)",
  1951. color,
  1952. type == OD_BACK_COLOR ? "background" :
  1953. type == OD_FORE_COLOR ? "foreground" : "pen"));
  1954. }
  1955. //
  1956. // Save the result for next time.
  1957. //
  1958. pasPerson->m_pView->m_odLastVGAColor[type] = color;
  1959. pasPerson->m_pView->m_odLastVGAResult[type] = *pColorOut;
  1960. DC_EXIT_POINT:
  1961. DebugExitVOID(ASShare::ODAdjustColor);
  1962. }
  1963. //
  1964. // LITTLE ASShare::ODUse() functions
  1965. //
  1966. //
  1967. // ASShare::ODUseTextBkColor()
  1968. //
  1969. void ASShare::ODUseTextBkColor
  1970. (
  1971. ASPerson * pasPerson,
  1972. BOOL fPalRGB,
  1973. TSHR_COLOR color
  1974. )
  1975. {
  1976. COLORREF rgb;
  1977. ValidateView(pasPerson);
  1978. rgb = ODCustomRGB(color.red, color.green, color.blue, fPalRGB);
  1979. SetBkColor(pasPerson->m_pView->m_usrDC, rgb);
  1980. // Update BK COLOR cache
  1981. pasPerson->m_pView->m_odLastBkColor = rgb;
  1982. }
  1983. //
  1984. // ASShare::ODUseBkColor()
  1985. //
  1986. void ASShare::ODUseBkColor
  1987. (
  1988. ASPerson * pasPerson,
  1989. BOOL fPalRGB,
  1990. TSHR_COLOR color
  1991. )
  1992. {
  1993. COLORREF rgb;
  1994. ValidateView(pasPerson);
  1995. rgb = ODCustomRGB(color.red, color.green, color.blue, fPalRGB);
  1996. if (rgb != pasPerson->m_pView->m_odLastBkColor)
  1997. {
  1998. SetBkColor(pasPerson->m_pView->m_usrDC, rgb);
  1999. // Update BK COLOR cache
  2000. pasPerson->m_pView->m_odLastBkColor = rgb;
  2001. }
  2002. }
  2003. //
  2004. // ASShare::ODUseTextColor()
  2005. //
  2006. void ASShare::ODUseTextColor
  2007. (
  2008. ASPerson * pasPerson,
  2009. BOOL fPalRGB,
  2010. TSHR_COLOR color
  2011. )
  2012. {
  2013. COLORREF rgb;
  2014. ValidateView(pasPerson);
  2015. rgb = ODCustomRGB(color.red, color.green, color.blue, fPalRGB);
  2016. if (rgb != pasPerson->m_pView->m_odLastTextColor)
  2017. {
  2018. SetTextColor(pasPerson->m_pView->m_usrDC, rgb);
  2019. // Update TEXT COLOR cache
  2020. pasPerson->m_pView->m_odLastTextColor = rgb;
  2021. }
  2022. }
  2023. //
  2024. // ASShare::ODUseBkMode()
  2025. //
  2026. void ASShare::ODUseBkMode(ASPerson * pasPerson, int mode)
  2027. {
  2028. if (mode != pasPerson->m_pView->m_odLastBkMode)
  2029. {
  2030. SetBkMode(pasPerson->m_pView->m_usrDC, mode);
  2031. // Update BK MODE cache
  2032. pasPerson->m_pView->m_odLastBkMode = mode;
  2033. }
  2034. }
  2035. //
  2036. // ASShare::ODUsePen()
  2037. //
  2038. void ASShare::ODUsePen
  2039. (
  2040. ASPerson * pasPerson,
  2041. BOOL fPalRGB,
  2042. UINT style,
  2043. UINT width,
  2044. TSHR_COLOR color
  2045. )
  2046. {
  2047. HPEN hPenNew;
  2048. COLORREF rgb;
  2049. ValidateView(pasPerson);
  2050. rgb = ODCustomRGB(color.red, color.green, color.blue, fPalRGB);
  2051. if ((style != pasPerson->m_pView->m_odLastPenStyle) ||
  2052. (rgb != pasPerson->m_pView->m_odLastPenColor) ||
  2053. (width != pasPerson->m_pView->m_odLastPenWidth))
  2054. {
  2055. hPenNew = CreatePen(style, width, rgb);
  2056. DeletePen(SelectPen(pasPerson->m_pView->m_usrDC, hPenNew));
  2057. // Update PEN cache
  2058. pasPerson->m_pView->m_odLastPenStyle = style;
  2059. pasPerson->m_pView->m_odLastPenColor = rgb;
  2060. pasPerson->m_pView->m_odLastPenWidth = width;
  2061. }
  2062. }
  2063. //
  2064. // ASShare::ODUseROP2()
  2065. //
  2066. void ASShare::ODUseROP2(ASPerson * pasPerson, int rop2)
  2067. {
  2068. if (rop2 != pasPerson->m_pView->m_odLastROP2)
  2069. {
  2070. SetROP2(pasPerson->m_pView->m_usrDC, rop2);
  2071. // Update ROP2 cache
  2072. pasPerson->m_pView->m_odLastROP2 = rop2;
  2073. }
  2074. }
  2075. //
  2076. // ASShare::ODUseTextCharacterExtra()
  2077. //
  2078. void ASShare::ODUseTextCharacterExtra(ASPerson * pasPerson, int extra)
  2079. {
  2080. if (extra != pasPerson->m_pView->m_odLastCharExtra)
  2081. {
  2082. SetTextCharacterExtra(pasPerson->m_pView->m_usrDC, extra);
  2083. // Update TEXT EXTRA cache
  2084. pasPerson->m_pView->m_odLastCharExtra = extra;
  2085. }
  2086. }
  2087. //
  2088. // ASShare::ODUseTextJustification()
  2089. //
  2090. void ASShare::ODUseTextJustification(ASPerson * pasPerson, int extra, int count)
  2091. {
  2092. if ((extra != pasPerson->m_pView->m_odLastJustExtra) ||
  2093. (count != pasPerson->m_pView->m_odLastJustCount))
  2094. {
  2095. SetTextJustification(pasPerson->m_pView->m_usrDC, extra, count);
  2096. // Update TEXT JUST cache
  2097. pasPerson->m_pView->m_odLastJustExtra = extra;
  2098. pasPerson->m_pView->m_odLastJustCount = count;
  2099. }
  2100. }
  2101. //
  2102. // ASShare::ODUseFillMode()
  2103. //
  2104. void ASShare::ODUseFillMode(ASPerson * pasPerson, UINT mode)
  2105. {
  2106. if (mode != pasPerson->m_pView->m_odLastFillMode)
  2107. {
  2108. SetPolyFillMode(pasPerson->m_pView->m_usrDC, (mode == ORD_FILLMODE_WINDING) ?
  2109. WINDING : ALTERNATE);
  2110. // Update FILL MODE cache
  2111. pasPerson->m_pView->m_odLastFillMode = mode;
  2112. }
  2113. }
  2114. //
  2115. // ASShare::ODUseArcDirection()
  2116. //
  2117. void ASShare::ODUseArcDirection(ASPerson * pasPerson, UINT dir)
  2118. {
  2119. if (dir != pasPerson->m_pView->m_odLastArcDirection)
  2120. {
  2121. SetArcDirection(pasPerson->m_pView->m_usrDC, (dir == ORD_ARC_CLOCKWISE) ?
  2122. AD_CLOCKWISE : AD_COUNTERCLOCKWISE);
  2123. // Update ARC DIR cache
  2124. pasPerson->m_pView->m_odLastArcDirection = dir;
  2125. }
  2126. }
  2127.