Граф коммитов

31 Коммитов

Автор SHA1 Сообщение Дата
Matthew Leibowitz 48f5d343b3
Update skia to fix #465 (#1436) 2020-07-30 22:38:46 +02:00
Matthew Leibowitz 3fb8c0cdc5
Adding back the removed enum members (#1285) 2020-05-13 02:36:33 +02:00
Matthew Leibowitz 14813f82e0
Resolve some concurrency issues (#1200)
* 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
2020-04-03 13:25:20 +02:00
Matthew Leibowitz fc9f030a08
A few changes and improvements (#1153)
A few changes and improvements:
- add some helper members
- improved the SKBitmap.CopyTo and related members
- added Encode(...) to SKBitmap
- added Encode(...) with a .NET Stream to SKBitmap, SKImage and SKPixmap
- start the move from SKEncoding to SKTextEncoding
- added more tests
- generator now has a validator for ensuring all declarations have implementations
- added equality members to all structs

Bugs Fixed
- Bitmaps copied with SKBitmap.Copy sometimes have incorrect colors
- The GC would sometimes collect a stream that was being used by a PDF document
2020-02-27 15:12:00 +02:00
Matthew Leibowitz d5aa34a787
Re-work the managed-native types (#900)
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.
2019-07-30 03:26:21 +02:00
Matthew Leibowitz fb51b90761
[harfbuzz] Allow loading face by table data (#862)
* Add hb_face_create_for_tables support

* Fix net core build

* Make sure blobs are reused

* Support cleanup for TableLoader

* Remove extension

* Fix dispose handler and add unit test

* Rework unit tests to reduce file access

* Keep delegate alive

* Improve font usage in unit tests

* Support for iOS

* Remove typeface extension

* Cleanup

* Add unit test

* update the docs before re-gen

* A few tweaks:
 - use Parse instead of FromString
 - create a "static" Blob type
 - remove default param values
 - fix tests namespaces and base tests

* More changes:
 - unified the destroy delegates
 - NativeDelegateContext now supports multiple delegates and contexts for a single pointer
 - public Face delegates no longer use pointers

* Reuse the code

* Added lower-level members to SKTypeface
 - get the table data without copying to array
 - added some TryXXX to avoid exceptions

* Revert parameter name change

* The empty Face is a static face that cannot be disposed

* Make sure to return the same managed instance

* Remove the duplicate iOS build run
2019-06-18 16:33:10 +02:00
Matthew Leibowitz 5da3cfd412
Support building SkiaSharp without fontconfig (#821) 2019-05-18 15:52:44 -07:00
Matthew Leibowitz 8f9975a722
Added a few overloads to SKImage
- FromEncodedData now can decode streams, buffers and files
 - FromPixelCopy now can copy from streams and buffers
2018-11-02 01:52:08 +02:00
Matthew Leibowitz 462d3a126d
Improve the tests to properly load platform values 2018-07-21 03:18:19 +02:00
Matthew Leibowitz 3103ee9662 Make sure to copy linux native files around 2018-01-24 21:04:35 +02:00
Matthew Leibowitz c408cd9eb7 Trying to see if skipping the GPU tests for CI gets a build complete 2018-01-23 16:41:07 +02:00
Matthew Leibowitz 9d2c14bc9d Fixing the tests for Xunit 2017-12-20 01:28:12 +02:00
Matthew Leibowitz f03118d336 Some tests need to be skipped on CI without a GL 2017-12-14 03:19:59 +02:00
Matthew Leibowitz 8c4087a226 Switch to Xunit as NUnit does not handle native exceptions well 2017-12-14 01:51:18 +02:00
Matthew Leibowitz d02cd89a68 Revert "Revert back to 1.59.1 so we can patch"
This reverts commit 96fa157f03.
2017-09-05 17:29:58 +02:00
Matthew Leibowitz 96fa157f03 Revert back to 1.59.1 so we can patch 2017-09-05 17:28:56 +02:00
Matthew Leibowitz d33ad19f99 Added bindings for SkManagedPixelSerializer 2017-08-21 21:58:39 +02:00
Matthew Leibowitz 210ca364b6 Update the managed API for the m60 update 2017-08-16 01:06:01 +02:00
Matthew Leibowitz 592a56fae5 Updated the test to not fail the build if a GPU is not available 2017-05-15 20:37:41 +02:00
Matthew Leibowitz d6f08816f5 Initial (win) support for skipping OpenGL tests when the version is too low 2017-02-21 05:50:54 +02:00
Matthew Leibowitz 8a1149a140 Added a test for assembling the GL interface 2017-02-17 03:46:45 +02:00
Matthew Leibowitz 70eec54cd0 Switched back to NUnit because xUnit had issues with the WGL tests 2017-02-16 16:15:35 +02:00
Matthew Leibowitz 1dbb79b2af Added WGL test context
Organized GL test contexts
2017-02-16 16:07:34 +02:00
Matthew Leibowitz 8444644b8e Added a macOS test GL context 2017-02-14 22:32:10 +02:00
Matthew Leibowitz ed95c9aeca Added some GL interface/context tests 2017-02-14 16:43:26 +04:00
Matthew Leibowitz 076bcc9ff6 Fix the mac/unix/linux detection logic 2017-01-30 17:48:05 -05:00
Matthew Leibowitz db3a3029ef Fixed the tests for linux. related to #225 2017-01-29 16:58:38 +02:00
Matthew Leibowitz c29c395049 Added a .NET Core test app 2017-01-22 00:27:08 +02:00
Matthew Leibowitz 76429b6cad Switched to xUnit for better cross platform testing 2017-01-21 02:38:48 +02:00
Matthew Leibowitz e1c60230c4 Updated to the bits based on m52 2016-06-17 22:54:08 +02:00
Matthew Leibowitz d2aa025de8 [Tests] [Build] Added a test for Mac OS (Console)
- also copy native files into the output folder
2016-02-02 16:39:03 +02:00