flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Projects and Ideas > ZeroMove scroll images in FreshLib

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3459
Location: Bulgaria
ZeroMove scroll images in FreshLib
Recently, I implemented in FreshLib images that can be scrolled without actually moving data, by only changing the origin of the image inside the pixel array. This trick accelerates the scrollable GUI elements significantly.

The structure of the OS independent image is:


Code:
struct TImage
  .width     dd ?  ; width in pixels.
  .height    dd ?  ; height in pixels.
  .pPixels   dd ?  ; pointer to the pixel memory.

  .orgX      dd ?
  .orgY      dd ?
  .wrapW     dd ?
  .wrapH     dd ?

  .lock      TMutex
ends



As you can see, it has a wrapW/wrapH size that is smaller or equal to the allocated size of the image. This way, the image can change its size without reallocating memory.

The orgX/orgY fields define the physical point of the [0, 0] pixel. By moving it, the whole image scrolls vertically (orgY) or horizontally (orgX).

The output of such images to the screen is a little bit tricky - by decomposition of the image in 1..4 rectangles and drawing them in the proper order on the screen surface.

The whole source is in the repository, in NoCanvasGUI branch.

In the attachment is a test application that demonstrates the above features. The source is in the project "freshlib/test_code0/TestGraphics.fpr" in the mentioned branch. The archive contains only the binaries for Windows/WINE and Linux.

Notice, that with the default window size, the demo application is expected to make very high FPS values (2000..3000fps). Maximize the window in order to get more reasonable values and to enjoy the beautiful background. Smile

Comments, fixes or simply FPS reports are welcome.
Enjoy.


Description:
Download
Filename: TestGraphics.tar.gz
Filesize: 23.27 KB
Downloaded: 20 Time(s)


_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 14 Nov 2017, 18:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
donn



Joined: 05 Mar 2010
Posts: 67
Neat. FPS was about 340 at fullscreen (1280x800) before opening Win's Snipping tool for a screengrab. Is this GDI, GDI+, neither, on Windows?

Also, after selecting the app icon in the taskbar to minimize it, the app stalls. I reproduced it ~4 times (Windows).

I got GDI working in FASM about a month ago for the first time, was tricky trying to figure out DIBs, bitmap formats, without any prior familiarity with it. I had Petzold's book but unfortunately sold it long ago, didn't think I would need it past the first few chapters.

Just noticed you posted a source link, will take a look later...!


Description: Minimize via taskbar icon.
Filesize: 22.55 KB
Viewed: 218 Time(s)

FreshImageScroll_Minimize.JPG


Description: FPS
Filesize: 20.14 KB
Viewed: 218 Time(s)

FreshImageScrollFPS.JPG


Post 14 Nov 2017, 21:35
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 668
Location: Mar del Plata
Win7 x64 I was able to get steady ~480fps
min: 62fps
max: 656fps
(I moved and resized the window a lot)

130fps fullscreen 1920x1080
Post 14 Nov 2017, 21:54
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3459
Location: Bulgaria
@Enko - What hardware is this. It looks strange, because the 130fps on 1920x1080 is a good value, but 480 or even 656 is pretty low for small window sizes.

@donn - thanks for the bug report. I will fix it. In Windows, the drawing on the windows surface is by BitBlt function (file: freshlib/graphics/Win32/images.asm, procedure DrawImageRect).
In Linux, the drawing is a little bit more complex. When available SHM extension of X server, the drawing is by using XShmPutImage. When the SHM extension is not available XPutImage is used. (file: freshlib/graphics/Linux/images.asm procedure DrawImageRect).
Post 15 Nov 2017, 06:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3459
Location: Bulgaria
Well, I fixed the bug with the hanging in Windows. It was because the real Windows sets the window size to 0,0 on minimizing, while WINE does not.

Also, the slow FPS rate with small windows on original Windows is because of the pretty slow text rendering in Windows. It is FreshLib flaw, because the need for transparent text rendering, that Windows API can't provide. This way FreshLib uses some dirty tricks that slow down the text output.

In Linux it uses directly FreeType library and the text output is much, much faster. I am wondering isn't it better to switch to FreeType in Windows as well, but I am not sure this library is available on most Windows systems.
Post 15 Nov 2017, 07:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
TheRaven



Joined: 22 Apr 2008
Posts: 77
Location: U.S.A.
Serious implications with the purpose of that code Johnny!

Screen magnifier, masking with clip --all type of sh!t. I'm salivating thinking about the possibilities. Many prominent imaging editing & creation systems use a similar technique for non-destructive masks and the like; very professional target John (pan & zoom too, oh yeah).

Noice stuff --will be checking it out.


Might be a bit premature, but the lil frame thingy you're developing specifically for GUI has potential to allow display of all types of stuff like image previews, document regions like when developing HTML; etc. Might be an awesome generic container if you haven't already considered it --supports your libs' re-usability focus (something like a dc [generic object]).

I also like the fact that those whom tested the code are using frame counters --that honestly rocks!

Keep up the good work you guys & gals (as applicable)!
I just noticed it's threaded Shocked --wow...
Post 09 Dec 2017, 21:47
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4157
Location: achtétépéhèseu://pasteubineu.comeu/Vw7WXXf4
fixed, but not updated in the upload Smile 200fps in 1080p, cool. i think it is very good also for any content scroll to use this kind of algorithm.

what about video/text/vectorial/3D etc... application?
Post 11 Dec 2017, 14:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.