- This topic has 17 replies, 6 voices, and was last updated Sep 23-7:48 am by blur13.
-
AuthorPosts
-
September 22, 2022 at 9:42 am #89518Member
Borg
::iznit: hmm thats a bit shame. Its weird that there is no FillRect proc to handle that (or its not used).
Its more easy to fill given rect with solid color that manipulate bitmap (memcopy).Here is very very simple FillRect in 32bit asm.
As you can see, the whole main loop (y_loop) is just 5 instructions.
And not much cache use like in rect to rect copying 😉For this example, we assume 1024×768 screen size, 32bit color.
DS=ES and points to vid mem already.
No error or out of bound checking of course 😉
Some hacks follows as well 😉PROC FillRect ; EAX - col, EBX - base vid mem, ECX - (x1,x2), EDX - (y1,y2) PUSH EDI PUSH EDX ; +20 PUSH ECX ; +16 PUSH EBX ; +12 PUSH EAX ; +8 MOV EAX,ECX AND ECX,65535 SHR EAX,16 SUB EAX,ECX PUSH EAX ; +4 - x pix cnt PUSH EBP MOV EBP,ESP MOV EDI,EBX MOV ECX,[EBP+16] AND ECX,65535 SHL ECX,2 ADD EDI,ECX MOV EAX,EDX AND EAX,65535 MOV EBX,4096 MUL EBX MOV ECX,[EBP+4] SHL ECX,2 SUB EAX,ECX ADD EDI,EAX MOV EBX,EAX ;y offset MOV EDX,[EBP+16] MOV EAX,EDX SHR EDX,16 AND EAX,65535 SUB EDX,EAX MOV EAX,[EBP+8] y_loop: MOV ECX,[EBP+4] REP STOSD ; fill single x-line ADD EDI,EBX DEC EDX JNZ y_loop POP EBP POP EAX POP EAX POP EBX POP ECX POP EDX POP EDI RET ENDP- This reply was modified 7 months, 3 weeks ago by Borg.
- This reply was modified 7 months, 3 weeks ago by Borg.
- This reply was modified 7 months, 3 weeks ago by Borg.
September 22, 2022 at 4:53 pm #89545Member
iznit
::X.org XFillRectangle exists but is a higher level operation, not the efficent operation you showed. The feh program and others, they would need to first use XCreatePixmap to create a (x*y*C) pixmap before calling XFillRectangle. As for “C” [[[ColorDepth]]], Xorg launches with a fixed color depth. We cannot conserve a significant amount of memory by specifying solidcolor, or even by using the X.org convenience macro ‘BlackPixel‘.
September 23, 2022 at 7:48 am #89577Member
blur13
::“Even if a 20Mb imagefile is specified, feh exits immediately after handing off the w*h*C sized pixmap to the X display server.”
iznit,
thank you for this! I’ve been optimizing background images for the display resolution thinking less memory would be involved. And I’ve also noticed the “tiling” effect when connecting a laptop to a larger display, now I understand why, and also why “Restart session” solves that.
-
AuthorPosts
- You must be logged in to reply to this topic.