GithubHelp home page GithubHelp logo

egui_skia's People

Contributors

ctrlcctrlv avatar lucasmerlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

egui_skia's Issues

Support egui 0.24

There are some changes in egui 0.24, primarily related to how points to pixels is handled, that breaks egui_skia.

Probably it would be good to somehow pin the egui version that egui_skia is known to work?

broken ColorTest with cpu rendering

While tracking down rendering errors, I found that color rendering is broken with cpu rendering (cpu_fix).
Here's a code snippet to render ColorTest.

use egui_skia::rasterize;
use skia_safe::{EncodedImageFormat, Paint, Point};
use std::fs::File;
use std::io::Write;

pub fn main() {
    let mut demo = egui_demo_lib::ColorTest::default();

    let mut surface = rasterize(
        (800, 2000),
        |ctx| {
            egui::CentralPanel::default().show(ctx, |ui| {
                demo.ui(ui);
            });
        },
        None,
    );

    let data = surface
        .image_snapshot()
        .encode_to_data(EncodedImageFormat::PNG)
        .expect("Failed to encode image");

    File::create("output.png")
        .unwrap()
        .write_all(&data)
        .unwrap();

    println!("wrote output.png");
}

This is cpu-rendered image, generate from a code above, which shows errors.
output

Here's a side-by-side screenshot, comparing cpu-rendered with webgl one (from https://egui.rs)
image

No need to swap skia surface R & B

skia surface type can be set by skia_safe::core::image_info::ColorType:
like following code.
let image_info = ImageInfo::new((px_w, px_h), ColorType::RGBA8888, AlphaType::Premul, None);
let surface = Surface::new_raster(&image_info, None, None).unwrap();

text selection rendering glitch

If you start or end a multiline text selection on a blank line in a TextEdit control, the rendering of that text box glitches with this painter. I implemented my own skia painter doesn't use skia-safe, and it exhibits the same behavior, so I think it's something to work around (with the vertex layout?) rather than a bug in our respective code.

When this is triggered:
On the OpenGL SDL and Metal Winit backends, both the text and the rectangle disappear.
On the CPU backend, it manifests differently - the selection color disappears but the text doesn't disappear.

I printed out the vertex positions and it looks like there are NaN verts.

Screen.Recording.2023-01-11.at.9.44.49.PM.mov

Compile error for cpu example

I am trying to compile the cpu example, but failing.

My rustup, rustic and cargo versions are:

lysgaard@morten-Precision-5570:~/work/egui_skia$ cargo --version
cargo 1.68.2 (6feb7c9cf 2023-03-26)
lysgaard@morten-Precision-5570:~/work/egui_skia$ rustc --version
rustc 1.68.2 (9eb3afe9e 2023-03-27)
lysgaard@morten-Precision-5570:~/work/egui_skia$ rustup --version
rustup 1.25.2 (17db695f1 2023-02-01)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.68.2 (9eb3afe9e 2023-03-27)`
lysgaard@morten-Precision-5570:~/work/egui_skia$ 

Below is the full compile log when trying to compile the CPU example.
Do you have any insight into why this fails?
Any help would be greatly appreciated!

Click to expand full compile log
user@laptop:~/work/egui_skia$ cargo run --example cpu --features winit,cpu_fix
   Compiling proc-macro2 v1.0.51
   Compiling unicode-ident v1.0.6
   Compiling cfg-if v1.0.0
   Compiling quote v1.0.23
   Compiling libc v0.2.139
   Compiling autocfg v1.1.0
   Compiling log v0.4.17
   Compiling cc v1.0.79
   Compiling syn v1.0.107
   Compiling memchr v2.5.0
   Compiling once_cell v1.17.1
   Compiling bitflags v1.3.2
   Compiling smallvec v1.10.0
   Compiling untrusted v0.7.1
   Compiling spin v0.5.2
   Compiling version_check v0.9.4
   Compiling tinyvec_macros v0.1.1
   Compiling glob v0.3.1
   Compiling xml-rs v0.8.4
   Compiling parking_lot_core v0.9.7
   Compiling tinyvec v1.6.0
   Compiling ttf-parser v0.18.1
   Compiling lazy_static v1.4.0
   Compiling scopeguard v1.1.0
   Compiling pkg-config v0.3.26
   Compiling crc32fast v1.3.2
   Compiling serde v1.0.152
   Compiling minimal-lexical v0.2.1
   Compiling ab_glyph_rasterizer v0.1.8
   Compiling rustls v0.20.8
   Compiling cfg_aliases v0.1.1
   Compiling unicode-bidi v0.3.10
   Compiling adler v1.0.2
   Compiling cty v0.2.2
   Compiling ahash v0.8.3
   Compiling percent-encoding v2.2.0
   Compiling lock_api v0.4.9
   Compiling miniz_oxide v0.6.2
   Compiling tracing-core v0.1.30
   Compiling clang-sys v1.4.0
   Compiling nom v7.1.3
   Compiling aho-corasick v0.7.20
   Compiling form_urlencoded v1.1.0
   Compiling libloading v0.7.4
   Compiling unicode-normalization v0.1.22
   Compiling serde_json v1.0.93
   Compiling either v1.8.1
   Compiling emath v0.21.0
   Compiling ecolor v0.21.0
   Compiling pin-project-lite v0.2.9
   Compiling nohash-hasher v0.2.0
   Compiling regex-syntax v0.6.28
   Compiling bindgen v0.63.0
   Compiling which v4.4.0
   Compiling tracing v0.1.37
   Compiling flate2 v1.0.25
   Compiling xattr v0.2.3
   Compiling filetime v0.2.20
   Compiling idna v0.3.0
   Compiling memoffset v0.7.1
   Compiling memoffset v0.6.5
   Compiling ring v0.16.20
   Compiling peeking_take_while v0.1.2
   Compiling itoa v1.0.5
   Compiling owned_ttf_parser v0.18.1
   Compiling parking_lot v0.12.1
   Compiling ab_glyph v0.2.20
   Compiling url v2.3.1
   Compiling version-compare v0.1.1
   Compiling shlex v1.1.0
   Compiling serde_derive v1.0.152
   Compiling epaint v0.21.0
   Compiling rustc-hash v1.1.0
   Compiling ryu v1.0.12
   Compiling base64 v0.13.1
   Compiling lazycell v1.3.0
   Compiling khronos_api v3.1.0
   Compiling sdl2-sys v0.35.2
   Compiling tar v0.4.38
   Compiling wayland-scanner v0.29.5
   Compiling wayland-sys v0.30.1
   Compiling cexpr v0.6.0
   Compiling io-lifetimes v1.0.5
   Compiling heck v0.4.1
   Compiling regex v1.7.1
   Compiling dlib v0.5.0
   Compiling wayland-backend v0.1.0
   Compiling raw-window-handle v0.5.0
   Compiling pin-utils v0.1.0
   Compiling toml v0.5.11
   Compiling egui v0.21.0
   Compiling static_assertions v1.1.0
   Compiling nix v0.26.2
   Compiling nix v0.25.1
   Compiling gl_generator v0.14.0
   Compiling x11-dl v2.21.0
   Compiling quick-xml v0.23.1
   Compiling instant v0.1.12
   Compiling sdl2 v0.35.2
   Compiling thiserror v1.0.38
   Compiling downcast-rs v1.2.0
   Compiling winit v0.28.1
   Compiling scoped-tls v1.0.1
   Compiling gethostname v0.2.3
   Compiling x11rb-protocol v0.11.1
error: The platform you're compiling for is not supported by winit
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:67:1
   |
67 | compile_error!("The platform you're compiling for is not supported by winit");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   Compiling raw-window-handle v0.4.3
   Compiling wayland-scanner v0.30.0
error[E0432]: unresolved import `self::platform`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:26:15
   |
26 | pub use self::platform::*;
   |               ^^^^^^^^ could not find `platform` in `self`

error[E0432]: unresolved import `crate::platform_impl::PlatformIcon`
 --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/icon.rs:1:5
  |
1 | use crate::platform_impl::PlatformIcon;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `PlatformIcon` in `platform_impl`

error[E0433]: failed to resolve: could not find `DeviceId` in `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event.rs:789:33
    |
