Window manager

The place to share and discuss your Ultibo projects.
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Window manager

Postby pik33 » Sat Apr 29, 2017 2:18 pm

The first run shown that this is possible with RPi3 CPU.

The idea is:

- there is a map in the memory which contains pointers to pixels
- the pixels can belong to different graphic windows
- to move a window on the screen you have to modify the map only, not these windows. You don't need to rewrite the main screen area which can then be 1 pixel with the background color only

I tried this with the retromachine player to test if the procedure can do this in real time on non overclocked RPi3. It can. The time is ~11500 microseconds with 8-bit screen. The 32-bit screen or GPU governed 8-bit will be faster because the CPU doesn't have to look into pallette registers - one ldr for pixel less.
Last edited by pik33 on Wed May 10, 2017 5:17 pm, edited 1 time in total.
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Mapping window manager

Postby pik33 » Tue May 02, 2017 5:07 pm

The concept works, so I started makng a window manager with it

Advantage: it will be simple in use. You create a windows and draw/putchar in it. That's all. If you want to move the window, the manager will do it, and you don't need to know where is your window, you don't need to refresh it after resizing or moving. The manager can animate it, or even distort it.

Disadvantage: a lot of CPU needed - only RPi3 can do this @ 60 FPS (as it is now)
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Mapping window manager

Postby pik33 » Wed May 03, 2017 5:29 pm

First test pushed to github https://github.com/pik33/ultibo_retro_gui

This is in reality the retromachine player, with added window test procedure - the project is now at its very start and the new procedures are in mwindow unit.

The window here is the real window: a hole in the background. You can look through the hole and see another graphic screen. You can move and resize the hole, you can move the second scren under the hole.
Gavinmc42
Posts: 1665
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Mapping window manager

Postby Gavinmc42 » Thu May 04, 2017 12:00 am

The window here is the real window: a hole in the background. You can look through the hole and see another graphic screen


Just had a flash back to a doco on Disney using layers of hand drawn celluloid frames.
Not sure how to get the parallax 3D effect, 2D only but maybe you could make a multilayer paint program? ;)
A GUI designer running on Ultibo, make it into a shell extension?
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Mapping window manager

Postby pik33 » Thu May 04, 2017 5:58 am

Multilayer paint program can be done with what I have now, but I am still in 8-bit graphic environment: i have to switch to 32-bit which is possible and not very complicated although the first try failed yesterday. I often manage somewhat to delete a line I don't want to delete - maybe I need a better mouse. Something failed when I switched to 32bit graphic and then didn't restore when I returned to 8bit so I restored 8-bit unit from backup

If you downloaded kernel7.img from github, press "w" to see the window demo. Set your graphic mode in config.tht to something (the gpu will cope with any resolution set) with 60Hz refresh or it will flicker
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Window manager

Postby pik33 » Wed May 10, 2017 5:24 pm

Some updates...

The new version pushed here: https://github.com/pik33/ultibo_retro_gui
This is still a retromachine player, used as developing environment, so it can play some music while testing.

Pressing 'W' creates a new window. The windows can be moved and resized (as usual, by dragging the edges) using the mouse. Right mouse click destroys the window.

The idea of mapping manager was beautiful, but the RPi, particularly its memory, is simply too slow to implement this in real life, so I had to change the main concept. Now this is compositing manager at 8-bit level so the memory moving amount is 4x lower.

Still, if you open too many windows, they start to flicker

This is of course very early stage of the window manager, for testing and developing purpose only. Next step: the decoration has to be fully implemented, displaying window title, scrollers and close/minimize/maximize buttons
Gavinmc42
Posts: 1665
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Window manager

Postby Gavinmc42 » Thu May 11, 2017 2:48 am

pik33, Full Window Manager :o
Not surprised it is a bit slow ;)
Probably going to need accelerated GPU graphics?
I have been thinking something a little less ambitious.

Had an old Pi nearly crash last week, corrupted python library files that run on Raspbian using the pygame library.
Took two days to get new updated OS and all software libraries downloaded and installed.
One on my first Pi projects from 5yrs ago.
It uses full screen bitmap overlayed by images which have transparent areas.
Text, changing data, lines and arrows are then added.

Just about all the things needed are already in Ultibo.
Had thought of porting pygame, but that uses SDL etc, big pain.
For simple UI's or displays a Window Manager is not needed.
About the only animation I do is changing text for the sensor data.

