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.

806 lines
21 KiB

  1. ;===============================================================================
  2. ;
  3. ; $Workfile: I386BRUS.ASM $
  4. ;
  5. ; Contents:
  6. ; This file contains the assembly code for some of the brush realization.
  7. ;
  8. ; Copyright (c) 1996, Cirrus Logic, Inc.
  9. ;
  10. ; $Log: X:/log/laguna/nt35/displays/cl546x/i386/I386BRUS.ASM $
  11. ;
  12. ; Rev 1.11 29 Apr 1997 16:29:24 noelv
  13. ; Merged in new SWAT code.
  14. ; SWAT:
  15. ; SWAT: Rev 1.3 24 Apr 1997 10:46:06 frido
  16. ; SWAT: NT140b09 merge.
  17. ; SWAT:
  18. ; SWAT: Rev 1.2 19 Apr 1997 16:31:40 frido
  19. ; SWAT: Added automatic include file dependencies for BUILD.EXE.
  20. ;
  21. ; Rev 1.10 08 Apr 1997 11:45:06 einkauf
  22. ;
  23. ; add call to SYNC_W_3D for MCD coordination
  24. ;
  25. ; Rev 1.9 22 Aug 1996 18:15:10 noelv
  26. ; Frido bug fix release 8-22.
  27. ;
  28. ; Rev 1.2 22 Aug 1996 19:11:14 frido
  29. ; #1308 - Added extra checks for empty cache slots.
  30. ;
  31. ; Rev 1.1 18 Aug 1996 15:19:52 frido
  32. ; #nbr - Added brush translation.
  33. ;
  34. ; Rev 1.0 14 Aug 1996 17:14:34 frido
  35. ; Initial revision.
  36. ;
  37. ; Rev 1.7 10 Apr 1996 13:39:20 NOELV
  38. ; Frido release 27
  39. ;
  40. ; Rev 1.11 08 Apr 1996 16:48:00 frido
  41. ; Added new check for 32-bpp brushes.
  42. ;
  43. ; Rev 1.10 01 Apr 1996 13:57:44 frido
  44. ; Added check for valid brush cache.
  45. ;
  46. ; Rev 1.9 30 Mar 1996 22:01:22 frido
  47. ; Refined check for invalid translation flags.
  48. ;
  49. ; Rev 1.8 27 Mar 1996 13:04:58 frido
  50. ; Removed 32-bpp colored brushes.
  51. ; Added check for undocumented translation flags.
  52. ; Masked 16-bit colors.
  53. ;
  54. ; Rev 1.7 04 Mar 1996 23:47:54 frido
  55. ; Removed bug in realization of dithered brush.
  56. ;
  57. ; Rev 1.6 29 Feb 1996 20:20:38 frido
  58. ; Fixed bug in 16-bpp brush realization.
  59. ;
  60. ; Rev 1.5 28 Feb 1996 22:40:08 frido
  61. ; Added Optimize.h.
  62. ;
  63. ; Rev 1.4 19 Feb 1996 07:23:02 frido
  64. ; Added comments.
  65. ; Added assembly version of CacheMono and CacheDither.
  66. ;
  67. ; Rev 1.3 17 Feb 1996 21:46:16 frido
  68. ; Revamped brushing algorithmn.
  69. ;
  70. ; Rev 1.2 13 Feb 1996 16:51:52 frido
  71. ; Changed the layout of the PDEV structure.
  72. ; Changed the layout of all brush caches.
  73. ; Changed the number of brush caches.
  74. ;
  75. ; Rev 1.1 10 Feb 1996 21:51:12 frido
  76. ; Split monochrome and colored translation cache.
  77. ; Added debugging macro.
  78. ; Fixed a bug that caused dithered brush never to be cached.
  79. ;
  80. ; Rev 1.0 08 Feb 1996 00:14:40 frido
  81. ; First release.
  82. ;
  83. ;===============================================================================
  84. .386
  85. .MODEL FLAT, STDCALL
  86. OPTION PROLOGUE:None
  87. OPTION EPILOGUE:None
  88. .NOLIST
  89. INCLUDE i386\Macros.inc
  90. INCLUDE i386\WinNT.inc
  91. INCLUDE i386\Laguna.inc
  92. INCLUDE Optimize.h
  93. COMMENT ! ;automatic include file dependencies for BUILD.EXE
  94. #include "i386\Macros.inc"
  95. #include "i386\WinNT.inc"
  96. #include "i386\Laguna.inc"
  97. #include "Optimize.h"
  98. !
  99. .LIST
  100. IF USE_ASM
  101. .DATA
  102. EXTERN Swiz :BYTE
  103. .CODE
  104. ;
  105. ; Function prototypes.
  106. ;
  107. vDitherColor PROTO PROC,
  108. rgb :ULONG,
  109. pul :PTR ULONG
  110. CacheBrush PROTO PROC,
  111. ppdev :PTR PDEV,
  112. pRbrush :PTR RBRUSH
  113. Cache4BPP PROTO PROC,
  114. ppdev :PTR PDEV,
  115. pRbrush :PTR RBRUSH
  116. IF 1 ;#nbr
  117. i386RealizeBrush PROTO PROC,
  118. pbo :PTR BRUSHOBJ,
  119. psoTarget :PTR SURFOBJ,
  120. psoPattern :PTR SURFOBJ,
  121. psoMask :PTR SURFOBJ,
  122. pxlo :PTR XLATEOBJ,
  123. iHatch :ULONG
  124. ENDIF
  125. ifdef WINNT_VER40
  126. Sync_w_3d_proc PROTO PROC,
  127. ppdev :PTR PDEV
  128. endif
  129. ;
  130. ; Stack frame for DrvRealizeBrush.
  131. ;
  132. espPTR = 0
  133. frmPTR = 0
  134. pbo_ TEXTEQU <DWORD PTR [esp + 4 + espPTR]>
  135. psoTarget_ TEXTEQU <DWORD PTR [esp + 8 + espPTR]>
  136. psoPattern_ TEXTEQU <DWORD PTR [esp + 12 + espPTR]>
  137. psoMask_ TEXTEQU <DWORD PTR [esp + 16 + espPTR]>
  138. pxlo_ TEXTEQU <DWORD PTR [esp + 20 + espPTR]>
  139. iHatch_ TEXTEQU <DWORD PTR [esp + 24 + espPTR]>
  140. DrvRealizeBrush PROC PUBLIC,
  141. pbo :PTR BRUSHOBJ,
  142. psoTarget :PTR SURFOBJ,
  143. psoPattern :PTR SURFOBJ,
  144. psoMask :PTR SURFOBJ,
  145. pxlo :PTR XLATEOBJ,
  146. iHatch :ULONG
  147. mov eax, [psoTarget_] ;EAX holds pointer to destination
  148. ASSUME eax:PTR SURFOBJ
  149. push_ esi
  150. push_ edi
  151. or eax, eax ;any destination?
  152. push_ ebx
  153. push_ ebp
  154. mov esi, [psoPattern_] ;ESI holds pointer to psoPattern
  155. ASSUME esi:PTR SURFOBJ
  156. jz Error ;error: we don't have a target
  157. mov ebx, [eax].dhpdev ;get handle to PDEV
  158. ASSUME ebx:PTR PDEV
  159. mov ebp, [iHatch_] ;get iHatch value
  160. test ebx, ebx
  161. jz Error ;error: we don't have a valid handle
  162. cmp [ebx].Bcache, 0 ;do we have a valid brush cache?
  163. je Error ;nope
  164. ifdef WINNT_VER40
  165. ;SYNC_W_3D macro equivalent
  166. cmp [ebx].NumMCDContexts, 0 ; is MCD alive?
  167. jle Sync_end ; no
  168. push eax ; save
  169. push ebx ; save
  170. push ebx ; input to Sync_w_3d_proc
  171. call Sync_w_3d_proc
  172. pop ebx ; restore
  173. pop eax ; restore
  174. Sync_end:
  175. endif
  176. IF RB_DITHERCOLOR EQ 80000000h
  177. or ebp, ebp ;must we realize a dither?
  178. js RealizeDither ;yes, go do it now
  179. ELSE
  180. test ebp, RB_DITHERCOLOR ;must we realize a dither?
  181. jnz RealizeDither ;yes, go do it now
  182. ENDIF
  183. mov ecx, [psoMask_]
  184. mov eax, [pxlo_]
  185. ASSUME eax:PTR XLATEOBJ
  186. cmp [esi].sizlBitmap._cx, 8 ;we only handle 8x8 patterns
  187. jne Error
  188. cmp [esi].sizlBitmap._cy, 8
  189. jne Error
  190. or ecx, ecx ;psoMask equals NULL?
  191. jnz Error ;no, we don't support masks
  192. cmp [esi].iType, STYPE_BITMAP
  193. jne Error ;we only handle normal bitmaps
  194. mov ecx, [esi].iBitmapFormat
  195. xor ebp, ebp ;zero pointer to translation table
  196. ;//frido BEGIN 07-Apr-96
  197. cmp ecx, BMF_1BPP ;monochrome pattern?
  198. je @F ;yes, supported
  199. cmp [ebx].iBitmapFormat, BMF_32BPP
  200. ;32-bpp mode?
  201. je Error ;yes, brushes are broken in chip
  202. @@: test eax, eax
  203. jz @F
  204. ;//frido END 07-Apr-96
  205. test [eax].flXlate, XO_TRIVIAL
  206. jnz @F
  207. mov ebp, [eax].pulXlate ;get pointer from XLATEOBJ
  208. test [eax].flXlate, XO_TABLE
  209. jnz @F ;we have a translation table
  210. INVOKE XLATEOBJ_piVector, ;get a pointer to the translation table
  211. eax
  212. mov ecx, [esi].iBitmapFormat
  213. mov ebp, eax
  214. ;//frido BEGIN 30-Mar-96
  215. @@: mov eax, [pxlo_]
  216. cmp ecx, BMF_4BPP ;test for 1- or 4-bpp pattern
  217. jb RealizeMono ;realize monochrome pattern
  218. je Realize4bpp ;realize 4-bpp pattern
  219. test eax, eax ;XLATEOBJ specified?
  220. jz @F ;no
  221. IF 1 ;#nbr
  222. test [eax].flXlate, XO_TRIVIAL
  223. ;trivial translation?
  224. jz ChainC ;no, chain to "C" code
  225. ELSE
  226. test [eax].flXlate, 10h ;invalid translation flags?
  227. jnz Error ;yes
  228. ENDIF
  229. @@: cmp ecx, BMF_24BPP ;get number of bytes in pattern
  230. ;//frido END 30-Mar-96
  231. mov edi, [esi].cjBits
  232. jne @F
  233. add edi, 64
  234. @@: cmp ecx, [ebx].iBitmapFormat;must be same as device format
  235. jne Error
  236. or ebp, ebp ;we don't support translation
  237. jnz Error
  238. lea eax, [SIZEOF(RBRUSH) + edi]
  239. mov edx, [pbo_] ;allocate the brush
  240. INVOKE BRUSHOBJ_pvAllocRbrush,
  241. edx,
  242. eax
  243. ASSUME eax:PTR RBRUSH
  244. test eax, eax
  245. jz Error ;error allocating the brush
  246. mov ecx, [esi].iBitmapFormat
  247. mov [eax].nPatSize, edi ;initialize the brush structure
  248. mov [eax].iBitmapFormat, ecx
  249. mov [eax].cjMask, 0
  250. mov [eax].iType, BRUSH_COLOR
  251. mov edx, [esi].lDelta ;get lDelta from pattern
  252. mov esi, [esi].pvScan0 ;get pointer to first scan line
  253. ASSUME esi:NOTHING
  254. lea edi, [eax].ajPattern ;get pointer to Rbrush->ajPattern
  255. mov ebp, 8 ;8 lines
  256. cmp ecx, BMF_16BPP ;dispatch brush realization
  257. jb Realize8bpp
  258. je Realize16bpp
  259. cmp ecx, BMF_24BPP
  260. je Realize24bpp
  261. ;-------------------------------------------------------------------------------
  262. ; Realize32bpp - Realize a 32-bpp brush.
  263. ;
  264. ; On entry: EDX lDelta.
  265. ; ESI Pointer to source pattern.
  266. ; EDI Pointer to destination brush.
  267. ; EBP Number of lines to copy.
  268. ;-------------------------------------------------------------------------------
  269. Realize32bpp:
  270. push eax ;store arguments for CacheBrush
  271. push ebx
  272. @@: mov eax, [esi + 0] ;copy line
  273. mov ebx, [esi + 4]
  274. mov [edi + 0], eax
  275. mov [edi + 4], ebx
  276. mov eax, [esi + 8]
  277. mov ebx, [esi + 12]
  278. mov [edi + 8], eax
  279. mov [edi + 12], ebx
  280. mov eax, [esi + 16]
  281. mov ebx, [esi + 20]
  282. mov [edi + 16], eax
  283. mov [edi + 20], ebx
  284. mov eax, [esi + 24]
  285. mov ebx, [esi + 28]
  286. mov [edi + 24], eax
  287. mov [edi + 28], ebx
  288. add esi, edx ;next line
  289. add edi, 32
  290. dec ebp
  291. jnz @B
  292. call CacheBrush ;cache the brush
  293. pop ebp
  294. pop ebx
  295. pop edi
  296. pop esi
  297. ret 24
  298. ;-------------------------------------------------------------------------------
  299. ; Realize24bpp - Realize a 24-bpp brush.
  300. ;
  301. ; On entry: EDX lDelta.
  302. ; ESI Pointer to source pattern.
  303. ; EDI Pointer to destination brush.
  304. ; EBP Number of lines to copy.
  305. ;-------------------------------------------------------------------------------
  306. Realize24bpp:
  307. push eax ;store arguments for CacheBrush
  308. push ebx
  309. @@: mov eax, [esi + 0] ;copy line
  310. mov ebx, [esi + 4]
  311. mov [edi + 0], eax
  312. mov [edi + 4], ebx
  313. mov eax, [esi + 8]
  314. mov ebx, [esi + 12]
  315. mov [edi + 8], eax
  316. mov [edi + 12], ebx
  317. mov eax, [esi + 16]
  318. mov ebx, [esi + 20]
  319. mov [edi + 16], eax
  320. mov [edi + 20], ebx
  321. mov eax, [esi + 0]
  322. mov ebx, [esi + 4]
  323. mov [edi + 24], eax
  324. mov [edi + 28], ebx
  325. add esi, edx ;next line
  326. add edi, 32
  327. dec ebp
  328. jnz @B
  329. call CacheBrush ;cache the brush
  330. pop ebp
  331. pop ebx
  332. pop edi
  333. pop esi
  334. ret 24
  335. ;-------------------------------------------------------------------------------
  336. ; Realize16bpp - Realize a 16-bpp brush.
  337. ;
  338. ; On entry: EDX lDelta.
  339. ; ESI Pointer to source pattern.
  340. ; EDI Pointer to destination brush.
  341. ; EBP Number of lines to copy.
  342. ;-------------------------------------------------------------------------------
  343. Realize16bpp:
  344. push eax ;store arguments for CacheBrush
  345. push ebx
  346. @@: mov eax, [esi + 0] ;copy line
  347. mov ebx, [esi + 4]
  348. mov [edi + 0], eax
  349. mov [edi + 4], ebx
  350. mov eax, [esi + 8]
  351. mov ebx, [esi + 12]
  352. mov [edi + 8], eax
  353. mov [edi + 12], ebx
  354. add esi, edx ;next line
  355. add edi, 16
  356. dec ebp
  357. jnz @B
  358. call CacheBrush ;cache the brush
  359. pop ebp
  360. pop ebx
  361. pop edi
  362. pop esi
  363. ret 24
  364. ;-------------------------------------------------------------------------------
  365. ; Realize8bpp - Realize an 8-bpp brush.
  366. ;
  367. ; On entry: EDX lDelta.
  368. ; ESI Pointer to source pattern.
  369. ; EDI Pointer to destination brush.
  370. ; EBP Number of lines to copy.
  371. ;-------------------------------------------------------------------------------
  372. Realize8bpp:
  373. push eax ;store arguments for CacheBrush
  374. push ebx
  375. @@: mov eax, [esi + 0] ;copy line
  376. mov ebx, [esi + 4]
  377. mov [edi + 0], eax
  378. mov [edi + 4], ebx
  379. add esi, edx ;next line
  380. add edi, 8
  381. dec ebp
  382. jnz @B
  383. call CacheBrush ;cache the brush
  384. pop ebp
  385. pop ebx
  386. pop edi
  387. pop esi
  388. ret 24
  389. ;-------------------------------------------------------------------------------
  390. ; RealizeDither - Realize a dithered brush.
  391. ;
  392. ; Dithered brushes are only used in 8-bpp modes and are cached off-screen. The
  393. ; dither cache consists of a small table containing the off-screen location for
  394. ; each cache slot entry and a color value that is cached in that entry. When-
  395. ; ever we have to realize a dither, we first lookup the color in the cache
  396. ; table. If the color is found, we just load the brush with the cache parameters
  397. ; and return TRUE. Otherwise, we allocate a new cache slot and call the
  398. ; dithering routine which will create the dither directly in off-screen memory.
  399. ;
  400. ; On entry: EBX Pointer to PDEV.
  401. ; EBP Logical RGB color in lower three bytes.
  402. ;-------------------------------------------------------------------------------
  403. RealizeDither:
  404. mov eax, [pbo_] ;allocate the brush
  405. ASSUME ebx:PTR PDEV
  406. INVOKE BRUSHOBJ_pvAllocRbrush,
  407. eax,
  408. SIZEOF(RBRUSH)
  409. ASSUME eax:PTR RBRUSH
  410. or eax, eax
  411. jz Error ;error
  412. and ebp, 00FFFFFFh ;mask RGB color
  413. mov edx, -SIZEOF(PDEV).Dtable
  414. mov [eax].nPatSize, 0 ;initialize brush structure
  415. mov [eax].iBitmapFormat, BMF_8BPP
  416. mov [eax].cjMask, 0
  417. mov [eax].iType, BRUSH_DITHER
  418. mov [eax].iUniq, ebp
  419. @@: cmp [ebx].Dtable[edx + SIZEOF(PDEV).Dtable].ulColor, ebp
  420. ;lookup color in Dtable
  421. jne NextDither ;we still don't have a match
  422. lea ebp, [edx + SIZEOF(PDEV).Dtable]
  423. ;get index into cache table
  424. mov esi, [ebx].Dtable[edx + SIZEOF(PDEV).Dtable].xy
  425. mov [eax].cache_slot, ebp ;brush is cached
  426. mov [eax].cache_xy, esi
  427. pop ebp
  428. pop ebx
  429. pop edi
  430. pop esi
  431. mov eax, 1 ;return TRUE
  432. ret 24
  433. NextDither:
  434. add edx, SIZEOF(DC_ENTRY) ;next cache slot
  435. jnz @B
  436. ;
  437. ; Cache the new dither.
  438. ;
  439. mov edx, [ebx].DNext ;get the index of the next cache slot
  440. mov ecx, edx
  441. and edx, NUM_DITHER_BRUSHES - 1
  442. inc ecx ;increment cache slot
  443. imul edx, SIZEOF(DC_ENTRY) ;build cache table index
  444. mov [ebx].DNext, ecx
  445. mov [eax].cache_slot, edx ;store cache slot index
  446. mov [ebx].Dtable[edx].ulColor, ebp
  447. ;store logical color in cache table
  448. mov esi, [ebx].Dtable[edx].xy
  449. ;copy the x/y location of brush
  450. mov edi, [ebx].Dtable[edx].pjLinear
  451. ;get linear address
  452. mov [eax].cache_xy, esi
  453. INVOKE vDitherColor, ;dither the color
  454. ebp,
  455. edi
  456. pop ebp
  457. pop ebx
  458. pop edi
  459. pop esi
  460. mov eax, 1 ;return TRUE
  461. ret 24
  462. ;-------------------------------------------------------------------------------
  463. ; Realize4bpp - Realize a 4-bpp brush.
  464. ;
  465. ; The 4-bpp cache consists of a small table containing the off-screen
  466. ; location for each cache slot entry, an 32-byte pattern, and a 16-color palette
  467. ; that is cached in that entry. Whenever we have to realize a 4-bpp brush, we
  468. ; first lookup the pattern and color palette in the cache table. If the pattern
  469. ; is found, we just load the brush with the cache parameters and return TRUE.
  470. ; Otherwise, we allocate a new cache slot and store the pattern and palette in
  471. ; the cache slot and translate the 4-bpp pattern in off-screen memory.
  472. ;
  473. ; On entry: EAX Pointer to XLATEOBJ.
  474. ; EBX Pointer to PDEV.
  475. ; ESI Pointer to psoPattern.
  476. ; EBP Pointer to translation table.
  477. ;-------------------------------------------------------------------------------
  478. Realize4bpp:
  479. ASSUME eax:PTR XLATEOBJ
  480. ASSUME ebx:PTR PDEV
  481. ASSUME esi:PTR SURFOBJ
  482. or ebp, ebp ;we must have a valid translation table
  483. jz Error
  484. cmp [eax].cEntries, 16 ;we only support 16 entries in the
  485. jne Error ; palette
  486. cmp [esi].cjBits, 32 ;we only support 32 bytes in the pattern
  487. jne Error
  488. mov edx, [pbo_] ;allocate the brush
  489. INVOKE BRUSHOBJ_pvAllocRbrush,
  490. edx,
  491. SIZEOF(RBRUSH) + 32 + 64
  492. ASSUME eax:PTR RBRUSH
  493. test eax, eax
  494. jz Error ;error allocating brush
  495. mov [eax].nPatSize, 32 + 64 ;initialize brush structure
  496. mov [eax].iBitmapFormat, BMF_4BPP
  497. lea edi, [eax].ajPattern
  498. mov [eax].cjMask, 0
  499. mov [eax].iType, BRUSH_4BPP
  500. cmp [esi].lDelta, -4 ;test for negative increment
  501. mov esi, [esi].pvScan0 ;get pointer to first scan line
  502. ASSUME esi:NOTHING
  503. jne Forward ;we have forward increment
  504. mov ecx, [esi - 0] ;copy the pattern from top to bottom
  505. mov edx, [esi - 4]
  506. mov [edi + 0], ecx
  507. mov [edi + 4], edx
  508. mov ecx, [esi - 8]
  509. mov edx, [esi - 12]
  510. mov [edi + 8], ecx
  511. mov [edi + 12], edx
  512. mov ecx, [esi - 16]
  513. mov edx, [esi - 20]
  514. mov [edi + 16], ecx
  515. mov [edi + 20], edx
  516. mov ecx, [esi - 24]
  517. mov edx, [esi - 28]
  518. mov [edi + 24], ecx
  519. mov [edi + 28], edx
  520. jmp CopyPalette
  521. Forward:
  522. mov ecx, [esi + 0] ;copy the pattern from top to bottom
  523. mov edx, [esi + 4]
  524. mov [edi + 0], ecx
  525. mov [edi + 4], edx
  526. mov ecx, [esi + 8]
  527. mov edx, [esi + 12]
  528. mov [edi + 8], ecx
  529. mov [edi + 12], edx
  530. mov ecx, [esi + 16]
  531. mov edx, [esi + 20]
  532. mov [edi + 16], ecx
  533. mov [edi + 20], edx
  534. mov ecx, [esi + 24]
  535. mov edx, [esi + 28]
  536. mov [edi + 24], ecx
  537. mov [edi + 28], edx
  538. CopyPalette:
  539. mov esi, ebp ;copy the palette into the brush
  540. add edi, 32
  541. mov ecx, 16
  542. mov ebp, -SIZEOF(PDEV).Xtable
  543. cld
  544. rep movsd
  545. @@: lea esi, [ebx].Xtable[ebp + SIZEOF(PDEV).Xtable].ajPattern
  546. lea edi, [eax].ajPattern ;check if the pattern and palette match
  547. mov ecx, 8 + 16
  548. repe cmpsd
  549. jne NextXlate ;we still don't have a match
  550. IF 1 ;#1308
  551. cmp [ebx].Xtable[ebp + SIZEOF(PDEV).Xtable].iUniq, 0
  552. je NextXlate
  553. ENDIF
  554. mov ecx, [ebx].Xtable[ebp + SIZEOF(PDEV).Xtable].xy
  555. ;copy the cached parameters
  556. mov ebx, [ebx].Xtable[ebp + SIZEOF(PDEV).Xtable].iUniq
  557. add ebp, SIZEOF(PDEV).Xtable
  558. mov [eax].iUniq, ebx
  559. mov [eax].cache_slot, ebp
  560. mov [eax].cache_xy, ecx
  561. pop ebp
  562. pop ebx
  563. pop edi
  564. pop esi
  565. mov eax, 1 ;return TRUE
  566. ret 24
  567. NextXlate:
  568. add ebp, SIZEOF(XC_ENTRY)
  569. jnz @B
  570. INVOKE Cache4BPP,
  571. ebx,
  572. eax
  573. pop ebp
  574. pop ebx
  575. pop edi
  576. pop esi
  577. ret 24
  578. Error:
  579. pop ebp
  580. pop ebx
  581. pop edi
  582. pop esi
  583. xor eax, eax ;return FALSE
  584. ret 24
  585. IF 1 ;#nbr
  586. ChainC:
  587. pop ebp
  588. pop ebx
  589. pop edi
  590. pop esi
  591. jmp i386RealizeBrush
  592. ENDIF
  593. ;-------------------------------------------------------------------------------
  594. ; RealizeMono - Realize a monochrome brush.
  595. ;
  596. ; The monochrome cache consists of a small table containing the off-screen
  597. ; location for each cache slot entry and an 8-byte pattern that is cached in
  598. ; that entry. Whenever we have to realize a monochrome brush, we first lookup
  599. ; the pattern in the cache table. If the pattern is found, we just load the
  600. ; brush with the cache parameters and return TRUE. Otherwise, we allocate a new
  601. ; cache slot and store the monochrome pattern in the cache slot and into off-
  602. ; screen memory.
  603. ;
  604. ; On entry: EBX Pointer to PDEV.
  605. ; ESI Pointer to psoPattern.
  606. ; EBP Pointer to translation table.
  607. ;-------------------------------------------------------------------------------
  608. RealizeMono:
  609. ASSUME ebx:PTR PDEV
  610. ASSUME esi:PTR SURFOBJ
  611. or ebp, ebp ;we must have a translation table
  612. jz Error
  613. mov edx, [pbo_] ;allocate the brush
  614. INVOKE BRUSHOBJ_pvAllocRbrush,
  615. edx,
  616. SIZEOF(RBRUSH) + 8
  617. ASSUME eax:PTR RBRUSH
  618. or eax, eax
  619. jz Error ;error
  620. mov [eax].nPatSize, 8 ;initialize the brush structure
  621. mov [eax].iBitmapFormat, BMF_1BPP
  622. mov [eax].cjMask, 0
  623. mov [eax].iType, BRUSH_MONO
  624. mov ecx, [ebp + 0] ;get the background color
  625. mov edx, [ebp + 4] ;get the foreground color
  626. cmp [ebx].iBytesPerPixel, 2 ;expand the colors
  627. ja XlateNone
  628. je @F
  629. mov ch, cl ;expand 8-bpp into 16-bit
  630. mov dh, dl
  631. @@: mov ebp, ecx ;expand 16-bpp into 32-bit
  632. mov edi, edx
  633. ;//frido BEGIN 27-Mar-96
  634. and ebp, 0000FFFFh ;mask 16-bits
  635. and edi, 0000FFFFh
  636. ;//frido END 27-Mar-96
  637. shl ecx, 16
  638. shl edx, 16
  639. or ecx, ebp
  640. or edx, edi
  641. XlateNone:
  642. mov [eax].ulBackColor, ecx ;store the background color
  643. mov [eax].ulForeColor, edx ;store the foreground color
  644. cmp [esi].lDelta, 4 ;test lDelta
  645. mov esi, [esi].pvScan0 ;get pointer to first scan line
  646. je mForward
  647. mov cl, [esi - 8] ;copy pattern into ECX/EDX bottom up
  648. mov ch, [esi - 12]
  649. mov dl, [esi - 24]
  650. mov dh, [esi - 28]
  651. shl ecx, 16
  652. mov ebp, -SIZEOF(PDEV).Mtable
  653. shl edx, 16
  654. mov cl, [esi - 0]
  655. mov ch, [esi - 4]
  656. mov dl, [esi - 16]
  657. mov dh, [esi - 20]
  658. jmp @F
  659. mForward:
  660. mov cl, [esi + 8] ;copy pattern into ECX/EDX bottom down
  661. mov ch, [esi + 12]
  662. mov dl, [esi + 24]
  663. mov dh, [esi + 28]
  664. shl ecx, 16
  665. mov ebp, -SIZEOF(PDEV).Mtable
  666. shl edx, 16
  667. mov cl, [esi + 0]
  668. mov ch, [esi + 4]
  669. mov dl, [esi + 16]
  670. mov dh, [esi + 20]
  671. @@: mov DWORD PTR [eax].ajPattern[0], ecx
  672. ;store pattern in brush
  673. mov DWORD PTR [eax].ajPattern[4], edx
  674. mPTR TEXTEQU <ebp + SIZEOF(PDEV).Mtable>
  675. @@: cmp DWORD PTR [ebx].Mtable[mPTR].ajPattern[0], ecx
  676. ;lookup pattern in cache table
  677. jne NextMono
  678. cmp DWORD PTR [ebx].Mtable[mPTR].ajPattern[4], edx
  679. jne NextMono
  680. IF 1 ;#1308
  681. cmp [ebx].Mtable[mPTR].iUniq, 0
  682. je NextMono
  683. ENDIF
  684. mov ecx, [ebx].Mtable[mPTR].xy
  685. ;copy the cached parameters
  686. mov ebx, [ebx].Mtable[mPTR].iUniq
  687. add ebp, SIZEOF(PDEV).Mtable
  688. mov [eax].iUniq, ebx
  689. mov [eax].cache_slot, ebp
  690. mov [eax].cache_xy, ecx
  691. pop ebp
  692. pop ebx
  693. pop edi
  694. pop esi
  695. mov eax, 1 ;return TRUE
  696. ret 24
  697. NextMono:
  698. add ebp, SIZEOF(MC_ENTRY) ;next table entry
  699. jnz @B
  700. ;
  701. ; Cache the new brush.
  702. ;
  703. mov edi, [ebx].MNext ;get the next monochrome cache slot
  704. mov esi, edi
  705. and edi, NUM_MONO_BRUSHES - 1
  706. inc esi ;increment slot number
  707. imul edi, SIZEOF(MC_ENTRY) ;build index into cache table
  708. mov [ebx].MNext, esi ;stor new slot number
  709. mov [eax].iUniq, esi ;store unique value
  710. mov [eax].cache_slot, edi ;store index into cache table
  711. mov [ebx].Mtable[edi].iUniq, esi
  712. ;store unique value in cache table
  713. mov DWORD PTR [ebx].Mtable[edi].ajPattern[0], ecx
  714. ;store pattern in cache table
  715. mov DWORD PTR [ebx].Mtable[edi].ajPattern[4], edx
  716. mov esi, [ebx].Mtable[edi].xy
  717. ;copy x/y location of brush
  718. mov edi, [ebx].Mtable[edi].pjLinear
  719. mov [eax].cache_xy, esi
  720. xor eax, eax ;copy the swizzled bits to off-screen
  721. xor ebx, ebx
  722. mov al, cl
  723. mov bl, ch
  724. shr ecx, 16
  725. mov al, [Swiz + eax]
  726. mov bl, [Swiz + ebx]
  727. mov [edi + 0], al
  728. mov [edi + 1], bl
  729. mov al, cl
  730. mov bl, ch
  731. mov al, [Swiz + eax]
  732. mov bl, [Swiz + ebx]
  733. mov [edi + 2], al
  734. mov [edi + 3], bl
  735. mov al, dl
  736. mov bl, dh
  737. shr edx, 16
  738. mov al, [Swiz + eax]
  739. mov bl, [Swiz + ebx]
  740. mov [edi + 4], al
  741. mov [edi + 5], bl
  742. mov al, dl
  743. mov bl, dh
  744. mov al, [Swiz + eax]
  745. mov bl, [Swiz + ebx]
  746. mov [edi + 6], al
  747. mov [edi + 7], bl
  748. pop ebp
  749. pop ebx
  750. pop edi
  751. pop esi
  752. mov eax, 1 ;return TRUE
  753. ret 24
  754. DrvRealizeBrush ENDP
  755. ENDIF ; USE_ASM
  756. END