Re: [gtk-list] Re: gdk_draw_* and friends

Owen Taylor wrote:

> Dan Kressin <> writes:
> > Antonio Campos wrote:
> > >
> > > Digging randomly through the gdk.h include file, I stopped at
> > > gdk_draw_* functions. I noticed the functions:
> > [snip]
> > > and of course:
> > > gdk_draw_rectangle             (*)
> > > gdk_draw_arc                        (*)
> > >
> > > Then, I realized than X has more drawing functions...
> > > I issued an "apropos", and XDrawRectangles, XDrawArcs appeared.
> > >
> > > Then I thought why shouldn't gdk wrap these two X drawing functions as
> > > well.
> > > If I'm correct, these two functions are used to send the X Server a
> > > bunch of rectangles or arcs, which is a very useful thing because the X
> > > Server may communicate with the clients through a network.
> > >
> > > So, wouldn't be nice to add two more functions to gdk?
> >
> > They do, in fact, save on network traffic over multiple *Arc or
> > *Rectangle calls.
> Yes for Arc, no for Rectangle. (Look at the implementation
> of XDrawRectangle if you don't believe me. Xlib is smart
> enough to batch up multiple consecutive DrawRectangle
> requests.)

But when the XDrawRectangles function is there, there must be a reason to use
At least the XDrawRectangles avoids invoking a lot of XDrawRectangle calls. So
even with a local X server, it could be faster.

> > I actually wrote and submitted the code to implement
> > the plural versions of those functions back in the early days of the 1.1
> > series, but I guess it never got accepted by the powers that be.  Not
> > entirely sure why.
> >
> > Owen?  I think you were the one that told me how to submit the code via
> > ftp, any idea why it was never included?
> I believe at the same time, I asked for benchmarks proving that
> there is a significant gain (E.g., "I can draw 50,000 arcs a second
> using XDrawArcs, but only 20,000 a second using XDrawArc".)
> Maybe you did send such benchmarks and I just missed them...
> I'm rather hesitant to complicate the drawing interfaces in
> GDK (for 1.3, this is a VTable that every Drawable implementation
> must implement and must also be supported on every platform)
> more than necesary.

I don't think that adding two functions and two types (gdkarc and
gdkrectangle) to GDK is complicating too much the drawing interface.
Besides this, then why do we need gdk_draw_points, gdk_draw_lines or
gdk_draw_segments?. Following you, one simply could call a lot of
gdk_draw_point, ...
I think that the API is more rationale if every drawing primitive for point,
line, segment, rectangle, arc has his plural counterpart.
An even is more rationale to avoid the filled argument for gdk_draw_rectangle
and gdk_draw_arc, because that should come from the graphics context passed as
argument to the function. (Maybe this was made because Win32 graphics contexts
don't have this filled argument?. I don't know, but anyway we have a wrapper
to GCs, the GDK graphics contexts. So I don't understand the problem).
Even you may say that the plural versions weren't added to GDK because Win32
or other platforms where gdk could be ported don't support a function like
XDrawRectangles or XDrawArcs. Well, in this case, gdk_draw_rectangles (for
that versions) could simply call gdk_draw_rectangle in a loop.

To sum up, I don't see the problem to add these two functions, and I don't
think these could make the API much more fatter. At the contrary, I think
these functions could make the drawings faster (I don't know how much faster,
but even if the were a little faster, they should be useful).

> Regards,
>                                         Owen
> --
> To unsubscribe: mail -s unsubscribe < /dev/null

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]