Commit graph

18 commits

Author SHA1 Message Date
Emil Ernerfeldt
f3e305a646 Replace TODO: with TODO(emilk): and update code guidelines 2022-05-21 16:53:25 +02:00
Hunter522
0a400a5bcc
Add Image::rotate and Mesh::rotate (#1371)
Co-authored-by: Hunter Morgan <hmorgan@bellflight.com>
2022-03-22 08:44:23 +01:00
jean-airoldie
734d4c57ad
Expose more epaint tessellator methods (#1384)
* Expose more tessellator method

* Make public the Tessellator methods to tessellate a circle, a
    mesh, a rectangle, a line, a path, a quadratic and cubic
    bezier curve.
* Add doc to tessellate_text.
* Add Mesh::append_ref method.

* Make tessellate_text take a reference

* Fix breaking change in benchmark
2022-03-20 20:38:48 +01:00
Emil Ernerfeldt
66d80e2519
Texture loading in egui (#1110)
* Move texture allocation into epaint/egui proper
* Add TextureHandle
* egui_glow: cast using bytemuck instead of unsafe code
* Optimize glium painter
* Optimize WebGL
* Add example of loading an image from file
2022-01-15 13:59:52 +01:00
Emil Ernerfeldt
c60d17b91b
Set MSRV to 1.56.0 and use rust edition 2021 (#998) 2021-12-25 19:32:25 +01:00
Emil Ernerfeldt
d97a369c44 End statements with semicolon (clippy::semicolon_if_nothing_returned) 2021-10-20 16:46:57 +02:00
Stock84
cd2227814f
Implement bytemuck behind a feature (#775) 2021-10-07 22:30:15 +02:00
Emil Ernerfeldt
5539dbe620
Add separate serialize feature and better persitence control (#753)
* Rename epaint feature "persistence" to "serialize"

* Add separate "serialize" feature to egui

* egui_demo_lib: separate serialize and persistence features

* Add App::persist_native_window and App::persist_egui_memory

Controls what gets persisted
2021-09-29 08:45:13 +02: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
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
6e5b52e3bc Add features extra_asserts and extra_debug_asserts for more asserts
This replaces all debug_asserts with these opt-in asserts

Related: https://github.com/emilk/egui/issues/395
2021-05-17 22:38:39 +02:00
Emil Ernerfeldt
b1559963bf Enable a bunch more clippy lints 2021-05-09 14:13:09 +02:00
Emil Ernerfeldt
46425f1e38 Optimize: add #[inline(always)] to various low-level things
saves up to 20% (text tesselation), and at least 5% overall
2021-03-28 23:16:19 +02:00
Emil Ernerfeldt
30885b85f9 Derive PartialEq for Vertex, Mesh, Row, Galley and Shape 2021-03-13 12:58:17 +01:00
Emil Ernerfeldt
1c415bd8fe Add benchmark for text layout and tesselation 2021-02-08 22:53:31 +01:00
Emil Ernerfeldt
c50190a7e8 Add fake italics (tilt text) 2021-01-30 15:55:40 +01:00
Emil Ernerfeldt
2a10747843 Mesh::split_to_u16 now returns a 16-bit indexed Mesh16 2021-01-25 22:06:06 +01:00
Emil Ernerfeldt
75fa77e040 Rename Triangles to Mesh 2021-01-25 21:23:24 +01:00
Renamed from epaint/src/triangles.rs (Browse further)