From 361d3ad8614d332ec44a3539eaa982ac894d5406 Mon Sep 17 00:00:00 2001 From: Jason Jarvis Date: Wed, 9 Mar 2016 08:44:30 -0800 Subject: [PATCH 01/16] added AffectsRender to Image control --- src/Perspex.Controls/Image.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Perspex.Controls/Image.cs b/src/Perspex.Controls/Image.cs index e1e6d9b9ab..b9af59a951 100644 --- a/src/Perspex.Controls/Image.cs +++ b/src/Perspex.Controls/Image.cs @@ -42,11 +42,17 @@ namespace Perspex.Controls set { SetValue(StretchProperty, value); } } - /// - /// Renders the control. - /// - /// The drawing context. - public override void Render(DrawingContext context) + static Image() + { + AffectsRender(SourceProperty); + AffectsRender(StretchProperty); + } + + /// + /// Renders the control. + /// + /// The drawing context. + public override void Render(DrawingContext context) { var source = Source; From 3bb58a20314ee087901049874cd295e47132a0f0 Mon Sep 17 00:00:00 2001 From: Jason Jarvis Date: Mon, 11 Apr 2016 22:25:02 -0700 Subject: [PATCH 02/16] First pass at SkiaSharp rendering back end. Lot's left to do still - see Skia/Perspex.Skia/readme.md. --- Perspex.sln | 35 +- samples/TestApplicationShared/App.cs | 18 +- .../Perspex.Skia.Android.TestApp.csproj | 2 +- .../Perspex.Skia.Android.TestApp.csproj.bak | 2 +- .../AndroidRenderTarget.cs | 3 + src/Skia/Perspex.Skia.Android/MethodTable.cs | 2 + .../Perspex.Skia.Android.csproj | 13 +- src/Skia/Perspex.Skia.Android/packages.config | 4 + .../Perspex.Skia.Desktop.TestApp/App.config | 14 + .../Perspex.Skia.Desktop.TestApp.csproj | 209 +++++++++++ .../Perspex.Skia.Desktop.TestApp/Program.cs | 91 +++++ .../Properties/AssemblyInfo.cs | 36 ++ .../packages.config | 11 + .../Perspex.Skia.Desktop/MethodTableImpl.cs | 3 + .../Perspex.Skia.Desktop.csproj | 38 ++ src/Skia/Perspex.Skia.Desktop/packages.config | 4 + src/Skia/Perspex.Skia.iOS.TestApp/Info.plist | 2 +- .../Perspex.Skia.iOS/Perspex.Skia.iOS.csproj | 7 + src/Skia/Perspex.Skia.iOS/SkiaView.cs | 31 +- src/Skia/Perspex.Skia.iOS/iOSMethodTable.cs | 6 +- src/Skia/Perspex.Skia.iOS/packages.config | 4 + src/Skia/Perspex.Skia/BitmapImpl.cs | 69 ++-- src/Skia/Perspex.Skia/DrawingContextImpl.cs | 289 ++++++++++----- src/Skia/Perspex.Skia/FormattedTextImpl.cs | 339 ++++++++++++++---- src/Skia/Perspex.Skia/MethodTable.cs | 4 +- src/Skia/Perspex.Skia/NativeBrush.cs | 2 + .../NativeDrawingContextSettings.cs | 14 +- src/Skia/Perspex.Skia/NativeFormattedText.cs | 6 +- src/Skia/Perspex.Skia/Perspex.Skia.projitems | 11 +- src/Skia/Perspex.Skia/PerspexHandleHolder.cs | 6 +- .../Perspex.Skia/PlatformRenderInterface.cs | 25 +- src/Skia/Perspex.Skia/RenderTarget.cs | 165 ++++++++- src/Skia/Perspex.Skia/SkRect.cs | 7 +- src/Skia/Perspex.Skia/SkiaPlatform.cs | 17 +- src/Skia/Perspex.Skia/SkiaPoint.cs | 6 +- src/Skia/Perspex.Skia/SkiaSharpExtensions.cs | 57 +++ src/Skia/Perspex.Skia/StreamGeometryImpl.cs | 178 ++++----- src/Skia/Perspex.Skia/TypefaceCache.cs | 52 ++- src/Skia/Perspex.Skia/readme.md | 42 +++ .../Perspex.Win32/Interop/UnmanagedMethods.cs | 67 +++- src/iOS/Perspex.iOSTestApplication/Info.plist | 68 ++-- 41 files changed, 1539 insertions(+), 420 deletions(-) create mode 100644 src/Skia/Perspex.Skia.Android/packages.config create mode 100644 src/Skia/Perspex.Skia.Desktop.TestApp/App.config create mode 100644 src/Skia/Perspex.Skia.Desktop.TestApp/Perspex.Skia.Desktop.TestApp.csproj create mode 100644 src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs create mode 100644 src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs create mode 100644 src/Skia/Perspex.Skia.Desktop.TestApp/packages.config create mode 100644 src/Skia/Perspex.Skia.Desktop/packages.config create mode 100644 src/Skia/Perspex.Skia.iOS/packages.config create mode 100644 src/Skia/Perspex.Skia/SkiaSharpExtensions.cs create mode 100644 src/Skia/Perspex.Skia/readme.md diff --git a/Perspex.sln b/Perspex.sln index 9cbaca445d..b3d6aa9d89 100644 --- a/Perspex.sln +++ b/Perspex.sln @@ -145,11 +145,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Benchmarks", "tests EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Logging.Serilog", "src\Perspex.Logging.Serilog\Perspex.Logging.Serilog.csproj", "{B61B66A3-B82D-4875-8001-89D3394FE0C9}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.DesignerSupport", "src\Perspex.DesignerSupport\Perspex.DesignerSupport.csproj", "{799A7BB5-3C2C-48B6-85A7-406A12C420DA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Skia.Desktop.TestApp", "src\Skia\Perspex.Skia.Desktop.TestApp\Perspex.Skia.Desktop.TestApp.csproj", "{383168DF-5A4E-45E5-A239-FB54D40D4F5C}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Shared\RenderHelpers\RenderHelpers.projitems*{fb05ac90-89ba-4f2f-a924-f37875fb547c}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{4488ad85-1495-4809-9aa4-ddfe0a48527e}*SharedItemsImports = 4 + samples\TestApplicationShared\TestApplicationShared.projitems*{383168df-5a4e-45e5-a239-fb54d40d4f5c}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13 src\Skia\Perspex.Skia\Perspex.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13 @@ -1015,10 +1017,10 @@ Global {925DD807-B651-475F-9F7C-CBEB974CE43D}.AppStore|iPhone.Build.0 = Release|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU - {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhone.Build.0 = Debug|Any CPU + {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|Any CPU.ActiveCfg = Debug|x86 + {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|Any CPU.Build.0 = Debug|x86 + {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhone.ActiveCfg = Debug|x86 + {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhone.Build.0 = Debug|x86 {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1349,6 +1351,30 @@ Global {799A7BB5-3C2C-48B6-85A7-406A12C420DA}.Release|iPhone.Build.0 = Release|Any CPU {799A7BB5-3C2C-48B6-85A7-406A12C420DA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {799A7BB5-3C2C-48B6-85A7-406A12C420DA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.AppStore|Any CPU.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.AppStore|iPhone.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Debug|Any CPU.ActiveCfg = Debug|x86 + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Debug|Any CPU.Build.0 = Debug|x86 + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Debug|iPhone.Build.0 = Debug|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Release|Any CPU.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Release|iPhone.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Release|iPhone.Build.0 = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1394,5 +1420,6 @@ Global {61BEC86C-F307-4295-B5B8-9428610D7D55} = {9B9E3891-2366-4253-A952-D08BCEB71098} {88060192-33D5-4932-B0F9-8BD2763E857D} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} + {383168DF-5A4E-45E5-A239-FB54D40D4F5C} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E} EndGlobalSection EndGlobal diff --git a/samples/TestApplicationShared/App.cs b/samples/TestApplicationShared/App.cs index e4211ffb82..8bab852747 100644 --- a/samples/TestApplicationShared/App.cs +++ b/samples/TestApplicationShared/App.cs @@ -16,8 +16,14 @@ namespace TestApplication public App() { RegisterServices(); - InitializeSubsystems((int)Environment.OSVersion.Platform); - Styles.Add(new DefaultTheme()); + +#if !__IOS__ // IOS Startup flow is a bit different and cannot use this + RegisterPlatformCallback(PlatformInitialization); +#endif + + InitializeSubsystems((int)Environment.OSVersion.Platform); + + Styles.Add(new DefaultTheme()); var loader = new PerspexXamlLoader(); var baseLight = (IStyle)loader.Load( @@ -32,5 +38,11 @@ namespace TestApplication x => x.Children), }; } - } + + protected virtual void PlatformInitialization() + { + // default behavior + InitializeSubsystems((int)Environment.OSVersion.Platform); + } + } } diff --git a/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj b/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj index 36cb4b0e0b..614b0210bb 100644 --- a/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj +++ b/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj @@ -16,7 +16,7 @@ Resources\Resource.Designer.cs Off True - v5.0 + v6.0 Properties\AndroidManifest.xml diff --git a/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj.bak b/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj.bak index 614b0210bb..36cb4b0e0b 100644 --- a/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj.bak +++ b/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj.bak @@ -16,7 +16,7 @@ Resources\Resource.Designer.cs Off True - v6.0 + v5.0 Properties\AndroidManifest.xml diff --git a/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs b/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs index 148236f716..2221c4bdb0 100644 --- a/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs +++ b/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs @@ -14,6 +14,8 @@ using Perspex.Platform; namespace Perspex.Skia { +/* This lives in shared project now, but we may need an android specific implementation anyways + * class RenderTarget : IRenderTarget { private IntPtr _currentRenderTarget = IntPtr.Zero; @@ -61,4 +63,5 @@ namespace Perspex.Skia new DrawingContextImpl(MethodTable.Instance.RenderTargetCreateRenderingContext(_currentRenderTarget))); } } +*/ } \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Android/MethodTable.cs b/src/Skia/Perspex.Skia.Android/MethodTable.cs index 0e9d53ac14..73454489d3 100644 --- a/src/Skia/Perspex.Skia.Android/MethodTable.cs +++ b/src/Skia/Perspex.Skia.Android/MethodTable.cs @@ -14,6 +14,7 @@ using Android.Widget; namespace Perspex.Skia { +/* No longer needed with SkiaSharp class MethodTableImpl : MethodTable { [DllImport(@"perspesk")] @@ -26,4 +27,5 @@ namespace Perspex.Skia PerspexJniInit(JNIEnv.Handle); } } + */ } \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj b/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj index 2160eb2592..b0864eb9e9 100644 --- a/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj +++ b/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj @@ -15,14 +15,14 @@ Resources\Resource.Designer.cs Off True - v5.0 + v6.0 true full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;ANDROID prompt 4 true @@ -31,7 +31,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;ANDROID prompt 4 true @@ -39,6 +39,10 @@ + + ..\..\..\packages\SkiaSharp.1.49.2.0-beta\lib\MonoAndroid\SkiaSharp.dll + True + @@ -95,6 +99,9 @@ native\x86\libperspesk.so + + + diff --git a/src/Skia/Perspex.Skia.Android/packages.config b/src/Skia/Perspex.Skia.Android/packages.config new file mode 100644 index 0000000000..c0f3883e68 --- /dev/null +++ b/src/Skia/Perspex.Skia.Android/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/App.config b/src/Skia/Perspex.Skia.Desktop.TestApp/App.config new file mode 100644 index 0000000000..2e292d1c8a --- /dev/null +++ b/src/Skia/Perspex.Skia.Desktop.TestApp/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/Perspex.Skia.Desktop.TestApp.csproj b/src/Skia/Perspex.Skia.Desktop.TestApp/Perspex.Skia.Desktop.TestApp.csproj new file mode 100644 index 0000000000..9d88e701fb --- /dev/null +++ b/src/Skia/Perspex.Skia.Desktop.TestApp/Perspex.Skia.Desktop.TestApp.csproj @@ -0,0 +1,209 @@ + + + + + Debug + AnyCPU + {383168DF-5A4E-45E5-A239-FB54D40D4F5C} + WinExe + Properties + Perspex.Skia.Desktop.TestApp + Perspex.Skia.Desktop.TestApp + v4.6 + 512 + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + + ..\..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll + True + + + ..\..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll + True + + + ..\..\..\packages\SkiaSharp.1.49.2.0-beta\lib\net45\SkiaSharp.dll + True + + + + + ..\..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll + True + + + ..\..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll + True + + + ..\..\..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll + True + + + ..\..\..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll + True + + + ..\..\..\packages\Rx-XAML.2.2.5\lib\net45\System.Reactive.Windows.Threading.dll + True + + + + + + + + + + + + + + + + + + + + + + + {FB05AC90-89BA-4F2F-A924-F37875FB547C} + Perspex.Cairo + + + {54F237D5-A70A-4752-9656-0C70B1A7B047} + Perspex.Gtk + + + {3E53A01A-B331-47F3-B828-4A5717E77A24} + Perspex.Markup.Xaml + + + {6417E941-21BC-467B-A771-0DE389353CE6} + Perspex.Markup + + + {D211E587-D8BC-45B9-95A4-F297C8FA5200} + Perspex.Animation + + + {799A7BB5-3C2C-48B6-85A7-406A12C420DA} + Perspex.Application + + + {B09B78D8-9B26-48B0-9149-D64A2F120F3F} + Perspex.Base + + + {D2221C82-4A25-4583-9B43-D791E3F6820C} + Perspex.Controls + + + {7062AE20-5DCC-4442-9645-8195BDECE63E} + Perspex.Diagnostics + + + {5FB2B005-0A7F-4DAD-ADD4-3ED01444E63D} + Perspex.HtmlRenderer + + + {62024B2D-53EB-4638-B26B-85EEAA54866E} + Perspex.Input + + + {6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B} + Perspex.Interactivity + + + {42472427-4774-4C81-8AFF-9F27B8E31721} + Perspex.Layout + + + {6417B24E-49C2-4985-8DB2-3AB9D898EC91} + Perspex.ReactiveUI + + + {EB582467-6ABB-43A1-B052-E981BA910E3A} + Perspex.SceneGraph + + + {F1BAA01A-F176-4C6A-B39D-5B40BB1B148F} + Perspex.Styling + + + {3E10A5FA-E8DA-48B1-AD44-6A5B6CB7750F} + Perspex.Themes.Default + + + {3E908F67-5543-4879-A1DC-08EACE79B3CD} + Perspex.Direct2D1 + + + {811A76CF-1CF6-440F-963B-BBE31BD72A82} + Perspex.Win32 + + + {925dd807-b651-475f-9f7c-cbeb974ce43d} + Perspex.Skia.Desktop + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs b/src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs new file mode 100644 index 0000000000..022306bbe9 --- /dev/null +++ b/src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs @@ -0,0 +1,91 @@ +// Copyright (c) The Perspex Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using System.Linq; +using System.IO; +using System.Reactive.Linq; +using Perspex; +using Perspex.Animation; +using Perspex.Collections; +using Perspex.Controls; +using Perspex.Controls.Html; +using Perspex.Controls.Primitives; +using Perspex.Controls.Shapes; +using Perspex.Controls.Templates; +using Perspex.Diagnostics; +using Perspex.Layout; +using Perspex.Media; +using Perspex.Media.Imaging; +using TestApplication; +using Perspex.Rendering; +#if PERSPEX_GTK +using Perspex.Gtk; +#endif +using ReactiveUI; + +namespace Perspex.Skia.Desktop.TestApp +{ + internal class Program + { + private static void Main(string[] args) + { + // The version of ReactiveUI currently included is for WPF and so expects a WPF + // dispatcher. This makes sure it's initialized. + System.Windows.Threading.Dispatcher foo = System.Windows.Threading.Dispatcher.CurrentDispatcher; + new SkiaApp(); + + //RendererMixin.DrawFpsCounter = true; + + MainWindow.RootNamespace = "Perspex.Skia.Desktop.TestApp"; + var wnd = MainWindow.Create(); + + // let's start small :) + //var wnd = SimpleWindow.Create(); + + DevTools.Attach(wnd); + Application.Current.Run(wnd); + } + } + + internal class SkiaApp : App + { + protected override void PlatformInitialization() + { + SkiaPlatform.Initialize(); + InitializeSubsystem("Perspex.Win32"); + } + } + + internal class SimpleWindow + { + public static Window Create() + { + Border container; + + Window window = new Window + { + Title = "Perspex Test Application", + Content = (container = new Border + { + Background = Brushes.Green, + BorderBrush = Brushes.Yellow, + BorderThickness = 12, + Padding = new Thickness(5), + Child = new Rectangle + { + Fill = Brushes.Blue, + Width = 200, + Height = 200, + Margin = new Thickness(50) + } + }) + + }; + + window.Show(); + return window; + } + + } +} diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs b/src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..ec1558ed5c --- /dev/null +++ b/src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Perspex.Skia.Desktop.TestApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Perspex.Skia.Desktop.TestApp")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("383168df-5a4e-45e5-a239-fb54d40d4f5c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/packages.config b/src/Skia/Perspex.Skia.Desktop.TestApp/packages.config new file mode 100644 index 0000000000..a23c1e822f --- /dev/null +++ b/src/Skia/Perspex.Skia.Desktop.TestApp/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Desktop/MethodTableImpl.cs b/src/Skia/Perspex.Skia.Desktop/MethodTableImpl.cs index 3a1014eb2b..bdd8b21821 100644 --- a/src/Skia/Perspex.Skia.Desktop/MethodTableImpl.cs +++ b/src/Skia/Perspex.Skia.Desktop/MethodTableImpl.cs @@ -9,6 +9,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; +/* OBSOLETE //Library loaders were taken from https://github.com/kekekeks/evhttp-sharp/tree/master/EvHttpSharp/Interop (MIT licensed) @@ -233,3 +234,5 @@ namespace Perspex.Skia } } } + + */ \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Desktop/Perspex.Skia.Desktop.csproj b/src/Skia/Perspex.Skia.Desktop/Perspex.Skia.Desktop.csproj index 6fb2549b69..3b520fd408 100644 --- a/src/Skia/Perspex.Skia.Desktop/Perspex.Skia.Desktop.csproj +++ b/src/Skia/Perspex.Skia.Desktop/Perspex.Skia.Desktop.csproj @@ -12,6 +12,8 @@ v4.5 512 + + true @@ -22,6 +24,7 @@ prompt 4 true + AnyCPU pdbonly @@ -32,7 +35,31 @@ 4 true + + true + bin\x86\Debug\ + TRACE;DEBUG;WIN32 + true + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE;WIN32 + true + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + ..\..\..\packages\SkiaSharp.1.49.2.0-beta\lib\net45\SkiaSharp.dll + True + @@ -45,6 +72,9 @@ + + UnmanagedMethods.cs + @@ -98,10 +128,18 @@ native\Linux\x86_64\libperspesk.so + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + - \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs b/src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs deleted file mode 100644 index 98e79c8a8d..0000000000 --- a/src/Skia/Perspex.Skia.Desktop.TestApp/Program.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) The Perspex Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -using System; -using System.Linq; -using System.IO; -using System.Reactive.Linq; -using Perspex; -using Perspex.Animation; -using Perspex.Collections; -using Perspex.Controls; -using Perspex.Controls.Html; -using Perspex.Controls.Primitives; -using Perspex.Controls.Shapes; -using Perspex.Controls.Templates; -using Perspex.Diagnostics; -using Perspex.Layout; -using Perspex.Media; -using Perspex.Media.Imaging; -using TestApplication; -using Perspex.Rendering; -#if PERSPEX_GTK -using Perspex.Gtk; -#endif -using ReactiveUI; - -namespace Perspex.Skia.Desktop.TestApp -{ - internal class Program - { - private static void Main(string[] args) - { - // The version of ReactiveUI currently included is for WPF and so expects a WPF - // dispatcher. This makes sure it's initialized. - System.Windows.Threading.Dispatcher foo = System.Windows.Threading.Dispatcher.CurrentDispatcher; - - new App() - .UseWin32() - .UseSkia(); - - //RendererMixin.DrawFpsCounter = true; - - MainWindow.RootNamespace = "Perspex.Skia.Desktop.TestApp"; - var wnd = MainWindow.Create(); - - // let's start small :) - //var wnd = SimpleWindow.Create(); - - DevTools.Attach(wnd); - Application.Current.Run(wnd); - } - } - - internal class SimpleWindow - { - public static Window Create() - { - Border container; - - Window window = new Window - { - Title = "Perspex Test Application", - Content = (container = new Border - { - Background = Brushes.Green, - BorderBrush = Brushes.Yellow, - BorderThickness = 12, - Padding = new Thickness(5), - Child = new Rectangle - { - Fill = Brushes.Blue, - Width = 200, - Height = 200, - Margin = new Thickness(50) - } - }) - - }; - - window.Show(); - return window; - } - - } -} diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs b/src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs deleted file mode 100644 index ec1558ed5c..0000000000 --- a/src/Skia/Perspex.Skia.Desktop.TestApp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Perspex.Skia.Desktop.TestApp")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Perspex.Skia.Desktop.TestApp")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("383168df-5a4e-45e5-a239-fb54d40d4f5c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Skia/Perspex.Skia.Desktop.TestApp/packages.config b/src/Skia/Perspex.Skia.Desktop.TestApp/packages.config deleted file mode 100644 index a23c1e822f..0000000000 --- a/src/Skia/Perspex.Skia.Desktop.TestApp/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file From 2c7d4570574d14057979ce4743adf7a12ea32608 Mon Sep 17 00:00:00 2001 From: Jason Jarvis Date: Sat, 16 Apr 2016 11:57:50 -0700 Subject: [PATCH 09/16] Deleted a bunch of obsolete files, addressed all of the code styling comments, etc. --- samples/TestApplicationShared/App.cs | 42 ++- .../AndroidRenderTarget.cs | 53 +--- src/Skia/Perspex.Skia.iOS/SkiaView.cs | 26 +- src/Skia/Perspex.Skia.iOS/iOSMethodTable.cs | 23 -- src/Skia/Perspex.Skia/DrawingContextImpl.cs | 27 +- src/Skia/Perspex.Skia/FormattedTextImpl.cs | 72 +++--- src/Skia/Perspex.Skia/MethodTable.cs | 240 ------------------ src/Skia/Perspex.Skia/NativeBrush.cs | 115 --------- .../NativeDrawingContextSettings.cs | 12 - src/Skia/Perspex.Skia/NativeFormattedText.cs | 27 -- src/Skia/Perspex.Skia/Perspex.Skia.projitems | 1 + src/Skia/Perspex.Skia/PerspexHandleHolder.cs | 110 -------- .../Perspex.Skia/PlatformRenderInterface.cs | 24 +- src/Skia/Perspex.Skia/RenderTarget.cs | 13 +- src/Skia/Perspex.Skia/SkRect.cs | 31 --- src/Skia/Perspex.Skia/SkiaPlatform.cs | 5 +- src/Skia/Perspex.Skia/SkiaPoint.cs | 33 --- src/Skia/Perspex.Skia/StreamGeometryImpl.cs | 11 +- .../Perspex.Skia/WindowDrawingContextImpl.cs | 21 ++ src/Skia/Perspex.Skia/readme.md | 7 +- src/Windows/Perspex.Win32/SystemDialogImpl.cs | 18 +- src/iOS/Perspex.iOS/Perspex.iOS.csproj | 2 +- src/iOS/Perspex.iOS/PerspexAppDelegate.cs | 77 ------ src/iOS/Perspex.iOS/PerspexView.cs | 30 +-- src/iOS/Perspex.iOS/WindowingPlatformImpl.cs | 33 +++ src/iOS/Perspex.iOS/iOSPlatform.cs | 41 +-- .../Perspex.iOSTestApplication/AppDelegate.cs | 56 +--- 27 files changed, 205 insertions(+), 945 deletions(-) delete mode 100644 src/Skia/Perspex.Skia.iOS/iOSMethodTable.cs delete mode 100644 src/Skia/Perspex.Skia/MethodTable.cs delete mode 100644 src/Skia/Perspex.Skia/NativeBrush.cs delete mode 100644 src/Skia/Perspex.Skia/NativeDrawingContextSettings.cs delete mode 100644 src/Skia/Perspex.Skia/NativeFormattedText.cs delete mode 100644 src/Skia/Perspex.Skia/PerspexHandleHolder.cs delete mode 100644 src/Skia/Perspex.Skia/SkRect.cs delete mode 100644 src/Skia/Perspex.Skia/SkiaPoint.cs create mode 100644 src/Skia/Perspex.Skia/WindowDrawingContextImpl.cs delete mode 100644 src/iOS/Perspex.iOS/PerspexAppDelegate.cs create mode 100644 src/iOS/Perspex.iOS/WindowingPlatformImpl.cs diff --git a/samples/TestApplicationShared/App.cs b/samples/TestApplicationShared/App.cs index 0812f535f3..8c6310e27f 100644 --- a/samples/TestApplicationShared/App.cs +++ b/samples/TestApplicationShared/App.cs @@ -11,6 +11,7 @@ using Perspex.Themes.Default; using Perspex.Diagnostics; using Perspex.Platform; using Perspex.Shared.PlatformSupport; +using Perspex.Media; namespace TestApplication { @@ -43,10 +44,49 @@ namespace TestApplication }; MainWindow.RootNamespace = "TestApplication"; - var wnd = MainWindow.Create(); + var wnd = MainWindow.Create(); wnd.AttachDevTools(); Run(wnd); } + + // This provides a simple UI tree for testing input handling, drawing, etc + public static Window CreateSimpleWindow() + { + Window window = new Window + { + Title = "Perspex Test Application", + Background = Brushes.Red, + Content = new StackPanel + { + Margin = new Thickness(30), + Background = Brushes.Yellow, + Children = new Controls + { + new TextBlock + { + Text = "TEXT BLOCK", + Width = 300, + Height = 40, + Background = Brushes.White, + Foreground = Brushes.Black + }, + + new Button + { + Content = "BUTTON", + Width = 150, + Height = 40, + Background = Brushes.LightGreen, + Foreground = Brushes.Black + } + + } + } + }; + + return window; + } + } } diff --git a/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs b/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs index 2221c4bdb0..dc78e217e5 100644 --- a/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs +++ b/src/Skia/Perspex.Skia.Android/AndroidRenderTarget.cs @@ -14,54 +14,11 @@ using Perspex.Platform; namespace Perspex.Skia { -/* This lives in shared project now, but we may need an android specific implementation anyways - * - class RenderTarget : IRenderTarget + /// + /// We will likely need platform specific pieces to support HW acceleration + /// so leaving this class here for now as placeholder. + /// + internal partial class RenderTarget : IRenderTarget { - private IntPtr _currentRenderTarget = IntPtr.Zero; - private Surface _currentSurface = null; - private SurfaceView _view = null; - - public RenderTarget(IPlatformHandle handle) - { - _view = (SurfaceView) handle; - } - - public void Dispose() - { - if (_currentRenderTarget != IntPtr.Zero) - { - MethodTable.Instance.DisposeRenderTarget(_currentRenderTarget); - _currentRenderTarget = IntPtr.Zero; - GC.SuppressFinalize(this); - } - } - - ~RenderTarget() - { - Dispose(); - } - - public DrawingContext CreateDrawingContext() - { - var surface = _view.Holder.Surface; - if (surface == null) - throw new InvalidOperationException("Surface isn't available"); - if (_currentSurface != surface) - { - _currentSurface = null; - if (_currentRenderTarget != IntPtr.Zero) - { - MethodTable.Instance.DisposeRenderTarget(_currentRenderTarget); - _currentRenderTarget = IntPtr.Zero; - } - - _currentRenderTarget = MethodTable.Instance.CreateWindowRenderTarget(surface.Handle); - _currentSurface = surface; - } - return new DrawingContext( - new DrawingContextImpl(MethodTable.Instance.RenderTargetCreateRenderingContext(_currentRenderTarget))); - } } -*/ } \ No newline at end of file diff --git a/src/Skia/Perspex.Skia.iOS/SkiaView.cs b/src/Skia/Perspex.Skia.iOS/SkiaView.cs index 01283d6625..b18ac2540c 100644 --- a/src/Skia/Perspex.Skia.iOS/SkiaView.cs +++ b/src/Skia/Perspex.Skia.iOS/SkiaView.cs @@ -15,35 +15,25 @@ using UIKit; namespace Perspex.Skia.iOS { - public abstract class SkiaView : UIView //GLKView + // TODO: This implementation will be revised as part of HW acceleration work + // and we may use the GLKView as a base for the implementation. + // + public abstract class SkiaView : UIView { - //[DllImport("__Internal")] - //static extern IntPtr GetPerspexEAGLContext(); - bool _drawQueued; - //CADisplayLink _link; static EAGLContext GetContext() { - /* No longer needed with SkiaSharp, but require a variant for HW accel - //Ensure initialization - MethodTable.Instance.SetOption((MethodTable.Option)0x10009999, IntPtr.Zero); - var ctx = GetPerspexEAGLContext(); - var rv = Runtime.GetNSObject(ctx); - rv.DangerousRetain(); - return rv; - */ return null; } - protected SkiaView(Action registerFrame) : base(UIScreen.MainScreen.ApplicationFrame) //, GetContext()) + protected SkiaView(Action registerFrame) : base(UIScreen.MainScreen.ApplicationFrame) { registerFrame(OnFrame); } - protected SkiaView() : base(UIScreen.MainScreen.ApplicationFrame) //, GetContext()) + protected SkiaView() : base(UIScreen.MainScreen.ApplicationFrame) { - //(_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); } protected void OnFrame() @@ -51,10 +41,6 @@ namespace Perspex.Skia.iOS if (_drawQueued) { _drawQueued = false; - - // GLKView - //Display(); - this.SetNeedsDisplay(); } } diff --git a/src/Skia/Perspex.Skia.iOS/iOSMethodTable.cs b/src/Skia/Perspex.Skia.iOS/iOSMethodTable.cs deleted file mode 100644 index 834d631b74..0000000000 --- a/src/Skia/Perspex.Skia.iOS/iOSMethodTable.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using ObjCRuntime; - -/* No longer needed with SkiaSharp - -[assembly: LinkWith("Perspex.Skia.iOS.libperspesk_standalone.a", ForceLoad = true, SmartLink = true, IsCxx = true, Frameworks = "ImageIO MobileCoreServices CoreText")] - -namespace Perspex.Skia -{ - class MethodTableImpl : MethodTable - { - [DllImport("__Internal")] - static extern IntPtr GetPerspexMethodTable(); - - public MethodTableImpl() : base(GetPerspexMethodTable()) - { - } - } - -} - -*/ diff --git a/src/Skia/Perspex.Skia/DrawingContextImpl.cs b/src/Skia/Perspex.Skia/DrawingContextImpl.cs index 730da6380a..20f3ee2208 100644 --- a/src/Skia/Perspex.Skia/DrawingContextImpl.cs +++ b/src/Skia/Perspex.Skia/DrawingContextImpl.cs @@ -2,13 +2,12 @@ using System.Collections.Generic; using Perspex.Media; using Perspex.Media.Imaging; -using Perspex.RenderHelpers; using SkiaSharp; using System.Linq; namespace Perspex.Skia { - unsafe class DrawingContextImpl : IDrawingContextImpl + internal class DrawingContextImpl : IDrawingContextImpl { public SKCanvas Canvas { get; private set; } @@ -160,6 +159,8 @@ namespace Perspex.Skia paint.StrokeMiter = (float)pen.MiterLimit; + // TODO: Implement Dash Style support + // //if (pen.DashStyle?.Dashes != null) //{ // var dashes = pen.DashStyle.Dashes; @@ -191,7 +192,7 @@ namespace Perspex.Skia } else { - // DrawRRect is not accesible in SkiaSharp yet. We should add that + // TODO: DrawRRect (ore DrawRoundedRect) is not accesible in SkiaSharp yet. We should add that // to SkiaSharp and initiate a PR.... Canvas.DrawRect(rc, paint); //Canvas.DrawRoundedRect(rc, cornerRadius, cornerRadius, paint); @@ -210,7 +211,7 @@ namespace Perspex.Skia } else { - // this does not appear to exist in SkiaSharp? + // TODO: this does not exist in SkiaSharp yet //throw new NotImplementedException(); //Canvas.DrawRoundedRect(rc, cornerRadius, cornerRadius, paint); Canvas.DrawRect(rc, paint); @@ -271,22 +272,4 @@ namespace Perspex.Skia } } } - - // not sure we need this yet - internal class WindowDrawingContextImpl : DrawingContextImpl - { - WindowRenderTarget _target; - - public WindowDrawingContextImpl(WindowRenderTarget target) - : base(target.Surface.Canvas) - { - _target = target; - } - - public override void Dispose() - { - base.Dispose(); - _target.Present(); - } - } } \ No newline at end of file diff --git a/src/Skia/Perspex.Skia/FormattedTextImpl.cs b/src/Skia/Perspex.Skia/FormattedTextImpl.cs index 493831dc26..639307bf44 100644 --- a/src/Skia/Perspex.Skia/FormattedTextImpl.cs +++ b/src/Skia/Perspex.Skia/FormattedTextImpl.cs @@ -22,7 +22,7 @@ namespace Perspex.Skia Paint.IsAntialias = true; LineOffset = 0; - //Replace 0 characters with zero-width spaces (200B) + // Replace 0 characters with zero-width spaces (200B) _text = _text.Replace((char)0, (char)0x200B); } @@ -108,16 +108,9 @@ namespace Perspex.Skia public void SetForegroundBrush(IBrush brush, int startIndex, int length) { - // Is this method even relevant now??? - // - //var scb = brush as SolidColorBrush; - //if (scb != null) - //{ - // Layout.Attributes.Insert(brushAttr); - //} + // TODO: we need an implementation here to properly support FormattedText } - void Rebuild() { var length = _text.Length; @@ -164,20 +157,13 @@ namespace Perspex.Skia subString = _text.Substring(curOff); - // TODO: This method is not linking into SkiaSharp so we must use the RAW buffer version + // TODO: This method is not linking into SkiaSharp so we must use the RAW buffer version for now //measured = (int)Paint.BreakText(subString, constraint, out lineWidth) / 2; bytes = Encoding.UTF8.GetBytes(subString); pinnedArray = GCHandle.Alloc(bytes, GCHandleType.Pinned); pointer = pinnedArray.AddrOfPinnedObject(); - // for some reason I have to pass nBytes * 2 + // for some reason I have to pass nBytes * 2. I assume under the hood it expects Unicode/WChar?? measured = (int)Paint.BreakText(pointer, (IntPtr)(bytes.Length * 2), constraint, out lineWidth) / 2; - - // some weird unicode byte issue again - //if(subString.Length % 2 == 1) - //{ - // measured -= 1; - //} - pinnedArray.Free(); if (measured == 0) @@ -192,20 +178,17 @@ namespace Perspex.Skia if (nextChar != ' ') { - //Perform scan for the last space and end the line there + // Perform scan for the last space and end the line there for (int si = curOff + measured - 1; si > curOff; si--) { if (_text[si] == ' ') { measured = si - curOff; extraSkip = 1; - //Rects[si] = SkRect(); break; } } } - - } PerspexFormattedTextLine line = new PerspexFormattedTextLine(); @@ -218,7 +201,7 @@ namespace Perspex.Skia if (line.Width < 0) line.Width = _skiaRects[line.Start + line.Length - 1].Right; - //Build character rects + // Build character rects for (int i = line.Start; i < line.Start + line.Length; i++) { float prevRight = 0; @@ -241,7 +224,13 @@ namespace Perspex.Skia _skiaLines.Add(line); - curY += lineHeight; // + mLeading; + curY += lineHeight; + + // TODO: We may want to consider adding Leading to the vertical line spacing but for now + // it appears to make no difference. Revisit as part of FormattedText improvements. + // + //curY += mLeading; + curOff += measured + extraSkip; } @@ -260,10 +249,14 @@ namespace Perspex.Skia } for (var c = 0; c < _text.Length; c++) + { _rects.Add(_skiaRects[c].ToPerspexRect()); + } if (_skiaLines.Count == 0) + { _size = new Size(); + } else { var lastLine = _skiaLines[_skiaLines.Count - 1]; @@ -275,38 +268,37 @@ namespace Perspex.Skia { SKPaint paint = Paint; - /* This originated from Native code, it might be useful - //Debugging code for character positions + /* TODO: This originated from Native code, it might be useful for debugging character positions as + * we improve the FormattedText support. Will need to port this to C# obviously. Rmove when + * not needed anymore. + SkPaint dpaint; ctx->Canvas->save(); ctx->Canvas->translate(origin.fX, origin.fY); for (int c = 0; c < Lines.size(); c++) { - dpaint.setARGB(255, 0, 0, 0); - SkRect rc; - rc.fLeft = 0; - rc.fTop = Lines[c].Top; - rc.fRight = Lines[c].Width; - rc.fBottom = rc.fTop + LineOffset; - ctx->Canvas->drawRect(rc, dpaint); + dpaint.setARGB(255, 0, 0, 0); + SkRect rc; + rc.fLeft = 0; + rc.fTop = Lines[c].Top; + rc.fRight = Lines[c].Width; + rc.fBottom = rc.fTop + LineOffset; + ctx->Canvas->drawRect(rc, dpaint); } for (int c = 0; c < Length; c++) { - dpaint.setARGB(255, c % 10 * 125 / 10 + 125, (c * 7) % 10 * 250 / 10, (c * 13) % 10 * 250 / 10); - dpaint.setStyle(SkPaint::kFill_Style); - ctx->Canvas->drawRect(Rects[c], dpaint); + dpaint.setARGB(255, c % 10 * 125 / 10 + 125, (c * 7) % 10 * 250 / 10, (c * 13) % 10 * 250 / 10); + dpaint.setStyle(SkPaint::kFill_Style); + ctx->Canvas->drawRect(Rects[c], dpaint); } ctx->Canvas->restore(); */ - // These seems to vertically align the text properly - var yOffset = (LineOffset); // + 1) / 2; - for (int c = 0; c < _skiaLines.Count; c++) { PerspexFormattedTextLine line = _skiaLines[c]; var subString = _text.Substring(line.Start, line.Length); - canvas.DrawText(subString, origin.X, origin.Y + line.Top + yOffset, paint); + canvas.DrawText(subString, origin.X, origin.Y + line.Top + LineOffset, paint); } } diff --git a/src/Skia/Perspex.Skia/MethodTable.cs b/src/Skia/Perspex.Skia/MethodTable.cs deleted file mode 100644 index 04524d4928..0000000000 --- a/src/Skia/Perspex.Skia/MethodTable.cs +++ /dev/null @@ -1,240 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using Perspex.Media; - -// ReSharper disable InconsistentNaming - -namespace Perspex.Skia -{ -/* No longer needed with SkiaSharp - - unsafe abstract class MethodTable - { - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _CreateWindowRenderTarget(IntPtr nativeHandle); - - public _CreateWindowRenderTarget CreateWindowRenderTarget; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _RenderTargetCreateRenderingContext(IntPtr target); - - public _RenderTargetCreateRenderingContext RenderTargetCreateRenderingContext; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DisposeRenderTarget(IntPtr target); - - public _DisposeRenderTarget DisposeRenderTarget; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DisposeRenderingContext(IntPtr ctx); - - public _DisposeRenderingContext DisposeRenderingContext; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DrawRectangle(IntPtr ctx, void* brush, ref SkRect rect, float borderRadius); - - public _DrawRectangle DrawRectangle; - - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _PushClip(IntPtr ctx, ref SkRect rect); - - public _PushClip PushClip; - - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _PopClip(IntPtr ctx); - - public _PopClip PopClip; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _SetTransform(IntPtr ctx, void* matrix6); - - public _SetTransform SetTransformNative; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DrawLine(IntPtr ctx, void* brush, float x1, float y1, float x2, float y2); - - public _DrawLine DrawLine; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _CreatePath(SkiaGeometryElement[] elements, int count, out SkRect bounds); - - public _CreatePath CreatePath; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DisposePath(IntPtr handle); - - public _DisposePath DisposePath; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _TransformPath(IntPtr path, void* matrix6); - - public _TransformPath TransformPathNative; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DrawGeometry(IntPtr ctx, IntPtr path, void* fill, void* stroke, bool useEvenOdd); - - public _DrawGeometry DrawGeometry; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DestroySkData(IntPtr handle); - - public _DestroySkData DestroySkData; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate bool _LoadImage(byte[] data, int len, out IntPtr image, out int width, out int height); - - public _LoadImage LoadImage; - - public enum SkiaImageType - { - Png,Gif,Jpeg - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _SaveImage(IntPtr image, SkiaImageType type, int quality); - - public _SaveImage SaveImage; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DrawImage(IntPtr ctx, IntPtr image, float opacity, ref SkRect srcRect, ref SkRect destRect); - - public _DrawImage DrawImage; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _CreateRenderTargetBitmap(int width, int height); - - public _CreateRenderTargetBitmap CreateRenderTargetBitmap; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DisposeImage(IntPtr image); - - public _DisposeImage DisposeImage; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate int _GetSkDataSize(IntPtr data); - - public _GetSkDataSize GetSkDataSize; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _ReadSkData(IntPtr data, byte[] buffer, int count); - - public _ReadSkData ReadSkData; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate NativeDrawingContextSettings* _GetDrawingContextSettingsPtr(IntPtr ctx); - - public _GetDrawingContextSettingsPtr GetDrawingContextSettingsPtr; - - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _CreateTypeface(void* name, int style); - - public _CreateTypeface CreateTypeface; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr _CreateFormattedText(void*utf16, int len, IntPtr typeface, float fontSize, TextAlignment align, NativeFormattedText** shared); - - public _CreateFormattedText CreateFormattedText; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _RebuildFormattedText(IntPtr handle); - - public _RebuildFormattedText RebuildFormattedText; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DestroyFormattedText(IntPtr handle); - - public _DestroyFormattedText DestroyFormattedText; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _DrawFormattedText(IntPtr ctx, void* brush, IntPtr text, float x, float y); - - public _DrawFormattedText DrawFormattedText; - - public enum Option - { - ForceSoftware = 0 - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void _SetOption(Option option, IntPtr value); - - public _SetOption SetOption; - - private static readonly Type[] TableOrder = new Type[] - { - typeof (_CreateWindowRenderTarget), - typeof (_DisposeRenderTarget), - typeof (_RenderTargetCreateRenderingContext), - typeof (_DisposeRenderingContext), - typeof (_DrawRectangle), - typeof (_PushClip), - typeof (_PopClip), - typeof (_SetTransform), - typeof (_DrawLine), - typeof (_CreatePath), - typeof (_DisposePath), - typeof (_DrawGeometry), - typeof (_GetSkDataSize), - typeof (_ReadSkData), - typeof (_DestroySkData), - typeof (_LoadImage), - typeof (_SaveImage), - typeof (_DrawImage), - typeof (_CreateRenderTargetBitmap), - typeof (_DisposeImage), - typeof (_GetDrawingContextSettingsPtr), - typeof (_CreateTypeface), - typeof (_CreateFormattedText), - typeof (_RebuildFormattedText), - typeof (_DestroyFormattedText), - typeof (_DrawFormattedText), - typeof (_SetOption), - typeof (_TransformPath) - }; - - void ConvertMatrix(Matrix value, float* target) - { - target[0] = (float)value.M11; - target[1] = (float)value.M21; - target[2] = (float)value.M31; - - target[3] = (float)value.M12; - target[4] = (float)value.M22; - target[5] = (float)value.M32; - } - - public unsafe IntPtr TransformPath(IntPtr path, Matrix matrix) - { - var tmp = stackalloc float[6]; - ConvertMatrix(matrix, tmp); - return TransformPathNative(path, tmp); - } - - public unsafe void SetTransform(IntPtr ctx, Matrix matrix) - { - var tmp = stackalloc float[6]; - ConvertMatrix(matrix, tmp); - SetTransformNative(ctx, tmp); - } - - protected MethodTable(IntPtr methodTable) - { - var dic = typeof (MethodTable).GetFields().ToDictionary(f => f.FieldType, f => f); - - for (var c = 0; c < TableOrder.Length; c++) - { - IntPtr pMethod = Marshal.ReadIntPtr(methodTable, IntPtr.Size*c); - var t = TableOrder[c]; - dic[t].SetValue(this, Marshal.GetDelegateForFunctionPointer(pMethod, t)); - } - } - - public static readonly MethodTable Instance = new MethodTableImpl(); - } - -*/ -} diff --git a/src/Skia/Perspex.Skia/NativeBrush.cs b/src/Skia/Perspex.Skia/NativeBrush.cs deleted file mode 100644 index 9d81c0a896..0000000000 --- a/src/Skia/Perspex.Skia/NativeBrush.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; -using Perspex.Media; - -namespace Perspex.Skia -{ -/* No longer needed with SkiaSharp - internal enum NativeBrushType - { - Solid, - LinearGradient, - RadialGradient, - Image - } - - [StructLayout(LayoutKind.Sequential)] - internal unsafe struct NativeBrush - { - public const int MaxGradientStops = 1024; - public const int MaxDashCount = 1024; - public NativeBrushType Type; - public double Opacity; - public uint Color; - - //Strokes - public bool Stroke; - public float StrokeThickness; - public PenLineJoin StrokeLineJoin; - public float StrokeMiterLimit; - public int StrokeDashCount; - public float StrokeDashOffset; - public PenLineCap StrokeLineCap; - - - //Gradients - public int GradientStopCount; - public GradientSpreadMethod GradientSpreadMethod; - public SkiaPoint GradientStartPoint, GradientEndPoint; - public float GradientRadius; - - //Image Brush - public IntPtr Bitmap; - public TileMode BitmapTileMode; - public SkiaPoint BitmapTranslation; - - //Blobs - public fixed uint GradientStopColors [MaxGradientStops]; - public fixed float GradientStops [MaxGradientStops]; - public fixed float StrokeDashes [MaxDashCount]; - - public void Reset() - { - Type = NativeBrushType.Solid; - Opacity = 1f; - Color = 0; - Stroke = false; - StrokeThickness = 1; - GradientStopCount = 0; - StrokeDashCount = 0; - StrokeLineCap = PenLineCap.Flat; - } - - } - - - unsafe class NativeBrushContainer : IDisposable - { - private readonly NativeBrushPool _pool; - public NativeBrush* Brush; - - readonly List _disposables = new List(); - - public NativeBrushContainer(NativeBrushPool pool) - { - _pool = pool; - Brush = (NativeBrush*) Marshal.AllocHGlobal(Marshal.SizeOf(typeof (NativeBrush))).ToPointer(); - Brush->Reset(); - } - - public void AddDisposable(IDisposable disp) - { - _disposables.Add(disp); - } - - public void Dispose() - { - foreach (var disp in _disposables) - disp.Dispose(); - _disposables.Clear(); - Brush->Reset(); - _pool?.Return(this); - } - } - - class NativeBrushPool - { - public static NativeBrushPool Instance { get; } = new NativeBrushPool(); - readonly Stack _pool = new Stack(); - - public void Return(NativeBrushContainer c) - { - _pool.Push(c); - } - - public NativeBrushContainer Get() - { - if (_pool.Count == 0) - return new NativeBrushContainer(this); - return _pool.Pop(); - } - } -*/ -} diff --git a/src/Skia/Perspex.Skia/NativeDrawingContextSettings.cs b/src/Skia/Perspex.Skia/NativeDrawingContextSettings.cs deleted file mode 100644 index eb655c633f..0000000000 --- a/src/Skia/Perspex.Skia/NativeDrawingContextSettings.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Runtime.InteropServices; - -/* No longer needed with SkiaSharp -namespace Perspex.Skia -{ - [StructLayout(LayoutKind.Sequential)] - struct NativeDrawingContextSettings - { - public double Opacity; - } -} -*/ \ No newline at end of file diff --git a/src/Skia/Perspex.Skia/NativeFormattedText.cs b/src/Skia/Perspex.Skia/NativeFormattedText.cs deleted file mode 100644 index 903ddc9794..0000000000 --- a/src/Skia/Perspex.Skia/NativeFormattedText.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Runtime.InteropServices; - -/* No longer needed with SkiaSharp - -namespace Perspex.Skia -{ - [StructLayout(LayoutKind.Sequential)] - unsafe struct NativeFormattedText - { - public float WidthConstraint; - public int LineCount; - public NativeFormattedTextLine* Lines; - public SkRect* Bounds; - }; - - [StructLayout(LayoutKind.Sequential)] - unsafe struct NativeFormattedTextLine - { - public float Top; - public int Start; - public int Length; - public float Height; - public float Width; - }; -} - -*/ \ No newline at end of file diff --git a/src/Skia/Perspex.Skia/Perspex.Skia.projitems b/src/Skia/Perspex.Skia/Perspex.Skia.projitems index fc35c28cd9..e9dabf49cc 100644 --- a/src/Skia/Perspex.Skia/Perspex.Skia.projitems +++ b/src/Skia/Perspex.Skia/Perspex.Skia.projitems @@ -18,6 +18,7 @@ + diff --git a/src/Skia/Perspex.Skia/PerspexHandleHolder.cs b/src/Skia/Perspex.Skia/PerspexHandleHolder.cs deleted file mode 100644 index fdf98fbdd3..0000000000 --- a/src/Skia/Perspex.Skia/PerspexHandleHolder.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; - -/* No longer needed with SkiaSharp - -namespace Perspex.Skia -{ - abstract class PerspexHandleHolder : IDisposable - { - private readonly IntPtr _handle; - - public IntPtr Handle - { - get - { - CheckDisposed(); - return _handle; - } - } - - public bool IsDisposed { get; private set; } - - public void CheckDisposed() - { - if (IsDisposed) - throw new ObjectDisposedException(GetType().FullName); - } - - protected PerspexHandleHolder(IntPtr handle) - { - _handle = handle; - } - - protected abstract void Delete(IntPtr handle); - - public void Dispose() - { - if(IsDisposed) - return; - IsDisposed = true; - Delete(_handle); - GC.SuppressFinalize(this); - } - - ~PerspexHandleHolder() - { - Dispose(); - } - } - - class RefCountable : IDisposable where T : PerspexHandleHolder - { - class Shared - { - public readonly T Target; - private int _refCount = 1; - - public Shared(T target) - { - Target = target; - } - - public void AddRef() => _refCount++; - public void Release() - { - _refCount--; - if (_refCount <= 0) - Target.Dispose(); - } - } - - public bool IsDisposed => _shared == null; - private Shared _shared; - public void CheckDisposed() - { - if (IsDisposed) - throw new ObjectDisposedException(GetType().FullName); - } - - public IntPtr Handle - { - get - { - CheckDisposed(); - return _shared.Target.Handle; - } - } - - public RefCountable(T handle) - { - _shared = new Shared(handle); - } - - public RefCountable(RefCountable other) - { - other._shared.Target.CheckDisposed(); - other._shared.AddRef(); - _shared = other._shared; - } - - public RefCountable Clone() => new RefCountable(this); - - public void Dispose() - { - _shared?.Release(); - _shared = null; - } - } -} - -*/ diff --git a/src/Skia/Perspex.Skia/PlatformRenderInterface.cs b/src/Skia/Perspex.Skia/PlatformRenderInterface.cs index 382f366aa0..5492f7e669 100644 --- a/src/Skia/Perspex.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Perspex.Skia/PlatformRenderInterface.cs @@ -30,16 +30,16 @@ namespace Perspex.Skia IBitmapImpl LoadBitmap(byte[] data) { - var bitmap = new SKBitmap(); - if(!SKImageDecoder.DecodeMemory(data, bitmap)) - { - throw new ArgumentException("Unable to load bitmap from provided data"); - } + var bitmap = new SKBitmap(); + if (!SKImageDecoder.DecodeMemory(data, bitmap)) + { + throw new ArgumentException("Unable to load bitmap from provided data"); + } - return new BitmapImpl(bitmap); - } + return new BitmapImpl(bitmap); + } - public IBitmapImpl LoadBitmap(System.IO.Stream stream) + public IBitmapImpl LoadBitmap(System.IO.Stream stream) { using (var sr = new BinaryReader(stream)) { @@ -62,9 +62,9 @@ namespace Perspex.Skia return new BitmapImpl(width, height); } - public IRenderTarget CreateRenderer(IPlatformHandle handle) - { - return new WindowRenderTarget(handle.Handle); - } + public IRenderTarget CreateRenderer(IPlatformHandle handle) + { + return new WindowRenderTarget(handle.Handle); + } } } diff --git a/src/Skia/Perspex.Skia/RenderTarget.cs b/src/Skia/Perspex.Skia/RenderTarget.cs index 7304b4bf7f..c631b7a558 100644 --- a/src/Skia/Perspex.Skia/RenderTarget.cs +++ b/src/Skia/Perspex.Skia/RenderTarget.cs @@ -17,22 +17,20 @@ using Perspex.Win32.Interop; namespace Perspex.Skia { - internal class RenderTarget : IRenderTarget + internal partial class RenderTarget : IRenderTarget { public SKSurface Surface { get; protected set; } - //protected override void Delete(IntPtr handle) => MethodTable.Instance.DisposeRenderTarget(handle); - public virtual DrawingContext CreateDrawingContext() { return new DrawingContext( - new DrawingContextImpl(Surface.Canvas)); // MethodTable.Instance.RenderTargetCreateRenderingContext(Handle))); + new DrawingContextImpl(Surface.Canvas)); } public void Dispose() { - //throw new NotImplementedException(); + // Nothing to do here. } } @@ -69,7 +67,7 @@ namespace Perspex.Skia } #endif - void FixSize() + private void FixSize() { int width, height; GetPlatformWindowSize(_hwnd, out width, out height); @@ -91,7 +89,6 @@ namespace Perspex.Skia _bitmap = new SKBitmap(width, height, SKColorType.N_32, SKAlphaType.Premul); - //bitmap.LockPixels(); IntPtr length; var pixels = _bitmap.GetPixels(out length); @@ -99,7 +96,7 @@ namespace Perspex.Skia Surface = SKSurface.Create(_bitmap.Info, pixels, _bitmap.RowBytes); } - void GetPlatformWindowSize(IntPtr hwnd, out int w, out int h) + private void GetPlatformWindowSize(IntPtr hwnd, out int w, out int h) { #if __IOS__ var bounds = GetApplicationFrame(); diff --git a/src/Skia/Perspex.Skia/SkRect.cs b/src/Skia/Perspex.Skia/SkRect.cs deleted file mode 100644 index 4d4492b0ee..0000000000 --- a/src/Skia/Perspex.Skia/SkRect.cs +++ /dev/null @@ -1,31 +0,0 @@ -using SkiaSharp; -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; - -/* No longer needed with SkiaSharp - -namespace Perspex.Skia -{ - [StructLayout(LayoutKind.Sequential)] - struct SkRect - { - public float Left, Top, Right, Bottom; - - public static SkRect FromRect(Rect rc) - { - return new SkRect() - { - Left = (float) rc.X, - Top = (float) rc.Y, - Right = (float) rc.Right, - Bottom = (float) rc.Bottom - }; - } - - public Rect ToRect() => new Rect(Left, Top, Right - Left, Bottom - Top); - } -} - -*/ diff --git a/src/Skia/Perspex.Skia/SkiaPlatform.cs b/src/Skia/Perspex.Skia/SkiaPlatform.cs index b05096b84b..b1b31ccf1a 100644 --- a/src/Skia/Perspex.Skia/SkiaPlatform.cs +++ b/src/Skia/Perspex.Skia/SkiaPlatform.cs @@ -31,8 +31,9 @@ namespace Perspex.Skia { s_forceSoftwareRendering = value; - // Do we still need this with SkiaSharp?? - //MethodTable.Instance.SetOption(MethodTable.Option.ForceSoftware, new IntPtr(value ? 1 : 0)); + // TODO: I left this property here as place holder. Do we still need the ability to Force software rendering? + // Is it even possible with SkiaSharp? Perhaps kekekes can answer as part of the HW accel work. + // throw new NotImplementedException(); } } diff --git a/src/Skia/Perspex.Skia/SkiaPoint.cs b/src/Skia/Perspex.Skia/SkiaPoint.cs deleted file mode 100644 index 2fde20eb9d..0000000000 --- a/src/Skia/Perspex.Skia/SkiaPoint.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Runtime.InteropServices; - -/* No longer needed with SkiaSharp - -namespace Perspex.Skia -{ - [StructLayout(LayoutKind.Sequential)] - struct SkiaPoint - { - public float X, Y; - - public SkiaPoint(float x, float y) - { - X = x; - Y = y; - } - - public SkiaPoint(double x, double y) - { - X = (float)x; - Y = (float)y; - } - - public SkiaPoint(Point p) : this(p.X, p.Y) - { - - } - - public static implicit operator SkiaPoint(Point pt) => new SkiaPoint(pt); - } -} - - */ \ No newline at end of file diff --git a/src/Skia/Perspex.Skia/StreamGeometryImpl.cs b/src/Skia/Perspex.Skia/StreamGeometryImpl.cs index ecf1e03779..6b7cbb1edf 100644 --- a/src/Skia/Perspex.Skia/StreamGeometryImpl.cs +++ b/src/Skia/Perspex.Skia/StreamGeometryImpl.cs @@ -85,7 +85,6 @@ namespace Perspex.Skia private readonly StreamGeometryImpl _geometryImpl; private SKPath _path; - //readonly List _elements = new List(); Point _currentPoint; public StreamContext(StreamGeometryImpl geometryImpl) { @@ -95,16 +94,13 @@ namespace Perspex.Skia public void Dispose() { - // Not sure what we need to do here.... - - // //throw new NotImplementedException(); - + // TODO: Not sure what we need to do here. This code left here for reference. + // // var arr = _elements.ToArray(); // SkRect rc; // _path?.Dispose(); // _path = new SKPath(new SkPath(MethodTable.Instance.CreatePath(arr, arr.Length, out rc))); // _geometryImpl.ApplyTransform(); - // _geometryImpl.Bounds = rc.ToRect(); SKRect rc; @@ -116,9 +112,6 @@ namespace Perspex.Skia public void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection) { throw new NotImplementedException(); - - //ArcToHelper.ArcTo(this, _currentPoint, point, size, rotationAngle, isLargeArc, sweepDirection); - //_currentPoint = point; } public void BeginFigure(Point startPoint, bool isFilled) diff --git a/src/Skia/Perspex.Skia/WindowDrawingContextImpl.cs b/src/Skia/Perspex.Skia/WindowDrawingContextImpl.cs new file mode 100644 index 0000000000..a3f6cd3a1e --- /dev/null +++ b/src/Skia/Perspex.Skia/WindowDrawingContextImpl.cs @@ -0,0 +1,21 @@ + +namespace Perspex.Skia +{ + // not sure we need this yet + internal class WindowDrawingContextImpl : DrawingContextImpl + { + WindowRenderTarget _target; + + public WindowDrawingContextImpl(WindowRenderTarget target) + : base(target.Surface.Canvas) + { + _target = target; + } + + public override void Dispose() + { + base.Dispose(); + _target.Present(); + } + } +} \ No newline at end of file diff --git a/src/Skia/Perspex.Skia/readme.md b/src/Skia/Perspex.Skia/readme.md index 698739415d..1c923df3c5 100644 --- a/src/Skia/Perspex.Skia/readme.md +++ b/src/Skia/Perspex.Skia/readme.md @@ -35,7 +35,12 @@ Android iOS - Get GLView working again. See HW above +Win32 +- Cleanup the unmanaged methods (BITMAPINFO) if possible + General - Cleanup/eliminate obsolete files - Finish cleanup of the many Test Applications -- Get Skia Unit Tests passing \ No newline at end of file +- Get Skia Unit Tests passing + + diff --git a/src/Windows/Perspex.Win32/SystemDialogImpl.cs b/src/Windows/Perspex.Win32/SystemDialogImpl.cs index 5cdcb0fac7..87bff80d26 100644 --- a/src/Windows/Perspex.Win32/SystemDialogImpl.cs +++ b/src/Windows/Perspex.Win32/SystemDialogImpl.cs @@ -40,23 +40,23 @@ namespace Perspex.Win32 var filterBuffer = new char[filters.Length]; filters.CopyTo(0, filterBuffer, 0, filterBuffer.Length); - var defExt = (dialog as SaveFileDialog)?.DefaultExtension.ToArray(); + var defExt = (dialog as SaveFileDialog)?.DefaultExtension.ToArray(); var fileBuffer = new char[256]; dialog.InitialFileName?.CopyTo(0, fileBuffer, 0, dialog.InitialFileName.Length); string userSelectedExt = null; - var title = dialog.Title.ToArray(); - var initialDir = dialog.InitialDirectory.ToArray(); + var title = dialog.Title.ToArray(); + var initialDir = dialog.InitialDirectory.ToArray(); - fixed (char* pFileBuffer = fileBuffer) + fixed (char* pFileBuffer = fileBuffer) fixed (char* pFilterBuffer = filterBuffer) fixed (char* pDefExt = defExt) fixed (char* pInitDir = initialDir) fixed (char* pTitle = title) { var ofn = new UnmanagedMethods.OpenFileName() - { + { hwndOwner = hWnd, hInstance = IntPtr.Zero, lCustData = IntPtr.Zero, @@ -124,8 +124,8 @@ namespace Perspex.Win32 !userSelectedExt.Contains("*")) dir = Path.ChangeExtension(dir, userSelectedExt); } - - return new[] {dir}; + + return new[] { dir }; } return files.Select(f => Path.Combine(dir, f)).ToArray(); @@ -133,7 +133,7 @@ namespace Perspex.Win32 } public Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) - { + { return Task.Factory.StartNew(() => { string result = string.Empty; @@ -177,7 +177,7 @@ namespace Perspex.Win32 { try { - result = Marshal.PtrToStringAuto(pszString); + result = Marshal.PtrToStringAuto(pszString); } finally { diff --git a/src/iOS/Perspex.iOS/Perspex.iOS.csproj b/src/iOS/Perspex.iOS/Perspex.iOS.csproj index 097c3f9bbd..3e1f8ab93a 100644 --- a/src/iOS/Perspex.iOS/Perspex.iOS.csproj +++ b/src/iOS/Perspex.iOS/Perspex.iOS.csproj @@ -39,11 +39,11 @@ - + diff --git a/src/iOS/Perspex.iOS/PerspexAppDelegate.cs b/src/iOS/Perspex.iOS/PerspexAppDelegate.cs deleted file mode 100644 index 3dd82d59ae..0000000000 --- a/src/iOS/Perspex.iOS/PerspexAppDelegate.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Perspex.Controls.Platform; -using Perspex.Input; -using Perspex.Input.Platform; -using Perspex.Platform; -using Perspex.Shared.PlatformSupport; -using Perspex.Skia; -using UIKit; - -/* No Longer needed -namespace Perspex.iOS -{ - public class PerspexAppDelegate : UIApplicationDelegate - { - static bool _initialized = false; - internal static MouseDevice MouseDevice; - internal static KeyboardDevice KeyboardDevice; - - protected void InitPerspex(Type appType) - { - if(_initialized) - return; - _initialized = true; - - var window = new UIWindow(UIScreen.MainScreen.Bounds); - var controller = new PerspexViewController(window); - window.RootViewController = controller; - window.MakeKeyAndVisible(); - - Application.RegisterPlatformCallback(() => - { - MouseDevice = new MouseDevice(); - KeyboardDevice = new KeyboardDevice(); - SharedPlatform.Register(appType.Assembly); - PerspexLocator.CurrentMutable - .Bind().ToTransient() - //.Bind().ToTransient() - .Bind().ToTransient() - .Bind().ToConstant(KeyboardDevice) - .Bind().ToConstant(MouseDevice) - .Bind().ToSingleton() - .Bind().ToConstant(PlatformThreadingInterface.Instance) - .Bind().ToConstant(new WindowingPlatform(controller.PerspexView)); - SkiaPlatform.Initialize(); - }); - } - - class WindowingPlatform : IWindowingPlatform - { - private readonly IWindowImpl _window; - - public WindowingPlatform(IWindowImpl window) - { - _window = window; - } - - public IWindowImpl CreateWindow() - { - return _window; - } - - public IWindowImpl CreateEmbeddableWindow() - { - throw new NotImplementedException(); - } - - public IPopupImpl CreatePopup() - { - throw new NotImplementedException(); - } - } - } -} -*/ \ No newline at end of file diff --git a/src/iOS/Perspex.iOS/PerspexView.cs b/src/iOS/Perspex.iOS/PerspexView.cs index 385e6d3293..51295038d6 100644 --- a/src/iOS/Perspex.iOS/PerspexView.cs +++ b/src/iOS/Perspex.iOS/PerspexView.cs @@ -57,8 +57,8 @@ namespace Perspex.iOS (_controller.InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || _controller.InterfaceOrientation == UIInterfaceOrientation.LandscapeRight); - // Bounds here (if top level) needs to correspond with the rendertarget - var frame = UIScreen.MainScreen.Bounds; + // Bounds here (if top level) needs to correspond with the rendertarget + var frame = UIScreen.MainScreen.Bounds; if (needFlip) Frame = new CGRect(frame.Y, frame.X, frame.Height, frame.Width); else @@ -76,14 +76,14 @@ namespace Perspex.iOS public IPlatformHandle Handle => PerspexPlatformHandle; public double Scaling - { - get - { - // This does not appear to make any difference, but on iOS we - // have Retina (x2) and we probably want this eventually - return 1; //UIScreen.MainScreen.Scale; - } - } + { + get + { + // This does not appear to make any difference, but on iOS we + // have Retina (x2) and we probably want this eventually + return 1; //UIScreen.MainScreen.Scale; + } + } public WindowState WindowState { @@ -169,7 +169,7 @@ namespace Perspex.iOS Input?.Invoke(new RawMouseEventArgs( iOSPlatform.MouseDevice, - (uint) touch.Timestamp, + (uint)touch.Timestamp, _inputRoot, RawMouseEventType.LeftButtonUp, location, @@ -185,10 +185,10 @@ namespace Perspex.iOS { var location = touch.LocationInView(this).ToPerspex(); _touchLastPoint = location; - Input?.Invoke(new RawMouseEventArgs(iOSPlatform.MouseDevice, (uint) touch.Timestamp, _inputRoot, + Input?.Invoke(new RawMouseEventArgs(iOSPlatform.MouseDevice, (uint)touch.Timestamp, _inputRoot, RawMouseEventType.Move, location, InputModifiers.None)); - Input?.Invoke(new RawMouseEventArgs(iOSPlatform.MouseDevice, (uint) touch.Timestamp, _inputRoot, + Input?.Invoke(new RawMouseEventArgs(iOSPlatform.MouseDevice, (uint)touch.Timestamp, _inputRoot, RawMouseEventType.LeftButtonDown, location, InputModifiers.None)); } } @@ -200,7 +200,7 @@ namespace Perspex.iOS { var location = touch.LocationInView(this).ToPerspex(); if (iOSPlatform.MouseDevice.Captured != null) - Input?.Invoke(new RawMouseEventArgs(iOSPlatform.MouseDevice, (uint) touch.Timestamp, _inputRoot, + Input?.Invoke(new RawMouseEventArgs(iOSPlatform.MouseDevice, (uint)touch.Timestamp, _inputRoot, RawMouseEventType.Move, location, InputModifiers.LeftMouseButton)); else { @@ -208,7 +208,7 @@ namespace Perspex.iOS double correction = 0.02; Input?.Invoke(new RawMouseWheelEventArgs(iOSPlatform.MouseDevice, (uint)touch.Timestamp, - _inputRoot, location, (location - _touchLastPoint)* correction, InputModifiers.LeftMouseButton)); + _inputRoot, location, (location - _touchLastPoint) * correction, InputModifiers.LeftMouseButton)); } _touchLastPoint = location; } diff --git a/src/iOS/Perspex.iOS/WindowingPlatformImpl.cs b/src/iOS/Perspex.iOS/WindowingPlatformImpl.cs new file mode 100644 index 0000000000..54f1a7fb37 --- /dev/null +++ b/src/iOS/Perspex.iOS/WindowingPlatformImpl.cs @@ -0,0 +1,33 @@ +using Perspex.Platform; +using System; + +namespace Perspex.iOS +{ + // This is somewhat generic, could probably put this elsewhere. But I don't think + // it should part of the iOS App Delegate + // + class WindowingPlatformImpl : IWindowingPlatform + { + private readonly IWindowImpl _window; + + public WindowingPlatformImpl(IWindowImpl window) + { + _window = window; + } + + public IWindowImpl CreateWindow() + { + return _window; + } + + public IWindowImpl CreateEmbeddableWindow() + { + throw new NotImplementedException(); + } + + public IPopupImpl CreatePopup() + { + throw new NotImplementedException(); + } + } +} diff --git a/src/iOS/Perspex.iOS/iOSPlatform.cs b/src/iOS/Perspex.iOS/iOSPlatform.cs index 8f608de13b..9abc384ecd 100644 --- a/src/iOS/Perspex.iOS/iOSPlatform.cs +++ b/src/iOS/Perspex.iOS/iOSPlatform.cs @@ -18,8 +18,7 @@ namespace Perspex return app; } - // I wish I could merge this with the SkiaPlatform itself. Might be possible - // once we switch to SkiaSharp + // TODO: Can we merge this with UseSkia somehow once HW/platform cleanup is done? public static AppT UseSkiaViewHost(this AppT app) where AppT : Application { var window = new UIWindow(UIScreen.MainScreen.Bounds); @@ -28,7 +27,7 @@ namespace Perspex window.MakeKeyAndVisible(); PerspexLocator.CurrentMutable - .Bind().ToConstant(new WindowingPlatform(controller.PerspexView)); + .Bind().ToConstant(new WindowingPlatformImpl(controller.PerspexView)); SkiaPlatform.Initialize(); @@ -40,45 +39,15 @@ namespace Perspex // Asset loading searches our own assembly? var loader = new AssetLoader(assembly); PerspexLocator.CurrentMutable.Bind().ToConstant(loader); - return app; } - - // This is somewhat generic, could probably put this elsewhere. But I don't think - // it should part of the iOS App Delegate - // - class WindowingPlatform : IWindowingPlatform - { - private readonly IWindowImpl _window; - - public WindowingPlatform(IWindowImpl window) - { - _window = window; - } - - public IWindowImpl CreateWindow() - { - return _window; - } - - public IWindowImpl CreateEmbeddableWindow() - { - throw new NotImplementedException(); - } - - public IPopupImpl CreatePopup() - { - throw new NotImplementedException(); - } - } - } } namespace Perspex.iOS { // TODO: Perhaps we should make this class handle all these interfaces directly, like we - // do for Win32 and Gtk + // do for Win32 and Gtk platforms // public class iOSPlatform //: IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform { @@ -90,12 +59,10 @@ namespace Perspex.iOS MouseDevice = new MouseDevice(); KeyboardDevice = new KeyboardDevice(); - // refactored - //SharedPlatform.Register(appType.Assembly); - PerspexLocator.CurrentMutable .Bind().ToSingleton() .Bind().ToTransient() + // TODO: what does this look like for iOS?? //.Bind().ToTransient() .Bind().ToTransient() .Bind().ToConstant(KeyboardDevice) diff --git a/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs b/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs index fcec8f01c5..6c1a244aa5 100644 --- a/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs +++ b/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs @@ -27,65 +27,17 @@ namespace Perspex.iOSTestApplication // public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) { - var app = new App(); + var app = new App() + .UseiOS() + .UseSkiaViewHost() + .UseSkia(); - app.UseiOS(); - app.UseSkiaViewHost(); - app.UseSkia(); - - // looking for this URI fails: "TestApplication.github_icon.png" var asm = typeof(App).Assembly; app.UseAssetAssembly(asm); - - //MainWindow.RootNamespace = "Perspex.iOSTestApplication"; - //var window = MainWindow.Create(); - ////var window = Create(); - //window.Show(); - //app.Run(window); app.Run(); return true; } - - // This provides a simple UI tree for testing input handling - public static Window Create() - { - Window window = new Window - { - Title = "Perspex Test Application", - //Width = 900, - //Height = 480, - Background = Brushes.Red, - Content = new StackPanel - { - Margin = new Thickness(30), - Background = Brushes.Yellow, - Children = new Controls.Controls - { - new TextBlock - { - Text = "TEXT BLOCK", - Width = 300, - Height = 40, - Background = Brushes.White, - Foreground = Brushes.Black - }, - - new Button - { - Content = "BUTTON", - Width = 150, - Height = 40, - Background = Brushes.LightGreen, - Foreground = Brushes.Black - } - - } - } - }; - - return window; - } } From 84a309b406f7c7c430a2102adc6a8010a328707b Mon Sep 17 00:00:00 2001 From: Jason Jarvis Date: Sat, 16 Apr 2016 15:48:24 -0700 Subject: [PATCH 10/16] Switched Skia.Desktop Release platform to x86 as it is required for SkiaSharp. --- Perspex.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Perspex.sln b/Perspex.sln index 01e79a2632..899e91f152 100644 --- a/Perspex.sln +++ b/Perspex.sln @@ -1304,8 +1304,8 @@ Global {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|x86.ActiveCfg = Debug|x86 {925DD807-B651-475F-9F7C-CBEB974CE43D}.Debug|x86.Build.0 = Debug|x86 - {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|Any CPU.Build.0 = Release|Any CPU + {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|Any CPU.ActiveCfg = Release|x86 + {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|Any CPU.Build.0 = Release|x86 {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|iPhone.ActiveCfg = Release|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|iPhone.Build.0 = Release|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU From 76d2fb10c4e80baa3f780a8df8571a403fc7e8d2 Mon Sep 17 00:00:00 2001 From: Jason Jarvis Date: Sat, 16 Apr 2016 16:36:21 -0700 Subject: [PATCH 11/16] Removing Skia.RenderTests for now so we can get appveyor happy. Will work on getting the tests up and running soon, once bitmap save is implemented, and rendering is mostly good. --- Perspex.sln | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/Perspex.sln b/Perspex.sln index 899e91f152..48f5551b4c 100644 --- a/Perspex.sln +++ b/Perspex.sln @@ -111,8 +111,6 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Perspex.Skia", "src\Skia\Pe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Skia.Desktop", "src\Skia\Perspex.Skia.Desktop\Perspex.Skia.Desktop.csproj", "{925DD807-B651-475F-9F7C-CBEB974CE43D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Skia.RenderTests", "tests\Perspex.RenderTests\Perspex.Skia.RenderTests.csproj", "{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Skia.Android", "src\Skia\Perspex.Skia.Android\Perspex.Skia.Android.csproj", "{BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Skia.Android.TestApp", "src\Skia\Perspex.Skia.Android.TestApp\Perspex.Skia.Android.TestApp.csproj", "{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}" @@ -1312,38 +1310,6 @@ Global {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|x86.ActiveCfg = Release|x86 {925DD807-B651-475F-9F7C-CBEB974CE43D}.Release|x86.Build.0 = Release|x86 - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Ad-Hoc|x86.Build.0 = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|Any CPU.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|Any CPU.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|iPhone.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|iPhone.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|x86.ActiveCfg = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.AppStore|x86.Build.0 = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|iPhone.Build.0 = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|x86.ActiveCfg = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Debug|x86.Build.0 = Debug|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|Any CPU.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhone.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhone.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.ActiveCfg = Release|Any CPU - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.Build.0 = Release|Any CPU {BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU {BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU @@ -1777,7 +1743,6 @@ Global {3C4C0CB4-0C0F-4450-A37B-148C84FF905F} = {A689DEF5-D50F-4975-8B72-124C9EB54066} {2F59F3D0-748D-4652-B01E-E0D954756308} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E} {925DD807-B651-475F-9F7C-CBEB974CE43D} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E} - {D35A9F3D-8BB0-496E-BF72-444038A7DEBB} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {BD43F7C0-396B-4AA1-BAD9-DFDE54D51298} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E} {F92E55A5-ED73-4CCB-AB4B-0541B6757F31} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E} {DA49C5F3-BE95-461C-B999-072128CCF59E} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E} From 67ff6c474ffa0953f49f1fad2aa4d1bc1d7b54db Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 17 Apr 2016 14:26:54 +0200 Subject: [PATCH 12/16] Removed tabs and moved static ctor. --- src/Perspex.Controls/Image.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Perspex.Controls/Image.cs b/src/Perspex.Controls/Image.cs index b9af59a951..c829f3e83a 100644 --- a/src/Perspex.Controls/Image.cs +++ b/src/Perspex.Controls/Image.cs @@ -23,7 +23,13 @@ namespace Perspex.Controls /// public static readonly StyledProperty StretchProperty = PerspexProperty.Register(nameof(Stretch), Stretch.Uniform); - + + static Image() + { + AffectsRender(SourceProperty); + AffectsRender(StretchProperty); + } + /// /// Gets or sets the bitmap image that will be displayed. /// @@ -42,17 +48,11 @@ namespace Perspex.Controls set { SetValue(StretchProperty, value); } } - static Image() - { - AffectsRender(SourceProperty); - AffectsRender(StretchProperty); - } - - /// - /// Renders the control. - /// - /// The drawing context. - public override void Render(DrawingContext context) + /// + /// Renders the control. + /// + /// The drawing context. + public override void Render(DrawingContext context) { var source = Source; From f2716cadc402aab1ef5fd0daff0a34d96c5d43f8 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 17 Apr 2016 14:27:07 +0200 Subject: [PATCH 13/16] Removed commented-out file. --- src/Skia/Perspex.Skia.Android/MethodTable.cs | 31 -------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/Skia/Perspex.Skia.Android/MethodTable.cs diff --git a/src/Skia/Perspex.Skia.Android/MethodTable.cs b/src/Skia/Perspex.Skia.Android/MethodTable.cs deleted file mode 100644 index 73454489d3..0000000000 --- a/src/Skia/Perspex.Skia.Android/MethodTable.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -using Android.App; -using Android.Content; -using Android.Graphics; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Widget; - -namespace Perspex.Skia -{ -/* No longer needed with SkiaSharp - class MethodTableImpl : MethodTable - { - [DllImport(@"perspesk")] - private static extern IntPtr GetPerspexMethodTable(); - [DllImport(@"perspesk")] - private static extern IntPtr PerspexJniInit(IntPtr jniEnv); - - public MethodTableImpl() : base(GetPerspexMethodTable()) - { - PerspexJniInit(JNIEnv.Handle); - } - } - */ -} \ No newline at end of file From c6a9cb8df033a62ad3b6a4570305151429adde04 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 17 Apr 2016 14:33:39 +0200 Subject: [PATCH 14/16] Forgot to save .csproj. --- src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj b/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj index b0864eb9e9..3f86f954e0 100644 --- a/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj +++ b/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj @@ -87,7 +87,6 @@ - From 4af8dd7297c86c37cdf48e6a6a172250ecee13b2 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 17 Apr 2016 14:53:56 +0200 Subject: [PATCH 15/16] Fix path to Perspex.Skia.Desktop. --- nuget/build-version.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget/build-version.ps1 b/nuget/build-version.ps1 index 5561631858..d2de767786 100644 --- a/nuget/build-version.ps1 +++ b/nuget/build-version.ps1 @@ -65,7 +65,7 @@ Copy-Item skia\build $skia_root -recurse mkdir $skia_native Copy-Item ..\src\Skia\native\Windows $skia_native -recurse Copy-Item ..\src\Skia\native\Linux $skia_native -recurse -Copy-Item ..\src\Skia\Perspex.Skia.Desktop\bin\Release\Perspex.Skia.Desktop.dll $skia_lib +Copy-Item ..\src\Skia\Perspex.Skia.Desktop\bin\x86\Release\Perspex.Skia.Desktop.dll $skia_lib Copy-Item ..\src\Android\Perspex.Android\bin\Release\Perspex.Android.dll $android From ee629df4185e720bfc7728b5bcc4fb6742f48f18 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 17 Apr 2016 17:38:33 +0200 Subject: [PATCH 16/16] VS changed the target framework version. --- .../Perspex.Skia.Android.TestApp.csproj | 2 +- src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj b/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj index 614b0210bb..36cb4b0e0b 100644 --- a/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj +++ b/src/Skia/Perspex.Skia.Android.TestApp/Perspex.Skia.Android.TestApp.csproj @@ -16,7 +16,7 @@ Resources\Resource.Designer.cs Off True - v6.0 + v5.0 Properties\AndroidManifest.xml diff --git a/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj b/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj index 3f86f954e0..04f0f6955e 100644 --- a/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj +++ b/src/Skia/Perspex.Skia.Android/Perspex.Skia.Android.csproj @@ -15,7 +15,7 @@ Resources\Resource.Designer.cs Off True - v6.0 + v5.0 true