Commit graph

94 commits

Author SHA1 Message Date
Héctor Ramón Jiménez
81dedbd042 Implement subpixel glyph positioning and scaling
The latest `cosmic-text` release performs bucketing calculations after
layouting. This allows us to provide proper subpixel offsets, as well as
scale any buffer thanks to its linear layout properties.

See https://github.com/pop-os/cosmic-text/pull/143.
2023-07-11 00:18:25 -02:30
Héctor Ramón Jiménez
595e09a497 Take an IntoIterator instead of Iterator in prepare methods 2023-07-10 15:25:47 -02:30
Héctor Ramón Jiménez
1469768013 Iterate over text areas only once in prepare 2023-07-10 15:25:47 -02:30
Héctor Ramón Jiménez
d40b6ad2ed Remove Copy implementation for TextArea 2023-07-10 15:25:47 -02:30
Héctor Ramón Jiménez
0857bef584 Take an Iterator of TextArea in prepare 2023-07-10 15:25:47 -02:30
Héctor Ramón Jiménez
7f31965063 Fix potentially evicting glyphs in use during try_allocate 2023-07-04 14:54:05 -02:30
Héctor Ramón Jiménez
bc9cc82050 Use new etagere release 🎉 2023-07-04 14:54:05 -02:30
Héctor Ramón Jiménez
f64771c2c3 Grow internal packer and re-upload glyphs automatically 2023-07-04 14:54:05 -02:30
Héctor Ramón Jiménez
a74ce29c1a Implement growing logic for TextAtlas
The `TextAtlas` will have an initial size of `256` (we could make this
configurable) and `try_allocate` will keep track of the glyphs in use
in the current frame, returning `None` when the LRU glyph is in use.

In that case, `TextRenderer::prepare` will return
`PrepareError::AtlasFull` with the `ContentType` of the atlas that is
full. The user of the library can then call `TextAtlas::grow` with the
provided `ContentType` to obtain a bigger atlas (by `256`).

A `TextAtlas::grow` call clears the whole atlas and, as a result, all of
the `prepare` calls need to be repeated in a frame until they all
succeed. Overall, the atlas will rarely need to grow and so the calls
will not need to be repated often.

Finally, the user needs to call `TextAtlas::trim` at the end of the
frame. This allows us to clear the glyphs in use collection in the atlas. Maybe
there is a better way to model this in an API that forces the user to
trim the atlas (e.g. make `trim` return a new type and changing `prepare` and `render` to take that type instead).
2023-07-04 14:54:05 -02:30
Gijs Burghoorn
d20643702f Doc: Add small summary of crate goal in doc.rs 2023-06-07 10:07:44 -02:30
Héctor Ramón Jiménez
9f82af4f7d Introduce ColorMode for Atlas 2023-06-06 11:56:02 -02:30
Héctor Ramón Jiménez
80e8465af6 Update wgpu to 0.16 2023-05-03 13:29:20 -02:30
Héctor Ramón Jiménez
ddaaae295c Update wgpu to 0.15 2023-04-08 12:43:37 -02:30
Héctor Ramón Jiménez
b9430c39b6 Update cosmic-text to 0.8 2023-04-08 12:43:04 -02:30
Héctor Ramón Jiménez
19d704f0c9 Make render take an immutable self 2023-03-27 23:20:26 -02:30
Héctor Ramón Jiménez
e457bca108 Use Srgb texture format for TextAtlas 2023-03-27 23:03:55 -02:30
Héctor Ramón Jiménez
2af2f357c5 Update cosmic-text to latest 2023-03-27 23:02:28 -02:30
Héctor Ramón Jiménez
ea5f122f78 Remove potentially huge texture_pending from InnerAtlas
Instead, issue a `write_texture` for every glyph that isn't present in
the atlas. I think this should be fine, since cache eviction should be
rare and, therefore, uploads will be too.

The result here is lower memory usage for bigger caches.
2023-03-27 23:00:19 -02:30
Héctor Ramón Jiménez
1f31586c55 Set default_color per TextArea 2023-02-26 23:30:30 -03:30
grovesNL
1dcb1735b4 Update to latest cosmic-text 2023-02-24 12:33:03 -03:30
grovesNL
c25f394c16 Allow depth to be attached to text using metadata 2023-02-15 07:54:31 -03:30
grovesNL
74e9aa37a1 Set renderer multisample and depth-stencil state 2023-02-15 07:54:31 -03:30
Héctor Ramón Jiménez
da4bb4af5c Use lru for glyph caching
I noticed that the `RecentlyUsed` map was actually a `RecentlyInserted`
map. This caused panics when trying to reduce the initial texture atlas size and
dynamically increase it (coming in another PR!).
2023-02-08 00:49:37 -03:30
grovesNL
bbe26f9c54 Move version back to 0.2.0 for now 2023-01-29 22:17:31 -03:30
grovesNL
05939b2731 Release 0.3.0 2023-01-29 22:15:32 -03:30
grovesNL
8aeb9f16bf Remove unnecessary cast 2023-01-29 22:14:55 -03:30
grovesNL
288cd89cf8 Simplify re-exports paths 2023-01-29 22:11:54 -03:30
grovesNL
658fcf4d6f Separate text area lifetimes 2023-01-29 22:11:54 -03:30
grovesNL
07b04f511a Update example to show emojis and clipping 2023-01-29 22:11:54 -03:30
grovesNL
8c8cfba093 Add clipping back 2023-01-29 22:11:54 -03:30
grovesNL
ba52cbdba6 Buffer doesn't need to be mutable anymore 2023-01-29 22:11:54 -03:30
grovesNL
e0998be181 Only multiply alpha 2023-01-29 22:11:54 -03:30
grovesNL
06766de965 Update to latest cosmic-text 2023-01-29 22:11:54 -03:30
Joshua Groves
65ff0a6eec Update to latest cosmic-text 2023-01-29 22:11:54 -03:30
Joshua Groves
3a0e965675 Split color and mask atlases apart 2023-01-29 22:11:54 -03:30
Joshua Groves
6cf10bba8d Fix alpha blending for emojis 2023-01-29 22:11:54 -03:30
Joshua Groves
609814de6b Use Fifo for example 2023-01-29 22:11:54 -03:30
grovesNL
8a1153039e Update to latest cosmic 2023-01-29 22:11:54 -03:30
grovesNL
84fb66e27e Use color packing from cosmic 2023-01-29 22:11:54 -03:30
grovesNL
4c1a83548e Use default font color and remove Color 2023-01-29 22:11:54 -03:30
grovesNL
7eb4d41c25 Update README 2023-01-29 22:11:54 -03:30
grovesNL
14499e4659 Remove HasColor 2023-01-29 22:11:54 -03:30
grovesNL
56bf0d759f Update to latest cosmic-text 2023-01-29 22:11:54 -03:30
grovesNL
981a7d1682 Handle initial window scale factor 2023-01-29 22:11:54 -03:30
grovesNL
cb68955045 Use 4 channel atlas for emojis 2023-01-29 22:11:54 -03:30
grovesNL
47fa03d079 Allow negative offsets 2023-01-29 22:11:54 -03:30
grovesNL
dcdb250e19 Use arabic.txt example and get_image_uncached 2023-01-29 22:11:54 -03:30
grovesNL
7fe35bdce3 Update to latest cosmic-text 2023-01-29 22:11:54 -03:30
grovesNL
75fc8f978f Start cosmic-text implementation 2023-01-29 22:11:54 -03:30
grovesNL
2a01a1b2e0 Handle negative glyph positions correctly 2022-11-29 14:33:12 -03:30