Added the various path ops features
This commit is contained in:
Родитель
38604e49a5
Коммит
6c49807288
|
@ -2469,5 +2469,13 @@ typeMask = Mask.Scale | Mask.RectStaysRect
|
|||
None = 0,
|
||||
Discard = 0x2,
|
||||
}
|
||||
|
||||
public enum SKPathOp {
|
||||
Difference,
|
||||
Intersect,
|
||||
Union,
|
||||
Xor,
|
||||
ReverseDifference,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -15,44 +15,33 @@ using System.Reflection;
|
|||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
public abstract class SKObject : IDisposable
|
||||
public abstract class SKObject : SKNativeObject
|
||||
{
|
||||
private static readonly Dictionary<IntPtr, WeakReference> instances = new Dictionary<IntPtr, WeakReference>();
|
||||
|
||||
private readonly List<SKObject> ownedObjects = new List<SKObject>();
|
||||
private IntPtr handle;
|
||||
|
||||
[Preserve]
|
||||
internal SKObject(IntPtr handle, bool owns)
|
||||
: base(handle)
|
||||
{
|
||||
Handle = handle;
|
||||
OwnsHandle = owns;
|
||||
}
|
||||
|
||||
~SKObject()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
protected bool OwnsHandle { get; private set; }
|
||||
|
||||
public IntPtr Handle
|
||||
public override IntPtr Handle
|
||||
{
|
||||
get { return handle; }
|
||||
get { return base.Handle; }
|
||||
protected set
|
||||
{
|
||||
handle = value;
|
||||
RegisterHandle(handle, this);
|
||||
base.Handle = value;
|
||||
|
||||
RegisterHandle(Handle, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (ownedObjects)
|
||||
{
|
||||
|
@ -63,8 +52,10 @@ namespace SkiaSharp
|
|||
ownedObjects.Clear();
|
||||
}
|
||||
|
||||
DeregisterHandle(handle, this);
|
||||
handle = IntPtr.Zero;}
|
||||
DeregisterHandle(Handle, this);
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
internal static TSkiaObject GetObject<TSkiaObject>(IntPtr handle, bool owns = true)
|
||||
where TSkiaObject : SKObject
|
||||
|
@ -81,7 +72,7 @@ namespace SkiaSharp
|
|||
if (instances.TryGetValue(handle, out reference))
|
||||
{
|
||||
var instance = reference.Target as TSkiaObject;
|
||||
if (instance != null && instance.handle != IntPtr.Zero)
|
||||
if (instance != null && instance.Handle != IntPtr.Zero)
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
@ -189,4 +180,30 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SKNativeObject : IDisposable
|
||||
{
|
||||
internal SKNativeObject(IntPtr handle)
|
||||
{
|
||||
Handle = handle;
|
||||
}
|
||||
|
||||
~SKNativeObject()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public virtual IntPtr Handle { get; protected set; }
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,101 +270,134 @@ namespace SkiaSharp
|
|||
|
||||
public Iterator CreateIterator (bool forceClose)
|
||||
{
|
||||
return new Iterator (this, SkiaApi.sk_path_create_iter (Handle, forceClose ? 1 : 0));
|
||||
return new Iterator (this, forceClose);
|
||||
}
|
||||
|
||||
public RawIterator CreateRawIterator ()
|
||||
{
|
||||
return new RawIterator (this, SkiaApi.sk_path_create_rawiter (Handle));
|
||||
return new RawIterator (this);
|
||||
}
|
||||
|
||||
public class Iterator : IDisposable {
|
||||
public bool Op (SKPath other, SKPathOp op, SKPath result)
|
||||
{
|
||||
if (other == null)
|
||||
throw new ArgumentNullException (nameof (other));
|
||||
if (result == null)
|
||||
throw new ArgumentNullException (nameof (result));
|
||||
|
||||
return SkiaApi.sk_pathop_op (Handle, other.Handle, op, result.Handle);
|
||||
}
|
||||
|
||||
public bool Simplify (SKPath result)
|
||||
{
|
||||
if (result == null)
|
||||
throw new ArgumentNullException (nameof (result));
|
||||
|
||||
return SkiaApi.sk_pathop_simplify (Handle, result.Handle);
|
||||
}
|
||||
|
||||
public bool GetTightBounds (out SKRect result)
|
||||
{
|
||||
return SkiaApi.sk_pathop_tight_bounds (Handle, out result);
|
||||
}
|
||||
|
||||
public class Iterator : SKNativeObject
|
||||
{
|
||||
SKPath Path => path;
|
||||
SKPath path;
|
||||
IntPtr handle;
|
||||
|
||||
internal Iterator (SKPath path, IntPtr handle)
|
||||
internal Iterator (SKPath path, bool forceClose)
|
||||
: base (SkiaApi.sk_path_create_iter (path.Handle, forceClose ? 1 : 0))
|
||||
{
|
||||
this.path = path;
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
~Iterator ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
void Dispose (bool disposing)
|
||||
{
|
||||
if (handle != IntPtr.Zero){
|
||||
// safe to call from a background thread to release resources.
|
||||
SkiaApi.sk_path_iter_destroy (handle);
|
||||
handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
if (Handle != IntPtr.Zero){
|
||||
// safe to call from a background thread to release resources.
|
||||
SkiaApi.sk_path_iter_destroy (Handle);
|
||||
}
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
|
||||
public Verb Next (SKPoint [] points, bool doConsumeDegenerates = true, bool exact = false)
|
||||
{
|
||||
if (points == null)
|
||||
throw new ArgumentNullException (nameof (points));
|
||||
if (points.Length != 4)
|
||||
throw new ArgumentException ("Must be an array of four elements", nameof (points));
|
||||
return SkiaApi.sk_path_iter_next (handle, points, doConsumeDegenerates ? 1 : 0, exact ? 1 : 0);
|
||||
return SkiaApi.sk_path_iter_next (Handle, points, doConsumeDegenerates ? 1 : 0, exact ? 1 : 0);
|
||||
}
|
||||
|
||||
public float ConicWeight () => SkiaApi.sk_path_iter_conic_weight (handle);
|
||||
public bool IsCloseLine () => SkiaApi.sk_path_iter_is_close_line (handle) != 0;
|
||||
public bool IsCloseContour () => SkiaApi.sk_path_iter_is_closed_contour (handle) != 0;
|
||||
public float ConicWeight () => SkiaApi.sk_path_iter_conic_weight (Handle);
|
||||
public bool IsCloseLine () => SkiaApi.sk_path_iter_is_close_line (Handle) != 0;
|
||||
public bool IsCloseContour () => SkiaApi.sk_path_iter_is_closed_contour (Handle) != 0;
|
||||
}
|
||||
|
||||
public class RawIterator : IDisposable {
|
||||
public class RawIterator : SKNativeObject
|
||||
{
|
||||
SKPath Path => path;
|
||||
SKPath path;
|
||||
IntPtr handle;
|
||||
|
||||
internal RawIterator (SKPath path, IntPtr handle)
|
||||
internal RawIterator (SKPath path)
|
||||
: base (SkiaApi.sk_path_create_rawiter (path.Handle))
|
||||
{
|
||||
this.path = path;
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
~RawIterator ()
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
void Dispose (bool disposing)
|
||||
{
|
||||
if (handle != IntPtr.Zero){
|
||||
if (Handle != IntPtr.Zero){
|
||||
// safe to call from a background thread to release resources.
|
||||
SkiaApi.sk_path_rawiter_destroy (handle);
|
||||
handle = IntPtr.Zero;
|
||||
SkiaApi.sk_path_rawiter_destroy (Handle);
|
||||
}
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
public Verb Next (SKPoint [] points)
|
||||
{
|
||||
if (points == null)
|
||||
throw new ArgumentNullException (nameof (points));
|
||||
if (points.Length != 4)
|
||||
throw new ArgumentException ("Must be an array of four elements", nameof (points));
|
||||
return SkiaApi.sk_path_rawiter_next (handle, points);
|
||||
return SkiaApi.sk_path_rawiter_next (Handle, points);
|
||||
}
|
||||
|
||||
public float ConicWeight () => SkiaApi.sk_path_rawiter_conic_weight (handle);
|
||||
public Verb Peek () => SkiaApi.sk_path_rawiter_peek (handle);
|
||||
public float ConicWeight () => SkiaApi.sk_path_rawiter_conic_weight (Handle);
|
||||
public Verb Peek () => SkiaApi.sk_path_rawiter_peek (Handle);
|
||||
}
|
||||
|
||||
public class OpBuilder : SKNativeObject
|
||||
{
|
||||
public OpBuilder ()
|
||||
: base (SkiaApi.sk_opbuilder_new ())
|
||||
{
|
||||
}
|
||||
|
||||
public void Add (SKPath path, SKPathOp op)
|
||||
{
|
||||
SkiaApi.sk_opbuilder_add (Handle, path.Handle, op);
|
||||
}
|
||||
|
||||
public bool Resolve (SKPath result)
|
||||
{
|
||||
if (result == null)
|
||||
throw new ArgumentNullException (nameof (result));
|
||||
|
||||
return SkiaApi.sk_opbuilder_resolve (Handle, result.Handle);
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (Handle != IntPtr.Zero) {
|
||||
SkiaApi.sk_opbuilder_destroy (Handle);
|
||||
}
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ using sk_pixelref_factory_t = System.IntPtr;
|
|||
using sk_colortable_t = System.IntPtr;
|
||||
using gr_context_t = System.IntPtr;
|
||||
using gr_glinterface_t = System.IntPtr;
|
||||
using sk_opbuilder_t = System.IntPtr;
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
|
@ -486,6 +487,28 @@ namespace SkiaSharp
|
|||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static int sk_path_get_points (sk_path_t path, [Out] SKPoint[] points, int max);
|
||||
|
||||
// path ops
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_pathop_op(sk_path_t one, sk_path_t two, SKPathOp op, sk_path_t result);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_pathop_simplify(sk_path_t path, sk_path_t result);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_pathop_tight_bounds(sk_path_t path, out SKRect result);
|
||||
|
||||
// path op builder
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static sk_opbuilder_t sk_opbuilder_new();
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void sk_opbuilder_destroy(sk_opbuilder_t builder);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void sk_opbuilder_add(sk_opbuilder_t builder, sk_path_t path, SKPathOp op);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_opbuilder_resolve(sk_opbuilder_t builder, sk_path_t result);
|
||||
|
||||
// iterator
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static sk_path_iterator_t sk_path_create_iter (sk_path_t path, int forceClose);
|
||||
|
|
|
@ -26,6 +26,7 @@ LOCAL_C_INCLUDES := ../../skia/src/c \
|
|||
../../skia/include/core \
|
||||
../../skia/include/codec \
|
||||
../../skia/include/effects \
|
||||
../../skia/include/pathops \
|
||||
../../skia/include/gpu \
|
||||
../../skia/include/config \
|
||||
../../skia/include/utils \
|
||||
|
|
|
@ -1935,6 +1935,7 @@
|
|||
../../skia/include/core,
|
||||
../../skia/include/codec,
|
||||
../../skia/include/effects,
|
||||
../../skia/include/pathops,
|
||||
../../skia/include/utils,
|
||||
../../skia/include/gpu,
|
||||
../../skia/include/config,
|
||||
|
@ -1970,6 +1971,7 @@
|
|||
../../skia/include/core,
|
||||
../../skia/include/codec,
|
||||
../../skia/include/effects,
|
||||
../../skia/include/pathops,
|
||||
../../skia/include/utils,
|
||||
../../skia/include/gpu,
|
||||
../../skia/include/config,
|
||||
|
|
|
@ -1633,6 +1633,7 @@
|
|||
../../skia/include/core,
|
||||
../../skia/include/codec,
|
||||
../../skia/include/effects,
|
||||
../../skia/include/pathops,
|
||||
../../skia/include/gpu,
|
||||
../../skia/include/utils,
|
||||
../../skia/include/config,
|
||||
|
@ -1660,6 +1661,7 @@
|
|||
../../skia/include/core,
|
||||
../../skia/include/codec,
|
||||
../../skia/include/effects,
|
||||
../../skia/include/pathops,
|
||||
../../skia/include/gpu,
|
||||
../../skia/include/utils,
|
||||
../../skia/include/config,
|
||||
|
|
|
@ -1930,6 +1930,7 @@
|
|||
../../skia/include/core,
|
||||
../../skia/include/codec,
|
||||
../../skia/include/effects,
|
||||
../../skia/include/pathops,
|
||||
../../skia/include/gpu,
|
||||
../../skia/include/utils,
|
||||
../../skia/include/config,
|
||||
|
@ -1965,6 +1966,7 @@
|
|||
../../skia/include/core,
|
||||
../../skia/include/codec,
|
||||
../../skia/include/effects,
|
||||
../../skia/include/pathops,
|
||||
../../skia/include/utils,
|
||||
../../skia/include/gpu,
|
||||
../../skia/include/config,
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;SK_BUILD_FOR_WINRT;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;SK_DEVELOPER=1;;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -162,7 +162,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;SK_BUILD_FOR_WINRT;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -180,7 +180,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;SK_BUILD_FOR_WINRT;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;SK_DEVELOPER=1;;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -201,7 +201,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;SK_BUILD_FOR_WINRT;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -222,7 +222,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;SK_BUILD_FOR_WINRT;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;SK_DEVELOPER=1;;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -243,7 +243,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;SK_BUILD_FOR_WINRT;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;;NDEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;SK_DEVELOPER=1;;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -109,7 +109,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;SK_DEVELOPER=1;;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -127,7 +127,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -147,7 +147,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>SK_INTERNAL;SK_GAMMA_SRGB;SK_GAMMA_APPLY_TO_A8;SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1;SK_SUPPORT_GPU=1;SK_SUPPORT_OPENCL=0;SK_FORCE_DISTANCE_FIELD_TEXT=0;SK_BUILD_FOR_WIN32;_CRT_SECURE_NO_WARNINGS;GR_GL_FUNCTION_TYPE=__stdcall;_HAS_EXCEPTIONS=0;;NDEBUG;_WINDOWS;_USRDLL;LIBSKIA_WINDOWS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\skia\include\c;..\..\skia\include\config;..\..\skia\include\core;..\..\skia\include\effects;..\..\skia\include\pathops;..\..\skia\include\codec;..\..\skia\include\pathops;..\..\skia\include\pipe;..\..\skia\include\ports;..\..\skia\include\private;..\..\skia\include\utils;..\..\skia\include\images;..\..\skia\src\c;..\..\skia\src\core;..\..\skia\src\sfnt;..\..\skia\src\image;..\..\skia\src\opts;..\..\skia\src\utils;..\..\gyp\config\win;..\..\skia\include\gpu;..\..\skia\src\gpu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
|
@ -1069,6 +1069,53 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PathBounds (SKCanvas canvas, int width, int height)
|
||||
{
|
||||
canvas.Clear (SKColors.White);
|
||||
canvas.Scale (2, 2);
|
||||
|
||||
using (SKPaint paint = new SKPaint ())
|
||||
{
|
||||
paint.Style = SKPaintStyle.Stroke;
|
||||
paint.StrokeWidth = 1;
|
||||
paint.IsAntialias = true;
|
||||
paint.StrokeCap = SKStrokeCap.Round;
|
||||
|
||||
using (SKPath path = new SKPath ())
|
||||
{
|
||||
path.MoveTo (-6.2157825e-7f, -25.814698f);
|
||||
path.RCubicTo (-34.64102137842175f, 19.9999998f, 0f, 40f, 0f, 40f);
|
||||
path.Offset (50, 35);
|
||||
|
||||
// draw using GetBounds
|
||||
paint.Color = XamLtBlue;
|
||||
canvas.DrawPath (path, paint);
|
||||
|
||||
SKRect rect;
|
||||
path.GetBounds (out rect);
|
||||
|
||||
paint.Color = XamDkBlue;
|
||||
canvas.DrawRect (rect, paint);
|
||||
|
||||
canvas.DrawText ("Bounds", rect.Left, rect.Bottom + paint.TextSize + 10, paint);
|
||||
|
||||
// move for next curve
|
||||
path.Offset (100, 0);
|
||||
|
||||
// draw using GetTightBounds
|
||||
paint.Color = XamLtBlue;
|
||||
canvas.DrawPath (path, paint);
|
||||
|
||||
path.GetTightBounds (out rect);
|
||||
|
||||
paint.Color = XamDkBlue;
|
||||
canvas.DrawRect (rect, paint);
|
||||
|
||||
canvas.DrawText ("TightBounds", rect.Left, rect.Bottom + paint.TextSize + 10, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum Platform
|
||||
|
@ -1139,6 +1186,7 @@ namespace SkiaSharp
|
|||
new Sample {Title="Create PDF", Method = CreatePdfSample, Platform = Platform.All, TapMethod = CreatePdfSampleTapped},
|
||||
new Sample {Title="Path Effects", Method = PathEffects, Platform = Platform.All},
|
||||
new Sample {Title="Nine Patch / Lattice", Method = BitmapLattice, Platform = Platform.All},
|
||||
new Sample {Title="Path Bounds", Method = PathBounds, Platform = Platform.All},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
2
skia
2
skia
|
@ -1 +1 @@
|
|||
Subproject commit 7f4e772937870243ce041e0e10bf38d013601f4d
|
||||
Subproject commit 64e0509ec28d3911c5e2c795a33e5f58de3b46d1
|
Загрузка…
Ссылка в новой задаче