The module drawing
The drawing module: the damage of a frame and the draw of its records, for each process that imports it. It holds the code that finds what changed between two draw tables and the code that draws the records of a draw table into pixels: the fills, the gradients, the lines, the text of the cells and the text of the interface font, with their blends. A process that imports it holds none of that code: the system has one copy.
What it is for. It is the first library module: code that each module with a window compiled into its own file. The interface package keeps, in the process, what a process calls many times for each frame: the elements, the layout, the input. The drawing module takes what a process calls a few times for each frame: damage_of_draw_table_20 one time, then execute_draw_table_in_rectangles_20 one time for all the damage rectangles of the frame.
No copy. Each parameter is memory of the caller, and a direct call passes its address: the draw table of the frame, the draw table of the frame before, the picture memory of the pictures, and the pixels of the surface, which the module writes in place.
What it keeps. It allocates nothing, and it keeps no address of the caller after a call. Its own data is a cache, one copy for each process that imports it: the text settings of the process (the choice of the font, and the font outlines that the starter of the process mapped, opened at the first draw), its private glyph cache, and the tables of the blend of a text. It reads the choice of the settings again at each draw, so a process sends it nothing when a setting changes. Each glyph is drawn into the private glyph cache of this copy, whose glyph memory the budget of the process pays.
Pictures. A picture record names its pixels by values: the place of its first pixel in a picture memory, and its stride. The caller passes one picture memory as bytes, and the module checks each picture against it.
Grids. A Text_Grid record names its cells by values too: the cells are a copy in the text table of the frame, so the module reads them in the text that each export already takes. The terminal draws its grid through the module.
The GPU back end. A caller with a virtual GPU calls draw_table_to_venus_20 in place of the draw into pixels: the module writes the Venus stream of the frame into the bytes of the caller, and draws no pixel. A caller with no GPU keeps execute_draw_table_in_rectangles_20, which does not change .
The version in the names. The 19 in the name of each export is the version of the draw record. A draw record of another version has exports with other names, so a module that reads the records in another way cannot take the place of this one.
See: The interface of the processes: Where it lives: the elements in each process, the drawing in a module, Text rendering: one module for text at any size in the repository, The text grid in a description in the repository, The access to a GPU for acceleration: The draw table on the virtual GPU in the repository
drawing module with no entry
- Hash
fe69ceff64b0aca04afdecef168b1f68f2180893c8f07436752cf601347bfee1- Size
177579 bytes- Exports
3- Imports
0- Imported by
42- License
- MIT
The drawing module: the damage of a frame and the draw of its records, for each process that imports it
| Fact | Value |
|---|---|
| Kind | Modules with no entry |
| Source | src/modules/libraries/drawing |
| Boot image | yes: in the boot image, 177579 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by |
|
Neighbours
What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.
Exports
| Export | What it does |
|---|---|
damage_of_draw_table_20(before: Table(Draw_Record, Read), before_text: Bytes(Read), now: Table(Draw_Record, Read), now_text: Bytes(Read)) -> Table(Damage_Rectangle) | gives the rectangles of the surface that differ between the draw table before and the draw table now |
execute_draw_table_in_rectangles_20(now: Table(Draw_Record, Read), now_text: Bytes(Read), picture_memory: Bytes(Read), pixels: Bytes(Change), canvas: Canvas_Shape, rectangles: Table(Damage_Rectangle, Read)) -> Integer | draws the records of a draw table into the pixels of a canvas, in each rectangle of rectangles, in their order, each cut to its rectangle: the pixels are those of one draw for each rectangle, also where two rectangles overlap |
draw_table_to_venus_20(now: Table(Draw_Record, Read), now_text: Bytes(Read), scratch: Bytes(Change), venus: Bytes(Change), target: Venus_Target) -> Integer | writes the Venus stream that draws a draw table on the virtual GPU, and returns its count of bytes |
damage_of_draw_table_20
damage_of_draw_table_20(before: (, Read), before_text: (Read), now: (, Read), now_text: (Read)) -> ()
damage_of_draw_table_20 gives the rectangles of the surface that differ between the draw table before and the draw table now. The result is a Table of at most 8 rectangles, which no two of them touch. A record that the border of the draw record refuses differs from each record of other bytes, and a text record or a Path record that names bytes past its text table differs from each record: the box of each is damaged. A Path record compares the bytes of its points, wherever they are in its text table, as a text compares its bytes. A Picture record differs when its generation, its format, its picture memory, its first pixel or its stride differs: the module reads no pixel of a picture. A Text_Grid record of the same place and size in the two tables damages, in each row, the span from the first changed cell to the last one; its cells are in its text table, and a grid whose cells its text table does not hold is damaged whole. Nothing is copied in a direct call: the two tables are read where the caller has them, and the rectangles are written into the buffer of the caller. It fails with -1 and the error record Too_Long, with the argument, for a table over 2^40 records or bytes.
before: (, Read)before_text: (Read)now: (, Read)now_text: (Read)
()- When it fails
- a negative result, and the error record
src/modules/libraries/drawing/drawing.odin:247
execute_draw_table_in_rectangles_20
execute_draw_table_in_rectangles_20(now: (, Read), now_text: (Read), picture_memory: (Read), pixels: (Change), canvas: , rectangles: (, Read)) ->
execute_draw_table_in_rectangles_20 draws the records of a draw table into the pixels of a canvas, in each rectangle of rectangles, in their order, each cut to its rectangle: the pixels are those of one draw for each rectangle, also where two rectangles overlap. With fill_background of the canvas not 0, each rectangle is painted with the color background before its records. A table of no rectangle draws nothing. With scale of the canvas a count of eighths from 8 to 16, the records are in logical pixels and the canvas and the rectangles in pixels of the screen: each edge of a box goes to the nearest pixel, a half up, each point and each origin to the nearest 1/64 pixel, each text is drawn at its size times the scale, and each pixel of a picture covers the pixels of the screen of its logical pixel; with 0 the records are in pixels of the canvas. The pixels are memory of the caller, written in place: no copy in a direct call. The text is drawn in the font that the settings of the process choose: each glyph from the fallback chain of its font, drawn from the font outlines that the starter of the process mapped into the private glyph cache of the process, or the replacement glyph when no font of the chain has it; with no outlines the text is Spleen 8x16. Each color of a record is 0xAARRGGBB with straight alpha, and blends over the pixels by one rule in linear light; an opaque color writes its pixels. The alpha of a text scales the cover of each pixel of its ink. A text is drawn at the text size of its record, from 4 to 128 logical pixels, times the scale: the line of the size, and in the font of the cells a cell of half the size, a half up. A Rectangle with no pattern and a Gradient can have a box inside the pixels: the part of an edge pixel inside the box scales its alpha. A Gradient mixes its two colors at the level of the center of each pixel on the line of its two points, in steps of 1/255. A Picture record of picture memory 0 takes its pixels from picture_memory, from its first pixel, a line each stride pixels: the format Opaque copies each pixel, and the format Straight_Alpha blends each pixel, 0xAARRGGBB, by the rule of the colors. A Text_Grid record draws its cells from now_text, from its first byte, a row each columns cells, each cell half its text size wide, a half up, and two widths high. A Path record reads its points from now_text, 12 bytes each, from its first byte: it fills its subpaths by the nonzero rule, then strokes them with butt ends and bevel joins, each pixel by the exact part of it that the shape covers, and cuts each quadratic curve into at most 16 segments. A record that the border of the draw record refuses (a word that names no kind, a reserved byte that is not 0, a box that is inverted, past the coordinate limit or not on whole pixels in a kind that draws on whole pixels, a color of alpha 0 that is not 0, two ends of a gradient of alpha 0 that are not both 0, two points of a gradient that are equal or too far apart, a path of fewer than 2 or more than 1024 points, a stroke of no width, wider than 64 pixels or with no color, a format of a picture that names no member, a text size under 4 or over 128 logical pixels, a field past its bound, a Clip_Pop whose box is not 0) draws nothing. A Clip_Push cuts the records after it to its box and to each clip open before it, until its Clip_Pop; a refused Clip_Push is an empty clip, and at most 16 clips are open. A text record that names bytes past its text table, a Picture record of another picture memory or with a pixel past picture_memory, a Text_Grid record with no column, with bytes that are not a whole count of rows, past its text table or at an address that is not a multiple of 4, and a Path record whose points are past its text table, at an address that is not a multiple of 4, or that the border of the points refuses (a command that names none, a first point that is not a Move, a subpath with no segment, a curve with no end, a Close out of its place, a point past the coordinate limit), draw nothing. The result is 0. It fails with -1 and an error record, and draws nothing: Bad_Value of canvas for a width or a height below 1 or a stride below the width, Too_Small of pixels for bytes that do not hold stride times height pixels, Bad_Address of pixels or of picture_memory for an address that is not a multiple of 4, Too_Long of rectangles for more than 8 rectangles, Too_Long for a table over 2^40 records or bytes, Bad_Value of now with the unit Records for clips out of order: the value is the problem (1 a Clip_Pop with no Clip_Push open, 2 a Clip_Push past 16 open, 3 a Clip_Push that no Clip_Pop ends), and found the number from 1 of the record.
now: (, Read)now_text: (Read)picture_memory: (Read)pixels: (Change)canvas:rectangles: (, Read)
- When it fails
- a negative result, and the error record
src/modules/libraries/drawing/drawing.odin:269
draw_table_to_venus_20
draw_table_to_venus_20(now: (, Read), now_text: (Read), scratch: (Change), venus: (Change), target: ) ->
draw_table_to_venus_20 writes the Venus stream that draws a draw table on the virtual GPU, and returns its count of bytes. The stream records one command buffer: the upload of the vertices and the indices, the barrier of the image to COLOR_ATTACHMENT_OPTIMAL, the render pass with a scissor for each clip and the draws, the barrier to TRANSFER_SRC_OPTIMAL, the copy of the image into the readback buffer and the barrier to the host; then it submits the command buffer. The caller sends the stream with Venus_Submit of the GPU device service. The scratch holds the WebGPU commands, the vertices and the indices of the translation: 64 KiB is enough for a frame that one packet carries. The module draws no pixel; a caller with no virtual GPU calls execute_draw_table_in_rectangles_20, which this export does not change. A refused call writes no byte of venus. It fails with -1 and the error record: Bad_Value of the target, with the word that names nothing; Bad_Value of the records, with the problem of the translation, for a table that the border of the draw table refuses; Too_Small of the scratch, or of the buffers of the target, that do not hold the frame; Too_Long of the records, for a frame whose stream does not fit in one packet of 65536 bytes; Too_Small of venus that does not hold the stream; Too_Long of a table over 2^40 records or bytes.
now: (, Read)now_text: (Read)scratch: (Change)venus: (Change)target:
- When it fails
- a negative result, and the error record
src/modules/libraries/drawing/drawing.odin:481
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
Table wire form
A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).
Draw_Record record of a module
A record of the module drawing: 48 bytes, aligned on 4 bytes, 0 bytes of padding.
kindu801 bytesreservedText(3)13 byteselementu3244 byteslefti3284 bytestopi32124 bytesrighti32164 bytesbottomi32204 bytesfieldsText(24)2424 bytes
Bytes wire form
A wire form of the module contract: one word of a call. Bytes with no description.
Damage_Rectangle record of a module
A record of the module drawing: 32 bytes, aligned on 8 bytes, 0 bytes of padding.
lefti6408 bytestopi6488 bytesrighti64168 bytesbottomi64248 bytes
Error_Record record of a module
A record of the module drawing: 56 bytes, aligned on 8 bytes, 0 bytes of padding.
kindi6408 bytesuniti6488 bytesoperationi64168 bytesargumenti64248 bytesvaluei64328 byteslimiti64408 bytesfoundi64488 bytes
Canvas_Shape record of a module
A record of the module drawing: 48 bytes, aligned on 8 bytes, 0 bytes of padding.
widthi6408 bytesheighti6488 bytesstridei64168 bytesfill_backgroundi64248 bytesbackgroundi64328 bytesscalei64408 bytes
Integer wire form
A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.
Venus_Target record of a module
A record of the module drawing: 128 bytes, aligned on 8 bytes, 0 bytes of padding.
widthi6408 bytesheighti6488 bytesformati64168 bytesstarti64248 bytesclear_colori64328 bytescommand_bufferi64408 bytesqueuei64488 bytesfencei64568 bytes
and 8 more
Error_Record struct
A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.
kindi6408 bytesuniti6488 bytesoperationi64168 bytesargumenti64248 bytesvaluei64328 byteslimiti64408 bytesfoundi64488 bytes
damage_of_draw_table_20 procedure of the package drawing
damage_of_draw_table_20 :: proc "c" (before: ^system.Table_To_Read(draw_record.Draw_Record), before_text: ^system.Bytes_To_Read, now: ^system.Table_To_Read(draw_record.Draw_Record), now_text: ^system.Bytes_To_Read, result: ^[]Damage_Rectangle, error: ^errors.) -> i64
damage_of_draw_table_20 gives the rectangles of the surface that differ between the draw table before and the draw table now.
execute_draw_table_in_rectangles_20 procedure of the package drawing
execute_draw_table_in_rectangles_20 :: proc "c" (now: ^system.Table_To_Read(draw_record.Draw_Record), now_text: ^system.Bytes_To_Read, picture_memory: ^system.Bytes_To_Read, pixels: ^system.Bytes_To_Change, canvas: ^Canvas_Shape, rectangles: ^system.Table_To_Read(Damage_Rectangle), error: ^errors.) -> i64
execute_draw_table_in_rectangles_20 draws the records of a draw table into the pixels of a canvas, in each rectangle of rectangles, in their order, each cut to its rectangle: the pixels are those of one draw for each rectangle, also where two rectangles overlap.
