Fresh IDE . Check-in [db0f4990ec]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:A small optimization of DrawSolidRect procedure.
Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:db0f4990ecc6b6689e0fa18622007cfcfad12887
User & Date: johnfound 2017-11-16 20:25:03
Context
2017-11-17
14:13
Some not finished fix of textcaret.asm; At least it does not crash. But needs some more simple and more elegant solution not based on timers. check-in: a312962919 user: johnfound tags: NoCanvasGUI
2017-11-16
20:25
A small optimization of DrawSolidRect procedure. check-in: db0f4990ec user: johnfound tags: NoCanvasGUI
20:19
Fixed bug in DrawSolidRect causing hanging of the application. check-in: 1714fae0d7 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/graphics/draw.asm.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
49
50
51
52
53
54
55




56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
module "Draw library"



proc DrawSolidRect, .pDstImage, .x, .y, .width, .height, .color
.drect RECT
.rect  RECT

begin
        pushad

        mov     esi, [.pDstImage]

        xor     eax, eax
        mov     ecx, [esi+TImage.wrapW]
................................................................................
        stdcall RectIntersect, ecx, ecx, edx
        jc      .finish

        stdcall LockImg, esi
        jc      .finish

; [.drect] contains the destination rectangle





        mov     edi, [.drect.top]
        add     edi, [esi+TImage.orgY]
        cmp     edi, [esi+TImage.wrapH]
        jb      @f
        sub     edi, [esi+TImage.wrapH]
@@:
        imul    edi, [esi+TImage.width]
        lea     edi, [4*edi]
        add     edi, [esi+TImage.pPixels]       ; the address of the starting line of the rectangle.

        mov     eax, [.drect.left]
        mov     edx, [.drect.right]

        add     eax, [esi+TImage.orgX]
        add     edx, [esi+TImage.orgX]
................................................................................

        mov     ecx, [.drect.bottom]
        add     ecx, [esi+TImage.orgY]
        cmp     ecx, [esi+TImage.wrapH]
        jb      @f
        sub     ecx, [esi+TImage.wrapH]
@@:
        imul    ecx, [esi+TImage.width]
        lea     ecx, [4*ecx]
        add     ecx, [esi+TImage.pPixels]       ; the address of the end of the rectangle.

        mov     edx, [esi+TImage.wrapH]
        imul    edx, [esi+TImage.width]
        lea     edx, [4*edx]
        add     edx, [esi+TImage.pPixels]       ; the address of the Y wrap

        stdcall __fix_color, [.color], regEAX

.loopY:

        mov     ebx, [.drect.right]      ; the end of the rect.
................................................................................
        cmovs   ebx, [esi+TImage.wrapW]

        mov     [edi+4*ebx], eax        ; fill the color, does not affect the flags.

        cmp     ebx, [.drect.left]
        jne     .loopX

        add     edi, [esi+TImage.width]
        add     edi, [esi+TImage.width]
        add     edi, [esi+TImage.width]
        add     edi, [esi+TImage.width]

        cmp     edi, edx
        jb      @f
        mov     edi, [esi+TImage.pPixels]
@@:
        cmp     edi, ecx
        jne     .loopY







>







 







>
>
>
>







|
<







 







|
<



|
<







 







|
<
<
<







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
..
87
88
89
90
91
92
93
94

95
96
97
98

99
100
101
102
103
104
105
...
109
110
111
112
113
114
115
116



117
118
119
120
121
122
123
module "Draw library"



proc DrawSolidRect, .pDstImage, .x, .y, .width, .height, .color
.drect RECT
.rect  RECT
.stepy dd ?
begin
        pushad

        mov     esi, [.pDstImage]

        xor     eax, eax
        mov     ecx, [esi+TImage.wrapW]
................................................................................
        stdcall RectIntersect, ecx, ecx, edx
        jc      .finish

        stdcall LockImg, esi
        jc      .finish

; [.drect] contains the destination rectangle

        mov     eax, [esi+TImage.width]
        shl     eax, 2
        mov     [.stepy], eax

        mov     edi, [.drect.top]
        add     edi, [esi+TImage.orgY]
        cmp     edi, [esi+TImage.wrapH]
        jb      @f
        sub     edi, [esi+TImage.wrapH]
@@:
        imul    edi, [.stepy]

        add     edi, [esi+TImage.pPixels]       ; the address of the starting line of the rectangle.

        mov     eax, [.drect.left]
        mov     edx, [.drect.right]

        add     eax, [esi+TImage.orgX]
        add     edx, [esi+TImage.orgX]
................................................................................

        mov     ecx, [.drect.bottom]
        add     ecx, [esi+TImage.orgY]
        cmp     ecx, [esi+TImage.wrapH]
        jb      @f
        sub     ecx, [esi+TImage.wrapH]
@@:
        imul    ecx, [.stepy]

        add     ecx, [esi+TImage.pPixels]       ; the address of the end of the rectangle.

        mov     edx, [esi+TImage.wrapH]
        imul    edx, [.stepy]

        add     edx, [esi+TImage.pPixels]       ; the address of the Y wrap

        stdcall __fix_color, [.color], regEAX

.loopY:

        mov     ebx, [.drect.right]      ; the end of the rect.
................................................................................
        cmovs   ebx, [esi+TImage.wrapW]

        mov     [edi+4*ebx], eax        ; fill the color, does not affect the flags.

        cmp     ebx, [.drect.left]
        jne     .loopX

        add     edi, [.stepy]




        cmp     edi, edx
        jb      @f
        mov     edi, [esi+TImage.pPixels]
@@:
        cmp     edi, ecx
        jne     .loopY