| View previous topic :: View next topic |
| Author |
Message |
dpap Guest
|
Posted: Tue Aug 16, 2005 9:41 am Post subject: what is faster |
|
|
Hi,
I want to draw the area of a big and complex drawing that fits in the
canvas. What is the faster of :
1. leave the program to desire what fits in the proper area
2. using cliprect function or
3. programmatically examine each line if has points iside this area ?
thanks in advance
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Tue Aug 16, 2005 9:58 am Post subject: Re: what is faster |
|
|
| Quote: | I want to draw the area of a big and complex drawing that fits in the
canvas. What is the faster of : 1. leave the program to desire what
fits in the proper area 2. using cliprect function or
3. programmatically examine each line if has points iside this area ?
|
The best way to test speed is nearly always making a benchmark and
running all of the possibilities. One can only rarely determine in
advance what is the fastest way to perform a specific task, especially
is not all of the code used is written by yourself.
Implement all possibilities and run them several times using inputs
very similar to those that will be used in practice. You can use the
QueryPerformanceCounter function to measure the time it takes for each
implementation:
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface
/windowing/timers/timerreference/timerfunctions/queryperformancecounter.
asp
(http://tinyurl.com/6kp4q)
Accuracy can be improved by:
- Using many runs
- Setting a higher thread priority for the test thread (which may be
the
main thread)
- Avoiding doing other stuff with the computer while testing
- Running the functions several times without benchmarking before
starting the timer (to give each an equal benefit of the CPU cache)
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Tue Aug 16, 2005 12:05 pm Post subject: Re: what is faster |
|
|
maybe it would be possible to give u advice if your question was written in
better english..
what does it mean for example:
| Quote: | leave the program to desire what fits in the proper area
|
|
|
| Back to top |
|
 |
Marko Binic Guest
|
Posted: Tue Aug 16, 2005 4:22 pm Post subject: Re: what is faster |
|
|
I don't think I understand the question too good, but I think the fastest
way to limit the drawing to a part of the canvas is by using regions. For
example:
var
rgn: HRGN;
begin
rgn := CreateRectRgnIndirect(LimitingRect);
SelectObject(Canvas.Handle, rgn);
//do the drawing here
DeleteObject(rgn);
end;
Hope this helps.
Marko
|
|
| Back to top |
|
 |
somebody Guest
|
Posted: Tue Aug 16, 2005 8:04 pm Post subject: Re: what is faster |
|
|
"dpap" <dpap (AT) softwaypro (DOT) gr> wrote
| Quote: | I want to draw the area of a big and complex drawing that fits in the
canvas. What is the faster of :
1. leave the program to desire what fits in the proper area
2. using cliprect function or
3. programmatically examine each line if has points iside this area ?
thanks in advance
|
Depends on how efficiently you can do the culling. If you have designed your
data structures with this in mind, obviously, custom culling can be made to
outperform generic clipping, at least asymptotically (since the former can
be made LogN, while the latter has to be N since a generic clipper won't
know anything about your data).
|
|
| Back to top |
|
 |
Nils Haeck Guest
|
Posted: Tue Aug 16, 2005 9:19 pm Post subject: Re: what is faster |
|
|
Check out info on "convex hulls". A convex hull is a convex polygon that
just fits around your data. You can then easily examine what is in and out,
and what are the extents. It is relatively easy to construct a convex hull
based on your data points.
Kind regards,
Nils
www.simdesign.nl
"dpap" <dpap (AT) softwaypro (DOT) gr> schreef in bericht
news:4301b4d7 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi,
I want to draw the area of a big and complex drawing that fits in the
canvas. What is the faster of :
1. leave the program to desire what fits in the proper area
2. using cliprect function or
3. programmatically examine each line if has points iside this area ?
thanks in advance
|
|
|
| Back to top |
|
 |
|