[haiku-appserver] Re: user needs to know about the clipping region?

  • From: Adi Oanca <adioanca@xxxxxxxxxxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Wed, 23 Nov 2005 17:48:03 +0200

Hi,

Gabe Yoder wrote:
On Wednesday 23 November 2005 07:03 am, DarkWyrm wrote:
        Guys, I have a(nother) question for you. :-)

        Why does the programmer/user needs to know about a view's clipping
region?
        (let BDirectWindow aside, it's a special case)


Please tell me everything that crosses your mind.
One thing I can think of is when lazy programmers don't want to bother
with doing high-level clipping on a particular graphics call --
especially a complicated shape such as BShape, so when they call
StrokeShape, they set the clipping region for that call only.

--DW

Assuming I know what is going on here (which is a bit of a stretch), it isn't just a matter of being a lazy programmer. There isn't any sense in drawing something that won't be shown, so time can be saved by eliminating some calls entirely (possibly eliminating calculations of figuring out what would be drawn in the area).

When you draw something, you should put your code in BView::Draw(). Then if you want to trigger a redraw, you call ::Invalidate(). As a result, ::Draw(rect) will be called with the rectangle that corresponds to the visible region of that view. No need to know the exact visible region, Draw()'s rect gives a close approximation.




bye,
Adi.

Other related posts: