These are chat archives for AvaloniaUI/Avalonia

1st
Nov 2015
Nikita Tsukanov
@kekekeks
Nov 01 2015 02:00
Skia samples - https://dl.dropboxusercontent.com/u/18301199/skia_angle.zip
press "D" to switch to hardware accellerated backend (ANGLE is DX9 based), press ← and → to switch between samples
As you can see it can provide the same api for OpenGL, DirectX and built-in hardware rasterizer
Egor Bogatov
@EgorBo
Nov 01 2015 11:30
Do you have any experience with Angle? It sounds it's very slow, isn't it?
to emulate opengl using dx :/
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:31
Ehm, wine does the opposite and games run pretty smoothly
Angle is also "good enough" for chrome
You can find libegl and libglesv2 in your chrome installation
Egor Bogatov
@EgorBo
Nov 01 2015 11:33
Wow, I didn't know that :)
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:33
skia is the library that is used by chrome and firefox
Egor Bogatov
@EgorBo
Nov 01 2015 11:34
does it have a C# api?
this project uses Skia afaik https://github.com/xamarin/XobotOS
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:36

does it have a C# api?

Nope

I've also gave up on the idea to create such api
Not worth the effort
For now I've started implementing Perspex's IPlatformRenderInterface in C++
Egor Bogatov
@EgorBo
Nov 01 2015 11:38
there is a project https://github.com/mono/CppSharp that helps building C# api over C++ code
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:39
The problem is that is has a bit different api accross platforms
Egor Bogatov
@EgorBo
Nov 01 2015 11:39
by "it" you mean Skia?
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:39
yep
Auto-generated wrappers are also usually slow
Egor Bogatov
@EgorBo
Nov 01 2015 11:40
this one is quite good :)
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:40
So it's better to define some simple C api that then gets pinvoked
in this case we can avoid a lot of managed-native transitions
Egor Bogatov
@EgorBo
Nov 01 2015 11:41
it actually creates pinvokes for each "exported" functions in C++
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:41
Yep, that's the point
Egor Bogatov
@EgorBo
Nov 01 2015 11:41
so it seems you are going to do the same but by hands :)
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:41
With my approach there will be one P/Invoked function
And all memory allocations will be managed by C++
Skia uses ref counting and uses it via templates
Egor Bogatov
@EgorBo
Nov 01 2015 11:42
don't stop, write everything in C++! :)
Nikita Tsukanov
@kekekeks
Nov 01 2015 11:42
Yep, the whole renderer will be in C++
Just like in WPF/Silverlight/Moonlight
Egor Bogatov
@EgorBo
Nov 01 2015 11:43
I hope it won't be as slow as them ;)
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:14
Congrats, guays! we're in the comments of this post of the WPF Team blog
we're not mentioned in the post, but yes, being in the comments means we're starting to be popular :)
Egor Bogatov
@EgorBo
Nov 01 2015 12:18
the official WPF blog makes me sad: http://www.jetScreenshot.com/demo/20151101-1b2-140kb.jpg
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:19
Yes. It's sad. The roadmap should have a goal: make WPF truly cross-platform
Egor Bogatov
@EgorBo
Nov 01 2015 12:19
the biggest change for the last 4 years: "Touch stack performance has been improved" :(
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:21
Everybody knows WPF has its problems, but all in all, it's the most powerful UI framework ever created in terms of possibilities
Egor Bogatov
@EgorBo
Nov 01 2015 12:21
Microsoft has more than 120k of employees :( it sad they didn't dedicate a few to develop WPF over the years
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:23
they were too busy at failing, reinventing the wheel
Egor Bogatov
@EgorBo
Nov 01 2015 12:23
Agree, but in general it has dead community. I mean you might find any control you want for Android and all of them are being activly maintained. Recenlty I needed a desktop app and I needed a simple text edit with suggestions list -- it wasn't easy to find it
for WPF*
Johan Larsson
@JohanLarsson
Nov 01 2015 12:27
wpf is not designed to be extensible
lots of internal ctors etc
also the implementation in general looks messy at many places, probably not much fun to maintain
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:30

Agree, but in general it has dead community. I mean you might find any control you want for Android and all of them are being activly maintained. Recenlty I needed a desktop app and I needed a simple text edit with suggestions list -- it wasn't easy to find it

It's not. Everybody wanted theire money after they created a useful control.

And it's OK, but that means that you cannot create a rich GUI without paying
Johan Larsson
@JohanLarsson
Nov 01 2015 12:31
there are free stuff, oxyplot, mahapps, mui etc
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:31
yes, right now!
Johan Larsson
@JohanLarsson
Nov 01 2015 12:31
extended toolkit has a free version right?
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:31
when WPF is 0.1% of what it was
Johan Larsson
@JohanLarsson
Nov 01 2015 12:32
yeah, I can imagine web & apps being totally different
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:33
Xceed offers a free version, yeah, it's good quality
it's the exception, not the rule
Johan Larsson
@JohanLarsson
Nov 01 2015 12:33
could perhaps be explained to some % by microsoft shops being skeptical about open source for whatever reason
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:33
IMHO, Microsoft should have promoted the community when it had the opportunity
yes, that's it
having a strong open source community is ESSENTIAL nowadays
Johan Larsson
@JohanLarsson
Nov 01 2015 12:34
wpf should have been open source from the start
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:34
they finally seem to understand
what? open source? you're crazy!
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:34
MS open sourcing WPF?
Johan Larsson
@JohanLarsson
Nov 01 2015 12:34
why?
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:34
never
it won't happen
Johan Larsson
@JohanLarsson
Nov 01 2015 12:34
they open source pretty much everything else in the framework no?
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:34
they are too worried about copyrights
about people collaborating to make WPF better
Egor Bogatov
@EgorBo
Nov 01 2015 12:35
and ashmed because of its code quality :)
Johan Larsson
@JohanLarsson
Nov 01 2015 12:35
haha, probably very true
José Manuel Nieto
@SuperJMN
Nov 01 2015 12:35
that's for granted, @egorBo
Johan Larsson
@JohanLarsson
Nov 01 2015 12:35
code quality would perhaps have been the biggest benefit from open sourcing it
I hope Rust takes off and becomes the next big thing, looks so nice
Would be sweet to be able to write nice code and know that it runs as fast as it can
^ good talk
Wiesław Šoltés
@wieslawsoltes
Nov 01 2015 13:18

we're not mentioned in the post, but yes, being in the comments means we're starting to be popular :)

