chuck@trantor.harris-atd.com (Chuck Musciano) (04/10/91)
I have a problem using clipping masks that appears to fail under both X11R4 and OpenWindows 2.0. Within XView, I have created a canvas, and I wish to render a number of small pixmaps in the canvas using clip masks. I am also rendering some text next to each pixmap. The net result is a file manager-like array of glyphs and names in a scrolling window. I use clip masks to preserve the background color when drawing non-rectangular glyphs. I do not draw into my canvas until my repaint proc is called. This proc is called once for each Expose event that the XView notifier gets from the X server. The first time I draw is when the window is initially mapped, generating an Expose event. When running under OpenWindows 2.0, on a color SPARCstation IPC, pixels along the edge of the rendered glyph are not drawn in the canvas. It is as if the edge of the clip mask is not being used correctly. For example, a square glyph with a correspondingly square clip mask is rendered as (. = gc BG color, @ = gc FG color, remainder is canvas background color): @@@@@@@@@@@@@@@@@@@@@@@ .....................@ .....................@ ..................... ..................... ..................... @@@@@@@@@@@@@@@@@@@@@@@ Notice the odd damage pattern, wherein only part of a column is not rendered. The glyph should be rendered as a box of "." with a complete border of "@". More puzzling is that if I create several canvases (canvi?), the clip mask error varies based upon the relative position of the canvi in the base frame. A glyph that is incorrectly masked in a canvas located at [0, 0] is rendered correctly in a canvas located at some other place. Attempts to fix the display by selecting Refresh from the window menu have no effect. Note to Sun engineers: I was able to try this on a beta copy of OW 3.0 at my Sun sales office, and the behavior was still incorrect. Before you jump to the pat answer of "Aha! OpenWindows bug!" consider the behavior under X11R4: upon receipt of the initial expose events, most of the glyphs do not render AT ALL, except for a few stray pixels here and there. All of the text (which uses a different gc, without a clip mask) renders fine. If you subsequently select Refresh from the window menu, all glyphs are rendered correctly, with correct clipping. Finally, when the application is run on an NCD color X terminal, all behavior is correct: initial, and subsequent, rendering is perfect. The sequence I use to render the glyphs is straightforward: XSetBackground(display, glyph_gc, color); /* set glyph color */ XSetClipMask(display, glyph_gc, glyph->mask); /* mask is a pixmap */ XSetClipOrigin(display, glyph_gc, left, top); XCopyPlane(display, glyph, window, glyph_gc, 0, 0, w, h, left, top, 1); XDrawString(display, window, label_gc, left, top, name, strlen(name)); Is there a race condition in setting and using a clip mask? Am I missing some fundamental aspect of clip masks? What would cause the "bad first display, good subsequent display" behavior of X? Why does it work fine on the NCD? ANY help would be much appreciated. If you would like code to try on your machine, let me know. Thanks for tolerating such a long post. -- Chuck Musciano ARPA : chuck@trantor.harris-atd.com Harris Corporation Usenet: ...!uunet!x102a!trantor!chuck PO Box 37, MS 3A/1912 AT&T : (407) 727-6131 Melbourne, FL 32902 FAX : (407) 729-3363 A good newspaper is never good enough, but a lousy newspaper is a joy forever. -- Garrison Keillor
chuck@trantor.harris-atd.com (Chuck Musciano) (04/11/91)
In article <6026@trantor.harris-atd.com>, chuck@trantor.harris-atd.com (Chuck Musciano) writes: > [ stuff about clip mask problem deleted ] In the sample code, it appears that the rendering of the label text overlays the glyph being rendered. In the actual code, this is not the case. In the course of sanitizing the code for posting, I inadvertantly made it appear that the label and the glyph are rendered at the same spot. Sorry for the confusion. So, does anyone have any good ideas? -- Chuck Musciano ARPA : chuck@trantor.harris-atd.com Harris Corporation Usenet: ...!uunet!x102a!trantor!chuck PO Box 37, MS 3A/1912 AT&T : (407) 727-6131 Melbourne, FL 32902 FAX : (407) 729-3363 A good newspaper is never good enough, but a lousy newspaper is a joy forever. -- Garrison Keillor
doyle@ingr.com (Doyle C. Davidson) (04/11/91)
In article <6026@trantor.harris-atd.com>, chuck@trantor.harris-atd.com (Chuck Musciano) writes: > > Within XView, I have created a canvas, and I wish to render a number of >small pixmaps in the canvas using clip masks. I am also rendering some text >next to each pixmap. The net result is a file manager-like array of glyphs >and names in a scrolling window. I use clip masks to preserve the background >color when drawing non-rectangular glyphs. > My method of drawing non-opaque pixmaps is: Create a bitmap with a bit set wherever there is a pixel set in the pixmap Fill the area non-opaquely with the bitmap pattern (don't forget pattern offsets) with foreground set to 0. (XCopyPlane) GXor in the pixmap (this requires that non-drawn pixel values of the pixmap be 0) with XCopyArea and Function = GXor. This avoids any clip masks in the server, which as a former server implementer, can be very abusive of the server. Just my $0.02 Doyle ------------------------------------------------------------------ Doyle C. Davidson | Intergraph Corp. | These comments are... Everywhere You Look!! | Third Party Software | Product Development | (205) 730-2000 | | X-clusively my own. ..doyle@ingr.com -or- | ..!uunet!ingr!doyle | ------------------------------------------------------------------