Subversion Repositories Kolibri OS

Rev

Rev 3232 | Rev 5565 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2011-2014. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 5164 $
  9.  
  10.  
  11. struct  BLITTER_BLOCK
  12.         xmin            dd ?
  13.         ymin            dd ?
  14.         xmax            dd ?
  15.         ymax            dd ?
  16. ends
  17.  
  18.  
  19. struct  BLITTER
  20.         dc              RECT
  21.         sc              RECT
  22.         dst_x           dd ?            ;  32
  23.         dst_y           dd ?            ;  36
  24.         src_x           dd ?            ;  40
  25.         src_y           dd ?            ;  44
  26.         w               dd ?            ;  48
  27.         h               dd ?            ;  52
  28.  
  29.         bitmap          dd ?            ;  56
  30.         stride          dd ?            ;  60
  31. ends
  32.  
  33.  
  34.  
  35. align 4
  36. block_clip:
  37. ;esi= clip RECT ptr
  38. ;edi= RECT ptr
  39. ;return code:
  40. ;eax= 0 - draw, 1 - don't draw
  41.  
  42.         push    ebx
  43.  
  44.         mov     eax, [edi+RECT.left]
  45.         mov     ebx, [edi+RECT.right]
  46.         mov     ecx, [esi+RECT.left]    ;clip.left
  47.         mov     edx, [esi+RECT.right]   ;clip.right
  48.  
  49.         cmp     eax, edx                ;left >= clip.right
  50.         jge     .fail
  51.  
  52.         cmp     ebx, ecx                ;right < clip.left
  53.         jl      .fail
  54.  
  55.         cmp     eax, ecx                ;left >= clip.left
  56.         jae     @F
  57.  
  58.         mov     eax, ecx
  59. @@:
  60.         mov     [edi+RECT.left], eax
  61.  
  62.         cmp     ebx, edx                ;right <= clip.right
  63.         jle     @f
  64.         mov     ebx, edx
  65. @@:
  66.         mov     [edi+RECT.right], ebx
  67.  
  68.         mov     eax, [edi+RECT.top]
  69.         mov     ebx, [edi+RECT.bottom]
  70.         mov     ecx, [esi+RECT.top]     ;clip.top
  71.         mov     edx, [esi+RECT.bottom]  ;clip.bottom
  72.  
  73.         cmp     eax, edx                ;top >= clip.bottom
  74.         jge     .fail
  75.  
  76.         cmp     ebx, ecx                ;bottom < clip.top
  77.         jl      .fail
  78.  
  79.         cmp     eax, ecx                ;top >= clip.top
  80.         jae     @F
  81.  
  82.         mov     eax, ecx
  83. @@:
  84.         mov     [edi+RECT.top], eax
  85.  
  86.         cmp     ebx, edx                ;bottom <= clip.bottom
  87.         jle     @f
  88.         mov     ebx, edx
  89. @@:
  90.         mov     [edi+RECT.bottom], ebx
  91.         pop     ebx
  92.         xor     eax, eax
  93.         ret
  94. .fail:
  95.         pop     ebx
  96.         mov     eax, 1
  97.         ret
  98.  
  99.  
  100. align 4
  101. blit_clip:
  102.  
  103. .sx0   equ 8
  104. .sy0   equ 12
  105. .sx1   equ 16
  106. .sy1   equ 20
  107.  
  108. .dx0   equ 24
  109. .dy0   equ 28
  110. .dx1   equ 32
  111. .dy1   equ 36
  112.  
  113.  
  114.         push    edi
  115.         push    esi
  116.         push    ebx
  117.         sub     esp, 40
  118.  
  119.         mov     ebx, ecx
  120.         mov     edx, [ecx+BLITTER.src_x]
  121.         mov     [esp+.sx0], edx
  122.         mov     eax, [ecx+BLITTER.src_y]
  123.         mov     [esp+.sy0], eax
  124.         add     edx, [ecx+BLITTER.w]
  125.         add     eax, [ecx+BLITTER.h]
  126.         mov     [esp+.sx1], edx
  127.         mov     [esp+.sy1], eax
  128.  
  129.         lea     edi, [esp+.sx0]
  130.         lea     esi, [ebx+BLITTER.sc]
  131.  
  132.         call    block_clip
  133.         test    eax, eax
  134.         mov     esi, 1
  135.         jnz     .done
  136.  
  137.         mov     edi, [esp+.sx0]
  138.         mov     edx, [ebx+BLITTER.dst_x]
  139.         add     edx, edi
  140.         sub     edx, [ebx+BLITTER.src_x]
  141.         mov     [esp+.dx0], edx
  142.  
  143.         mov     ecx, [esp+.sy0]
  144.         mov     eax, [ebx+BLITTER.dst_y]
  145.         add     eax, ecx
  146.         sub     eax, [ebx+BLITTER.src_y]
  147.         mov     [esp+.dy0], eax
  148.  
  149.         sub     edx, edi
  150.         add     edx, [esp+.sx1]
  151.         mov     [esp+.dx1], edx
  152.  
  153.         sub     eax, ecx
  154.         add     eax, [esp+.sy1]
  155.         mov     [esp+.dy1], eax
  156.  
  157.         lea     edi, [esp+.dx0]
  158.         lea     esi, [ebx+BLITTER.dc]
  159.         call    block_clip
  160.         test    eax, eax
  161.         mov     esi, 1
  162.         jnz     .done
  163.  
  164.         mov     edx, [esp+.dx0]
  165.         mov     eax, [esp+.dx1]
  166.         sub     eax, edx
  167.         mov     [ebx+BLITTER.w], eax
  168.  
  169.         mov     eax, [esp+.dy0]
  170.         mov     ecx, [esp+.dy1]
  171.         sub     ecx, eax
  172.         mov     [ebx+BLITTER.h], ecx
  173.  
  174.         mov     ecx, [ebx+BLITTER.src_x]
  175.         add     ecx, edx
  176.         sub     ecx, [ebx+BLITTER.dst_x]
  177.         mov     [ebx+BLITTER.src_x], ecx
  178.  
  179.         mov     ecx, [ebx+BLITTER.src_y]
  180.         add     ecx, eax
  181.         sub     ecx, [ebx+BLITTER.dst_y]
  182.         mov     [ebx+BLITTER.src_y], ecx
  183.         mov     [ebx+BLITTER.dst_x], edx
  184.         mov     [ebx+BLITTER.dst_y], eax
  185.         xor     esi, esi
  186. .done:
  187.         mov     eax, esi
  188.         add     esp, 40
  189.         pop     ebx
  190.         pop     esi
  191.         pop     edi
  192.  
  193.  
  194. purge .sx0
  195. purge .sy0
  196. purge .sx1
  197. purge .sy1
  198.  
  199. purge .dx0
  200. purge .dy0
  201. purge .dx1
  202. purge .dy1
  203.  
  204.         ret
  205.  
  206. align 4
  207. blit_32:
  208.  
  209. .x_y        equ  72
  210. .tmp_x_y    equ  76
  211.  
  212.  
  213.         push    ebp
  214.         push    edi
  215.         push    esi
  216.         push    ebx
  217.         sub     esp, 80
  218.  
  219.         mov     eax, [TASK_BASE]
  220.         mov     ebx, [eax-twdw + WDATA.box.width]
  221.         mov     edx, [eax-twdw + WDATA.box.height]
  222.         inc     ebx
  223.         inc     edx
  224.  
  225.         xor     eax, eax
  226.  
  227.         mov     [esp+BLITTER.dc.left], eax
  228.         mov     [esp+BLITTER.dc.top], eax
  229.         mov     [esp+BLITTER.dc.right], ebx
  230.         mov     [esp+BLITTER.dc.bottom], edx
  231.  
  232.         mov     [esp+BLITTER.sc.left], eax
  233.         mov     [esp+BLITTER.sc.top], eax
  234.         mov     eax, [ecx+24]
  235.  
  236.         mov     [esp+BLITTER.sc.right], eax
  237.         mov     eax, [ecx+28]
  238.  
  239.         mov     [esp+BLITTER.sc.bottom], eax
  240.  
  241.         mov     eax, [ecx]
  242.         mov     [esp+BLITTER.dst_x], eax
  243.         mov     eax, [ecx+4]
  244.         mov     [esp+BLITTER.dst_y], eax
  245.  
  246.         mov     eax, [ecx+16]
  247.         mov     [esp+BLITTER.src_x], eax
  248.         mov     eax, [ecx+20]
  249.         mov     [esp+BLITTER.src_y], eax
  250.         mov     eax, [ecx+8]
  251.         mov     [esp+BLITTER.w], eax
  252.         mov     eax, [ecx+12]
  253.         mov     [esp+BLITTER.h], eax
  254.  
  255.  
  256.         mov     eax, [ecx+32]
  257.         mov     [esp+56], eax
  258.         mov     eax, [ecx+36]
  259.         mov     [esp+60], eax
  260.  
  261.         mov     ecx, esp
  262.         call    blit_clip
  263.         test    eax, eax
  264.         jne     .done
  265.  
  266.         mov     eax, [TASK_BASE]
  267.  
  268.         mov     ebx, [esp+BLITTER.dst_x]
  269.         mov     ebp, [esp+BLITTER.dst_y]
  270.         add     ebx, [eax-twdw + WDATA.box.left]
  271.         add     ebp, [eax-twdw + WDATA.box.top]
  272.  
  273.         mov     ecx, ebx
  274.         shl     ecx, 16
  275.         mov     cx, bp
  276.         mov     [esp+.x_y], ecx
  277.  
  278.         mov     edi, ebp
  279.  
  280.         mov     edi, [BPSLine_calc_area+edi*4]
  281.         mov     ebp, [d_width_calc_area+ebp*4]
  282.  
  283.         add     ebp, ebx
  284.         add     ebp, [_WinMapAddress]
  285.  
  286.         mov     eax, [esp+BLITTER.src_y]
  287.         imul    eax, [esp+BLITTER.stride]
  288.         mov     esi, [esp+BLITTER.src_x]
  289.         lea     esi, [eax+esi*4]
  290.         add     esi, [esp+BLITTER.bitmap]
  291.  
  292.         mov     ecx, [esp+BLITTER.h]
  293.         mov     edx, [esp+BLITTER.w]
  294.  
  295.         test    ecx, ecx    ;FIXME check clipping
  296.         jz      .done
  297.  
  298.         test    edx, edx
  299.         jz      .done
  300.  
  301.         lea     edi, [edi+ebx*4]
  302.  
  303. ;        xchg bx, bx
  304.  
  305.         mov     ebx, [CURRENT_TASK]
  306.         mov     ecx, [esp+80]
  307.         shr     ecx, 4
  308.         and     ecx, 3
  309.  
  310.         jmp     dword [.tbl_32+ecx*4]
  311.  
  312. align 4
  313. .tbl_32 dd blit_copy_32
  314.         dd blit_copy_32_bgr
  315.         dd blit_trans_32
  316.         dd blit_trans_32_bgr
  317.  
  318. .done:
  319.         add     esp, 80
  320.         pop     ebx
  321.         pop     esi
  322.         pop     edi
  323.         pop     ebp
  324.         ret
  325.  
  326. align 4
  327. blit_copy_32_bgr:
  328.        mov      ebx, 1
  329.  
  330. align 4
  331. blit_copy_32:
  332.  
  333. .outer32:
  334.         mov     eax, [esp+.x_y]
  335.         mov     [esp+.tmp_x_y], eax
  336.         xor     ecx, ecx
  337. align 4
  338. .inner32:
  339.         cmp     [ebp+ecx], bl
  340.         jne     .skip
  341. ;--------------------------------------
  342.         mov     eax, [esi+ecx*4]
  343.  
  344. ; check for hardware cursor
  345.         cmp     [_display.select_cursor], select_cursor
  346.         je      @f
  347.         cmp     [_display.select_cursor], 0
  348.         jne     .no_mouseunder
  349. ;--------------------------------------
  350. align 4
  351. @@:
  352.         push    ecx
  353.         mov     ecx, [esp+4+.tmp_x_y]
  354.  
  355. ; check mouse area for putpixel
  356.         call    [_display.check_mouse]
  357.         pop     ecx
  358.  
  359. ;--------------------------------------
  360. align 4
  361. .no_mouseunder:
  362. ; store to real LFB
  363.         mov     [LFB_BASE+edi+ecx*4], eax
  364. ;--------------------------------------
  365. align 4
  366. .skip:
  367.         add     [esp+.tmp_x_y], dword 0x10000
  368.         inc     ecx
  369.         dec     edx
  370.         jnz     .inner32
  371.  
  372.         add     esi, [esp+BLITTER.stride]
  373.         add     edi, [_display.pitch]
  374.         add     ebp, [_display.width]
  375.         inc     dword [esp+.x_y]
  376.  
  377.         mov     edx, [esp+BLITTER.w]
  378.         dec     [esp+BLITTER.h]
  379.         jnz     .outer32
  380.  
  381.         jmp     blit_32.done
  382.  
  383.  
  384. align 4
  385. blit_trans_32_bgr:
  386.        mov  ebx, 1
  387.  
  388. align 4
  389. blit_trans_32:
  390.  
  391. .outer32:
  392.         mov     eax, [esp+.x_y]
  393.         mov     [esp+.tmp_x_y], eax
  394.         xor     ecx, ecx
  395.  
  396. align 4
  397. .inner32:
  398.  
  399.         cmp     [ebp+ecx], bl
  400.         jne     .skip
  401. ;--------------------------------------
  402.         mov     eax, [esi+ecx*4]
  403.         test    eax, 0xFF000000
  404.         jz      .skip
  405.  
  406. ; check for hardware cursor
  407.         cmp     [_display.select_cursor], select_cursor
  408.         je      @f
  409.         cmp     [_display.select_cursor], 0
  410.         jne     .no_mouseunder
  411. ;--------------------------------------
  412. align 4
  413. @@:
  414.         push    ecx
  415.  
  416.         mov     ecx, [esp+4+.tmp_x_y]
  417.  
  418. ; check mouse area for putpixel
  419.         call    [_display.check_mouse]
  420.         pop     ecx
  421. ;--------------------------------------
  422. align 4
  423. .no_mouseunder:
  424. ; store to real LFB
  425.         mov     [LFB_BASE+edi+ecx*4], eax
  426. ;--------------------------------------
  427. align 4
  428. .skip:
  429.         add     [esp+.tmp_x_y], dword 0x10000
  430.         inc     ecx
  431.         dec     edx
  432.         jnz     .inner32
  433.  
  434.         add     esi, [esp+BLITTER.stride]
  435.         add     edi, [_display.pitch]
  436.         add     ebp, [_display.width]
  437.         inc     dword [esp+.x_y]
  438.  
  439.         mov     edx, [esp+BLITTER.w]
  440.         dec     [esp+BLITTER.h]
  441.         jnz     .outer32
  442.  
  443.         jmp     blit_32.done
  444.