3 draw \- screen graphics
11 .BI /dev/draw/ n /data
12 .BI /dev/draw/ n /colormap
13 .BI /dev/draw/ n /refresh
20 ushort BGSHORT(uchar *p)
21 ulong BGLONG(uchar *p)
22 void BPSHORT(uchar *p, ushort v)
23 void BPLONG(uchar *p, ulong v)
29 device serves a three-level file system
30 providing an interface to the graphics facilities of the system.
31 Each client of the device connects by opening
33 and reading 12 strings, each 11 characters wide followed by a blank:
38 of the display image (always zero),
55 of the clipping rectangle.
56 The channel format string is described in
58 and the other fields are decimal numbers.
60 The client can then open the directory
68 files associated with the connection.
76 device provides access to
77 images and font caches
78 in its private storage,
81 Each image is identified by a 4-byte integer, its
86 file yields 12 strings formatted as in
88 but for the current image rather
89 than the display image.
90 The current image may be set by writing a
91 binary image id to the
95 A process can write messages to
97 to allocate and free images, fonts, and subfonts;
98 read or write portions of the images;
99 and draw line segments and character
100 strings in the images.
101 All graphics requests are clipped to their images.
102 Some messages return a response to be recovered by
107 The format of messages written to
110 followed by binary parameters;
111 multibyte integers are transmitted with the low order byte first.
116 macros place correctly formatted two- and four-byte integers into a character
121 retrieve values from a character buffer.
122 Points are two four-byte numbers:
125 Rectangles are four four-byte numbers: min
133 Images, screens, and fonts have 32-bit identifiers.
134 In the discussion of the protocol below,
135 the distinction between identifier and actual image, screen, or font
139 should be interpreted as
140 ``the object with identifier
142 The definitions of constants used in the description below can be found in
145 The following requests are accepted by the
148 The numbers in brackets give the length in bytes of the parameters.
171 byte is non-zero, the screen can
172 be accessed from other processes
187 Allocate an image with a given
192 The image will have rectangle
194 and clipping rectangle
198 is non-zero, the image's replicate
203 specifies the method to be used to draw the window
204 when it is uncovered.
206 causes the server to maintain a backing store,
208 does not refresh the image,
211 causes a message to be sent via
217 The image format is described by
219 a binary version of the channel format string.
220 Specifically, the image format is the catenation of up to four
221 8-bit numbers, each describing a particular image channel.
222 Each of these 8-bit numbers contains a channel type in its
223 high nibble and a bit count in its low nibble.
224 The channel type is one of
237 is the catenation of four 8-bit numbers
238 specifying the red, green, blue, and alpha
239 channels of the color that the new image should
240 be initially filled with.
241 The red channel is in the highest 8 bits, and
242 the alpha in the lowest.
243 Note that color is always in this format, independent of
251 Change the replicate bit and clipping rectangle of the
254 This overrides whatever settings were specified in
255 the allocate message.
267 operator to combine the rectangle
275 using a rectangle of image
277 as an alpha mask to further control blending.
278 The three rectangles are congruent and aligned such that
279 the upper left corner
301 is non-zero, enable debugging output.
303 The meaning of ``debugging output'' is implementation dependent.
316 Draw an ellipse in image
318 centered on the point
320 with horizontal and vertical semiaxes
324 The ellipse is drawn using the image
335 The ellipse is drawn with thickness
341 only the arc of the ellipse from degree angles
346 For the purposes of drawing the arc,
348 is treated as a signed 31-bit number
349 by ignoring its high bit.
362 Draws an ellipse or arc as the
364 message, but rather than outlining it, fills
365 the corresponding sector using the image
369 field is ignored, but must be non-negative.
374 Free the resources associated with the image
380 Free the the screen with the specified
382 Windows on the screen must be freed separately.
393 character cells, each with
406 Load a character into the font cache associated with image
410 The character data is drawn in rectangle
412 of the font cache image
414 the congruent rectangle in image
416 with upper left corner
419 specifies the width of the character\(emthe spacing from this character to the next\(emwhile
422 the horizontal distance from the left side
423 of the character to the left side of the cache image.
424 The dimensions of the image of the character are defined by
437 Draw a line of thickness
445 The line is drawn using the image
447 translated so that point
459 fields specify whether the corresponding
460 line end should be a square, a disc,
476 is non-zero, associate the image
484 already corresponds to the
487 the association is deleted.
494 Introduce the identifier
496 to correspond to the image named
507 so that its upper left corner is at the
511 Simultaneously change its internal (logical) coordinate system
514 corresponds to the upper left corner of the window.
519 Set the compositing operator to
521 for the next draw operation.
535 Draw a polygon of thickness
537 It is conceptually equivalent to a series of
539 line-drawing messages (see
542 joining adjacent points in the list of points
546 is translated so that the point
550 aligns with the first point
553 The polygon need not be closed:
557 specify the line endings for the first and
558 last point on the polygon.
559 All interior lines have rounded ends
560 to make smooth joins.
571 Draw a polygon as the
574 fill it rather than outlining it.
575 The winding rule parameter
577 resolves ambiguities about what to fill if the polygon is self-intersecting.
582 a pixel is inside the polygon if the polygon's winding number about the point
588 a pixel is inside if the winding number is odd.
589 Complementary values (0 or ~1) cause outside pixels to be filled.
590 The meaning of other values is undefined.
591 The polygon is closed with a line if necessary.
597 Cause the next read of the
599 file to return the image pixel data corresponding to the
617 the text string specified by the
623 starting with the upper left corner at point
627 The image drawn is taken from image
637 All drawing is confined to the clipping rectangle
654 Like the string drawing
656 command, but fill the background of each character
657 with pixels from image
661 is translated so that the point
672 Attach to the public screen with the specified
674 It is an error if the screen does not exist, is not public, or does not
675 have the channel descriptor
677 for its associated image.
686 windows to the top (if
688 is non-zero) or bottom (if
690 is zero) of the window stack.
691 The window is specified by the list of
695 are moved as a group, maintaining their own order within the stack.
699 Flush changes from a soft screen, if any, to the display buffer.
712 Replace the rectangle
716 with the pixel data in
718 The pixel data must be in the format dictated by
720 image channel descriptor (see
724 message uses uncompressed data,
727 message uses compressed data.
729 it is an error to include more data than necessary.
733 returns the system color map used on 8-bit displays.
734 Each color map entry consists of a single line containing
735 four space-separated decimal strings.
736 The first is an index into the map, and the remaining three are
737 the red, green, and blue values associated with that index.
738 The color map can be changed by writing entries in the
743 Note that changing the system color map
744 does not change the color map used for
745 calculations involving
747 images, which is immutable.
752 As windows owned by the client are uncovered,
753 if they cannot be refreshed by the server (such as when they have
754 refresh functions associated with them), a message is made available
757 file reporting what needs to be repainted by the client.
758 The message has five decimal integers formatted as in the
760 message: the image id of the window and the coordinates of the rectangle
761 that should be refreshed.
763 .B /sys/src/9/port/devdraw.c
765 .B /sys/src/libmemdraw
770 these can be detected by a system call error
774 of the data containing the erroneous message.
775 The most common error is a failure to allocate
776 because of insufficient free resources. Most other errors occur
777 only when the protocol is mishandled by the application.
783 refresh method is not fully implemented.
787 files only reference the system color map, and as
788 such should be called
791 .BI /dev/draw/ n /colormap\f1.