789 |         DeviceId(platform_impl::DeviceId::dummy())
    |                                 ^^^^^^^^ could not find `DeviceId` in `platform_impl`

   Compiling softbuffer v0.2.0 (https://github.com/john01dav/softbuffer#fec8decc)
error[E0433]: failed to resolve: could not find `WindowId` in `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:86:33
   |
86 |         WindowId(platform_impl::WindowId::dummy())
   |                                 ^^^^^^^^ could not find `WindowId` in `platform_impl`

error[E0433]: failed to resolve: could not find `Window` in `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:465:24
    |
465 |         platform_impl::Window::new(&window_target.p, self.window, self.platform_specific).map(
    |                        ^^^^^^ could not find `Window` in `platform_impl`

error[E0412]: cannot find type `OsError` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/error.rs:25:27
   |
25 |     error: platform_impl::OsError,
   |                           ^^^^^^^ not found in `platform_impl`
   |
help: there is an enum variant `crate::window::BadIcon::OsError`; try using the variant's enum
   |
25 |     error: crate::window::BadIcon,
   |            ~~~~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `OsError` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/error.rs:38:76
   |
38 |     pub(crate) fn new(line: u32, file: &'static str, error: platform_impl::OsError) -> OsError {
   |                                                                            ^^^^^^^ not found in `platform_impl`
   |
help: there is an enum variant `crate::window::BadIcon::OsError`; try using the variant's enum
   |
38 |     pub(crate) fn new(line: u32, file: &'static str, error: crate::window::BadIcon) -> OsError {
   |                                                             ~~~~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `DeviceId` in module `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event.rs:776:47
    |
776 | pub struct DeviceId(pub(crate) platform_impl::DeviceId);
    |                                               ^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `EventLoop` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:36:43
   |
36 |     pub(crate) event_loop: platform_impl::EventLoop<T>,
   |                                           ^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `EventLoopWindowTarget` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:47:34
   |
47 |     pub(crate) p: platform_impl::EventLoopWindowTarget<T>,
   |                                  ^^^^^^^^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `PlatformSpecificEventLoopAttributes` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:57:50
   |
57 |     pub(crate) platform_specific: platform_impl::PlatformSpecificEventLoopAttributes,
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0433]: failed to resolve: could not find `EventLoop` in `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:121:40
    |
121 |             event_loop: platform_impl::EventLoop::new(&mut self.platform_specific),
    |                                        ^^^^^^^^^ could not find `EventLoop` in `platform_impl`
    |
help: consider importing this struct
    |
10  | use crate::event_loop::EventLoop;
    |
help: if you import `EventLoop`, refer to it directly
    |
121 -             event_loop: platform_impl::EventLoop::new(&mut self.platform_specific),
121 +             event_loop: EventLoop::new(&mut self.platform_specific),
    |

error[E0412]: cannot find type `EventLoopProxy` in module `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:373:38
    |
373 |     event_loop_proxy: platform_impl::EventLoopProxy<T>,
    |                                      ^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `VideoMode` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/monitor.rs:18:43
   |
18 |     pub(crate) video_mode: platform_impl::VideoMode,
   |                                           ^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `MonitorHandle` in module `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/monitor.rs:107:38
    |
107 |     pub(crate) inner: platform_impl::MonitorHandle,
    |                                      ^^^^^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `VideoMode` in this scope
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:31:15
   |
31 |     Exclusive(VideoMode),
   |               ^^^^^^^^^ not found in this scope
   |
help: consider importing this struct
   |
1  | use crate::monitor::VideoMode;
   |

error[E0412]: cannot find type `MonitorHandle` in this scope
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:32:23
    |
32  |     Borderless(Option<MonitorHandle>),
    |                       ^^^^^^^^^^^^^
    |
   ::: /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/monitor.rs:106:1
    |
106 | pub struct MonitorHandle {
    | ------------------------ similarly named struct `RootMonitorHandle` defined here
    |
help: a struct with a similar name exists
    |
32  |     Borderless(Option<RootMonitorHandle>),
    |                       ~~~~~~~~~~~~~~~~~
help: consider importing this struct
    |
1   | use crate::monitor::MonitorHandle;
    |

error[E0412]: cannot find type `Window` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:45:39
   |
45 |     pub(crate) window: platform_impl::Window,
   |                                       ^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `WindowId` in module `platform_impl`
  --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:73:47
   |
73 | pub struct WindowId(pub(crate) platform_impl::WindowId);
   |                                               ^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `PlatformSpecificWindowBuilderAttributes` in module `platform_impl`
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:110:50
    |
110 |     pub(crate) platform_specific: platform_impl::PlatformSpecificWindowBuilderAttributes,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `platform_impl`

   Compiling gl v0.14.0
error[E0282]: type annotations needed
   --> /home/lysgaard/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:492:17
    |
492 |         builder.build(event_loop)
    |                 ^^^^^ cannot infer type of the type parameter `T` declared on the associated function `build`
    |
help: consider specifying the generic argument
    |
492 |         builder.build::<T>(event_loop)
    |                      +++++

Some errors have detailed explanations: E0282, E0412, E0432, E0433.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `winit` due to 22 previous errors
warning: build failed, waiting for other jobs to finish...

Minor rendering differences between skia and wgpu backend

I'm comparing the winit+metal example of egui_skia with the egui_demo_app wgpu. It seems like the text in egui_skia is slightly off and harder to read. Also, the highlight around the text box appears less vibrant and has white points in the corners. This is only noticeable for me on a non-retina screen. The white dots are also in the corners of the right sidebar.

Here is a screenshot from the code editor example:

skia:
image

wgpu:
image

Both at 400%
image

EDIT:

Perhaps this could be related to some alpha blending issue? Perhaps related to gamma (not quite sure yet what that it is, but egui says in the release notes that since 0.20.0 all color blending has to be done in gamma space)? In the Bezier curve example, the blended red and green colors on the checkboard background look much lighter in skia. The antialasing is also off, perhaps because egui uses alpha for anti aliasing.

skia:
image

wgpu:
image

CPU rendering is a little off

Hey there!

I know you're already aware of this issue (it's even mentioned in the README), but I thought I'd open a tracking issue regardless so I could express my interest in seeing this fixed.

I just managed to integrate egui_skia in a project of mine (https://github.com/daniel5151/wide-libretro), and I'm seeing the same rendering issues as in examples/cpu.rs.

Thanks again for implementing this! Even in its current somewhat broken state, it should be sufficient to start doing what I wanted to do :)

Capture

Windows don't render with rasterizer

I was expecting cargo run --example rasterizer --features cpu_fix to render a few windows but it does not. It only renders the sidebar, the menu, and a transparent area in between

output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.