These are chat archives for AvaloniaUI/Avalonia

4th
Nov 2017
Wiesław Šoltés
@wieslawsoltes
Nov 04 2017 06:09 UTC
Avalonia now has Resources so porting from WPF got a bit easier.
Big Jake
@jakesays
Nov 04 2017 15:13 UTC
css-like selectors?
Big Jake
@jakesays
Nov 04 2017 15:27 UTC
so i'm looking for a UI for a small screen - 320x240 on linux, using coreclr. is the skia backend in good enough shape?
Nikita Tsukanov
@kekekeks
Nov 04 2017 15:28 UTC
Skia backend - yes
Our /dev/fb0 support... Well, I've only tested it on my laptop and with QEMU VM
And I haven't even started working on support for /dev/drm
Big Jake
@jakesays
Nov 04 2017 15:33 UTC
i just need the framebuffer
its a pretty simple screen
is there support for the linux input system?
Nikita Tsukanov
@kekekeks
Nov 04 2017 15:34 UTC
There is some basic support for evdev
Big Jake
@jakesays
Nov 04 2017 15:35 UTC
ok cool. just need to be able to handle my finger. lol
when did you guys switch to portable.xaml?
oh and is ide usable?
damn you guys have been busy! i see an avalonedit port.
Nikita Tsukanov
@kekekeks
Nov 04 2017 15:43 UTC
IDE isn't completely usable yet
Big Jake
@jakesays
Nov 04 2017 15:46 UTC
i got excited when i saw the vs plugin, but then remembered i'm doing all my dev in wsl
i could probably still make it work
hmm. this would be an interesting port: https://github.com/ArthurHub/HTML-Renderer
would make for an interesting rich text control
Nikita Tsukanov
@kekekeks
Nov 04 2017 15:49 UTC
We already have it ported
Back in 2015, I think
Big Jake
@jakesays
Nov 04 2017 15:50 UTC
oh??
awesome!
does it work?
Nikita Tsukanov
@kekekeks
Nov 04 2017 15:51 UTC
Nobody have checked if it does since 2016
Big Jake
@jakesays
Nov 04 2017 15:52 UTC
damn wish i had more time
Nikita Tsukanov
@kekekeks
Nov 04 2017 15:52 UTC
It would probably be better to make the original one to target netstandard
and push our backend to their main repo
Big Jake
@jakesays
Nov 04 2017 15:52 UTC
yeah
so avalonia is netstandard 2 compliant?
Nikita Tsukanov
@kekekeks
Nov 04 2017 16:09 UTC
yep
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 16:11 UTC

@Nikita I followed your suggestion. I took a piece of code form some example

var fb = new Framebuffer(PixelFormat.Bgra8888, (int)this.Width, (int)this.Height);
var r = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();
using (var target = r.CreateRenderTarget(new object[] { fb }))
{
var bmp = new Bitmap(PixelFormat.Bgra8888, fb.Address, fb.Width, fb.Height, fb.RowBytes);
bmp.Save(@"D:\test1.bmp");
}

fb.Deallocate();

using (var rtb = new RenderTargetBitmap((int)this.Width, (int)this.Height))
{
rtb.Render(this);
rtb.Save(@"D:\test2.png");
}

All bytes in fb.Address are 0. So test1.bmp doesn't contain antything
test2.png is correct

What is wrong?
Thank you

Nikita Tsukanov
@kekekeks
Nov 04 2017 16:14 UTC
Well, you aren't rendering anything
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 16:22 UTC
ops, sorry. I thought this feature return the buffer of the window content
Nikita Tsukanov
@kekekeks
Nov 04 2017 16:25 UTC
Nope, you can render controls to a render target
one of the possible render targets is a framebuffer
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 16:26 UTC
In my WPF application I use rendertargetbitmap Render and after that CopyPixel to get the pixels
how can I render targets in a framebuffer?
Nikita Tsukanov
@kekekeks
Nov 04 2017 16:26 UTC
You can render to a framebuffer instead of RTB
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 16:34 UTC
var fb = new Framebuffer(PixelFormat.Bgra8888, (int)this.Width, (int)this.Height);
var r = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();
using (var target = r.CreateRenderTarget(new object[] { fb }))
using (var ctx = target.CreateDrawingContext(null))
{
Avalonia.Rendering.Render(this, ctx);
}
            var bmp = new Bitmap(PixelFormat.Bgra8888, fb.Address, fb.Width, fb.Height, fb.RowBytes);
            bmp.Save(@"D:\test1.bmp");

            fb.Deallocate();
something like that?
Nikita Tsukanov
@kekekeks
Nov 04 2017 16:44 UTC
Yeah, but you can probably render to your video card's framebuffer directly
instead of using intermediate bitmaps
It gives you an IntPtr, right?
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 16:57 UTC
Right
I don’t find avaloniA.rendering what should I add?
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 17:11 UTC
Should I call this function in ui thread or can I call in another thread?
Big Jake
@jakesays
Nov 04 2017 17:30 UTC
@kekekeks hey how does omnigui compare to avalonia?
Wiesław Šoltés
@wieslawsoltes
Nov 04 2017 17:43 UTC

