Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL-accelerated Skia drawing for Win32/GTK backends #1935

Merged
merged 11 commits into from
Oct 2, 2018
26 changes: 26 additions & 0 deletions Avalonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Designer.HostApp.N
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Skia.UnitTests", "tests\Avalonia.Skia.UnitTests\Avalonia.Skia.UnitTests.csproj", "{E1240B49-7B4B-4371-A00E-068778C5CF0B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.OpenGL", "src\Avalonia.OpenGL\Avalonia.OpenGL.csproj", "{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
Expand Down Expand Up @@ -1663,6 +1665,30 @@ Global
{E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|iPhone.Build.0 = Release|Any CPU
{E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhone.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhone.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|Any CPU.Build.0 = Release|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhone.ActiveCfg = Release|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhone.Build.0 = Release|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions packages.cake
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public class Packages
new [] { "./src/", "Avalonia.Logging.Serilog"},
new [] { "./src/", "Avalonia.Visuals"},
new [] { "./src/", "Avalonia.Styling"},
new [] { "./src/", "Avalonia.OpenGL"},
new [] { "./src/", "Avalonia.Themes.Default"},
new [] { "./src/Markup/", "Avalonia.Markup"},
new [] { "./src/Markup/", "Avalonia.Markup.Xaml"},
Expand Down
1 change: 1 addition & 0 deletions src/Avalonia.Base/Avalonia.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Avalonia.Base</AssemblyName>
<RootNamespace>Avalonia</RootNamespace>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<Import Project="..\..\build\Base.props" />
<Import Project="..\..\build\Binding.props" />
Expand Down
18 changes: 18 additions & 0 deletions src/Avalonia.Base/Platform/Interop/IDynamicLibraryLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace Avalonia.Platform.Interop
{
public interface IDynamicLibraryLoader
{
IntPtr LoadLibrary(string dll);
IntPtr GetProcAddress(IntPtr dll, string proc, bool optional);
}

public class DynamicLibraryLoaderException : Exception
{
public DynamicLibraryLoaderException(string message) : base(message)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Runtime.InteropServices;
using System.Text;

namespace Avalonia.Gtk3.Interop
namespace Avalonia.Platform.Interop
{
class Utf8Buffer : SafeHandle
public class Utf8Buffer : SafeHandle
{
private GCHandle _gchandle;
private byte[] _data;
Expand Down
12 changes: 12 additions & 0 deletions src/Avalonia.OpenGL/Avalonia.OpenGL.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />
<ProjectReference Include="..\Avalonia.Visuals\Avalonia.Visuals.csproj" />
</ItemGroup>

</Project>
196 changes: 196 additions & 0 deletions src/Avalonia.OpenGL/EglConsts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable IdentifierTypo
namespace Avalonia.OpenGL
{
public static class EglConsts
{
public const int EGL_ALPHA_SIZE = 0x3021;
public const int EGL_BAD_ACCESS = 0x3002;
public const int EGL_BAD_ALLOC = 0x3003;
public const int EGL_BAD_ATTRIBUTE = 0x3004;
public const int EGL_BAD_CONFIG = 0x3005;
public const int EGL_BAD_CONTEXT = 0x3006;
public const int EGL_BAD_CURRENT_SURFACE = 0x3007;
public const int EGL_BAD_DISPLAY = 0x3008;
public const int EGL_BAD_MATCH = 0x3009;
public const int EGL_BAD_NATIVE_PIXMAP = 0x300A;
public const int EGL_BAD_NATIVE_WINDOW = 0x300B;
public const int EGL_BAD_PARAMETER = 0x300C;
public const int EGL_BAD_SURFACE = 0x300D;
public const int EGL_BLUE_SIZE = 0x3022;
public const int EGL_BUFFER_SIZE = 0x3020;
public const int EGL_CONFIG_CAVEAT = 0x3027;
public const int EGL_CONFIG_ID = 0x3028;
public const int EGL_CORE_NATIVE_ENGINE = 0x305B;
public const int EGL_DEPTH_SIZE = 0x3025;
public const int EGL_DONT_CARE = -1;
public const int EGL_DRAW = 0x3059;
public const int EGL_EXTENSIONS = 0x3055;
public const int EGL_FALSE = 0;
public const int EGL_GREEN_SIZE = 0x3023;
public const int EGL_HEIGHT = 0x3056;
public const int EGL_LARGEST_PBUFFER = 0x3058;
public const int EGL_LEVEL = 0x3029;
public const int EGL_MAX_PBUFFER_HEIGHT = 0x302A;
public const int EGL_MAX_PBUFFER_PIXELS = 0x302B;
public const int EGL_MAX_PBUFFER_WIDTH = 0x302C;
public const int EGL_NATIVE_RENDERABLE = 0x302D;
public const int EGL_NATIVE_VISUAL_ID = 0x302E;
public const int EGL_NATIVE_VISUAL_TYPE = 0x302F;
public const int EGL_NONE = 0x3038;
public const int EGL_NON_CONFORMANT_CONFIG = 0x3051;
public const int EGL_NOT_INITIALIZED = 0x3001;
public const int EGL_NO_CONTEXT = 0;
public const int EGL_NO_DISPLAY = 0;
public const int EGL_NO_SURFACE = 0;
public const int EGL_PBUFFER_BIT = 0x0001;
public const int EGL_PIXMAP_BIT = 0x0002;
public const int EGL_READ = 0x305A;
public const int EGL_RED_SIZE = 0x3024;
public const int EGL_SAMPLES = 0x3031;
public const int EGL_SAMPLE_BUFFERS = 0x3032;
public const int EGL_SLOW_CONFIG = 0x3050;
public const int EGL_STENCIL_SIZE = 0x3026;
public const int EGL_SUCCESS = 0x3000;
public const int EGL_SURFACE_TYPE = 0x3033;
public const int EGL_TRANSPARENT_BLUE_VALUE = 0x3035;
public const int EGL_TRANSPARENT_GREEN_VALUE = 0x3036;
public const int EGL_TRANSPARENT_RED_VALUE = 0x3037;
public const int EGL_TRANSPARENT_RGB = 0x3052;
public const int EGL_TRANSPARENT_TYPE = 0x3034;
public const int EGL_TRUE = 1;
public const int EGL_VENDOR = 0x3053;
public const int EGL_VERSION = 0x3054;
public const int EGL_WIDTH = 0x3057;
public const int EGL_WINDOW_BIT = 0x0004;

public const int EGL_BACK_BUFFER = 0x3084;
public const int EGL_BIND_TO_TEXTURE_RGB = 0x3039;
public const int EGL_BIND_TO_TEXTURE_RGBA = 0x303A;
public const int EGL_CONTEXT_LOST = 0x300E;
public const int EGL_MIN_SWAP_INTERVAL = 0x303B;
public const int EGL_MAX_SWAP_INTERVAL = 0x303C;
public const int EGL_MIPMAP_TEXTURE = 0x3082;
public const int EGL_MIPMAP_LEVEL = 0x3083;
public const int EGL_NO_TEXTURE = 0x305C;
public const int EGL_TEXTURE_2D = 0x305F;
public const int EGL_TEXTURE_FORMAT = 0x3080;
public const int EGL_TEXTURE_RGB = 0x305D;
public const int EGL_TEXTURE_RGBA = 0x305E;
public const int EGL_TEXTURE_TARGET = 0x3081;

public const int EGL_ALPHA_FORMAT = 0x3088;
public const int EGL_ALPHA_FORMAT_NONPRE = 0x308B;
public const int EGL_ALPHA_FORMAT_PRE = 0x308C;
public const int EGL_ALPHA_MASK_SIZE = 0x303E;
public const int EGL_BUFFER_PRESERVED = 0x3094;
public const int EGL_BUFFER_DESTROYED = 0x3095;
public const int EGL_CLIENT_APIS = 0x308D;
public const int EGL_COLORSPACE = 0x3087;
public const int EGL_COLORSPACE_sRGB = 0x3089;
public const int EGL_COLORSPACE_LINEAR = 0x308A;
public const int EGL_COLOR_BUFFER_TYPE = 0x303F;
public const int EGL_CONTEXT_CLIENT_TYPE = 0x3097;
public const int EGL_DISPLAY_SCALING = 10000;
public const int EGL_HORIZONTAL_RESOLUTION = 0x3090;
public const int EGL_LUMINANCE_BUFFER = 0x308F;
public const int EGL_LUMINANCE_SIZE = 0x303D;
public const int EGL_OPENGL_ES_BIT = 0x0001;
public const int EGL_OPENVG_BIT = 0x0002;
public const int EGL_OPENGL_ES_API = 0x30A0;
public const int EGL_OPENVG_API = 0x30A1;
public const int EGL_OPENVG_IMAGE = 0x3096;
public const int EGL_PIXEL_ASPECT_RATIO = 0x3092;
public const int EGL_RENDERABLE_TYPE = 0x3040;
public const int EGL_RENDER_BUFFER = 0x3086;
public const int EGL_RGB_BUFFER = 0x308E;
public const int EGL_SINGLE_BUFFER = 0x3085;
public const int EGL_SWAP_BEHAVIOR = 0x3093;
public const int EGL_UNKNOWN = -1;
public const int EGL_VERTICAL_RESOLUTION = 0x3091;
public const int EGL_CONFORMANT = 0x3042;
public const int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public const int EGL_MATCH_NATIVE_PIXMAP = 0x3041;
public const int EGL_OPENGL_ES2_BIT = 0x0004;
public const int EGL_VG_ALPHA_FORMAT = 0x3088;
public const int EGL_VG_ALPHA_FORMAT_NONPRE = 0x308B;
public const int EGL_VG_ALPHA_FORMAT_PRE = 0x308C;
public const int EGL_VG_ALPHA_FORMAT_PRE_BIT = 0x0040;
public const int EGL_VG_COLORSPACE = 0x3087;
public const int EGL_VG_COLORSPACE_sRGB = 0x3089;
public const int EGL_VG_COLORSPACE_LINEAR = 0x308A;
public const int EGL_VG_COLORSPACE_LINEAR_BIT = 0x0020;
public const int EGL_DEFAULT_DISPLAY = 0;
public const int EGL_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200;
public const int EGL_MULTISAMPLE_RESOLVE = 0x3099;
public const int EGL_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A;
public const int EGL_MULTISAMPLE_RESOLVE_BOX = 0x309B;
public const int EGL_OPENGL_API = 0x30A2;
public const int EGL_OPENGL_BIT = 0x0008;
public const int EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400;
public const int EGL_CONTEXT_MAJOR_VERSION = 0x3098;
public const int EGL_CONTEXT_MINOR_VERSION = 0x30FB;
public const int EGL_CONTEXT_OPENGL_PROFILE_MASK = 0x30FD;
public const int EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY = 0x31BD;
public const int EGL_NO_RESET_NOTIFICATION = 0x31BE;
public const int EGL_LOSE_CONTEXT_ON_RESET = 0x31BF;
public const int EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT = 0x00000001;
public const int EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT = 0x00000002;
public const int EGL_CONTEXT_OPENGL_DEBUG = 0x31B0;
public const int EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE = 0x31B1;
public const int EGL_CONTEXT_OPENGL_ROBUST_ACCESS = 0x31B2;
public const int EGL_OPENGL_ES3_BIT = 0x00000040;
public const int EGL_CL_EVENT_HANDLE = 0x309C;
public const int EGL_SYNC_CL_EVENT = 0x30FE;
public const int EGL_SYNC_CL_EVENT_COMPLETE = 0x30FF;
public const int EGL_SYNC_PRIOR_COMMANDS_COMPLETE = 0x30F0;
public const int EGL_SYNC_TYPE = 0x30F7;
public const int EGL_SYNC_STATUS = 0x30F1;
public const int EGL_SYNC_CONDITION = 0x30F8;
public const int EGL_SIGNALED = 0x30F2;
public const int EGL_UNSIGNALED = 0x30F3;

public const int EGL_SYNC_FLUSH_COMMANDS_BIT = 0x0001;

public const int EGL_TIMEOUT_EXPIRED = 0x30F5;
public const int EGL_CONDITION_SATISFIED = 0x30F6;
public const int EGL_NO_SYNC = 0;
public const int EGL_SYNC_FENCE = 0x30F9;
public const int EGL_GL_COLORSPACE = 0x309D;
public const int EGL_GL_COLORSPACE_SRGB = 0x3089;
public const int EGL_GL_COLORSPACE_LINEAR = 0x308A;
public const int EGL_GL_RENDERBUFFER = 0x30B9;
public const int EGL_GL_TEXTURE_2D = 0x30B1;
public const int EGL_GL_TEXTURE_LEVEL = 0x30BC;
public const int EGL_GL_TEXTURE_3D = 0x30B2;
public const int EGL_GL_TEXTURE_ZOFFSET = 0x30BD;
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x30B3;
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x30B4;
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x30B5;
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x30B6;
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x30B7;
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x30B8;
public const int EGL_IMAGE_PRESERVED = 0x30D2;
public const int EGL_NO_IMAGE = 0;


public const int EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE = 0x3207;
public const int EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE = 0x3208;

//EGL_ANGLE_platform_angle
public const int EGL_PLATFORM_ANGLE_ANGLE = 0x3202;
public const int EGL_PLATFORM_ANGLE_TYPE_ANGLE = 0x3203;
public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE = 0x3204;
public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE = 0x3205;
public const int EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED = 0x3451;
public const int EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE = 0x3206;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE = 0x320A;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE = 0x345E;

//EGL_ANGLE_platform_angle_d3d
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE = 0x3209;
public const int EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE = 0x320F;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE = 0x320B;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE = 0x320C;
}
}
Loading