https://github.com/trending?l=csharp&since=weekly

Egor Bogatov
@EgorBo
Nov 01 2015 13:22
wow!
José Manuel Nieto
@SuperJMN
Nov 01 2015 14:24
Yay!
Nikita Tsukanov
@kekekeks
Nov 01 2015 15:47
blob
blob
Johan Larsson
@JohanLarsson
Nov 01 2015 15:49
is it using the skia thing?
Nikita Tsukanov
@kekekeks
Nov 01 2015 15:51
Yep
At last, I've got something on the screen
It's not that simple if you aren't using their window abstraction
blob
Looks better with antialiasing and larger stroke
Johan Larsson
@JohanLarsson
Nov 01 2015 15:53
colors are perfect :)
Nikita Tsukanov
@kekekeks
Nov 01 2015 15:54
    [StructLayout(LayoutKind.Sequential)]
    internal struct NativeBrush
    {
        public float Opacity;
        public uint Color;
        public bool Stroke;
        public float StrokeThickness;
    }

        NativeBrush CreateBrush(Brush brush)
        {
            var rv = new NativeBrush();
            rv.Opacity = (float)brush.Opacity;

            var solid = brush as SolidColorBrush;
            if (solid != null)
            {
                rv.Color = solid.Color.ToUint32();
            }
            return rv;
        }

        NativeBrush CreateBrush(Pen pen)
        {
            var brush = CreateBrush(pen.Brush);
            brush.Stroke = true;
            brush.StrokeThickness = (float)pen.Thickness;
            return brush;
        }

        public void DrawRectangle(Pen pen, Rect rect, float cornerRadius = 0)
        {
            var brush = CreateBrush(pen);
            var rc = SkRect.FromRect(rect);
            MethodTable.Instance.DrawRectangle(Handle, ref brush, ref rc, cornerRadius);
        }

        public void FillRectangle(Brush pbrush, Rect rect, float cornerRadius = 0)
        {
            var brush = CreateBrush(pbrush);
            var rc = SkRect.FromRect(rect);
            MethodTable.Instance.DrawRectangle(Handle, ref brush, ref rc, cornerRadius);
        }
inline SkPaint CreatePaint(PerspexBrush*brush)
{
    SkPaint paint;
    paint.setColor(brush->Color);
    //paint.setAlpha(brush->Opacity);
    if (brush->Stroke)
    {
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setStrokeWidth(brush->StrokeThickness);
    }
    else
        paint.setStyle(SkPaint::kFill_Style);
    paint.setAntiAlias(true);
    return paint;
}

extern void DrawRectangle(RenderingContext*ctx, PerspexBrush*brush, SkRect*rect, float borderRadius)
{
    SkPaint paint = CreatePaint(brush);

    if (borderRadius == 0)
        ctx->Canvas->drawRect(*rect, paint);
    else
        ctx->Canvas->drawRoundRect(*rect, borderRadius, borderRadius, paint);
}
See? One single native call for drawing stuff
It will even setup gradients, bitmap fill, etc
All using that shared data structure
Johan Larsson
@JohanLarsson
Nov 01 2015 15:55
how much overhead is a native call?
Nikita Tsukanov
@kekekeks
Nov 01 2015 15:55
Almost nothing
It doesn't do any heavy marshaling and it's just a delegate extracted using Marshal.GetDelegateForFunctionPtr
We are already spending more time on managed->native transitions with our current backends
Johan Larsson
@JohanLarsson
Nov 01 2015 15:57
was just curious
Nikita Tsukanov
@kekekeks
Nov 01 2015 15:57
It's also easy to port this calling technique to android/ios/whatever, since we only need to call GetPerspexMethodTable from native library
Everything else will work using Marshal.GetDelegateForFunctionPtr
I'll also be able to keep most of platform-specific stuff inside the native part
Where I can use #ifdef heavily
Johan Larsson
@JohanLarsson
Nov 01 2015 16:00
what platform specific stuff leaks?
dc has a pretty small api right?
Nikita Tsukanov
@kekekeks
Nov 01 2015 16:01
You'll need to somehow pass platform-specific window handle
It's the only thing that I see leaking
Johan Larsson
@JohanLarsson
Nov 01 2015 16:01
nice
I don't know any c++
afraid of c++ :)
Nikita Tsukanov
@kekekeks
Nov 01 2015 16:02
Well, I've been developing for embedded devices for several years
C++ is pretty simple as long as you know what are you doing and don't use any template/macro magic
José Manuel Nieto
@SuperJMN
Nov 01 2015 16:46
it resumes to @Kekekeks being a fuck**g code wizard
he's nearing the Mount of the Coding Minotaur, were the man becomes a deity.
Johan Larsson
@JohanLarsson
Nov 01 2015 16:58
nice that you spell out the fukk but star the rest :)
José Manuel Nieto
@SuperJMN
Nov 01 2015 17:16
lol
José Manuel Nieto
@SuperJMN
Nov 01 2015 17:28
didn't even notice!
Johan Larsson
@JohanLarsson
Nov 01 2015 17:28
:)
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:29
ARGH
Latest mono can't run on XP
Johan Larsson
@JohanLarsson
Nov 01 2015 17:29
how important is it to support xp?
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:30
Well, it has significant market share
More market share than linux
Johan Larsson
@JohanLarsson
Nov 01 2015 17:30
ms does not support it any more
ok
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:30
MS also doesn't support linux
Johan Larsson
@JohanLarsson
Nov 01 2015 17:30
they have their win distro
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 17:35
I wouldn't worry about XP. It's share is falling fast
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:35
Nope, it isn't
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 17:35
By the time perspex is practical, it'll be a pretty small, and falling, share
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:36
Win10 market share is growing by getting win7/win8 users
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 17:36
Most things show its around 11-12% now, which is less than half of share in 2014
Johan Larsson
@JohanLarsson
Nov 01 2015 17:36
jinx
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:38
Well, it's still larger than Win10's
Johan Larsson
@JohanLarsson
Nov 01 2015 17:38
surprising that win is so big
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:38
And, of course, larger than Linux
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 17:38
It's significant, but falling
Nikita Tsukanov
@kekekeks
Nov 01 2015 17:38
Every 10th user in the world is using WinXP
that's huge
The question is do we really need to target that 4.5 PCL profile?
José Manuel Nieto
@SuperJMN
Nov 01 2015 17:46
feeling dizzy
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 17:49
And realistically, people who won't move away from a legacy OS are not your target market probably
Steven Kirk
@grokys
Nov 01 2015 17:52
personally, i think xp can go do one, but it's unlikely we'd convince kekekeks
as long as it doesn't make things more difficult for us however we can support it
but i'd rather wait until close to 1.0 before we think about it
Johan Larsson
@JohanLarsson
Nov 01 2015 17:53
strange that linux never starts growing
José Manuel Nieto
@SuperJMN
Nov 01 2015 17:54

strange that linux never starts growing

It's a hostile world

Johan Larsson
@JohanLarsson
Nov 01 2015 17:55
yeah, I guess the preinstalled win on every computer hurts linux adoption
really hard to buy a laptop without win installed
or mac
José Manuel Nieto
@SuperJMN
Nov 01 2015 17:56
probably it's the same network effect that hurts Windows Phone's adoption ;)
Steven Kirk
@grokys
Nov 01 2015 17:56
well also windows phone is a bit crap ;)
Johan Larsson
@JohanLarsson
Nov 01 2015 17:57
my company has been trying to give me an iphone for like five years
I refuse, use old broken phones instead :)
José Manuel Nieto
@SuperJMN
Nov 01 2015 17:59
@grokys No, it isn't!
My Lumia 920 is the best mobile phone I've ever had
also, my first Windows Phone.
Steven Kirk
@grokys
Nov 01 2015 18:00
i dunno, i have a windows phone and and an android phone and windows phone 8 just feels like the level of android 2.6 or something
and it's so ugly compared to android
José Manuel Nieto
@SuperJMN
Nov 01 2015 18:02
:) it's ugly
at least WP 8.1
Windows 10 Mobile feels exactly like Win 10.
Steven Kirk
@grokys
Nov 01 2015 18:03
i wonder if i can upgrade?
José Manuel Nieto
@SuperJMN
Nov 01 2015 18:06
Which model is it?
Steven Kirk
@grokys
Nov 01 2015 18:07
lumia 520 - a cheapo one
José Manuel Nieto
@SuperJMN
Nov 01 2015 18:07
haha, nice
absolutely cheapo, yeah
yes, I think you can upgrade
Steven Kirk
@grokys
Nov 01 2015 18:08
i just tried to check for updates, but it says "we are currently unable to check for updates"
José Manuel Nieto
@SuperJMN
Nov 01 2015 18:08
you just have to become a Windows Insider, because Win10 Phone hasn't still been released
so, it's a preview
it's my daily driver, so I think you can use it, too
if you have 2 phones, I could definitely do the upgrade to see if it fits :)
Steven Kirk
@grokys
Nov 01 2015 18:10
ah ok
tbh i hardly use the lumia so i'll just wait
José Manuel Nieto
@SuperJMN
Nov 01 2015 18:15
it's easy to upgrade. Just install an app and the update will be ready to install
Nikita Tsukanov
@kekekeks
Nov 01 2015 19:03
Got transformations up and running
The only thing that skia lacks is layered opacity
Nikita Tsukanov
@kekekeks
Nov 01 2015 19:08
I think I'll have to emulate it like we do it in Cairo backend
José Manuel Nieto
@SuperJMN
Nov 01 2015 19:11
I don't know what that is, but I have been hypnotized
I'm a chicken
Johan Larsson
@JohanLarsson
Nov 01 2015 19:14
will perspex support svg?
Nikita Tsukanov
@kekekeks
Nov 01 2015 19:14
Skia can even render to SVG
We can't use it for WinPhone, however
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 19:45
Is win phone on their roadmap?
Nikita Tsukanov
@kekekeks
Nov 01 2015 19:45
No idea
skia is a C++ lib that relies on opengl
Nikita Tsukanov
@kekekeks
Nov 01 2015 21:18
@grokys IBitmapImpl isn't disposable? Seriously?
IStreamingGeometryImpl too
Well, I guess I'll rely on finalizer
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 21:22
Why is there an interface named *impl? Weird...
Nikita Tsukanov
@kekekeks
Nov 01 2015 21:23
Because we have xplat Bitmap class
and platform specific bitmap implementation
Which is an interface
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 21:24
Seems like that should be a different namespace, not an impl thing... just odd naming
Also seems like they should be idisposable
Nikita Tsukanov
@kekekeks
Nov 01 2015 21:26
whatever
May be it's more convenient to have them to be non-disposable
They are long-living objects anyway
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 21:27
Hahaha... sorry, I'm a design purist ;)
Johan Larsson
@JohanLarsson
Nov 01 2015 21:27
how can the library know that they are long lived?
Seriously?
wtf, guys
Reed Copsey, Jr.
@ReedCopsey
Nov 01 2015 21:29
Does cleanup care about thread context
It's a risk with finalized
Nikita Tsukanov
@kekekeks
Nov 01 2015 21:29
Skia seems to be thread safe on that front
If bitmap/path isn't used anywhere you are free to delete it from any thread
I'm fine with that
Well, I have no idea how to implement WPF-like arcTo with skia
Skia wants 2 points and angle
And it seems that it's what most APIs do - http://www.w3schools.com/tags/canvas_arcto.asp
Nikita Tsukanov
@kekekeks
Nov 01 2015 21:35
Well, if GTK backend can live without arcTo, fine, Skia one will too
Nikita Tsukanov
@kekekeks
Nov 01 2015 21:44
@ncarrillo @grokys
Cairo backend also ignores isFilled in BeginFigure
Wow
Skia has goddamn direct2d emulator
Nikita Tsukanov
@kekekeks
Nov 01 2015 22:00
@grokys
1) Cairo and Skia have non-M$ arcTo API
2) Cairo and Skia don't seem to support filled/not filled path figures
The same is true for android and CoreGraphics
Basically, our current geometry API is not portable
Johan Larsson
@JohanLarsson
Nov 01 2015 22:06
svg has filled paths iirc
Nikita Tsukanov
@kekekeks
Nov 01 2015 22:07
Yep, Path can be filled
The thing that is called "figure" doesn't
SVG doesn't have a concept of BeginFigure/EndFigure
Nobody does
It's M$-specific
No wonder it doesn't map on OSS drawing api
Argh
We need to change that api
We can find someone who knows what "arc" actually is, so converting that alien M$ arcTo shouldn't be an issue
Nikita Tsukanov
@kekekeks
Nov 01 2015 22:17
But filled/not filled figures inside one path just won't work at all
Nikita Tsukanov
@kekekeks
Nov 01 2015 22:48
Mkay, geometry seems to be working
So, I have yet to implement
1) bitmaps
2) text
3) opacity hack
4) gradient brushes
5) image brushes
6) RenderTargetBitmap
7) Visual brush (why don't we have them implemented in xplat way?)