Skip to content

Commit dbe9bc8

Browse files
authored
Merge pull request #1935 from kekekeks/skiagl
OpenGL-accelerated Skia drawing for Win32/GTK backends
2 parents 1007b54 + f2bd597 commit dbe9bc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1932
-54
lines changed

Avalonia.sln

+26
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Designer.HostApp.N
186186
EndProject
187187
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Skia.UnitTests", "tests\Avalonia.Skia.UnitTests\Avalonia.Skia.UnitTests.csproj", "{E1240B49-7B4B-4371-A00E-068778C5CF0B}"
188188
EndProject
189+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.OpenGL", "src\Avalonia.OpenGL\Avalonia.OpenGL.csproj", "{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}"
190+
EndProject
189191
Global
190192
GlobalSection(SharedMSBuildProjectFiles) = preSolution
191193
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
@@ -1663,6 +1665,30 @@ Global
16631665
{E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|iPhone.Build.0 = Release|Any CPU
16641666
{E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
16651667
{E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
1668+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
1669+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
1670+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
1671+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
1672+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1673+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
1674+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
1675+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|Any CPU.Build.0 = Debug|Any CPU
1676+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
1677+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhone.Build.0 = Debug|Any CPU
1678+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1679+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
1680+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1681+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|Any CPU.Build.0 = Debug|Any CPU
1682+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhone.ActiveCfg = Debug|Any CPU
1683+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhone.Build.0 = Debug|Any CPU
1684+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1685+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
1686+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|Any CPU.ActiveCfg = Release|Any CPU
1687+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|Any CPU.Build.0 = Release|Any CPU
1688+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhone.ActiveCfg = Release|Any CPU
1689+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhone.Build.0 = Release|Any CPU
1690+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
1691+
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
16661692
EndGlobalSection
16671693
GlobalSection(SolutionProperties) = preSolution
16681694
HideSolutionNode = FALSE

packages.cake

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public class Packages
167167
new [] { "./src/", "Avalonia.Logging.Serilog"},
168168
new [] { "./src/", "Avalonia.Visuals"},
169169
new [] { "./src/", "Avalonia.Styling"},
170+
new [] { "./src/", "Avalonia.OpenGL"},
170171
new [] { "./src/", "Avalonia.Themes.Default"},
171172
new [] { "./src/Markup/", "Avalonia.Markup"},
172173
new [] { "./src/Markup/", "Avalonia.Markup.Xaml"},

src/Avalonia.Base/Avalonia.Base.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<AssemblyName>Avalonia.Base</AssemblyName>
55
<RootNamespace>Avalonia</RootNamespace>
6+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
67
</PropertyGroup>
78
<Import Project="..\..\build\Base.props" />
89
<Import Project="..\..\build\Binding.props" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace Avalonia.Platform.Interop
4+
{
5+
public interface IDynamicLibraryLoader
6+
{
7+
IntPtr LoadLibrary(string dll);
8+
IntPtr GetProcAddress(IntPtr dll, string proc, bool optional);
9+
}
10+
11+
public class DynamicLibraryLoaderException : Exception
12+
{
13+
public DynamicLibraryLoaderException(string message) : base(message)
14+
{
15+
16+
}
17+
}
18+
}

src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Runtime.InteropServices;
33
using System.Text;
44

5-
namespace Avalonia.Gtk3.Interop
5+
namespace Avalonia.Platform.Interop
66
{
7-
class Utf8Buffer : SafeHandle
7+
public class Utf8Buffer : SafeHandle
88
{
99
private GCHandle _gchandle;
1010
private byte[] _data;
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />
9+
<ProjectReference Include="..\Avalonia.Visuals\Avalonia.Visuals.csproj" />
10+
</ItemGroup>
11+
12+
</Project>

src/Avalonia.OpenGL/EglConsts.cs

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
// ReSharper disable UnusedMember.Global
2+
// ReSharper disable IdentifierTypo
3+
namespace Avalonia.OpenGL
4+
{
5+
public static class EglConsts
6+
{
7+
public const int EGL_ALPHA_SIZE = 0x3021;
8+
public const int EGL_BAD_ACCESS = 0x3002;
9+
public const int EGL_BAD_ALLOC = 0x3003;
10+
public const int EGL_BAD_ATTRIBUTE = 0x3004;
11+
public const int EGL_BAD_CONFIG = 0x3005;
12+
public const int EGL_BAD_CONTEXT = 0x3006;
13+
public const int EGL_BAD_CURRENT_SURFACE = 0x3007;
14+
public const int EGL_BAD_DISPLAY = 0x3008;
15+
public const int EGL_BAD_MATCH = 0x3009;
16+
public const int EGL_BAD_NATIVE_PIXMAP = 0x300A;
17+
public const int EGL_BAD_NATIVE_WINDOW = 0x300B;
18+
public const int EGL_BAD_PARAMETER = 0x300C;
19+
public const int EGL_BAD_SURFACE = 0x300D;
20+
public const int EGL_BLUE_SIZE = 0x3022;
21+
public const int EGL_BUFFER_SIZE = 0x3020;
22+
public const int EGL_CONFIG_CAVEAT = 0x3027;
23+
public const int EGL_CONFIG_ID = 0x3028;
24+
public const int EGL_CORE_NATIVE_ENGINE = 0x305B;
25+
public const int EGL_DEPTH_SIZE = 0x3025;
26+
public const int EGL_DONT_CARE = -1;
27+
public const int EGL_DRAW = 0x3059;
28+
public const int EGL_EXTENSIONS = 0x3055;
29+
public const int EGL_FALSE = 0;
30+
public const int EGL_GREEN_SIZE = 0x3023;
31+
public const int EGL_HEIGHT = 0x3056;
32+
public const int EGL_LARGEST_PBUFFER = 0x3058;
33+
public const int EGL_LEVEL = 0x3029;
34+
public const int EGL_MAX_PBUFFER_HEIGHT = 0x302A;
35+
public const int EGL_MAX_PBUFFER_PIXELS = 0x302B;
36+
public const int EGL_MAX_PBUFFER_WIDTH = 0x302C;
37+
public const int EGL_NATIVE_RENDERABLE = 0x302D;
38+
public const int EGL_NATIVE_VISUAL_ID = 0x302E;
39+
public const int EGL_NATIVE_VISUAL_TYPE = 0x302F;
40+
public const int EGL_NONE = 0x3038;
41+
public const int EGL_NON_CONFORMANT_CONFIG = 0x3051;
42+
public const int EGL_NOT_INITIALIZED = 0x3001;
43+
public const int EGL_NO_CONTEXT = 0;
44+
public const int EGL_NO_DISPLAY = 0;
45+
public const int EGL_NO_SURFACE = 0;
46+
public const int EGL_PBUFFER_BIT = 0x0001;
47+
public const int EGL_PIXMAP_BIT = 0x0002;
48+
public const int EGL_READ = 0x305A;
49+
public const int EGL_RED_SIZE = 0x3024;
50+
public const int EGL_SAMPLES = 0x3031;
51+
public const int EGL_SAMPLE_BUFFERS = 0x3032;
52+
public const int EGL_SLOW_CONFIG = 0x3050;
53+
public const int EGL_STENCIL_SIZE = 0x3026;
54+
public const int EGL_SUCCESS = 0x3000;
55+
public const int EGL_SURFACE_TYPE = 0x3033;
56+
public const int EGL_TRANSPARENT_BLUE_VALUE = 0x3035;
57+
public const int EGL_TRANSPARENT_GREEN_VALUE = 0x3036;
58+
public const int EGL_TRANSPARENT_RED_VALUE = 0x3037;
59+
public const int EGL_TRANSPARENT_RGB = 0x3052;
60+
public const int EGL_TRANSPARENT_TYPE = 0x3034;
61+
public const int EGL_TRUE = 1;
62+
public const int EGL_VENDOR = 0x3053;
63+
public const int EGL_VERSION = 0x3054;
64+
public const int EGL_WIDTH = 0x3057;
65+
public const int EGL_WINDOW_BIT = 0x0004;
66+
67+
public const int EGL_BACK_BUFFER = 0x3084;
68+
public const int EGL_BIND_TO_TEXTURE_RGB = 0x3039;
69+
public const int EGL_BIND_TO_TEXTURE_RGBA = 0x303A;
70+
public const int EGL_CONTEXT_LOST = 0x300E;
71+
public const int EGL_MIN_SWAP_INTERVAL = 0x303B;
72+
public const int EGL_MAX_SWAP_INTERVAL = 0x303C;
73+
public const int EGL_MIPMAP_TEXTURE = 0x3082;
74+
public const int EGL_MIPMAP_LEVEL = 0x3083;
75+
public const int EGL_NO_TEXTURE = 0x305C;
76+
public const int EGL_TEXTURE_2D = 0x305F;
77+
public const int EGL_TEXTURE_FORMAT = 0x3080;
78+
public const int EGL_TEXTURE_RGB = 0x305D;
79+
public const int EGL_TEXTURE_RGBA = 0x305E;
80+
public const int EGL_TEXTURE_TARGET = 0x3081;
81+
82+
public const int EGL_ALPHA_FORMAT = 0x3088;
83+
public const int EGL_ALPHA_FORMAT_NONPRE = 0x308B;
84+
public const int EGL_ALPHA_FORMAT_PRE = 0x308C;
85+
public const int EGL_ALPHA_MASK_SIZE = 0x303E;
86+
public const int EGL_BUFFER_PRESERVED = 0x3094;
87+
public const int EGL_BUFFER_DESTROYED = 0x3095;
88+
public const int EGL_CLIENT_APIS = 0x308D;
89+
public const int EGL_COLORSPACE = 0x3087;
90+
public const int EGL_COLORSPACE_sRGB = 0x3089;
91+
public const int EGL_COLORSPACE_LINEAR = 0x308A;
92+
public const int EGL_COLOR_BUFFER_TYPE = 0x303F;
93+
public const int EGL_CONTEXT_CLIENT_TYPE = 0x3097;
94+
public const int EGL_DISPLAY_SCALING = 10000;
95+
public const int EGL_HORIZONTAL_RESOLUTION = 0x3090;
96+
public const int EGL_LUMINANCE_BUFFER = 0x308F;
97+
public const int EGL_LUMINANCE_SIZE = 0x303D;
98+
public const int EGL_OPENGL_ES_BIT = 0x0001;
99+
public const int EGL_OPENVG_BIT = 0x0002;
100+
public const int EGL_OPENGL_ES_API = 0x30A0;
101+
public const int EGL_OPENVG_API = 0x30A1;
102+
public const int EGL_OPENVG_IMAGE = 0x3096;
103+
public const int EGL_PIXEL_ASPECT_RATIO = 0x3092;
104+
public const int EGL_RENDERABLE_TYPE = 0x3040;
105+
public const int EGL_RENDER_BUFFER = 0x3086;
106+
public const int EGL_RGB_BUFFER = 0x308E;
107+
public const int EGL_SINGLE_BUFFER = 0x3085;
108+
public const int EGL_SWAP_BEHAVIOR = 0x3093;
109+
public const int EGL_UNKNOWN = -1;
110+
public const int EGL_VERTICAL_RESOLUTION = 0x3091;
111+
public const int EGL_CONFORMANT = 0x3042;
112+
public const int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
113+
public const int EGL_MATCH_NATIVE_PIXMAP = 0x3041;
114+
public const int EGL_OPENGL_ES2_BIT = 0x0004;
115+
public const int EGL_VG_ALPHA_FORMAT = 0x3088;
116+
public const int EGL_VG_ALPHA_FORMAT_NONPRE = 0x308B;
117+
public const int EGL_VG_ALPHA_FORMAT_PRE = 0x308C;
118+
public const int EGL_VG_ALPHA_FORMAT_PRE_BIT = 0x0040;
119+
public const int EGL_VG_COLORSPACE = 0x3087;
120+
public const int EGL_VG_COLORSPACE_sRGB = 0x3089;
121+
public const int EGL_VG_COLORSPACE_LINEAR = 0x308A;
122+
public const int EGL_VG_COLORSPACE_LINEAR_BIT = 0x0020;
123+
public const int EGL_DEFAULT_DISPLAY = 0;
124+
public const int EGL_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200;
125+
public const int EGL_MULTISAMPLE_RESOLVE = 0x3099;
126+
public const int EGL_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A;
127+
public const int EGL_MULTISAMPLE_RESOLVE_BOX = 0x309B;
128+
public const int EGL_OPENGL_API = 0x30A2;
129+
public const int EGL_OPENGL_BIT = 0x0008;
130+
public const int EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400;
131+
public const int EGL_CONTEXT_MAJOR_VERSION = 0x3098;
132+
public const int EGL_CONTEXT_MINOR_VERSION = 0x30FB;
133+
public const int EGL_CONTEXT_OPENGL_PROFILE_MASK = 0x30FD;
134+
public const int EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY = 0x31BD;
135+
public const int EGL_NO_RESET_NOTIFICATION = 0x31BE;
136+
public const int EGL_LOSE_CONTEXT_ON_RESET = 0x31BF;
137+
public const int EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT = 0x00000001;
138+
public const int EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT = 0x00000002;
139+
public const int EGL_CONTEXT_OPENGL_DEBUG = 0x31B0;
140+
public const int EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE = 0x31B1;
141+
public const int EGL_CONTEXT_OPENGL_ROBUST_ACCESS = 0x31B2;
142+
public const int EGL_OPENGL_ES3_BIT = 0x00000040;
143+
public const int EGL_CL_EVENT_HANDLE = 0x309C;
144+
public const int EGL_SYNC_CL_EVENT = 0x30FE;
145+
public const int EGL_SYNC_CL_EVENT_COMPLETE = 0x30FF;
146+
public const int EGL_SYNC_PRIOR_COMMANDS_COMPLETE = 0x30F0;
147+
public const int EGL_SYNC_TYPE = 0x30F7;
148+
public const int EGL_SYNC_STATUS = 0x30F1;
149+
public const int EGL_SYNC_CONDITION = 0x30F8;
150+
public const int EGL_SIGNALED = 0x30F2;
151+
public const int EGL_UNSIGNALED = 0x30F3;
152+
153+
public const int EGL_SYNC_FLUSH_COMMANDS_BIT = 0x0001;
154+
155+
public const int EGL_TIMEOUT_EXPIRED = 0x30F5;
156+
public const int EGL_CONDITION_SATISFIED = 0x30F6;
157+
public const int EGL_NO_SYNC = 0;
158+
public const int EGL_SYNC_FENCE = 0x30F9;
159+
public const int EGL_GL_COLORSPACE = 0x309D;
160+
public const int EGL_GL_COLORSPACE_SRGB = 0x3089;
161+
public const int EGL_GL_COLORSPACE_LINEAR = 0x308A;
162+
public const int EGL_GL_RENDERBUFFER = 0x30B9;
163+
public const int EGL_GL_TEXTURE_2D = 0x30B1;
164+
public const int EGL_GL_TEXTURE_LEVEL = 0x30BC;
165+
public const int EGL_GL_TEXTURE_3D = 0x30B2;
166+
public const int EGL_GL_TEXTURE_ZOFFSET = 0x30BD;
167+
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x30B3;
168+
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x30B4;
169+
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x30B5;
170+
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x30B6;
171+
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x30B7;
172+
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x30B8;
173+
public const int EGL_IMAGE_PRESERVED = 0x30D2;
174+
public const int EGL_NO_IMAGE = 0;
175+
176+
177+
public const int EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE = 0x3207;
178+
public const int EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE = 0x3208;
179+
180+
//EGL_ANGLE_platform_angle
181+
public const int EGL_PLATFORM_ANGLE_ANGLE = 0x3202;
182+
public const int EGL_PLATFORM_ANGLE_TYPE_ANGLE = 0x3203;
183+
public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE = 0x3204;
184+
public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE = 0x3205;
185+
public const int EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED = 0x3451;
186+
public const int EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE = 0x3206;
187+
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE = 0x320A;
188+
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE = 0x345E;
189+
190+
//EGL_ANGLE_platform_angle_d3d
191+
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE = 0x3209;
192+
public const int EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE = 0x320F;
193+
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE = 0x320B;
194+
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE = 0x320C;
195+
}
196+
}

0 commit comments

Comments
 (0)