Fresh IDE . Check-in [2d46744055]
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:Preventing set wrapW/wrapH to zero. More compact DrawImageRect procedure for Linux.
Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:2d46744055affc37877f290363795f753da9bb20
User & Date: johnfound 2017-11-15 10:40:42
Context
2017-11-15
13:26
Removed unnecessary call of XFlush and XFlushGC. check-in: cc61b3e780 user: johnfound tags: NoCanvasGUI
10:40
Preventing set wrapW/wrapH to zero. More compact DrawImageRect procedure for Linux. check-in: 2d46744055 user: johnfound tags: NoCanvasGUI
2017-11-14
18:08
Fixed bug in Win32 GetTextBounds - not handling length of -1 normally. check-in: 1ec5c6a094 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/graphics/Linux/images.asm.

209
210
211
212
213
214
215
216
217


218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
...
288
289
290
291
292
293
294


295
296
297
298
299
300
301
302
303
304
305
306



307

308
309
310
311
312
313
314

315
316
317

318
319


320
321

322
323
324
325
326
327
328
329

330
331
332
333
334

335
336


337
338
339
340
341
342
343


344
345
346
347
348

349
350
351
352
353

354
355













356

357
358












359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
.maskLR RECT ; lower right

.sRect  RECT ; the rectangle used for intersecting the source rectangle.

.event XEvent
       rb 256

.cnt_events dd ?
.gc         dd ?



begin
        pushad

        mov     esi, [.pImage]
        test    esi, esi
        jz      .finish

;        OutputValue "Destination rect X:", [.xDst], 10, -1
;        OutputValue "                 Y:", [.yDst], 10, -1
;        OutputValue "                 W:", [.width], 10, -1
;        OutputValue "                 H:", [.height], 10, -1

        stdcall LockImg, esi
        jc      .finish

        xor     eax, eax








        cmp     [esi+TLinuxImage.ximage], eax
        je      .exit

        mov     ecx, [esi+TImage.wrapW]
        mov     edx, [esi+TImage.wrapH]

        mov     [.cnt_events], eax              ; the events awaited.

        mov     [.maskUL.left], eax     ; UL
        mov     [.maskUL.top], eax      ; UL
        mov     [.maskLL.left], eax             ; LL
        mov     [.maskUR.top], eax                      ; UR

        mov     [.maskUL.right], ecx    ; UL
        mov     [.maskUL.bottom], edx   ; UL
................................................................................
        add     ecx, [.width]
        add     edx, [.height]
        mov     [.sRect.right], ecx
        mov     [.sRect.bottom], edx

        lea     eax, [.sRect]
        lea     edx, [.maskUL]
        stdcall RectIntersect, eax, eax, edx
        jc      .exit

; at least some part of the image, has to be drawn.

        cinvoke XCreateGC, [hApplicationDisplay], [.where], 0, 0
        mov     [.gc], eax

................................................................................
        add     [.sRect.left], ebx
        add     [.sRect.top], edx
        add     [.sRect.right], ebx
        add     [.sRect.bottom], edx

        mov     ebx, [esi+TImage.wrapW]
        mov     edx, [esi+TImage.wrapH]


        lea     ecx, [.sRect]

        lea     eax, [.maskUL]
        stdcall RectIntersect2, eax, ecx
        jc      .upper_left_ok

;        DebugMsg "Upper-left"
        call    .DoDraw

.upper_left_ok:
        lea     eax, [.maskUR]
        stdcall RectIntersect2, eax, ecx



        jc      .upper_right_ok


        sub     [.maskUR.left], ebx
        sub     [.maskUR.right], ebx

        mov     edi, [.maskUL.right]    ; width of maskUL or 0
        sub     edi, [.maskUL.left]
        add     [.xDst], edi


;        DebugMsg "Upper-right"
        call    .DoDraw


        sub     [.xDst], edi



.upper_right_ok:

        lea     eax, [.maskLL]
        stdcall RectIntersect, eax, eax, ecx
        jc      .lower_left_ok

        sub     [.maskLL.top], edx
        sub     [.maskLL.bottom], edx

        mov     edi, [.maskUR.bottom]

        sub     edi, [.maskUR.top]
        add     [.yDst], edi

;        DebugMsg "Lower-left"
        call    .DoDraw


        sub     [.yDst], edi



.lower_left_ok:
        lea     eax, [.maskLR]
        stdcall RectIntersect, eax, eax, ecx
        jc      .lower_right_ok

        sub     [.maskLR.left], ebx


        sub     [.maskLR.top], edx
        sub     [.maskLR.right], ebx
        sub     [.maskLR.bottom], edx

        mov     edi, [.maskUL.right]

        sub     edi, [.maskUL.left]
        add     [.xDst], edi
        mov     edi, [.maskUR.bottom]
        sub     edi, [.maskUR.top]
        add     [.yDst], edi


;        DebugMsg "Lower-right"













        call    .DoDraw


.lower_right_ok:













; now, wait for the events:
        cinvoke XFlushGC, [hApplicationDisplay], [.gc]
        cinvoke XFlush, [hApplicationDisplay]

.event_wait:
        dec     [.cnt_events]
        js      .events_ok

        lea     eax, [.event]
        cinvoke XIfEvent, [hApplicationDisplay], eax, ___CheckCompletionEvent, eax
        jmp     .event_wait

.events_ok:

        cinvoke XFreeGC, [hApplicationDisplay], [.gc]

.exit:
        stdcall UnlockImg, esi

.finish:
        popad
        return


; Draws the rectangle pointed by EAX, on POINT

.DoDraw:
        pushad

        mov     ecx, XPutImage

        cmp     [flagSharedMemory], 0
        je      .drawit

        mov     ecx, XShmPutImage
        inc     [.cnt_events]

.drawit:
        mov     ebx, [eax+RECT.bottom]
        mov     edx, [eax+RECT.right]
        sub     ebx, [eax+RECT.top]
        sub     edx, [eax+RECT.left]

;        OutputValue "Drawit source X:", [eax+RECT.left], 10, -1
;        OutputValue "              Y:", [eax+RECT.top], 10, -1
;        OutputValue "  destination X:", [.xDst], 10, -1
;        OutputValue "              Y:", [.yDst], 10, -1
;        OutputValue "              W:", edx, 10, -1
;        OutputValue "              H:", ebx, 10, -1

        push    TRUE
        push    ebx                             ; .height
        push    edx                             ; .width
        push    [.yDst]                         ; .yDst
        push    [.xDst]                         ; .xDst
        push    [eax+RECT.top]                  ; .ySrc
        push    [eax+RECT.left]                 ; .xSrc
        push    [esi+TLinuxImage.ximage]        ; .ximage
        push    [.gc]                           ; .context
        push    [.where]                        ; .drawable
        push    [hApplicationDisplay]           ; .display

        call    dword [ecx]
        add     esp, 11*4

        popad
        retn

endp







<

>
>








<
<
<
<
<




>
>
>
>
>
>
>







<
<







 







|







 







>
>


|
<
<

|
<

<
<
|
>
>
>
|
>

|
|

<
|
|
>

<
|
>

<
>
>

<
>
|
<
|

<
|

<
>
|
|

|
|
>

<
>
>

<
<
|
<

<
>
>
|
|
<

|
>
|
|
|
|
|
>

<
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>

<
>
>
>
>
>
>
>
>
>
>
>
>





<
<
<
<


<












<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

209
210
211
212
213
214
215

216
217
218
219
220
221
222
223
224
225
226





227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244


245
246
247
248
249
250
251
...
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
...
289
290
291
292
293
294
295
296
297
298
299
300


301
302

303


304
305
306
307
308
309
310
311
312
313

314
315
316
317

318
319
320

321
322
323

324
325

326
327

328
329

330
331
332
333
334
335
336
337

338
339
340


341

342

343
344
345
346

347
348
349
350
351
352
353
354
355
356

357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372

373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389




390
391

392
393
394
395
396
397
398
399
400
401
402
403













































404
.maskLR RECT ; lower right

.sRect  RECT ; the rectangle used for intersecting the source rectangle.

.event XEvent
       rb 256


.gc         dd ?
.draw_proc  dd ?
.fDraw   rd 1

begin
        pushad

        mov     esi, [.pImage]
        test    esi, esi
        jz      .finish






        stdcall LockImg, esi
        jc      .finish

        xor     eax, eax

        cmp     [flagSharedMemory], eax
        cmovz   edx, [XPutImage]
        cmovnz  edx, [XShmPutImage]
        mov     [.draw_proc], edx

        mov     [.fDraw], eax

        cmp     [esi+TLinuxImage.ximage], eax
        je      .exit

        mov     ecx, [esi+TImage.wrapW]
        mov     edx, [esi+TImage.wrapH]



        mov     [.maskUL.left], eax     ; UL
        mov     [.maskUL.top], eax      ; UL
        mov     [.maskLL.left], eax             ; LL
        mov     [.maskUR.top], eax                      ; UR

        mov     [.maskUL.right], ecx    ; UL
        mov     [.maskUL.bottom], edx   ; UL
