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

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Wed, 23 Nov 2005 23:13:09 +0100

On 2005-11-23 at 16:48:03 [+0100], Adi Oanca wrote:
> 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.

I believe, most of the existing Draw()ing code does just use the supplied 
update rect. But theoretically it is possible that someone who has an area 
which is extremely expensive to draw (or it is unknown how expensive it might 
be; like the cells in a column list view) checks the clipping region, whether 
that area is touched at all. Admittedly that's quite far-fetched.

May I ask, why you asked the question in the first place?

CU, Ingo

Other related posts: