OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:02 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GUI Window clipping
PostPosted: Wed Aug 31, 2022 1:13 am 
Offline
Member
Member

Joined: Fri Nov 01, 2019 1:17 am
Posts: 95
Hello, I have confusion regarding window clipping, when an window is overlaped by another window, the overlapping window is drawn fully and from the overlapped window only those portion are redrawn which are visible, the confusion is here-- every window owns there own buffer where pixels are drawn by each application who owns that window and the compositor composites that buffer to final image, so the portion which are visible are calculated using rectangle clipping and those rectangles are in device coordinates how can I convert those same rects to window coordinate? So that I can only copy those visible portion of window buffer to final image? Or my method is wrong?

For example if the clip rect is in 100,100 as per screen coord, the same rect should be in 0,0 in window coord..


Top
 Profile  
 
 Post subject: Re: GUI Window clipping
PostPosted: Wed Aug 31, 2022 3:05 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
Kamal123 wrote:
For example if the clip rect is in 100,100 as per screen coord, the same rect should be in 0,0 in window coord..

What are you talking about ? Shouldn't you just make a bitmap of the Window and process rects locally and draw them. Then the compositor will simply copy the window bitmap (or the modified portions only?)

I don't understand the rest of the question, can you provide more details and maybe a screenshot

Devc1,


Top
 Profile  
 
 Post subject: Re: GUI Window clipping
PostPosted: Wed Aug 31, 2022 7:04 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
For converting coordinates on the screen to coordinates on the window:

Position in window = position on screen - window's position
E.g. if your window is as 100,100 and you click at 150,150 on the screen, that will be 50,50 in the window.

For compositing window managers (where each window is drawn into its own buffer, and the window manager then combines them together), the easiest way is to draw them back-to-front, so overlapping buffers. All of this is drawn into the window manager's buffer, then once all the windows are drawn to it, this is the copied into the graphic device's framebuffer.

Now, you might have noticed there's a lot of overdrawn (pixels being copied from background windows that are covered up by foreground windows). If you are comfortable doing rectangle slicing, you can cut one rectangle out of another, that way you don't copy pixels that aren't shown, and you can avoid the need for a window manager's back buffer.

---

This is what I do: I iterate through the windows back-to-front, and call Draw on my window.
https://github.com/AndrewAPrice/Percept ... positor.cc

But the Draw function doesn't really draw, it calls the CopyTexture function adds a rectangle to copy to quad tree.

Here's my quad tree that slices up/removes rectangles behind it:
https://github.com/AndrewAPrice/Percept ... uad_tree.h

Then my window manager sends a collection of "copy rectangle from a to b" commands to the graphics driver.

_________________
My OS is Perception.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], mrjbom and 54 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group