Fresh IDE . Check-in [7f2c82fcc6]
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:Almost working, at least with TForm and TButton components.
Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:7f2c82fcc6c0598c84218a8b217137b7f6befe24
User & Date: johnfound 2017-06-02 13:56:59
Context
2017-08-21
02:51
The next code refactoring for the GUI library. The idea is to not refresh the controls all the time, but only when needed. In addition, the drawing methods are now not fixed, but can vary for the different classes, using only common interface: TWindow:SelfPaint method; check-in: 215e9a11c6 user: johnfound tags: NoCanvasGUI
2017-06-02
13:56
Almost working, at least with TForm and TButton components. check-in: 7f2c82fcc6 user: johnfound tags: NoCanvasGUI
12:29
An attempt to increase the performance of the GUI libraries, by drawing directly on the screen images when possible. At least this approach is more flexible. Not working in this checkin! check-in: 7a655a26e5 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/gui/TCanvasWindow.asm.

50
51
52
53
54
55
56


57
58
59
60
61
62
63
..
98
99
100
101
102
103
104



105
106
107
108
109
110
111
...
135
136
137
138
139
140
141
142
143

144
145
146
147
148
149
150



method TCanvasWindow.__UpdateCanvas
begin
        pushad
        mov     esi, [.self]



        mov     ebx, [esi+TCanvasWindow._visible]
        mov     edi, [esi+TCanvasWindow._canvas]

        mov     ecx, [esi+TCanvasWindow._width]
        mov     edx, [esi+TCanvasWindow._height]

................................................................................

        add     ecx, 256
        add     edx, 256

        stdcall CreateImage, ecx, edx
        mov     [esi+TCanvasWindow._canvas], eax




.exit:
        popad
        return
endp



................................................................................
        return
endp



method TCanvasWindow.SetVisible
begin
        exec    [.self], TCanvasWindow:__UpdateCanvas
        inherited [.value]

        return
endp


method TCanvasWindow.Resize     ;, .newWidth, .newHeight
begin
        inherited [.newWidth], [.newHeight]







>
>







 







>
>
>







 







<

>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155



method TCanvasWindow.__UpdateCanvas
begin
        pushad
        mov     esi, [.self]

        DebugMsg "TCanvasWindow._UpdateCanvas"

        mov     ebx, [esi+TCanvasWindow._visible]
        mov     edi, [esi+TCanvasWindow._canvas]

        mov     ecx, [esi+TCanvasWindow._width]
        mov     edx, [esi+TCanvasWindow._height]

................................................................................

        add     ecx, 256
        add     edx, 256

        stdcall CreateImage, ecx, edx
        mov     [esi+TCanvasWindow._canvas], eax

        OutputValue "Create new canvas: ", eax, 16, 8
        exec    esi, TCanvasWindow:Paint

.exit:
        popad
        return
endp



................................................................................
        return
endp



method TCanvasWindow.SetVisible
begin

        inherited [.value]
        exec    [.self], TCanvasWindow:__UpdateCanvas
        return
endp


method TCanvasWindow.Resize     ;, .newWidth, .newHeight
begin
        inherited [.newWidth], [.newHeight]

Changes to freshlib/gui/TWindow.asm.

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
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
...
476
477
478
479
480
481
482
483






484
485
486
487
488
489
490
...
497
498
499
500
501
502
503




504
505
506
507
508
509
510
...
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
....
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252


1253
1254
1255
1256
1257
1258
1259
....
1323
1324
1325
1326
1327
1328
1329




1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
....
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365

1366
1367
1368
1369
1370
1371
1372
1373
1374
        lea     eax, [.dest]
        stdcall RectIntersect, eax, eax, edi
        jc      .children_loop                  ; the rectangles does not intersect, so the child should not to be painted.

        mov     eax, [.dest.left]
        mov     edx, [.dest.top]
        sub     [.dest.right], eax      ; source rectangle width
        sub     [.dest.bottom], eax     ; source rectangle height

        sub     eax, [esi+TWindow._x]
        sub     edx, [esi+TWindow._y]
        mov     [.dest.left], eax
        mov     [.dest.top], eax

        add     eax, [.xDst]
        add     edx, [.yDst]

; notice, that the children are self painted only with spBlend operation!
        exec    esi, TWindow:SelfPaint, spBlend, [.pDstImage], eax, edx, [.dest.left], [.dest.top], [.dest.right], [.dest.bottom]

        jmp     .children_loop

.end_loop:
        stdcall UnlockImg, [.pDstImage]
        popad
        return
................................................................................

        xor     eax, eax
        mov     esi, [.self]

        cmp     [esi+TWindow._screen], eax
        je      .finish_screen

        OutputValue "Window screen image: ", [esi+TWindow._screen], 16, 8

        stdcall LockImg, [esi+TWindow._screen]
        jc      .finish_screen

if defined options.Threads & options.Threads
        lea     eax, [esi+TWindow._rect_mx]
        stdcall WaitForMutex, eax, 1000
        jc      .finish_screen
end if

        mov     edi, [esi+TWindow._rect_list]   ; list of the rectangles that need rendering.
        test    edi, edi
        jz      .finish_release                 ; no changes, the screen is up to date.

        mov     ecx, [edi+TArray.count]
................................................................................
        lea     ebx, [.client]
        lea     edx, [.rect]

.rect_loop:
        stdcall RectIntersect, edx, ebx, edi
        jc      .next_rect

        stdcall TWindow.__BlendOneRect, esi, edx







.next_rect:

        add     edi, sizeof.RECT
        loop    .rect_loop

.finish_free:
................................................................................
.finish_release:

if defined options.Threads & options.Threads
        lea     eax, [esi+TWindow._rect_mx]
        stdcall MutexRelease, eax
end if





.finish_screen:
        mov     eax, [esi+TWindow._screen]
        mov     [esp+4*regEAX], eax
        popad
        return
endp

................................................................................
begin
        pushad

        mov     esi, [.pWindow]
        mov     edi, [.pRect]
        mov     edx, [esi+TWindow._screen]

.process_screen:

; start with the background.

        mov     eax, [edi+RECT.right]
        mov     ecx, [edi+RECT.bottom]

        sub     eax, [edi+RECT.left]
        jz      .end_loop

        sub     ecx, [edi+RECT.top]
        jz      .end_loop

        exec    esi, TWindow:SelfPaint, spCopy, edx, [edi+RECT.left], [edi+RECT.top], [edi+RECT.left], [edi+RECT.top], eax, ecx

; then blend the children windows

        get     ebx, esi, TObject:Children
        test    ebx, ebx
        jz      .end_loop

        xor     ecx, ecx
        dec     ecx

.children_loop:
        inc     ecx
        cmp     ecx, [ebx+TArray.count]
        je      .end_loop

        mov     esi, [ebx+4*ecx+TArray.array]

        istype  esi, TWindow
        jne     .children_loop

        get     eax, esi, TWindow:Visible
        test    eax, eax
        jz      .children_loop

        push    [esi+TWindow._x] [esi+TWindow._y] [esi+TWindow._width] [esi+TWindow._height]
        pop     [.dest.bottom] [.dest.right] [.dest.top] [.dest.left]

        mov     eax, [.dest.left]
        add     [.dest.right], eax

        mov     eax, [.dest.top]
        add     [.dest.bottom], eax

        lea     eax, [.dest]
        stdcall RectIntersect, eax, eax, edi
        jc      .children_loop                  ; the rectangles does not intersect, so the child should not to be painted.

        mov     eax, [.dest.left]
        sub     [.dest.right], eax

        sub     eax, [esi+TWindow._x]
        mov     [.xSrc], eax

        mov     eax, [.dest.top]
        sub     [.dest.bottom], eax

        sub     eax, [esi+TWindow._y]
        mov     [.ySrc], eax

;        get     eax, esi, TWindow:Screen
;        test    eax, eax
;        jz      .children_loop

;  method .SelfPaint, .Operation, .pDstImage, .xDst, .yDst, .xSrc, .ySrc, .width, .height    ; Paints itself on the caller provided TImage. Replaces the direct use of TWindow:Canvas image.

        exec    esi, TWindow:SelfPaint, spBlend, edx, [.dest.left], [.dest.top], [.xSrc], [.ySrc], [.dest.right], [.dest.bottom]

;        stdcall BlendImage, edx, [.dest.left], [.dest.top], eax, [.xSrc], [.ySrc], [.dest.right], [.dest.bottom]
;        stdcall BlendImageTile, edx, [.dest.left], [.dest.top], [.dest.right], [.dest.bottom], eax, [.xSrc], [.ySrc], [.dest.right], [.dest.bottom]

;        stdcall UnlockImg, eax
        jmp     .children_loop

.end_loop:

        popad
        return
endp



;_________________________________________________________________________________________
................................................................................
        jbe     .exit


.destroy:
        stdcall DestroyImage, edi                         ; screen

        xor     eax, eax
        mov     [esi+TCanvasWindow._screen], eax

        test    ebx, ebx
        jz      .exit


.create_new:

        add     ecx, 256
        add     edx, 256

        cmp     [esi+TCanvasWindow.__pChildren], 0
        je      .exit

        stdcall CreateImage, ecx, edx
        mov     [esi+TCanvasWindow._screen], eax



.exit:
        popad
        return
endp


................................................................................
        cmp     ebx, [esi+TWindow._x]
        jne     .update

        cmp     ecx, [esi+TWindow._y]
        je      .finish

.update:




        exec    esi, TWindow:RectChangedXY, [esi+TWindow._x], [esi+TWindow._y], [esi+TWindow._width], [esi+TWindow._height], TRUE        ; previous position.

        mov     [esi+TWindow._x], ebx
        mov     [esi+TWindow._y], ecx

        exec    esi, TWindow:RectChangedXY, [esi+TWindow._x], [esi+TWindow._y], [esi+TWindow._width], [esi+TWindow._height], TRUE        ; new position.

; here some system events have to be generated in order to repaint the parent window.

.finish:
        popad
        return
endp


................................................................................
        cmp     ebx, [esi+TWindow._width]
        jne     .update

        cmp     ecx, [esi+TWindow._height]
        je      .finish

.update:
        exec    [.self], TCanvasWindow:__UpdateScreen
        exec    esi, TWindow:RectChangedXY, [esi+TWindow._x], [esi+TWindow._y], [esi+TWindow._width], [esi+TWindow._height], FALSE        ; previous rectangle

        mov     [esi+TWindow._width], ebx
        mov     [esi+TWindow._height], ecx


        exec    esi, TWindow:RectChangedXY, [esi+TWindow._x], [esi+TWindow._y], [esi+TWindow._width], [esi+TWindow._height], FALSE        ; new rectangle

.finish:
        popad
        return
endp









|



<
<

<
<
<

|







 







<
<






|







 







|
>
>
>
>
>
>







 







>
>
>
>







 







<
<






|


|



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







 







|










|



|
>
>







 







>
>
>
>
|




|
<
<







 







<
|



>

|







402
403
404
405
406
407
408
409
410
411
412


413



414
415
416
417
418
419
420
421
422
...
434
435
436
437
438
439
440


441
442
443
444
445
446
447
448
449
450
451
452
453
454
...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
...
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
...
520
521
522
523
524
525
526


527
528
529
530
531
532
533
534
535
536
537
538
539
































































540
541
542
543
544
545
546
....
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
....
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278


1279
1280
1281
1282
1283
1284
1285
....
1295
1296
1297
1298
1299
1300
1301

1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
        lea     eax, [.dest]
        stdcall RectIntersect, eax, eax, edi
        jc      .children_loop                  ; the rectangles does not intersect, so the child should not to be painted.

        mov     eax, [.dest.left]
        mov     edx, [.dest.top]
        sub     [.dest.right], eax      ; source rectangle width
        sub     [.dest.bottom], edx     ; source rectangle height

        sub     eax, [esi+TWindow._x]
        sub     edx, [esi+TWindow._y]






; notice, that the children are self painted only with spBlend operation!
        exec    esi, TWindow:SelfPaint, spBlend, [.pDstImage], [.dest.left], [.dest.top], eax, edx, [.dest.right], [.dest.bottom]

        jmp     .children_loop

.end_loop:
        stdcall UnlockImg, [.pDstImage]
        popad
        return
................................................................................

        xor     eax, eax
        mov     esi, [.self]

        cmp     [esi+TWindow._screen], eax
        je      .finish_screen



        stdcall LockImg, [esi+TWindow._screen]
        jc      .finish_screen

if defined options.Threads & options.Threads
        lea     eax, [esi+TWindow._rect_mx]
        stdcall WaitForMutex, eax, 1000
        jc      .finish_unlock
end if

        mov     edi, [esi+TWindow._rect_list]   ; list of the rectangles that need rendering.
        test    edi, edi
        jz      .finish_release                 ; no changes, the screen is up to date.

        mov     ecx, [edi+TArray.count]
................................................................................
        lea     ebx, [.client]
        lea     edx, [.rect]

.rect_loop:
        stdcall RectIntersect, edx, ebx, edi
        jc      .next_rect

        mov     eax, [edx+RECT.left]
        sub     [edx+RECT.right], eax

        mov     eax, [edx+RECT.top]
        sub     [edx+RECT.top], eax

        exec    esi, TWindow:SelfPaint, spCopy, [esi+TWindow._screen], [edx+RECT.left], [edx+RECT.top], [edx+RECT.left], [edx+RECT.top], [edx+RECT.right], [edx+RECT.bottom]

.next_rect:

        add     edi, sizeof.RECT
        loop    .rect_loop

.finish_free:
................................................................................
.finish_release:

if defined options.Threads & options.Threads
        lea     eax, [esi+TWindow._rect_mx]
        stdcall MutexRelease, eax
end if

.finish_unlock:

        stdcall UnlockImg, [esi+TWindow._screen]

.finish_screen:
        mov     eax, [esi+TWindow._screen]
        mov     [esp+4*regEAX], eax
        popad
        return
endp

................................................................................
begin
        pushad

        mov     esi, [.pWindow]
        mov     edi, [.pRect]
        mov     edx, [esi+TWindow._screen]



; start with the background.

        mov     eax, [edi+RECT.right]
        mov     ecx, [edi+RECT.bottom]

        sub     eax, [edi+RECT.left]
        jle      .end_loop

        sub     ecx, [edi+RECT.top]
        jle     .end_loop

        exec    esi, TWindow:SelfPaint, spCopy, edx, [edi+RECT.left], [edi+RECT.top], [edi+RECT.left], [edi+RECT.top], eax, ecx

































































        popad
        return
endp



;_________________________________________________________________________________________
................................................................................
        jbe     .exit


.destroy:
        stdcall DestroyImage, edi                         ; screen

        xor     eax, eax
        mov     [esi+TWindow._screen], eax

        test    ebx, ebx
        jz      .exit


.create_new:

        add     ecx, 256
        add     edx, 256

        cmp     [esi+TWindow.__pChildren], 0
        je      .exit

        stdcall CreateImage, ecx, edx
        mov     [esi+TWindow._screen], eax

        OutputValue "Create new screen image:", eax, 16, 8

.exit:
        popad
        return
endp


................................................................................
        cmp     ebx, [esi+TWindow._x]
        jne     .update

        cmp     ecx, [esi+TWindow._y]
        je      .finish

.update:
        get     edx, esi, TWindow:Parent
        test    edx, edx
        jz      .finish

        exec    edx, TWindow:RectChangedXY, [esi+TWindow._x], [esi+TWindow._y], [esi+TWindow._width], [esi+TWindow._height], TRUE        ; previous position.

        mov     [esi+TWindow._x], ebx
        mov     [esi+TWindow._y], ecx

        exec    edx, TWindow:RectChangedXY, [esi+TWindow._x], [esi+TWindow._y], [esi+TWindow._width], [esi+TWindow._height], TRUE        ; new position.



.finish:
        popad
        return
endp


................................................................................
        cmp     ebx, [esi+TWindow._width]
        jne     .update

        cmp     ecx, [esi+TWindow._height]
        je      .finish

.update:

        exec    esi, TWindow:RectChangedXY, 0, 0, [esi+TWindow._width], [esi+TWindow._height], FALSE        ; previous rectangle

        mov     [esi+TWindow._width], ebx
        mov     [esi+TWindow._height], ecx
        exec    [.self], TWindow:__UpdateScreen

        exec    esi, TWindow:RectChangedXY, 0, 0, [esi+TWindow._width], [esi+TWindow._height], FALSE        ; new rectangle

.finish:
        popad
        return
endp