Commit graph

27 commits

Author SHA1 Message Date
Emil Ernerfeldt
fa43d16c41
Choose your own font and size (#1154)
* Refactor text layout: don't need &Fonts in all functions
* Replace indexing in Fonts with member function
* Wrap Fonts in a Mutex
* Remove mutex for Font::glyph_info_cache
* Remove RwLock around Font::characters
* Put FontsImpl and GalleyCache behind the same Mutex
* Round font sizes to whole pixels before deduplicating them
* Make TextStyle !Copy
* Implement user-named TextStyle:s
* round font size earlier
* Cache fonts based on family and size
* Move TextStyle into egui and Style
* Remove body_text_style
* Query graphics about max texture size and use that as font atlas size
* Recreate texture atlas when it is getting full
2022-01-24 14:32:36 +01:00
Emil Ernerfeldt
462f181db3
Partial font texture update (#1149) 2022-01-22 11:23:12 +01:00
Emil Ernerfeldt
d5673412dd
Put everything in Context behind the same Mutex (#1050)
* Move all interior mutability from Context to CtxRef and make it a handle
* Rename `CtxRef` to `Context`
* The old `Context` is now `ContextImpl` and is non-pub
* Add benchmark Painter::rect

Co-authored-by: Daniel Keller <dklr433@gmail.com>
2022-01-10 23:13:10 +01:00
Emil Ernerfeldt
190c85a40f Rename Texture to FontImage 2021-12-28 21:19:24 +01:00
Emil Ernerfeldt
49e43885ff
Replace Context::begin_frame/end_frame with fn run taking a closure (#872)
* Replace Context begin_frame/end_frame with `fn run` taking a closure
* Create `egui::__run_test_ui` to replace `Ui::__test`
* Add helper `egui::__run_test_ctx` for doctests
2021-11-03 20:11:25 +01:00
Emil Ernerfeldt
e7cfda4941
Shape refactor (#705)
* More introspection stats about vertices/indices etc

* more serde derive

* #[inline] to Shape constructors

* Introduce RectShape

* Introduce CircleShape

* Introduce PathShape

* More serde derive

* impl Copy for RectShape and CircleShape

* Simplify some code

* More serde derive

* Add helpers for appending more input or output

* Serde derives for RawInput

* Rename Fonts::from_definitions to Fonts::new

* Add Output::take

* refactor EguiGlium slightly

* Derive PartialEq for RawInput

* Improve egui::util::History interface

* tweaks

* Improve History filter: add minimum length

* Calculate galley bounding rect

* tessellator: cull line segments and paths

* tessellator: cull meshes

* Fix bug in History bandwidth estimator
2021-09-20 21:36:56 +02:00
Emil Ernerfeldt
14c989fdfa Implement rotating text
Closes https://github.com/emilk/egui/issues/428
2021-09-05 09:06:53 +02:00
Emil Ernerfeldt
71d18ba3e7 Spelling: tesselate -> tessellate 2021-09-03 21:07:25 +02:00
Emil Ernerfeldt
de1a1ba9b2
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.

This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.

One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.


## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).

Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.

All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 18:18:00 +02:00
Emil Ernerfeldt
fbd0e35017 Clippy fixes for benchmark 2021-04-18 23:14:35 +02:00
Emil Ernerfeldt
c07f439b28 Add benchmark of ui.label
This is to help evaluate the impact of
https://github.com/emilk/egui/pull/302
2021-04-18 10:24:31 +02:00
Emil Ernerfeldt
44869a6718 Clean up benchmarks 2021-04-01 21:42:45 +02:00
Emil Ernerfeldt
4808da44a2 Optimize: more inlining and more use of AHashMap
No real gains, but it didn't hurt either
2021-03-31 17:06:12 +02:00
Emil Ernerfeldt
17983e1bbc Optimize tessellator by around 9% 2021-03-30 22:36:45 +02:00
Emil Ernerfeldt
8c4bb0d1d9 refactor: no need to pass Fonts structure to tessellator
This makes the tesselator take only data as argument,
which is a lot nicer.
2021-03-30 21:41:39 +02:00
Emil Ernerfeldt
1c60dc8d66 Pass around Arc<Galley> to avoid copying a lot of data 2021-03-29 22:49:54 +02:00
Emil Ernerfeldt
f9c4be33a7 Add a realistic end-to-end benchmark 2021-03-29 22:49:40 +02:00
Emil Ernerfeldt
d4e5133da2 refactor fonts: put TextStyle in Galley instead of in Shape::Text 2021-03-29 21:24:09 +02:00
Emil Ernerfeldt
ccc501f302 Spelling: tesselate -> tessellate 2021-03-28 22:44:03 +02:00
Emil Ernerfeldt
7dad76b913 Use explicit epaint over paint alias (re-export)
egui reexports the `epaint` crate both under its original name
and under the alias `paint` (for historical reasons)
2021-02-14 10:53:39 +01:00
Emil Ernerfeldt
1c415bd8fe Add benchmark for text layout and tesselation 2021-02-08 22:53:31 +01:00
Emil Ernerfeldt
fb2317c993 Rename PaintCmd to Shape 2021-01-10 11:43:01 +01:00
Emil Ernerfeldt
14a96ca5d0 Add a dummy warm-up frame to the demo app to pre-cache emojis 2021-01-02 14:42:43 +01:00
Emil Ernerfeldt
b3d1016507 [demo] Move backend into an optional panel of WrapApp 2021-01-02 01:01:01 +01:00
Emil Ernerfeldt
3e0bedd96d [demo] Move color test to WrapApp 2021-01-02 00:13:34 +01:00
Emil Ernerfeldt
4848c171eb [demo] Move Fractal Clock to WrapApp 2021-01-02 00:12:45 +01:00
Emil Ernerfeldt
6953dc7d5d Split out the Egui demo code to new crate egui_demo_lib 2020-12-29 13:40:11 +01:00
Renamed from egui/benches/benchmark.rs (Browse further)