[haiku-development] Re: Implementing the B_OUTLINE_RESIZE flag for BWindow

  • From: "Adrien Destugues" <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 26 Jun 2020 06:26:08 +0000

25 juin 2020 20:50 "Jacob Secunda" <secundaja@xxxxxxxxx> a écrit:

Good day to all Haiku developers,

(I previously posted this on an older Haiku app_server development mailing 
list, though was
recommended by Humdinger to post here instead, as the list I had been using 
was obsolete.)

Yes, that's correct. The team is small enough that multiple lists are not 
useful.


I am currently working on the app_server in the hopes of implementing the 
B_OUTLINE_RESIZE flag for
the BWindow class. As a refresher, the B_OUTLINE_RESIZE flag is used to allow 
an application to
hide its window contents while being resized to avoid continuous redrawing 
and tearing (like in
Haiku's Magnify application for example). So far, I have gotten pretty far in 
implementing this
functionality. A decorator is able to draw their own special "outline border" 
when needed. Though
here is the problem: While the contents of the window won't resize as the 
border is resized, I
can't figure how to have the decorator temporarily draw over the contents of 
a window, and keep the
window contents erased/transparent. What surprised me, is that using code 
like this:
"fWindow->TopView()->SetHidden()" only stopped the View from being redrawn 
(leading to continuous
smearing), rather than the causing the center of the window to become empty.

There is a previous attempt here: https://review.haiku-os.org/c/haiku/+/344
But I think it has similar problems.

I think in BeOS B_OUTLINE_RESIZE was implemented by using the XOR drawing mode, 
which allowed for
"reversible" drawing. You could draw the same thing again and it would undo 
itself. Unfortunately
this may not work as well in Haiku due to antialiasing and gamma adjustments. 
But maybe for straight
lines it can be made to work.

So that's what I would try:
- Prevent any update to the window contents (do not send any FrameResized or 
Invalidate or anything to it)
- Use only XOR drawing to draw the outline, so that it's possible to erase it 
without needing to ask the windows under to redraw themselves

To answer X512 who said the feature shouldn't be implemented: this is a flag 
that can be enabled explicitly by
each window. The idea is to use it only when a window has a very complex layout 
and is slow to render, which
makes resizing annoying. It is indeed some kind of workaround, but sometimes 
there is no way around it. I think
we should implement it, but advise apps to avoid it if possible by other means, 
such as using an offscreen buffer.

-- 
Adrien.


Other related posts: