[GRASS5] [cworth@east.isi.edu: GRASS on iPAQ]

... some comments on GRASS display system from Carl Worth
(posted with permission :slight_smile: - see attachment.

On Wed, Oct 02, 2002 at 02:42:47PM -0400, Carl Worth wrote:

On Oct 2, Markus Neteler wrote:
> do you see a chance to send your *very* interesting notes to the
> grass5 developers list (the community would benefit!)?

Feel free to forward on anything that would seem appropriate.

> Probably Glynn or someone else might also use your developments
> for integration into 5.1? Then we didn't have to reimplement the
> wheel :slight_smile:

Yes. As I said, I think Xr will probably be the right layer upon which
to build any future vector-drawing packages for X, (in my very humble
opinion of course).

-Carl

Markus

Markus Neteler wrote:

However, I have been doing quite a bit of work on a new vector-based
drawing engine for X which uses the Render extension. This new library,
(Xr), supports wide lines and splines, (all the common join, cap, and
dash styles), with anti-aliased edges. All shapes can be drawn
translucently as well. The Xr drawing API is quite easy to use, (it's
similar to PostScript). So, I do think that Xr might be very useful as
the backend for X-based drawing in GRASS instead of the old core Xlib
drawing routines. (There's even a layer under Xr called Xc that will
eventually support all of the rendering on the client side so that Xr
will be usable even on X servers without the Render extension).

Xr is still in progress. The code is in the CVS server pointed to at
http://www.keithp.com, but there is not much documentation yet. It
will probably be documented and quite ready to use early next year, so
maybe in time for GRASS 5.1.

1. I would only consider it ready to use when either Xr is ubiquitous
or Xc is available. Making GRASS unusable on systems which don't
support the Render extension is out of the question, IMHO.

2. We also need to allow for Windows. Either Xc needs to work there,
or we would need to find equivalent native functionality.

3. We also need to allow for non-screen output, i.e. the PNG and CELL
drivers.

4. For the future, I would like to also allow hardcopy output in a
compatible manner. That would impose some significant constraints,
primarily:

a) the architecture has to scale to much higher spatial resolutions
than are typical for screen display.

b) OTOH, printers typically have low colour resolution (i.e. 1 bit per
component), and rely upon dithering.

c) A printer's framebuffer is often write-only, which precludes
read-modify-write operations such as alpha-blending, and XOR plotting.

Do keep up the great work. I'll definitely check back on GRASS in the
future.

-Carl Worth

PS. I'll mention here some of the specific frustrations I ran into
with GRASS. These are intended not as complaints, but as things to
keep in mind while redesigning things for 5.1 and beyond. As I
mentioned, some of these are due to the fact that GRASS just wasn't
designed to do some of the things that I wanted, (although there's no
reason a future version couldn't be).

1) The drawing support was quite limited, (things like fixed palette
   of colors, fixed line width, fixed line style, fixed set of
   possible icons, etc.)

2) The drawing support was often too slow for the things I needed. I
   was stressing GRASS out pretty hard since I was trying to do some
   animation of real-time data, (about 1 frame per second), on top of
   some large raster data sets. On top of that, I wanted this to work
   on a handheld computer with no floating-point unit. The need to
   continuously rescale the background for a simple pan or a local
   modification of some higher layer made things infeasible.

The existing display architecture just isn't suited to real-time
applications. Furthermore, imposing a real-time requirement on a
future display architecture could create significant complications.
The main issue is that increasing functionality eliminates the
possibility of supporting environments which can't implement it.

3) I overcame both problems to some extent by using the XDRIVER_WINDOW
   hack to get at the window ID of the GRASS window. Then, since GRASS
   uses a backing pixmap for all of its drawing, I actually was able
   to erase/redraw my graphics on top of background maps without GRASS
   needing to rescale/redraw things. Plus, I also got to do my own
   drawing, so I could do interesting things including drawing
   translucent regions, etc.

   Allowing a custom program to draw on top of graphics from GRASS is
   actually a powerful idea, (although the current XDRIVER_WINDOW
   support is really just a hack that hints at the idea).

   With that I was able to make an image such as:

  http://dsn.east.isi.edu/grass/spesutie_translucent.jpg

   In which GRASS is only drawing the background raster layer, and I
   was manually drawing everything on top. If GRASS could have
   supported drawing like that, (bitmapped icons, translucent
   polygons, TrueType fonts, etc.), that would be quite nice.

Any display architecture will have limitations, and there will always
be potential applications which exceed those limitations. In which
case, the only solution is for the application to bypass the display
architecture and do it itself.

4) Another problem came up when I was doing the drawing via
   XDRIVER_WINDOW. I needed to map geographical coordinates to screen
   coordinates. GRASS has code to do this of course, but it is
   implemented via static variables. This only works because GRASS is
   primarily standalone programs, each of which starts up, sets the
   variables, performs some computation/drawing, then exits. The
   problem comes in a program such as mine that starts up and
   continues to run even after an intervening d.zoom for example. When
   that happens, the static variables used by the functions called in
   my program continue to have the old values, so the mapping is
   totally broken. I had to go to considerable effort to keep my
   drawing in synch. And even then it only works if the pan is done
   from within my program so that it nows to re-calculate the
   variables. I still lose if an external d.zoom is run, (since my
   program doesn't know the mapping parameters are stale). All of this
   should be cleanly handled within the GRASS library.

Are you asking for some kind of event/callback mechanism, or just a
simpler way to check if the region has changed and/or update it?

5) Finally, I was repeatedly frustrated by only being able to run more
   than one GRASS session at a time. I know that GRASS doesn't yet
   have all of the fine-grained locking that it really needs. But even
   so, it is quite frustrating that it would not let me run multiple
   sessions in different locations simultaneously, (unless I ran them
   as a different user).

The current startup isn't that hard to bypass. The main complication
is that monitor names (x0, x1, ...) are per-user, not per-session.

--
Glynn Clements <glynn.clements@virgin.net>

On Oct 3, Glynn Clements wrote:
[ Description of work-in-progress Xr/Xc libraries ]

> 1. I would only consider it ready to use when either Xr is ubiquitous
> or Xc is available. Making GRASS unusable on systems which don't
> support the Render extension is out of the question, IMHO.

Yes, Xc is an important part of the transition strategy. That's why
the decision has already been made to not incorporate Xr into the
XFree86 tree until Xc supports client-side emulation of the Render
extension.

> 2. We also need to allow for Windows. Either Xc needs to work there,
> or we would need to find equivalent native functionality.

This is not an issue I'm addressing.

> 3. We also need to allow for non-screen output, i.e. the PNG and CELL
> drivers.

The plan is that Xc will have output options to things besides X
drawables. The current proposed list is PNG, PDF, and PS. These have
not been implemented yet.

PDF output would be trivial to implement right now. PNG will be
trivial once Xc has all of the client-side rendering code. PS support
will need some clever code to efficiently handle alpha-blended
rendering, (shoving out giant bitmapped postscript would not be hard,
but it's really not what I want to do).

> 4. For the future, I would like to also allow hardcopy output in a
> compatible manner.

I've got the same goal for Xr.

> That would impose some significant constraints, primarily:
>
> a) the architecture has to scale to much higher spatial resolutions
> than are typical for screen display.

Xr should deal with this fine since it uses doubles for all
coordinates, hence it will be able to expose all the spatial
resolution of hardcopy output devices. Also, for screen display,
Render support 16 bits of sub-pixel precision for all coordinates.

> b) OTOH, printers typically have low colour resolution (i.e. 1 bit per
> component), and rely upon dithering.
>
> c) A printer's framebuffer is often write-only, which precludes
> read-modify-write operations such as alpha-blending, and XOR
> plotting.

Yes, both issues need to be addressed. In some cases, (such as PDF
output), we can rely on the PDF implementation to take care of all of
this. Eventually, though, I expect all of this functionality to be in
Xr/Xc.

Anyway, that's just enough to say that, yes, I think we're dealing
with all of the issues that need to be addressed for an application
domain as sophisticated as GRASS. This was really meant just as a
heads-up that we are working on this rendering architecture that might
save a lot of work for future GRASS implementations.

Xr doesn't do everything that's needed today, but it does already
support anti-aliased, alpha-blended drawing of lines/cubic bezier
splines on an X drawable if anyone wants to take it for a spin. The
drawing API is also stabilizing quickly, and I would be very
interested in any feedback there.

I'll let you know when Xr/Xc are initially released. At that point
there should be enough functionality for GRASS to seriously consider
building a new rendering architecture on top of Xr.

-Carl

--
Carl Worth
USC Information Sciences Institute cworth@east.isi.edu
3811 N. Fairfax Dr. #200, Arlington VA 22203 703-812-3725