* Improve the Vulkan APIs
- removed the context argument as this is unused as well as an older C/C++ feature
- added a SharpVk version of the GetProc property.
* Removed the context argument (this is more an older C/C++ feature/requirement)
* Expose the WebGL APIs
* Improve the GRGlInterface and GPU delegates
- removing the object context for the GPU construction
- obsoleted GRGlGetProcDelegate in favour of the better named GRGlGetProcedureAddressDelegate
- renamed GRVkGetProcDelegate to GRVkGetProcedureAddressDelegate
- use "ProcedureAddress" instead of "Proc" to show that it is the "address" not the actual procedure
- reworked the GRGlInterface
- use the new non-context delegates
- use better naming: Create*
- adding WebGL
- created a SharpVk-specific delegate GRSharpVkGetProcedureAddressDelegate
- use actual types instead of IntPtr
* Reduce the using obsolete warnings
- still a few left, mainly the colorspace and text blob
* Switch the way GRGlInterface.Create() works
- first try OpenGL as that is actually what is expected
- don't explode on an error, return null, like the rest
* Update API usages
Several iterations of development to come to this:
* [UWP] Fix the ARM build and add ARM64
* [Win32] GDI is optional - and we don't want it
* Update harfbuzz to v2.6.2
* Use Docker
* Use a later version of the linux tools
* Use VS 2019
* Use Xcode 11
* Go all in with MSVC 14.2
* Disable the Tizen builds for now
* Add support for manually specifying VS (This can be done in a few ways, but the common way would be: --vsinstall='C:\PF\MVS\XXX\YYY')
* Update OpenJDK and Tizen Studio
* Using C++ 17
* Also added a THROW_ON_TEST_FAILURE env var to allow previews to be put out when tests are still failing
* Support basic text alignment
* Implement breakText in native code.
* Rework the assembly fixtures
* Fix concurrency issue with handle registration
* Save several ms and useless allocations
* Make sure to correctly own objects
* Native objects may be disposed at any time
* Keep the bitmap alive when just using the pixmap
* Cache the "static" font styles
* Upgraded a good few things
- multitargeting for netstandard1.3, netstandard2.0, netcoreapp3.0 and net45
- iOS, tvOS, macOS, watchOS now builds on non-macOS (not embedded binaries)
- removed empty assembly infos
- using Directory.Build.* to clean up a few things
- improved the msbuild tasks to properly skip
* Add the targets file to the nuget
* Let all the tests run before failing the build
* Pack and validate in one go
* Update the samples to use the new projects
* Use VS 2017 for native builds for now
* Update Dockerfiles
* removed references from Views.WPF to OpenTK #1029 (#1078)
* Install the type redirector
* Update depot_tools
* Don't do any signing for macOS
Co-authored-by: Tyson Williams <34664007+bender2k14@users.noreply.github.com>
* Some of the colorspaces created are just references
- SRGB and SRGB Linear colorspaces are static and should never be disposed
* Fix concurrent disposal and creation
- In some cases, a new native object is created with the same memory location while the
managed instances is still being disposed. In this case, we cannot remove the managed
instance from the dictionary, since it is not the current object being disposed anymore.
- SKColorSpace has some members that should not be disposed, since they are static on the
native side. Just, there is no docs for this, so calling dispose will crash everything.
- Added the logic to make sure that all static objects are created before anything, so we can
get a handle on them and make sure they are static managed instances.
* Make sure the objects are not collected when using spans
Changes:
- Added `GCHandleProxy` to debug builds
- this is used to track all `GCHandle` `Alloc` and `Free` calls to ensure that all allocations are freed.
- added some unit tests to make sure this is actually enforced
- as a result, several object are now freed correctly
- Added `ISKReferenceCounted` and `ISKNonVirtualReferenceCounted` interfaces to represent the reference counting types used in the native library
- this helps with automatically de-referencing objects
- `SKAbstractManagedStream`, `SKAbstractManagedWStream` and `SKDrawable` have been re-written to use better delegates
- instead of passing each of the delegates as parameters, they are now a struct that is passed as a single object
- better for extensions (which there shouldn't be) and only a single static field on the type
- removed the usage of `Marshal.GetFunctionPointerForDelegate`, which should help out with WASM (see #876)
- the objects now only keep weak references, meaning that they can now be garbage collected
- instead of trying to resolve the instances with a dictionary, a delegate is used and passed as "user context"
- Moved some of the repetitive logic from the types into the base `SKObject` and `SKNativeObject`
- some logic is automatically executed if the concrete type is `ISKReferenceCounted` or `ISKNonVirtualReferenceCounted`
- with the more centralized logic and stricter patterns, better tests can be written to make sure all memory is freed correctly and timely
- `SKData`, `SKFontManager` and `SKTypeface` now correctly prevent disposal of the "static" instances
- `SKPaint` now references the `Shader`, `MaskFilter`, `ColorFilter`, `ImageFilter`, `Typeface` and `PathEffect` properties
- this prevents accidental collection, or non-collection when the object goes out of scope
- the `SKPath` iterators (`Iterator` and `RawIterator`) and op builder (`OpBuilder`) now correctly own and dispose their native objects
- `SKRegion` objects are now disposed on the native side
- `SKTypeface` construction from a `SKManagedStream` (via both `SKTypeface` and `SKFontManager`) now copy the contents of the .NET `Stream` into a native memory
- typeface construction requires multiple seeks (previously, the stream was copied only if it was non-seekable)
- it also requires "duplicating" the stream, which is not supported on .NET streams
- duplicates or forks of a stream means that each of the streams need to be read concurrently from different locations
- .NET streams can only have a single position
- Updated the NuGets used for the tests
- using the `Xunit.AssemblyFixture` and `Xunit.SkippableFact` NuGets instead of using the code directly
- removed the `Xunit.Categories` NuGet as it was preventing tests from running
This PR has a big set of changes that may be breaking due to bug fixes:
- The `SKAbstractManagedStream`, `SKAbstractManagedWStream` and `SKDrawable` no longer prevent the GC from collecting them. This means that if code no longer references them, they will be disposed.
- As far as I can tell, this should not be a problem for the streams as they are never kept around - they are just used for reading and writing and typically only need to live for as long as a single method, and then need to be disposed by the caller. The `SKTypeface` and `SKDocument` do keep it around for a bit, but then they also take ownership of the stream and keep a hard reference to the streams themselves. They will dispose the streams when they are disposed.
- `SKDrawable` is never kept around and is entirely a user-controlled object. If it goes out of scope, skia doesn't have a reference anyway.
- The `SKFontManager` and `SKTypeface` no longer use the managed streams (`SKManagedStream` or `Stream`) directly
- they make a copy.
- This is simply because skia streams can do things that are not possible for .NET - they can be read concurrently from different positions. If a `SKFileStream` or `SKMemoryStream` are passed, then the streams are not copied.
- Further optimizations can be made in the case of a `MemoryStream` or `byte[]` to not actually copy but use GC pinning to get a handle to the managed data and work with pointers. But this can be done later so that this PR can be merged and tested.