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.

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