I think Ultibo could replace this Raspbian OS and lots of libraries in <3MB plus images.
Just need to get ubitmap unit figured out?
For animation your methods might be a way to do it?
Attachments
GTSE_sm.jpg
GTSE_sm.jpg (59.05 KiB) Viewed 5470 times
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Window manager

Postby pik33 » Thu May 11, 2017 4:55 am

GPU will not hep a lot here as the problem is mostly the memory speed. The GPU could help here freeing CPU for other task while doing the blitting.

I could do bitblitting with DMA but then I still have problems with cache coherency: either the transfer is slow as hell (the CPU can do this 5x faster than DMA) or it is fast but then I lose all this gain flushing the cache, while the screen flickers. So the CPU does all blitting and it is not CPU which limits speed. It is RAM. Blitting full 8MB 32bit screen data takes about 4 ms using ldm/stm unrolled loop.

------------------------------------------------------

The still screen with some animated elements is simple with what I have now.

Draw the screen using box, line, circle and putpixel - or copy prepared bitmap from the file byte by byte (fileread fh,screen,1792*1120)

Use blit procedure to save the background where animated elements will be drawn

Draw animated elements. When they have to change, use waitvbl to wait for vblank, then (1) restore the background (blit) and (2) draw the element.

7 animated, scalable, with transparent color #0, 32x32 sprites are also available. 8th of them is used as a mouse cursor: if mouse cursor is not needed it can be used too

There is a 'outtextxyz' function to output scaled text to the screen. It uses 8x16 font.

All of these functions are working now. All the code base (all I have written for Ultibo environment) can be found in the window manager repository.
Gavinmc42
Posts: 1665
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Window manager

Postby Gavinmc42 » Thu May 11, 2017 8:31 am

Ok, you have convince me to have a go.
I think I will start with a static display and image overlays and no assembler ;)
Should be simple compared what you have done.
Time for me to visit fpGUI again?

You might want to have a look at Garry's console/graphics Windows code, see if that could be extended into variable sizes.
Even non moving but variable sizes would make a difference to GUI making.
pik33
Posts: 891
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Window manager

Postby pik33 » Thu May 11, 2017 12:45 pm

Get a player from github (ultibo-retro-sid) or even a GUI from ultibo-retro-gui

The main project has a main loop. You can experiment in there. Simply add "else if" to the main loop which will react when a selected key is pressed.

Then you can experiment calling putpixel, box, etc :) This is what I am doing developing the GUI: I am writing a new unit called mwindows, and then in the main loop, in Project1.pas, I added this

Code: Select all

     else if key=ord('w') then   
       begin
       wh:=window(1920,1200,'');
       wh^.title:='Test window '+inttohex(integer(wh),8);
       wcls(wh,16*random(16)+2);
       wouttextxy(wh,10,10,'Window handle: '+inttostr(integer(wh)),136);
       wouttextxy(wh,10,42,'Moving window test line 1',152);
       wouttextxy(wh,10,74,'Moving window test line 2',168);
       wouttextxy(wh,10,106,'Moving window test line 3',184);
       wouttextxy(wh,10,138,'Moving window test line 4',200);
       wouttextxy(wh,10,170,'Moving window test line 5',216);
       wouttextxy(wh,10,202,'Moving window test line 6',232);
       wouttextxy(wh,10,234,'Moving window test line 7',248);
       wouttextxy(wh,10,266,'Moving window test line 8',8);
       wouttextxy(wh,10,298,'Moving window test line 9',24);
       wouttextxy(wh,10,330,'Moving window test line 10',40);
       wouttextxy(wh,10,363,'Moving window test line 11',56);
       wouttextxy(wh,10,394,'Moving window test line 12',72);
       wouttextxy(wh,10,426,'Moving window test line 13',88);
       wouttextxy(wh,10,458,'Moving window test line 14',104);
       wouttextxy(wh,10,490,'Moving window test line 15',120);
       movewindow(wh,100,100,300,300,0,0);
       end   


Then pressing W key creates a new window , fills it with text lines and displays it on the screen, so I can test it (and the rest of the player still works) :)

No asm required to use these functions; all asm is done inside them :)

As far as I know you have 75 Hz refreshing monitor - set 60 Hz mode in config.txt or the player will flicker. The new screen procedure dose its job somewhat faster, maybe it is fast enough to cope with 75 Hz...

--------------------------------
Pushed new GUI, some work on decoration done, this is still all experimental and it will change.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 36 guests