................................................................................
        add     ecx, [.width]
        add     edx, [.height]
        mov     [.sRect.right], ecx
        mov     [.sRect.bottom], edx

        lea     eax, [.sRect]
        lea     edx, [.maskUL]
        stdcall RectIntersect2, eax, edx
        jc      .exit

; at least some part of the image, has to be drawn.

        cinvoke XCreateGC, [hApplicationDisplay], [.where], 0, 0
        mov     [.gc], eax

................................................................................
        add     [.sRect.left], ebx
        add     [.sRect.top], edx
        add     [.sRect.right], ebx
        add     [.sRect.bottom], edx

        mov     ebx, [esi+TImage.wrapW]
        mov     edx, [esi+TImage.wrapH]

        lea     edi, [.maskUL]
        lea     ecx, [.sRect]

        mov     eax, 3



.loop_rect:




        stdcall RectIntersect2, edi, ecx
        cmc
        rcl     [.fDraw], 1

        test    eax, 1  ; horizontal
        jnz     .h_ok

        sub     [edi+RECT.left], ebx
        sub     [edi+RECT.right], ebx


.h_ok:
        test    eax, 2 ; vertical
        jnz     .v_ok


        sub     [edi+RECT.top], edx
        sub     [edi+RECT.bottom], edx


.v_ok:
        stdcall RectToBounds, edi, edi


        add     edi, sizeof.RECT
        dec     eax

        jns     .loop_rect


; Now draw the rectangles.



        lea     ebx, [.maskLR]
        mov     edi, 3

.draw_loop:
        shr     [.fDraw], 1
        jnc     .next


        setz    cl              ; is it the last rectangle to draw?
        movzx   ecx, cl



; arguments from here!



        push    ecx     ; events flag

        mov     ecx, [.yDst]
        mov     eax, [.xDst]


        test    edi, 2
        jz      .y_ok
        add     ecx, [.maskUR.bottom]
.y_ok:
        test    edi, 1
        jz      .x_ok
        add     eax, [.maskUL.right]
.x_ok:


        push    [ebx+RECT.bottom]               ; .height
        push    [ebx+RECT.right]                ; .width

        push    ecx                             ; destination Y
        push    eax                             ; destination X

        push    [ebx+RECT.top]                  ; .ySrc
        push    [ebx+RECT.left]                 ; .xSrc
        push    [esi+TLinuxImage.ximage]        ; .ximage
        push    [.gc]                           ; .context
        push    [.where]                        ; .drawable
        push    [hApplicationDisplay]           ; .display

        call    [.draw_proc]
        add     esp, 11*4


.next:
        cmp     [.fDraw], 0
        je      .end_draw

        sub     ebx, sizeof.RECT
        dec     edi
        jns     .draw_loop

.end_draw:

        cmp     [flagSharedMemory], 0
        je      .events_ok

; now, wait for the events:
        cinvoke XFlushGC, [hApplicationDisplay], [.gc]
        cinvoke XFlush, [hApplicationDisplay]





        lea     eax, [.event]
        cinvoke XIfEvent, [hApplicationDisplay], eax, ___CheckCompletionEvent, eax


.events_ok:

        cinvoke XFreeGC, [hApplicationDisplay], [.gc]

.exit:
        stdcall UnlockImg, esi

.finish:
        popad
        return














































endp

Changes to freshlib/graphics/images.asm.

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108






109
110
111
112
113
114
115
        pushad
        mov     ebx, [.pImage]
        stdcall LockImg, ebx
        jc      .finish

        stdcall ZeroOrgImage, ebx


        mov     ecx, [.newWrapW]
        mov     edx, [.newWrapH]
        cmp     ecx, [ebx+TImage.width]
        cmova   ecx, [ebx+TImage.width]
        cmp     edx, [ebx+TImage.height]
        cmova   edx, [ebx+TImage.height]







        mov     [ebx+TImage.wrapW], ecx
        mov     [ebx+TImage.wrapH], edx

        stdcall UnlockImg, ebx
        clc

.finish:







<







>
>
>
>
>
>







94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
        pushad
        mov     ebx, [.pImage]
        stdcall LockImg, ebx
        jc      .finish

        stdcall ZeroOrgImage, ebx


        mov     ecx, [.newWrapW]
        mov     edx, [.newWrapH]
        cmp     ecx, [ebx+TImage.width]
        cmova   ecx, [ebx+TImage.width]
        cmp     edx, [ebx+TImage.height]
        cmova   edx, [ebx+TImage.height]

        mov     eax, 1
        test    ecx, ecx
        cmovz   ecx, eax
        test    edx, edx
        cmovz   edx, eax

        mov     [ebx+TImage.wrapW], ecx
        mov     [ebx+TImage.wrapH], edx

        stdcall UnlockImg, ebx
        clc

.finish: