Родитель
2550d14410
Коммит
0195b18746
|
@ -39,7 +39,7 @@ namespace SkiaSharp
|
|||
/// Retrieve or create an instance for the native handle.
|
||||
/// </summary>
|
||||
/// <returns>The instance, or null if the handle was null.</returns>
|
||||
internal static TSkiaObject GetOrAddObject<TSkiaObject> (IntPtr handle, bool owns, bool unrefExisting, bool refNew, Func<IntPtr, bool, TSkiaObject> objectFactory)
|
||||
internal static TSkiaObject GetOrAddObject<TSkiaObject> (IntPtr handle, bool owns, bool unrefExisting, Func<IntPtr, bool, TSkiaObject> objectFactory)
|
||||
where TSkiaObject : SKObject
|
||||
{
|
||||
if (handle == IntPtr.Zero)
|
||||
|
@ -65,8 +65,6 @@ namespace SkiaSharp
|
|||
|
||||
var obj = objectFactory.Invoke (handle, owns);
|
||||
|
||||
if (refNew && obj is ISKReferenceCounted toRef)
|
||||
toRef.SafeRef ();
|
||||
return obj;
|
||||
} finally {
|
||||
instancesLock.ExitUpgradeableReadLock ();
|
||||
|
|
|
@ -992,7 +992,7 @@ namespace SkiaSharp
|
|||
}
|
||||
|
||||
internal static SKCanvas GetObject (IntPtr handle, bool owns = true, bool unrefExisting = true) =>
|
||||
GetOrAddObject (handle, owns, unrefExisting, false, (h, o) => new SKCanvas (h, o));
|
||||
GetOrAddObject (handle, owns, unrefExisting, (h, o) => new SKCanvas (h, o));
|
||||
}
|
||||
|
||||
public class SKAutoCanvasRestore : IDisposable
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace SkiaSharp
|
|||
//
|
||||
|
||||
internal static SKColorSpace GetObject (IntPtr handle, bool owns = true, bool unrefExisting = true) =>
|
||||
GetOrAddObject (handle, owns, unrefExisting, false, (h, o) => new SKColorSpace (h, o));
|
||||
GetOrAddObject (handle, owns, unrefExisting, (h, o) => new SKColorSpace (h, o));
|
||||
|
||||
private sealed class SKColorSpaceStatic : SKColorSpace
|
||||
{
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace SkiaSharp
|
|||
if (handle == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
return HandleDictionary.GetOrAddObject (handle, true, true, false, objectFactory);
|
||||
return HandleDictionary.GetOrAddObject (handle, true, true, objectFactory);
|
||||
}
|
||||
|
||||
internal static TSkiaObject GetOrAddObject<TSkiaObject> (IntPtr handle, bool owns, Func<IntPtr, bool, TSkiaObject> objectFactory)
|
||||
|
@ -95,16 +95,16 @@ namespace SkiaSharp
|
|||
if (handle == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
return HandleDictionary.GetOrAddObject (handle, owns, true, false, objectFactory);
|
||||
return HandleDictionary.GetOrAddObject (handle, owns, true, objectFactory);
|
||||
}
|
||||
|
||||
internal static TSkiaObject GetOrAddObject<TSkiaObject> (IntPtr handle, bool owns, bool unrefExisting, bool refNew, Func<IntPtr, bool, TSkiaObject> objectFactory)
|
||||
internal static TSkiaObject GetOrAddObject<TSkiaObject> (IntPtr handle, bool owns, bool unrefExisting, Func<IntPtr, bool, TSkiaObject> objectFactory)
|
||||
where TSkiaObject : SKObject
|
||||
{
|
||||
if (handle == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
return HandleDictionary.GetOrAddObject (handle, owns, unrefExisting, refNew, objectFactory);
|
||||
return HandleDictionary.GetOrAddObject (handle, owns, unrefExisting, objectFactory);
|
||||
}
|
||||
|
||||
internal static void RegisterHandle (IntPtr handle, SKObject instance)
|
||||
|
|
|
@ -40,6 +40,6 @@ namespace SkiaSharp
|
|||
//
|
||||
|
||||
internal static SKPicture GetObject (IntPtr handle, bool owns = true, bool unrefExisting = true) =>
|
||||
GetOrAddObject (handle, owns, unrefExisting, false, (h, o) => new SKPicture (h, o));
|
||||
GetOrAddObject (handle, owns, unrefExisting, (h, o) => new SKPicture (h, o));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ namespace SkiaSharp.Tests
|
|||
{
|
||||
internal class WglContext : GlContext
|
||||
{
|
||||
private static readonly object fLock = new object();
|
||||
|
||||
private static ushort gWC;
|
||||
|
||||
private static IntPtr fWindow;
|
||||
|
@ -82,7 +84,11 @@ namespace SkiaSharp.Tests
|
|||
};
|
||||
var piFormats = new int[1];
|
||||
uint nFormats;
|
||||
Wgl.wglChoosePixelFormatARB(fDeviceContext, iAttrs, null, (uint)piFormats.Length, piFormats, out nFormats);
|
||||
lock (fLock)
|
||||
{
|
||||
// HACK: This call seems to cause deadlocks on some systems.
|
||||
Wgl.wglChoosePixelFormatARB(fDeviceContext, iAttrs, null, (uint)piFormats.Length, piFormats, out nFormats);
|
||||
}
|
||||
if (nFormats == 0)
|
||||
{
|
||||
Destroy();
|
||||
|
|
Загрузка…
Ссылка в новой задаче