It would probably be better to make the original one to target netstandard

@kekekeks ArthurHub/HTML-Renderer#112

danwalmsley
@danwalmsley
Nov 04 2017 19:37 UTC
@jakesays omnigui uses native controls, its more like xamarin forms, avalonia is 100% lookless controls, afaik
Jeremy Koritzinsky
@jkoritzinsky
Nov 04 2017 19:51 UTC
@jakesays @danwalmsley OmniGui is lookless like Avalonia, but with a much smaller control library, immediate-rendering only, no binding priority system, and a much less performant XAML engine. It's actually run by the guy who develops our previous XAML engine. He started it after we switch off his XAML engine because of performance issues
rconde01
@rconde01
Nov 04 2017 19:57 UTC
gui toolkit rumble
Jeremy Koritzinsky
@jkoritzinsky
Nov 04 2017 19:59 UTC
Also OmniGui won't handle the window creation. It renders into a view provided by the user
Nikita Tsukanov
@kekekeks
Nov 04 2017 20:02 UTC

Should I call this function in ui thread or can I call in another thread

It is possible to render on non-UI thread, but that involves quite complex setup

ImmediateRenderer.Render should be called on UI-thread
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 20:43 UTC
thank you Nikita
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 20:52 UTC

you wrote

"but you can probably render to your video card's framebuffer directly
instead of using intermediate bitmaps
It gives you an IntPtr, right?"

where shoud I pass IntPtr?
Nikita Tsukanov
@kekekeks
Nov 04 2017 21:11 UTC
You need to implement ILockedFramebuffer
and return that IntPtr from Address property
Just make sure to set width, height, stride and pixel format correctly
Big Jake
@jakesays
Nov 04 2017 21:12 UTC
@jkoritzinsky ok cool. thanks.
i'm trying to decide if i work today or play with skia-avalonia on my LCD
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 21:13 UTC
thank you
Nikita Tsukanov
@kekekeks
Nov 04 2017 21:24 UTC
@jakesays you still need to get an ARM build of libSkiaSharp somewhere...
Big Jake
@jakesays
Nov 04 2017 21:25 UTC
@kekekeks yeah i'll build it
if i get it working i'm going to try to implement my own userspace that loads just my app
but thats down the road
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 21:49 UTC

I'm testing the speed of rendering function

            Stopwatch stopwatch = new Stopwatch();
            var fb = new Framebuffer(PixelFormat.Bgra8888, (int)this.Width, (int)this.Height);
            var r = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();
            using (var target = r.CreateRenderTarget(new object[] { fb }))
            using (var ctx = new DrawingContext(target.CreateDrawingContext(null)))
            {
                stopwatch.Start();
                ImmediateRenderer.Render(this, ctx);
                Trace.WriteLine(stopwatch.ElapsedMilliseconds);
                var bmp = new Bitmap(PixelFormat.Bgra8888, fb.Address, fb.Width, fb.Height, fb.RowBytes);
                bmp.Save(@"D:\test1.bmp");
            }

            fb.Deallocate();

            using (var rtb = new RenderTargetBitmap((int)this.Width, (int)this.Height))
            {
                stopwatch.Restart();
                rtb.Render(this);
                Trace.WriteLine(stopwatch.ElapsedMilliseconds);
                rtb.Save(@"D:\test2.png");
            }

ImmediateRenderer.Render seems to be slower than RenderTargetBitmap Render

Nikita Tsukanov
@kekekeks
Nov 04 2017 21:51 UTC
Are you using Skia backend?
If you are using Direct2D RTB rendering will be faster, but it will take time to get it back from the video memory
So rtb.Save(@"D:\test2.png"); will be slower than bmp.Save(@"D:\test1.bmp");
It also won't actually flush the drawing operations immediately
So if you are using Direct2D backend, your benchmark is incorrect
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 21:53 UTC
not the "save" function. I'm watching the stopwatch.elapsedmilliseconds
Nikita Tsukanov
@kekekeks
Nov 04 2017 21:54 UTC
Yes, but you don't measure the time of rendering
You are measuring the time of sending drawing commands to DirectX
Switch to Skia backend
You also shouldn't access the bitmap data before disposing DrawingContext
It's not guaranteed to have the complete image at that point
Alessandro Miorelli
@AlessandroMiorelli
Nov 04 2017 22:00 UTC
sorry I'm newbie, what's mean "switch to skia backend"?
Nikita Tsukanov
@kekekeks
Nov 04 2017 22:03 UTC
In your Main method add UseSkia() after UsePlatformDetect()
Wiesław Šoltés
@wieslawsoltes
Nov 04 2017 23:03 UTC
@kekekeks I have finished adding support for netstandar2.0 for HTML-Renderer ArthurHub/HTML-Renderer#112 https://ci.appveyor.com/project/ArthurHub/html-renderer/build/1.5.1.136/artifacts, hopefully it will get merged in main repo :smile:
Nikita Tsukanov
@kekekeks
Nov 04 2017 23:11 UTC
:+1: