From de524208f2885e6761c0361edb9d246829f4c00c Mon Sep 17 00:00:00 2001 From: Charlenni Date: Tue, 3 May 2016 11:31:43 +0200 Subject: [PATCH 01/17] Added missing functions for SKPath: - Reset() - Rewind() Added to SKPath.cs and SkiaAPI.cs in same style as SKPath.Close() --- binding/Binding/SKPath.cs | 7 ++++++- binding/Binding/SkiaApi.cs | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/binding/Binding/SKPath.cs b/binding/Binding/SKPath.cs index 53ae2d5b..5d9b3256 100644 --- a/binding/Binding/SKPath.cs +++ b/binding/Binding/SKPath.cs @@ -102,7 +102,12 @@ namespace SkiaSharp SkiaApi.sk_path_close (Handle); } - public void AddRect (SKRect rect, SKPathDirection direction) + public void Rewind() + { + SkiaApi.sk_path_rewind(Handle); + } + + public void AddRect (SKRect rect, SKPathDirection direction) { SkiaApi.sk_path_add_rect (Handle, ref rect, direction); } diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index 69ccb8aa..a5686c30 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -318,7 +318,9 @@ namespace SkiaSharp public extern static void sk_path_rcubic_to(sk_path_t t, float dx0, float dy0, float dx1, float dy1, float dx2, float dy2); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_close(sk_path_t t); - [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_rewind(sk_path_t t); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_add_rect(sk_path_t t, ref SKRect rect, SKPathDirection direction); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_add_rect_start(sk_path_t t, ref SKRect rect, SKPathDirection direction, uint startIndex); From 8156a2fdf5d5da9f23a16e6a0332137e97915410 Mon Sep 17 00:00:00 2001 From: Charlenni Date: Tue, 3 May 2016 11:31:43 +0200 Subject: [PATCH 02/17] Added missing functions for SKPath: - Reset() - Rewind() Added to SKPath.cs and SkiaAPI.cs in same style as SKPath.Close() --- binding/Binding/SKPath.cs | 12 +++++++++++- binding/Binding/SkiaApi.cs | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/binding/Binding/SKPath.cs b/binding/Binding/SKPath.cs index 53ae2d5b..dd0ebecc 100644 --- a/binding/Binding/SKPath.cs +++ b/binding/Binding/SKPath.cs @@ -102,7 +102,17 @@ namespace SkiaSharp SkiaApi.sk_path_close (Handle); } - public void AddRect (SKRect rect, SKPathDirection direction) + public void Rewind() + { + SkiaApi.sk_path_rewind(Handle); + } + + public void Reset() + { + SkiaApi.sk_path_reset(Handle); + } + + public void AddRect (SKRect rect, SKPathDirection direction) { SkiaApi.sk_path_add_rect (Handle, ref rect, direction); } diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index 69ccb8aa..95b09aae 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -318,7 +318,11 @@ namespace SkiaSharp public extern static void sk_path_rcubic_to(sk_path_t t, float dx0, float dy0, float dx1, float dy1, float dx2, float dy2); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_close(sk_path_t t); - [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_rewind(sk_path_t t); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_reset(sk_path_t t); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_add_rect(sk_path_t t, ref SKRect rect, SKPathDirection direction); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_add_rect_start(sk_path_t t, ref SKRect rect, SKPathDirection direction, uint startIndex); From 723e32f08c83d77776e15ddfd555b1ab9df12824 Mon Sep 17 00:00:00 2001 From: Charlenni Date: Tue, 3 May 2016 17:37:09 +0200 Subject: [PATCH 03/17] Changed whitespace handling --- binding/Binding/SKPath.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/binding/Binding/SKPath.cs b/binding/Binding/SKPath.cs index 8fbe37b0..f55e6462 100644 --- a/binding/Binding/SKPath.cs +++ b/binding/Binding/SKPath.cs @@ -103,16 +103,16 @@ namespace SkiaSharp } public void Rewind() - { - SkiaApi.sk_path_rewind(Handle); - } + { + SkiaApi.sk_path_rewind(Handle); + } - public void Reset() - { - SkiaApi.sk_path_reset(Handle); - } + public void Reset() + { + SkiaApi.sk_path_reset(Handle); + } - public void AddRect (SKRect rect, SKPathDirection direction) + public void AddRect (SKRect rect, SKPathDirection direction) { SkiaApi.sk_path_add_rect (Handle, ref rect, direction); } From 5eeb06b75337a9aa0025f8f2634f9b69accf9649 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Mon, 27 Jun 2016 23:20:41 -0400 Subject: [PATCH 04/17] [SKMatrix] Add Rotation by degrees, some missing overloads, concatenation and inversion --- binding/Binding/Definitions.cs | 197 +++++++++++++++++++--- binding/Binding/SkiaApi.cs | 22 ++- docs/en/SkiaSharp/SKMatrix.xml | 294 ++++++++++++++++++++++++++++++--- docs/en/index.xml | 4 +- skia | 2 +- 5 files changed, 466 insertions(+), 53 deletions(-) diff --git a/binding/Binding/Definitions.cs b/binding/Binding/Definitions.cs index ff83349a..44cb82fa 100644 --- a/binding/Binding/Definitions.cs +++ b/binding/Binding/Definitions.cs @@ -84,7 +84,7 @@ namespace SkiaSharp public SKColor (byte red, byte green, byte blue) { - color = (uint)(0xff000000 | (red << 16) | (green << 8) | blue); + color = (uint)(0xff000000u | (red << 16) | (green << 8) | blue); } public SKColor WithAlpha (byte alpha) @@ -1059,12 +1059,49 @@ namespace SkiaSharp public float SkewY, ScaleY, TransY; public float Persp0, Persp1, Persp2; +#if OPTIMIZED_SKMATRIX + + // + // If we manage to get an sk_matrix_t that contains the extra + // the fTypeMask flag, we could accelerate various operations + // as well, as this caches state of what is needed to be done. + // + + [Flags] + enum Mask : uint { + Identity = 0, + Translate = 1, + Scale = 2, + Affine = 4, + Perspective = 8, + RectStaysRect = 0x10, + OnlyPerspectiveValid = 0x40, + Unknown = 0x80, + OrableMasks = Translate | Scale | Affine | Perspective, + AllMasks = OrableMasks | RectStaysRect + } + Mask typeMask; + + Mask GetMask () + { + if (typeMask.HasFlag (Mask.Unknown)) + typeMask = (Mask) SkiaApi.sk_matrix_get_type (ref this); + + // only return the public masks + return (Mask) ((uint)typeMask & 0xf); + } +#endif + static float sdot (float a, float b, float c, float d) => a * b + c * d; static float scross(float a, float b, float c, float d) => a * b - c * d; public static SKMatrix MakeIdentity () { - return new SKMatrix () { ScaleX = 1, ScaleY = 1, Persp2 = 1 }; + return new SKMatrix () { ScaleX = 1, ScaleY = 1, Persp2 = 1 +#if OPTIMIZED_SKMATRIX + , typeMask = Mask.Identity | Mask.RectStaysRect +#endif + }; } public void SetScaleTranslate (float sx, float sy, float tx, float ty) @@ -1080,13 +1117,23 @@ namespace SkiaSharp Persp0 = 0; Persp1 = 0; Persp2 = 1; + +#if OPTIMIZED_SKMATRIX + typeMask = Mask.RectStaysRect | + ((sx != 1 || sy != 1) ? Mask.Scale : 0) | + ((tx != 0 || ty != 0) ? Mask.Translate : 0); +#endif } public static SKMatrix MakeScale (float sx, float sy) { if (sx == 1 && sy == 1) return MakeIdentity (); - return new SKMatrix () { ScaleX = sx, ScaleY = sy, Persp2 = 1 }; + return new SKMatrix () { ScaleX = sx, ScaleY = sy, Persp2 = 1, +#if OPTIMIZED_SKMATRIX +typeMask = Mask.Scale | Mask.RectStaysRect +#endif + }; } @@ -1098,41 +1145,132 @@ namespace SkiaSharp { if (sx == 1 && sy == 1) return MakeIdentity (); - //this->setScaleTranslate(sx, sy, px - sx * px, py - sy * py); + float tx = pivotX - sx * pivotX; + float ty = pivotY - sy * pivotY; +#if OPTIMIZED_SKMATRIX + Mask mask = Mask.RectStaysRect | + ((sx != 1 || sy != 1) ? Mask.Scale : 0) | + ((tx != 0 || ty != 0) ? Mask.Translate : 0); +#endif return new SKMatrix () { ScaleX = sx, ScaleY = sy, - TransX = pivotX - sx * pivotX, - TransY = pivotY - sy * pivotY, - Persp2 = 1 + TransX = tx, + TransY = ty, + Persp2 = 1, +#if OPTIMIZED_SKMATRIX + typeMask = mask +#endif }; } public static SKMatrix MakeTranslation (float dx, float dy) { + if (dx == 0 && dy == 0) + return MakeIdentity (); + return new SKMatrix () { ScaleX = 1, ScaleY = 1, TransX = dx, TransY = dy, - Persp2 = 1 + Persp2 = 1, +#if OPTIMIZED_SKMATRIX + typeMask = Mask.Translate | Mask.RectStaysRect +#endif }; } public static SKMatrix MakeRotation (float radians) { var sin = (float) Math.Sin (radians); - var cos = (float)Math.Cos (radians); + var cos = (float) Math.Cos (radians); - return new SKMatrix () { - ScaleX = cos, - SkewX = -sin, - TransX = 0, - SkewY = sin, - ScaleY = cos, - TransY = 0, - Persp0 = 0, - Persp1 = 0, - Persp2 = 1 - }; + var matrix = new SKMatrix (); + SetSinCos (ref matrix, sin, cos); + return matrix; + } + + public static SKMatrix MakeRotation (float radians, float pivotx, float pivoty) + { + var sin = (float) Math.Sin (radians); + var cos = (float) Math.Cos (radians); + + var matrix = new SKMatrix (); + SetSinCos (ref matrix, sin, cos, pivotx, pivoty); + return matrix; + } + + const float degToRad = (float)System.Math.PI / 180.0f; + + public static SKMatrix MakeRotationDegrees (float degrees) + { + return MakeRotation (degrees * degToRad); + } + + public static SKMatrix MakeRotationDegrees (float degrees, float pivotx, float pivoty) + { + return MakeRotation (degrees * degToRad, pivotx, pivoty); + } + + static void SetSinCos (ref SKMatrix matrix, float sin, float cos) + { + matrix.ScaleX = cos; + matrix.SkewX = -sin; + matrix.TransX = 0; + matrix.SkewY = sin; + matrix.ScaleY = cos; + matrix.TransY = 0; + matrix.Persp0 = 0; + matrix.Persp1 = 0; + matrix.Persp2 = 1; +#if OPTIMIZED_SKMATRIX + matrix.typeMask = Mask.Unknown | Mask.OnlyPerspectiveValid; +#endif + } + + static void SetSinCos (ref SKMatrix matrix, float sin, float cos, float pivotx, float pivoty) + { + float oneMinusCos = 1-cos; + + matrix.ScaleX = cos; + matrix.SkewX = -sin; + matrix.TransX = sdot(sin, pivoty, oneMinusCos, pivotx); + matrix.SkewY = sin; + matrix.ScaleY = cos; + matrix.TransY = sdot(-sin, pivotx, oneMinusCos, pivoty); + matrix.Persp0 = 0; + matrix.Persp1 = 0; + matrix.Persp2 = 1; +#if OPTIMIZED_SKMATRIX + matrix.typeMask = Mask.Unknown | Mask.OnlyPerspectiveValid; +#endif + } + + public static void Rotate (ref SKMatrix matrix, float radians, float pivotx, float pivoty) + { + var sin = (float) Math.Sin (radians); + var cos = (float) Math.Cos (radians); + SetSinCos (ref matrix, sin, cos, pivotx, pivoty); + } + + public static void RotateDegrees (ref SKMatrix matrix, float degrees, float pivotx, float pivoty) + { + var sin = (float) Math.Sin (degrees * degToRad); + var cos = (float) Math.Cos (degrees * degToRad); + SetSinCos (ref matrix, sin, cos, pivotx, pivoty); + } + + public static void Rotate (ref SKMatrix matrix, float radians) + { + var sin = (float) Math.Sin (radians); + var cos = (float) Math.Cos (radians); + SetSinCos (ref matrix, sin, cos); + } + + public static void RotateDegrees (ref SKMatrix matrix, float degrees) + { + var sin = (float) Math.Sin (degrees * degToRad); + var cos = (float) Math.Cos (degrees * degToRad); + SetSinCos (ref matrix, sin, cos); } public static SKMatrix MakeSkew (float sx, float sy) @@ -1146,9 +1284,26 @@ namespace SkiaSharp TransY = 0, Persp0 = 0, Persp1 = 0, - Persp2 = 1 + Persp2 = 1, +#if OPTIMIZED_SKMATRIX + typeMask = Mask.Unknown | Mask.OnlyPerspectiveValid +#endif }; } + + public bool TryInvert (out SKMatrix inverse) + { + return SkiaApi.sk_matrix_try_invert (ref this, out inverse) != 0; + } + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl, EntryPoint="sk_matrix_concat")] + public extern static void Concat (ref SKMatrix target, ref SKMatrix first, ref SKMatrix second); + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl, EntryPoint="sk_matrix_pre_concat")] + public extern static void PreConcat (ref SKMatrix target, ref SKMatrix matrix); + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl, EntryPoint="sk_matrix_post_concat")] + public extern static void PostConcat (ref SKMatrix target, ref SKMatrix matrix); } [StructLayout(LayoutKind.Sequential)] diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index c2cbd1b2..eb1c6f42 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -43,19 +43,19 @@ namespace SkiaSharp internal static class SkiaApi { #if __TVOS__ && __UNIFIED__ - const string SKIA = "@rpath/libSkiaSharp.framework/libSkiaSharp"; + public const string SKIA = "@rpath/libSkiaSharp.framework/libSkiaSharp"; #elif __IOS__ && __UNIFIED__ - const string SKIA = "@rpath/libSkiaSharp.framework/libSkiaSharp"; + public const string SKIA = "@rpath/libSkiaSharp.framework/libSkiaSharp"; #elif __ANDROID__ - const string SKIA = "libSkiaSharp.so"; + public const string SKIA = "libSkiaSharp.so"; #elif XAMARIN_MAC - const string SKIA = "libSkiaSharp.dylib"; + public const string SKIA = "libSkiaSharp.dylib"; #elif DESKTOP - const string SKIA = "libSkiaSharp.dll"; // redirected using .dll.config to 'libSkiaSharp.dylib' on OS X + public const string SKIA = "libSkiaSharp.dll"; // redirected using .dll.config to 'libSkiaSharp.dylib' on OS X #elif WINDOWS_UWP - const string SKIA = "libSkiaSharp.dll"; + public const string SKIA = "libSkiaSharp.dll"; #else - const string SKIA = "libSkiaSharp"; + public const string SKIA = "libSkiaSharp"; #endif [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] @@ -808,6 +808,14 @@ namespace SkiaSharp public extern static bool sk_imagedecoder_decode_memory(IntPtr buffer, IntPtr size, sk_bitmap_t bitmap, SKColorType pref, SKImageDecoderMode mode, ref SKImageDecoderFormat format); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static bool sk_imagedecoder_decode_stream(sk_stream_streamrewindable_t cstream, sk_bitmap_t bitmap, SKColorType pref, SKImageDecoderMode mode, ref SKImageDecoderFormat format); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static int sk_matrix_try_invert(ref SKMatrix matrix, out SKMatrix result); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static int sk_matrix_preconcat(ref SKMatrix target, ref SKMatrix first, ref SKMatrix second); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static int sk_matrix_preconcat(ref SKMatrix target, ref SKMatrix matrix); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static int sk_matrix_postconcat(ref SKMatrix target, ref SKMatrix matrix); } } diff --git a/docs/en/SkiaSharp/SKMatrix.xml b/docs/en/SkiaSharp/SKMatrix.xml index 5482fa05..68a830fa 100644 --- a/docs/en/SkiaSharp/SKMatrix.xml +++ b/docs/en/SkiaSharp/SKMatrix.xml @@ -14,11 +14,34 @@ 2D Transformation matrix with perspective. The SKMatrix is a full 3x3 matrix. - + It extends the traditional 2D affine transformation matrix with three perspective components that allow simple 3D effects to be created with it.   Those components must be manually set by using the  fields of the matrix. + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + + The result matrix value. + The first matrix to concatenate. + The second matrix to concatenate. + Concatenates the specified matrices into the resulting target matrix.    + Either source matrices can also be the target matrix. + + @@ -52,12 +75,85 @@ - To be added. + The angle for the rotation, in radians. Creates a rotation matrix To be added. To be added. + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKMatrix + + + + + + + + The angle for the rotation, in radians. + The X coordiate for the rotation pivot. + The Y coordiate for the rotation pivot. + Creates an  that represents a specific rotation in radians with a specific pivot point. + Returns a new matrix with the specific rotation at the pivot point. + + + + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKMatrix + + + + + + + The angle for the rotation, in degrees. + + + Creates an  that represents a specific rotation in degrees. + Returns a new matrix with the specific rotation in degrees. + To be added. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKMatrix + + + + + + + + The angle for the rotation, in degrees. + The X coordiate for the rotation pivot. + The Y coordiate for the rotation pivot. + Creates an  that represents a specific rotation in degrees. + To be added. + To be added. + + @@ -74,10 +170,10 @@ - To be added. - To be added. + Scale X component. + Scale Y component. Creates a scaling matrix. - To be added. + Returns a new matrix with the specific scale factor. To be added. @@ -99,12 +195,12 @@ - To be added. - To be added. - To be added. - To be added. + Scale X component. + Scale Y component. + The X coordiate for the rotation pivot. + The Y coordiate for the rotation pivot. Creates a scaling matrix with a pivot point. - To be added. + Returns a new matrix with the specific scale factor at the pivot point. To be added. @@ -124,10 +220,10 @@ - To be added. - To be added. + Skew X component. + Skew Y component. Creates a skewing matrix. - To be added. + Returns a new matrix with the specific skewing factor. To be added. @@ -147,10 +243,10 @@ - To be added. - To be added. + The X offset for the translation. + The Y offset for the translation. Creates a translation matrix. - To be added. + Returns a new matrix with the specific translation factor. To be added. @@ -202,6 +298,140 @@ To be added. + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + Target matrix. + The matrix to be post-concatenated. + Post-concatenates the matrix to the target matrix + This represents newTarget = matrix * target + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + Target matrix. + The matrix to be post-concatenated. + Pre-concatenates the matrix to the target matrix + This represents newTarget = target * matrix + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + Target matrix. + The angle for the rotation, in radians. + Rotates the spefixied matrix by the specified radians. + To be added. + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + + + Target matrix. + The angle for the rotation, in radians. + The X coordiate for the rotation pivot. + The Y coordiate for the rotation pivot. + Rotates the spefixied matrix by the specified radians. + To be added. + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + Target matrix. + The angle for the rotation, in degrees. + Rotates the spefixied matrix by the specified degrees. + To be added. + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + + + Target matrix. + The angle for the rotation, in degrees. + The X coordiate for the rotation pivot. + The Y coordiate for the rotation pivot. + Rotates the spefixied matrix by the specified degrees. + To be added. + + @@ -214,7 +444,7 @@ System.Single - To be added. + The ScaleX component of the SKMatrix. To be added. @@ -230,7 +460,7 @@ System.Single - To be added. + The ScaleY component of the SKMatrix. To be added. @@ -272,7 +502,7 @@ System.Single - To be added. + The SkewX component of the SKMatrix. To be added. @@ -288,7 +518,7 @@ System.Single - To be added. + The SkewY component of the SKMatrix. To be added. @@ -304,7 +534,7 @@ System.Single - To be added. + The TransX component of the SKMatrix. To be added. @@ -320,7 +550,27 @@ System.Single - To be added. + The TransY component of the SKMatrix. + To be added. + + + + + + Method + + 1.49.0.0 + + + System.Boolean + + + + + + The destination value to store the inverted matrix if the matrix can be inverted. + Attempts to invert the matrix, if possible the inverse matrix contains the result. + True if the matrix can be inverted, and the inverse parameter is initialized with the inverted matrix, false otherwise. To be added. diff --git a/docs/en/index.xml b/docs/en/index.xml index 9d4149e4..26fb7365 100644 --- a/docs/en/index.xml +++ b/docs/en/index.xml @@ -3,7 +3,7 @@ - System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) System.Reflection.AssemblyCompany("") @@ -21,7 +21,7 @@ System.Reflection.AssemblyFileVersion("1.49.4.0") - System.Reflection.AssemblyInformationalVersion("1.49.4.0") + System.Reflection.AssemblyInformationalVersion("1.49.4.0-{GIT_SHA}") System.Reflection.AssemblyProduct("SkiaSharp") diff --git a/skia b/skia index f930e7f7..4cd61dc5 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit f930e7f75b71fef58c3f440f9279bc5506fab303 +Subproject commit 4cd61dc5e7f5b7b79b3a2815798c4d7479aad51d From 89374f14af1e62b3939326d27f00065aa6636815 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Mon, 27 Jun 2016 23:32:28 -0400 Subject: [PATCH 05/17] Update docs --- docs/en/SkiaSharp/SKTextEncoding.xml | 3 +-- docs/en/SkiaSharp/SKTypeface.xml | 19 ++++++++++--------- docs/en/SkiaSharp/SKTypefaceStyle.xml | 9 ++++++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/en/SkiaSharp/SKTextEncoding.xml b/docs/en/SkiaSharp/SKTextEncoding.xml index bd3e1631..d47602f5 100644 --- a/docs/en/SkiaSharp/SKTextEncoding.xml +++ b/docs/en/SkiaSharp/SKTextEncoding.xml @@ -12,8 +12,7 @@ Possible encodings. - - + diff --git a/docs/en/SkiaSharp/SKTypeface.xml b/docs/en/SkiaSharp/SKTypeface.xml index bd6935cc..b7484678 100644 --- a/docs/en/SkiaSharp/SKTypeface.xml +++ b/docs/en/SkiaSharp/SKTypeface.xml @@ -14,12 +14,15 @@ The SkTypeface class specifies the typeface and intrinsic style of a font. The SkTypeface class specifies the typeface and intrinsic style of a font. - This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, kFakeBoldText_Mask, to specifyhow text appears when drawn (and measured). - - + This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, FakeBoldText, to specifyhow text appears when drawn (and measured). + Typeface objects are immutable, and so they can be shared between threads. - - + If you want to create type faces with specific weights not covered by the SKTypefaceStyle, you can pass a suffix to the font family name to trigger this, like this: + + + + + @@ -204,8 +207,7 @@ The font face index. Return a new typeface given a file.  - - + If the file does not exist, or is not a valid font file, returns . @@ -233,8 +235,7 @@ Return a new typeface given a stream. Ownership of the stream is transferred, so the caller must not reference it again. If the stream is not a valid font file, returns - - + System.Enum - Specifies the intrinsic style attributes of a given typeface + Specifies the intrinsic style attributes of a given typeface. - - + While the API does not surface enumeration values for other thin, light, ultra-light, heavy and black, you can achieve the same result by creating an SKTypeface with the suffix “-light”, “-thin” and so on. + + Like this: + + From 1757a3bb467e584d4d2dadcdca164eb2f8eb263d Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 28 Jun 2016 09:07:00 -0400 Subject: [PATCH 06/17] Clarification --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae047c1b..46dc0bc6 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,20 @@ Run from Bash $ ./bootstrapper.sh -t libs +This runs the build process by using the `libs` build target. + ### Windows You need Python 2.7 in `PATH` environment variable. Then you can build it: > .\bootstrapper.ps1 -Target libs +This runs the build process by using the `libs` build target. + ### Build Targets -There are several targets available: +There are several targets available, you can specify the target as the argument to the `-t` command line +option in the bootstrapper script. - `Everything` - builds everything for the current platform - `externals` - builds all the native libraries From c53ab2b03bdbb3a18eacd8812b93bdea16f4b583 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 28 Jun 2016 20:03:13 -0400 Subject: [PATCH 07/17] [SkMatrix] Add various Map methods --- binding/Binding/Definitions.cs | 94 ++++++++++ binding/Binding/SkiaApi.cs | 4 +- docs/en/SkiaSharp/SKBitmap.xml | 3 +- docs/en/SkiaSharp/SKMatrix.xml | 177 ++++++++++++++++++ docs/en/SkiaSharp/SKTextEncoding.xml | 3 +- docs/en/SkiaSharp/SKTypeface.xml | 21 ++- docs/en/SkiaSharp/SKTypefaceStyle.xml | 6 +- .../libSkiaSharp.xcodeproj/project.pbxproj | 2 + skia | 2 +- 9 files changed, 297 insertions(+), 15 deletions(-) diff --git a/binding/Binding/Definitions.cs b/binding/Binding/Definitions.cs index 44cb82fa..eb376c27 100644 --- a/binding/Binding/Definitions.cs +++ b/binding/Binding/Definitions.cs @@ -1304,6 +1304,100 @@ typeMask = Mask.Scale | Mask.RectStaysRect [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl, EntryPoint="sk_matrix_post_concat")] public extern static void PostConcat (ref SKMatrix target, ref SKMatrix matrix); + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl, EntryPoint="sk_matrix_map_rect")] + extern static void MapRect (ref SKMatrix matrix, out SKRect dest, ref SKRect source); + + public SKRect MapRect (SKRect source) + { + SKRect result; + MapRect (ref this, out result, ref source); + return result; + } + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl)] + extern static void sk_matrix_map_points (ref SKMatrix matrix, IntPtr dst, IntPtr src, int count); + + public void MapPoints (SKPoint [] result, SKPoint [] points) + { + if (result == null) + throw new ArgumentNullException ("result"); + if (points == null) + throw new ArgumentNullException ("points"); + int dl = result.Length; + if (dl != points.Length) + throw new ArgumentException ("buffers must be the same size"); + unsafe { + fixed (SKPoint *rp = &result[0]){ + fixed (SKPoint *pp = &points[0]){ + sk_matrix_map_points (ref this, (IntPtr) rp, (IntPtr) pp, dl); + } + } + } + } + + public SKPoint [] MapPoints (SKPoint [] points) + { + if (points == null) + throw new ArgumentNullException ("points"); + var res = new SKPoint [points.Length]; + MapPoints (res, points); + return res; + } + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl)] + extern static void sk_matrix_map_vectors (ref SKMatrix matrix, IntPtr dst, IntPtr src, int count); + + public void MapVectors (SKPoint [] result, SKPoint [] vectors) + { + if (result == null) + throw new ArgumentNullException ("result"); + if (vectors == null) + throw new ArgumentNullException ("vectors"); + int dl = result.Length; + if (dl != vectors.Length) + throw new ArgumentException ("buffers must be the same size"); + unsafe { + fixed (SKPoint *rp = &result[0]){ + fixed (SKPoint *pp = &vectors[0]){ + sk_matrix_map_vectors (ref this, (IntPtr) rp, (IntPtr) pp, dl); + } + } + } + } + + public SKPoint [] MapVectors (SKPoint [] vectors) + { + if (vectors == null) + throw new ArgumentNullException ("vectors"); + var res = new SKPoint [vectors.Length]; + MapVectors (res, vectors); + return res; + } + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl)] + extern static SKPoint sk_matrix_map_xy (ref SKMatrix matrix, float x, float y); + + public SKPoint MapXY (float x, float y) + { + return sk_matrix_map_xy (ref this, x, y); + } + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl)] + extern static SKPoint sk_matrix_map_vector (ref SKMatrix matrix, float x, float y); + + public SKPoint MapVector (float x, float y) + { + return sk_matrix_map_vector (ref this, x, y); + } + + [DllImport(SkiaApi.SKIA, CallingConvention = CallingConvention.Cdecl)] + extern static float sk_matrix_map_radius (ref SKMatrix matrix, float radius); + + public float MapRadius (float radius) + { + return sk_matrix_map_radius (ref this, radius); + } } [StructLayout(LayoutKind.Sequential)] diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index eb1c6f42..eefacb20 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -811,11 +811,9 @@ namespace SkiaSharp [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static int sk_matrix_try_invert(ref SKMatrix matrix, out SKMatrix result); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static int sk_matrix_preconcat(ref SKMatrix target, ref SKMatrix first, ref SKMatrix second); - [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static int sk_matrix_preconcat(ref SKMatrix target, ref SKMatrix matrix); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static int sk_matrix_postconcat(ref SKMatrix target, ref SKMatrix matrix); + public extern static int sk_matrix_post_concat(ref SKMatrix target, ref SKMatrix matrix); } } diff --git a/docs/en/SkiaSharp/SKBitmap.xml b/docs/en/SkiaSharp/SKBitmap.xml index ea2567c2..78c7094f 100644 --- a/docs/en/SkiaSharp/SKBitmap.xml +++ b/docs/en/SkiaSharp/SKBitmap.xml @@ -135,7 +135,8 @@ Returns the configured alpha type for the bitmap. - + + This determines the kind of encoding used for the alpha channel, opaque, premultiplied or unpremultiplied. diff --git a/docs/en/SkiaSharp/SKMatrix.xml b/docs/en/SkiaSharp/SKMatrix.xml index 68a830fa..c3441cb6 100644 --- a/docs/en/SkiaSharp/SKMatrix.xml +++ b/docs/en/SkiaSharp/SKMatrix.xml @@ -250,6 +250,183 @@ To be added. + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPoint[] + + + + + + An array of points that you want to map. + + Apply the to the array of points and return the mapped results. + + New array allocated with the mapped results. + + Mapping points uses all components of the matrix.   If you want to ignore the translation, use MapVectors. + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + Array where the mapped results will be stored, the array needs to have the same number of elements of the array. + Source array with the points to convert. + Apply the to the array of points and return the mapped results. + + Mapping points uses all components of the matrix.   If you want to ignore the translation, use MapVectors. + + + + + + + + Method + + 1.49.0.0 + + + System.Single + + + + + + Radius to map. + + Return the mean radius of a circle after it has been mapped by this matrix + + Return the mean radius of a circle after it has been mapped by this matrix + To be added. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKRect + + + + + + Source recatngle to map. + Apply the matrix to the source rectangle and return the mapped rectangle. + The rectangle with the matrix. + To be added. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPoint + + + + + + + X component of the vector. + Y component of the vector. + Applies the matrix to a vector. + Returns the mapped point. + Mapping vectors ignores the translation component in the matrix.   If you want to take the translation into consideration, use MapXY. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPoint[] + + + + + + An array of vectors that you want to map. + Apply the to the array of vectors and return the mapped results.. + New array allocated with the mapped results. + Mapping vectors ignores the translation component in the matrix.   If you want to take the translation into consideration, use MapPoints. + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + Array where the mapped results will be stored, the array needs to have the same number of elements of the  array. + To be added. + An array of vectors that you want to map. + Apply the to the array of vectors and return the mapped results.. + Mapping vectors ignores the translation component in the matrix.   If you want to take the translation into consideration, use MapPoints. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPoint + + + + + + + X coordinate. + Y coordinate. + Applies the matrix to a point. + Returns the mapped point. + To be added. + + diff --git a/docs/en/SkiaSharp/SKTextEncoding.xml b/docs/en/SkiaSharp/SKTextEncoding.xml index d47602f5..bd3e1631 100644 --- a/docs/en/SkiaSharp/SKTextEncoding.xml +++ b/docs/en/SkiaSharp/SKTextEncoding.xml @@ -12,7 +12,8 @@ Possible encodings. - + + diff --git a/docs/en/SkiaSharp/SKTypeface.xml b/docs/en/SkiaSharp/SKTypeface.xml index b7484678..9372b7d0 100644 --- a/docs/en/SkiaSharp/SKTypeface.xml +++ b/docs/en/SkiaSharp/SKTypeface.xml @@ -15,14 +15,19 @@ The SkTypeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, FakeBoldText, to specifyhow text appears when drawn (and measured). - + + Typeface objects are immutable, and so they can be shared between threads. If you want to create type faces with specific weights not covered by the SKTypefaceStyle, you can pass a suffix to the font family name to trigger this, like this: - - + + + + - - + + + + @@ -207,7 +212,8 @@ The font face index. Return a new typeface given a file.  - + + If the file does not exist, or is not a valid font file, returns . @@ -235,7 +241,8 @@ Return a new typeface given a stream. Ownership of the stream is transferred, so the caller must not reference it again. If the stream is not a valid font file, returns - + + Specifies the intrinsic style attributes of a given typeface. While the API does not surface enumeration values for other thin, light, ultra-light, heavy and black, you can achieve the same result by creating an SKTypeface with the suffix “-light”, “-thin” and so on. - + + Like this: - + + diff --git a/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj b/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj index 1298747f..dc36a681 100644 --- a/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj +++ b/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj @@ -1073,6 +1073,8 @@ TargetAttributes = { 21FD2B2F1C014C000023CFAE = { CreatedOnToolsVersion = 7.1.1; + DevelopmentTeam = PJQC57N853; + DevelopmentTeamName = "Miguel De Icaza"; }; }; }; diff --git a/skia b/skia index 4cd61dc5..2d35987d 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 4cd61dc5e7f5b7b79b3a2815798c4d7479aad51d +Subproject commit 2d35987d8ad6e25e2126998d8585fbb7a1b20fd2 From 50130194ffede28a59b8abe4c4dbac420e9a3c21 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 28 Jun 2016 20:18:16 -0400 Subject: [PATCH 08/17] [SKCanvas] Add DrawCircle --- binding/Binding/SKCanvas.cs | 7 +++++++ binding/Binding/SkiaApi.cs | 6 ++---- docs/en/SkiaSharp/SKImage.xml | 14 +++++--------- skia | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/binding/Binding/SKCanvas.cs b/binding/Binding/SKCanvas.cs index 5f8d663a..c7f0bbeb 100644 --- a/binding/Binding/SKCanvas.cs +++ b/binding/Binding/SKCanvas.cs @@ -163,6 +163,13 @@ namespace SkiaSharp throw new ArgumentNullException ("paint"); SkiaApi.sk_canvas_draw_oval (Handle, ref rect, paint.Handle); } + + public void DrawCircle (float cx, float cy, float radius, SKPaint paint) + { + if (paint == null) + throw new ArgumentNullException ("paint"); + SkiaApi.sk_canvas_draw_circle (Handle, cx, cy, radius, paint.Handle); + } public void DrawPath (SKPath path, SKPaint paint) { diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index eefacb20..9936b9b8 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -110,6 +110,8 @@ namespace SkiaSharp [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_canvas_draw_oval(sk_canvas_t t, ref SKRect rect, sk_paint_t paint); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_canvas_draw_circle(sk_canvas_t t, float cx, float cy, float radius, sk_paint_t paint); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_canvas_draw_path(sk_canvas_t t, sk_path_t path, sk_paint_t paint); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_canvas_draw_image(sk_canvas_t t, sk_image_t image, float x, float y, sk_paint_t paint); @@ -810,10 +812,6 @@ namespace SkiaSharp public extern static bool sk_imagedecoder_decode_stream(sk_stream_streamrewindable_t cstream, sk_bitmap_t bitmap, SKColorType pref, SKImageDecoderMode mode, ref SKImageDecoderFormat format); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static int sk_matrix_try_invert(ref SKMatrix matrix, out SKMatrix result); - [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static int sk_matrix_preconcat(ref SKMatrix target, ref SKMatrix matrix); - [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static int sk_matrix_post_concat(ref SKMatrix target, ref SKMatrix matrix); } } diff --git a/docs/en/SkiaSharp/SKImage.xml b/docs/en/SkiaSharp/SKImage.xml index 8c5f10ca..14ef6593 100644 --- a/docs/en/SkiaSharp/SKImage.xml +++ b/docs/en/SkiaSharp/SKImage.xml @@ -14,11 +14,9 @@ Abstraction for drawing a rectangle of pixels. SkImage is an abstraction for drawing a rectagle of pixels, though the particular type of image could be actually storing its data on the GPU, or as drawing commands (picture or PDF or otherwise), ready to be played back into another canvas. - - + The content of SkImage is always immutable, though the actual storage may change, if for example that image can be re-created via encoded data or other means. - - + SkImage always has a non-zero dimensions. If there is a request to create a new image, either directly or via SkSurface, and either of the requested dimensions are zero, then will be returned. @@ -59,8 +57,7 @@ Encodes the image as a PNG image SKData wrapping the encoded image as a PNG. - - + @@ -85,7 +82,7 @@ Encodes an image, multiple file formats supported SKData wrapping the encoded image as a PNG. - + @@ -133,8 +130,7 @@ Creates an SKImage from an encoded image wrapped by the data. The decoded image, or on error. - - + diff --git a/skia b/skia index 2d35987d..055122ba 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 2d35987d8ad6e25e2126998d8585fbb7a1b20fd2 +Subproject commit 055122ba73e0c46cc48e95a26a7d069c7a915335 From 0ec41ff2f9d7668e25dda4ec9b75b203a9363923 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 1 Jul 2016 22:47:52 -0400 Subject: [PATCH 09/17] Bring Skia updates --- skia | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skia b/skia index 055122ba..ebc8075f 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 055122ba73e0c46cc48e95a26a7d069c7a915335 +Subproject commit ebc8075f3db62c53768a5724ec2e6c4f59976a0a From 2a007da1e38153877ea93797014f01b0ed72f41c Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sat, 2 Jul 2016 03:05:12 -0400 Subject: [PATCH 10/17] Update docs --- docs/en/SkiaSharp/SKCanvas.xml | 85 +++++++++++++++++--------------- docs/en/SkiaSharp/SKImage.xml | 15 ++++-- docs/en/SkiaSharp/SKMatrix.xml | 15 ++++-- docs/en/SkiaSharp/SKPath.xml | 63 +++++++++++++++++------ docs/en/SkiaSharp/SKTypeface.xml | 21 +++----- 5 files changed, 121 insertions(+), 78 deletions(-) diff --git a/docs/en/SkiaSharp/SKCanvas.xml b/docs/en/SkiaSharp/SKCanvas.xml index 8d188078..b5624f53 100644 --- a/docs/en/SkiaSharp/SKCanvas.xml +++ b/docs/en/SkiaSharp/SKCanvas.xml @@ -14,22 +14,18 @@ Encapsulates all of the state about drawing into a device (bitmap). Encapsulates all of the state about drawing into a device (bitmap). - - + This includes a reference to the device itself, and a stack of matrix/clip values. For any given draw call (e.g. drawRect), the geometry of the object being drawn is transformed by the concatenation of all the matrices in the stack. The transformed geometry is clipped by the intersection of all of the clips in the stack. - - + While the Canvas holds the state of the drawing device, the state (style) of the object being drawn is held by the Paint, which is provided as a parameter to each of the draw() methods. The Paint holds attributes such as color, typeface, the text size, the stroke width, the shader (for example, gradients, patterns), etc. - - + The SkCanvas is returned when accessing the  property of a surface. Transformations The  supports a number of 2D transformations.   Unlike other 2D graphic systems like CoreGraphics or Cairo, SKCanvas extends the transformations to include perspectives.    You can use the  to perform some of the most common 2D transformations.    For more control you can use the  to set an arbitrary transformation using the  and the  to concatenate an  transformation to the current matrix in use. The  can be used to reset the state of the matrix - - + Drawing The drawing operations can take a  parameter to affect their drawing.  You use  objects to cache the style and color information to draw geometries, texts and bitmaps. Clipping Path @@ -37,12 +33,9 @@ It is possible to save the current transformations by calling the  method which preserves the current transformation matrix, you can then alter the matrix and restore the previous state by using the  or  methods.    Additionally, it is possible to push a new state with  which will make an offscreen copy of a region, and once the drawing is completed, calling the  method which copies the offscreen bitmap into this canvas. The example below shows a typical use: - - - - - - + + + To be added. + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + + + Center X coordinate. + Center Y coordinate. + Radius for the circle. + The paint used to draw the bitmap. + Draws a circle on the canvas. + To be added. + + @@ -326,8 +344,7 @@ The transfer mode for the color. Fills the current clipping path with the specified color using the specified transfer mode. - - + @@ -525,8 +542,7 @@ The paint used to draw the picture, or . Draws a picture on the canvas. - - + @@ -631,20 +647,15 @@ Draws an array of points, lines or a polygon in the canvas. For all modes, the count parameter is interpreted as the total number of points. For kLine mode, count/2 line segments are drawn. - - + For point mode, each point is drawn centered at its coordinate, and its size is specified by the paint's stroke-width. It draws as a square, unless the paint's cap-type is round, in which the points are drawn as circles. - - + For line mode, each pair of points is drawn as a line segment, respecting the paint's settings for cap, join and width.  - - + For polygon mode, the entire array is drawn as a series of connected line segments. - - + Note that, while similar, the line and polygon modes draw slightly differently than the equivalent path built with a series of move to, line to calls, in that the path will draw all of its contours at once, with no interactions if contours intersect each other (think XOR xfermode).  DrawPoints always draws each element one at a time. - - + @@ -748,8 +759,7 @@ Draws text from a UTF-8 buffer at specified locations on the canvas. Draw the text, with each character/glyph origin specified by the  array. The origin is interpreted by the Align setting in the paint. - - + The parameter is a pointer to a region in memory that contains a UTF-8 encoded block of text.   This only consumes up to bytes from the buffer. @@ -845,8 +855,7 @@ Draws text encoded in a UTF-8 buffer on the canvas. Draws the , with origin at (,), using the specified . The origin is interpreted based on the Align setting in the paint. - - + The  parameter is a pointer to a region in memory that contains a UTF-8 encoded block of text.   This only consumes up to  bytes from the buffer. @@ -993,8 +1002,7 @@ Restore the canvas state. This call balances a previous call to , and is used to remove all modifications to the matrix, clip and draw filter state since the last Save call. - - + It is an error to call Restore() more times than Save() was called. @@ -1041,8 +1049,7 @@ The number of degrees to rotate. Preconcat the current matrix with the specified rotation. - - + @@ -1064,8 +1071,7 @@ The number of radiants to rotate. Preconcat the current matrix with the specified rotation. - - + @@ -1110,8 +1116,7 @@ This will equal the number of Save calls minus Retore calls + 1. The save count on a new canvas is 1. - - + diff --git a/docs/en/SkiaSharp/SKImage.xml b/docs/en/SkiaSharp/SKImage.xml index 14ef6593..078cb424 100644 --- a/docs/en/SkiaSharp/SKImage.xml +++ b/docs/en/SkiaSharp/SKImage.xml @@ -14,9 +14,11 @@ Abstraction for drawing a rectangle of pixels. SkImage is an abstraction for drawing a rectagle of pixels, though the particular type of image could be actually storing its data on the GPU, or as drawing commands (picture or PDF or otherwise), ready to be played back into another canvas. - + + The content of SkImage is always immutable, though the actual storage may change, if for example that image can be re-created via encoded data or other means. - + + SkImage always has a non-zero dimensions. If there is a request to create a new image, either directly or via SkSurface, and either of the requested dimensions are zero, then will be returned. @@ -57,7 +59,8 @@ Encodes the image as a PNG image SKData wrapping the encoded image as a PNG. - + + @@ -82,7 +85,8 @@ Encodes an image, multiple file formats supported SKData wrapping the encoded image as a PNG. - + + @@ -130,7 +134,8 @@ Creates an SKImage from an encoded image wrapped by the data. The decoded image, or on error. - + + diff --git a/docs/en/SkiaSharp/SKMatrix.xml b/docs/en/SkiaSharp/SKMatrix.xml index c3441cb6..20a94a52 100644 --- a/docs/en/SkiaSharp/SKMatrix.xml +++ b/docs/en/SkiaSharp/SKMatrix.xml @@ -14,7 +14,8 @@ 2D Transformation matrix with perspective. The SKMatrix is a full 3x3 matrix. - + + It extends the traditional 2D affine transformation matrix with three perspective components that allow simple 3D effects to be created with it.   Those components must be manually set by using the  fields of the matrix. @@ -103,7 +104,8 @@ Creates an  that represents a specific rotation in radians with a specific pivot point. Returns a new matrix with the specific rotation at the pivot point. - + + @@ -123,7 +125,8 @@ The angle for the rotation, in degrees. - + + Creates an  that represents a specific rotation in degrees. Returns a new matrix with the specific rotation in degrees. @@ -271,7 +274,8 @@ New array allocated with the mapped results. Mapping points uses all components of the matrix.   If you want to ignore the translation, use MapVectors. - + + @@ -295,7 +299,8 @@ Apply the to the array of points and return the mapped results. Mapping points uses all components of the matrix.   If you want to ignore the translation, use MapVectors. - + + diff --git a/docs/en/SkiaSharp/SKPath.xml b/docs/en/SkiaSharp/SKPath.xml index cf8b4cf0..00068333 100644 --- a/docs/en/SkiaSharp/SKPath.xml +++ b/docs/en/SkiaSharp/SKPath.xml @@ -44,9 +44,9 @@ - To be added. - To be added. - To be added. + The path to clone. + Creates an SKPath by making a copy of an existing path + This constructor can throw InvalidOperationException if there is a problem copying the source path. @@ -94,8 +94,7 @@ The direction to wind the oval's contour. Adds an oval to the current path. - - + @@ -192,8 +191,7 @@ Add a conic path from the last point.  If no  call has been made for this contour, the first point is automatically set to (0,0). - - + @@ -342,8 +340,7 @@ The y-coordinate of the start of a new contour Set the beginning of the next contour to the point. - - + @@ -434,8 +431,47 @@ Same as  but the coordinates are considered relative to the last point on this contour.  If no  call has been made for this contour, the first point is automatically set to (0,0). - - + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + Clear any lines and curves from the path, making it empty. + + This frees up internal storage associated with those segments. + + On Android, does not change fSourcePath. + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + Clear any lines and curves from the path, making it empty. + + However, any internal storage for those lines/curves is retained, making reuse of the path potentially faster. + + On Android, does not change fSourcePath. @@ -479,8 +515,7 @@ The amount to add to the x-coordinate of the last point on this contour, to specify the start of a new contour. Same as  but the coordinates are considered relative to the last point on this contour. - - + @@ -524,7 +559,7 @@ To be added. - To be added. + Applies a transformation matrix to the all the elements in the path. To be added. diff --git a/docs/en/SkiaSharp/SKTypeface.xml b/docs/en/SkiaSharp/SKTypeface.xml index 9372b7d0..b7484678 100644 --- a/docs/en/SkiaSharp/SKTypeface.xml +++ b/docs/en/SkiaSharp/SKTypeface.xml @@ -15,19 +15,14 @@ The SkTypeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, FakeBoldText, to specifyhow text appears when drawn (and measured). - - + Typeface objects are immutable, and so they can be shared between threads. If you want to create type faces with specific weights not covered by the SKTypefaceStyle, you can pass a suffix to the font family name to trigger this, like this: - - - - + + - - - - + + @@ -212,8 +207,7 @@ The font face index. Return a new typeface given a file.  - - + If the file does not exist, or is not a valid font file, returns . @@ -241,8 +235,7 @@ Return a new typeface given a stream. Ownership of the stream is transferred, so the caller must not reference it again. If the stream is not a valid font file, returns - - + Date: Sun, 3 Jul 2016 00:10:37 -0400 Subject: [PATCH 11/17] bump skia --- skia | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skia b/skia index ebc8075f..84542ff1 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit ebc8075f3db62c53768a5724ec2e6c4f59976a0a +Subproject commit 84542ff11495bdf5ead30821bdf8b04564a9571e From c7b7208ed069b6346b3f59f3c24a6a5d671dca68 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sun, 3 Jul 2016 00:27:51 -0400 Subject: [PATCH 12/17] Bump skia --- skia | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skia b/skia index 84542ff1..246039fd 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 84542ff11495bdf5ead30821bdf8b04564a9571e +Subproject commit 246039fd056bcec1abc12c8aa7e42d0686ad0fc2 From aed73d856518d416031a83216f0f030cbaeea255 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 5 Jul 2016 22:49:03 -0400 Subject: [PATCH 13/17] [SKPath] Add various requested APIs --- binding/Binding/SKPath.cs | 141 ++++++++++++++++++++++ binding/Binding/SkiaApi.cs | 35 ++++++ docs/en/SkiaSharp/SKCanvas.xml | 60 ++++++--- docs/en/SkiaSharp/SKPath+AddMode.xml | 51 ++++++++ docs/en/SkiaSharp/SKPath+Iterator.xml | 147 +++++++++++++++++++++++ docs/en/SkiaSharp/SKPath+RawIterator.xml | 116 ++++++++++++++++++ docs/en/SkiaSharp/SKPath+Verb.xml | 115 ++++++++++++++++++ docs/en/SkiaSharp/SKPath.xml | 137 +++++++++++++++++++++ docs/en/SkiaSharp/SKTypeface.xml | 21 ++-- docs/en/index.xml | 4 + skia | 2 +- 11 files changed, 801 insertions(+), 28 deletions(-) create mode 100644 docs/en/SkiaSharp/SKPath+AddMode.xml create mode 100644 docs/en/SkiaSharp/SKPath+Iterator.xml create mode 100644 docs/en/SkiaSharp/SKPath+RawIterator.xml create mode 100644 docs/en/SkiaSharp/SKPath+Verb.xml diff --git a/binding/Binding/SKPath.cs b/binding/Binding/SKPath.cs index 8a6d5029..2dd12645 100644 --- a/binding/Binding/SKPath.cs +++ b/binding/Binding/SKPath.cs @@ -12,6 +12,16 @@ namespace SkiaSharp { public class SKPath : SKObject { + public enum Verb { + Move, Line, Quad, Conic, Cubic, Close, Done + } + + public enum AddMode { + Append, + Extend + } + + [Preserve] internal SKPath (IntPtr handle) : base (handle) @@ -149,6 +159,137 @@ namespace SkiaSharp { SkiaApi.sk_path_transform (Handle, ref matrix); } + + public void AddPath (SKPath other, float dx, float dy, AddMode mode = AddMode.Append) + { + if (other == null) + throw new ArgumentNullException (nameof (other)); + + SkiaApi.sk_path_add_path_offset (Handle, other.Handle, dx, dy, mode); + } + + public void AddPath (SKPath other, ref SKMatrix matrix, AddMode mode = AddMode.Append) + { + if (other == null) + throw new ArgumentNullException (nameof (other)); + + SkiaApi.sk_path_add_path_matrix (Handle, other.Handle, ref matrix, mode); + } + + public void AddPath (SKPath other, AddMode mode = AddMode.Append) + { + if (other == null) + throw new ArgumentNullException (nameof (other)); + + SkiaApi.sk_path_add_path (Handle, other.Handle, mode); + } + + public void AddPathReverse (SKPath other) + { + if (other == null) + throw new ArgumentNullException (nameof (other)); + + SkiaApi.sk_path_add_path_reverse (Handle, other.Handle); + } + + public Iterator CreateIterator (bool forceClose) + { + return new Iterator (this, SkiaApi.sk_path_create_iter (Handle, forceClose ? 1 : 0)); + } + + public RawIterator CreateRawIterator () + { + return new RawIterator (this, SkiaApi.sk_path_create_rawiter (Handle)); + } + + public class Iterator : IDisposable { + SKPath Path => path; + SKPath path; + IntPtr handle; + + internal Iterator (SKPath path, IntPtr handle) + { + 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 () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + 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); + } + + 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_close_countour (handle) != 0; + } + + public class RawIterator : IDisposable { + SKPath Path => path; + SKPath path; + IntPtr handle; + + internal RawIterator (SKPath path, IntPtr handle) + { + this.path = path; + this.handle = handle; + } + + ~RawIterator () + { + Dispose (false); + } + + void Dispose (bool disposing) + { + if (handle != IntPtr.Zero){ + // safe to call from a background thread to release resources. + SkiaApi.sk_path_rawiter_destroy (handle); + handle = IntPtr.Zero; + } + } + + 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); + } + + public float ConicWeight () => SkiaApi.sk_path_rawiter_conic_weight (handle); + public Verb Peek () => SkiaApi.sk_path_rawiter_peek (handle); + } } } diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index ef8a57f4..84484b15 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -37,6 +37,7 @@ using sk_imagefilter_croprect_t = System.IntPtr; using sk_imagefilter_t = System.IntPtr; using sk_colorfilter_t = System.IntPtr; using sk_document_t = System.IntPtr; +using sk_path_iterator_t = System.IntPtr; namespace SkiaSharp { @@ -345,6 +346,14 @@ namespace SkiaSharp [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_path_add_arc(sk_path_t t, ref SKRect rect, float startAngle, float sweepAngle); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_add_path_offset (sk_path_t t, sk_path_t other, float dx, float dy, SKPath.AddMode mode); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_add_path_matrix (sk_path_t t, sk_path_t other, ref SKMatrix matrix, SKPath.AddMode mode); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_add_path (sk_path_t t, sk_path_t other, SKPath.AddMode mode); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_add_path_reverse (sk_path_t t, sk_path_t other); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static bool sk_path_get_bounds(sk_path_t t, out SKRect rect); [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static SKPathFillType sk_path_get_filltype (sk_path_t t); @@ -355,6 +364,32 @@ namespace SkiaSharp [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_path_t sk_path_transform (sk_path_t t, ref SKMatrix matrix); + // iterator + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_iterator_t sk_path_create_iter (sk_path_t path, int forceClose); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static SKPath.Verb sk_path_iter_next (sk_path_iterator_t iterator, [Out] SKPoint [] points, int doConsumeDegenerates, int exact); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static float sk_path_iter_conic_weight (sk_path_iterator_t iterator); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static int sk_path_iter_is_close_line (sk_path_iterator_t iterator); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static int sk_path_iter_is_close_countour (sk_path_iterator_t iterator); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_iter_destroy (sk_path_t path); + + // Raw iterator + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_iterator_t sk_path_create_rawiter (sk_path_t path); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static SKPath.Verb sk_path_rawiter_next (sk_path_iterator_t iterator, [Out] SKPoint [] points); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static SKPath.Verb sk_path_rawiter_peek (sk_path_iterator_t iterator); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static float sk_path_rawiter_conic_weight (sk_path_iterator_t iterator); + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_path_rawiter_destroy (sk_path_t path); + // SkMaskFilter [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_maskfilter_unref(sk_maskfilter_t t); diff --git a/docs/en/SkiaSharp/SKCanvas.xml b/docs/en/SkiaSharp/SKCanvas.xml index b5624f53..b4c37138 100644 --- a/docs/en/SkiaSharp/SKCanvas.xml +++ b/docs/en/SkiaSharp/SKCanvas.xml @@ -14,18 +14,22 @@ Encapsulates all of the state about drawing into a device (bitmap). Encapsulates all of the state about drawing into a device (bitmap). - + + This includes a reference to the device itself, and a stack of matrix/clip values. For any given draw call (e.g. drawRect), the geometry of the object being drawn is transformed by the concatenation of all the matrices in the stack. The transformed geometry is clipped by the intersection of all of the clips in the stack. - + + While the Canvas holds the state of the drawing device, the state (style) of the object being drawn is held by the Paint, which is provided as a parameter to each of the draw() methods. The Paint holds attributes such as color, typeface, the text size, the stroke width, the shader (for example, gradients, patterns), etc. - + + The SkCanvas is returned when accessing the  property of a surface. Transformations The  supports a number of 2D transformations.   Unlike other 2D graphic systems like CoreGraphics or Cairo, SKCanvas extends the transformations to include perspectives.    You can use the  to perform some of the most common 2D transformations.    For more control you can use the  to set an arbitrary transformation using the  and the  to concatenate an  transformation to the current matrix in use. The  can be used to reset the state of the matrix - + + Drawing The drawing operations can take a  parameter to affect their drawing.  You use  objects to cache the style and color information to draw geometries, texts and bitmaps. Clipping Path @@ -33,9 +37,12 @@ It is possible to save the current transformations by calling the  method which preserves the current transformation matrix, you can then alter the matrix and restore the previous state by using the  or  methods.    Additionally, it is possible to push a new state with  which will make an offscreen copy of a region, and once the drawing is completed, calling the  method which copies the offscreen bitmap into this canvas. The example below shows a typical use: - - - + + + + + + The transfer mode for the color. Fills the current clipping path with the specified color using the specified transfer mode. - + + @@ -542,7 +550,8 @@ The paint used to draw the picture, or . Draws a picture on the canvas. - + + @@ -647,15 +656,20 @@ Draws an array of points, lines or a polygon in the canvas. For all modes, the count parameter is interpreted as the total number of points. For kLine mode, count/2 line segments are drawn. - + + For point mode, each point is drawn centered at its coordinate, and its size is specified by the paint's stroke-width. It draws as a square, unless the paint's cap-type is round, in which the points are drawn as circles. - + + For line mode, each pair of points is drawn as a line segment, respecting the paint's settings for cap, join and width.  - + + For polygon mode, the entire array is drawn as a series of connected line segments. - + + Note that, while similar, the line and polygon modes draw slightly differently than the equivalent path built with a series of move to, line to calls, in that the path will draw all of its contours at once, with no interactions if contours intersect each other (think XOR xfermode).  DrawPoints always draws each element one at a time. - + + @@ -759,7 +773,8 @@ Draws text from a UTF-8 buffer at specified locations on the canvas. Draw the text, with each character/glyph origin specified by the  array. The origin is interpreted by the Align setting in the paint. - + + The parameter is a pointer to a region in memory that contains a UTF-8 encoded block of text.   This only consumes up to bytes from the buffer. @@ -855,7 +870,8 @@ Draws text encoded in a UTF-8 buffer on the canvas. Draws the , with origin at (,), using the specified . The origin is interpreted based on the Align setting in the paint. - + + The  parameter is a pointer to a region in memory that contains a UTF-8 encoded block of text.   This only consumes up to  bytes from the buffer. @@ -1002,7 +1018,8 @@ Restore the canvas state. This call balances a previous call to , and is used to remove all modifications to the matrix, clip and draw filter state since the last Save call. - + + It is an error to call Restore() more times than Save() was called. @@ -1049,7 +1066,8 @@ The number of degrees to rotate. Preconcat the current matrix with the specified rotation. - + + @@ -1071,7 +1089,8 @@ The number of radiants to rotate. Preconcat the current matrix with the specified rotation. - + + @@ -1116,7 +1135,8 @@ This will equal the number of Save calls minus Retore calls + 1. The save count on a new canvas is 1. - + + diff --git a/docs/en/SkiaSharp/SKPath+AddMode.xml b/docs/en/SkiaSharp/SKPath+AddMode.xml new file mode 100644 index 00000000..748e8fe1 --- /dev/null +++ b/docs/en/SkiaSharp/SKPath+AddMode.xml @@ -0,0 +1,51 @@ + + + + + SkiaSharp + 1.49.0.0 + + + System.Enum + + + Controls how a path is added to another path. + + + + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+AddMode + + + Source path contours are added as new contours. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+AddMode + + + + Path is added by extending the last contour of the destination path with the first contour of the source path. If the last contour of the destination path is closed, then it will not be extended. + + Instead, the start of source path will be extended by a straight line to the end point of the destination path. + + + + + diff --git a/docs/en/SkiaSharp/SKPath+Iterator.xml b/docs/en/SkiaSharp/SKPath+Iterator.xml new file mode 100644 index 00000000..6ff3cee1 --- /dev/null +++ b/docs/en/SkiaSharp/SKPath+Iterator.xml @@ -0,0 +1,147 @@ + + + + + SkiaSharp + 1.49.0.0 + + + System.Object + + + + System.IDisposable + + + + Iterator object to scan the all of the segments (lines, quadratics, cubics) of each contours in a path.    + Iterators are created by calling the  method. + + + + + + Method + + 1.49.0.0 + + + System.Single + + + + + Return the weight for the current conic. Only valid if the current segment return by  was a conic. + + + + + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + Releases the iterator. + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + To be added. + To be added. + + + + + + Method + + 1.49.0.0 + + + System.Boolean + + + + Returns true if the current contour is closed (has a ). + + + + + + + + + + + + Method + + 1.49.0.0 + + + System.Boolean + + + + If the last call to  returns a line, returns true if the line was the result of a  command. + If the last call to  returns a line, returns true if the line was the result of a  command. + If the call to Next returned a different value than Line, the result is undefined. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + + + + + + Outgoing parameter, should be an array of four points, on return this contains points representing the current verb and/or segment. + + If , first scan for segments that are deemed degenerate (too short) and skip those. + + + if is and exact is true, skip only degenerate elements with lengths exactly equal to zero. If exact is , skip degenerate elements with lengths close to zero. If is , exact has no effect. + + Return the next verb in this iteration of the path. + The verb of the current segment. + + When all segments have been visited, returns Verb.Done + + + + + diff --git a/docs/en/SkiaSharp/SKPath+RawIterator.xml b/docs/en/SkiaSharp/SKPath+RawIterator.xml new file mode 100644 index 00000000..6dfabc3e --- /dev/null +++ b/docs/en/SkiaSharp/SKPath+RawIterator.xml @@ -0,0 +1,116 @@ + + + + + SkiaSharp + 1.49.0.0 + + + System.Object + + + + System.IDisposable + + + + To be added. + To be added. + + + + + + Method + + 1.49.0.0 + + + System.Single + + + + Return the weight for the current conic. Only valid if the current segment return by  was a conic. + + + + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + Releases the iterator. + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + To be added. + To be added. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + + + + Outgoing parameter, should be an array of four points, on return this contains points representing the current verb and/or segment. + Return the next verb in this iteration of the path. + The verb of the current segment. + To be added. + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + + Return what the next verb will be, but do not visit the next segment. + The verb for the next segment + + + + + + + diff --git a/docs/en/SkiaSharp/SKPath+Verb.xml b/docs/en/SkiaSharp/SKPath+Verb.xml new file mode 100644 index 00000000..f5dea805 --- /dev/null +++ b/docs/en/SkiaSharp/SKPath+Verb.xml @@ -0,0 +1,115 @@ + + + + + SkiaSharp + 1.49.0.0 + + + System.Enum + + + To be added. + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + + + Field + + 1.49.0.0 + + + SkiaSharp.SKPath+Verb + + + To be added. + + + + diff --git a/docs/en/SkiaSharp/SKPath.xml b/docs/en/SkiaSharp/SKPath.xml index 00068333..d820e0e0 100644 --- a/docs/en/SkiaSharp/SKPath.xml +++ b/docs/en/SkiaSharp/SKPath.xml @@ -98,6 +98,102 @@ + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + The path containing the elements to be added to the current path. + Determines how the path contours are added to the path.   On Append mode, contours are added as new contours.   On Extend mode, the last contour of the path is extended with the first contour of the path. + Extends the current path with the path elements from another path, using the specified extension mode. + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + + The path containing the elements to be added to the current path. + Transformation applied to the path. + Determines how the path contours are added to the path.   On Append mode, contours are added as new contours.   On Extend mode, the last contour of the path is extended with the first contour of the  path. + Extends the current path with the path elements from another path, by applying the specified transformation matrix, using the specified extension mode. + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + + + + The path containing the elements to be added to the current path. + The amount to translate the path in X as it is added. + The amount to translate the path in Y as it is added. + Determines how the  path contours are added to the path.   On Append mode, contours are added as new contours.   On Extend mode, the last contour of the path is extended with the first contour of the  path. + Extends the current path with the path elements from another path offset by (), using the specified extension mode. + + + + + + + + + Method + + 1.49.0.0 + + + System.Void + + + + + + The path containing the elements to be added to the current path. + Extends the current path with the path elements from another path in reverse. + + + + + @@ -195,6 +291,47 @@ + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPath+Iterator + + + + + + + When this is true, each contour (as defined by a new starting move command) will be completed with a close verb regardless of the contour's contents. + + Creates an iterator object to scan the all of the segments (lines, quadratics, cubics) of each contours in a path. + An object that can be used to iterate over the various elements of the path. + + This iterator is able to clean up the path as the values are returned.   If you do not desire to get verbs that have been cleaned up, use the  method instead. + + + + + + + Method + + 1.49.0.0 + + + SkiaSharp.SKPath+RawIterator + + + + Creates a raw iterator object to scan the all of the segments (lines, quadratics, cubics) of each contours in a path. + An object that can be used to iterate over the various elements of the path. + Unlike the  method, this iterator does not clean up or normalize the values in the path.   It returns the raw elements contained in the path. + + diff --git a/docs/en/SkiaSharp/SKTypeface.xml b/docs/en/SkiaSharp/SKTypeface.xml index b7484678..9372b7d0 100644 --- a/docs/en/SkiaSharp/SKTypeface.xml +++ b/docs/en/SkiaSharp/SKTypeface.xml @@ -15,14 +15,19 @@ The SkTypeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, FakeBoldText, to specifyhow text appears when drawn (and measured). - + + Typeface objects are immutable, and so they can be shared between threads. If you want to create type faces with specific weights not covered by the SKTypefaceStyle, you can pass a suffix to the font family name to trigger this, like this: - - + + + + - - + + + + @@ -207,7 +212,8 @@ The font face index. Return a new typeface given a file.  - + + If the file does not exist, or is not a valid font file, returns . @@ -235,7 +241,8 @@ Return a new typeface given a stream. Ownership of the stream is transferred, so the caller must not reference it again. If the stream is not a valid font file, returns - + + + + + + diff --git a/skia b/skia index 246039fd..9bd4382e 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 246039fd056bcec1abc12c8aa7e42d0686ad0fc2 +Subproject commit 9bd4382e6d99a57b9c94fe9a3ff972f03a7f0f4e From 7758f65f9e6991c06c96e569f81d1f8f7d88a8b4 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Wed, 6 Jul 2016 10:30:34 -0400 Subject: [PATCH 14/17] Bump skia --- docs/en/SkiaSharp/SKPath+Verb.xml | 18 +++++++++--------- skia | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/en/SkiaSharp/SKPath+Verb.xml b/docs/en/SkiaSharp/SKPath+Verb.xml index f5dea805..e0e5991f 100644 --- a/docs/en/SkiaSharp/SKPath+Verb.xml +++ b/docs/en/SkiaSharp/SKPath+Verb.xml @@ -9,8 +9,8 @@ System.Enum - To be added. - To be added. + Verbs contained in an . + In the description below, the number of points returned represents the number of valid entries on the return array of SKPoints that is passed to the Next method on the iterator. @@ -24,7 +24,7 @@ SkiaSharp.SKPath+Verb - To be added. + Close path, a call to the iterator’s Next() method will return one point (countour’s MoveTo point). @@ -38,7 +38,7 @@ SkiaSharp.SKPath+Verb - To be added. + Conic path, a call to the iterator’s Next() method will return three points, plus the ConicWeight point. @@ -52,7 +52,7 @@ SkiaSharp.SKPath+Verb - To be added. + Cubic path, a call to the iterator’s Next() method will return four points @@ -66,7 +66,7 @@ SkiaSharp.SKPath+Verb - To be added. + The path is completed, points will not contain any data. @@ -80,7 +80,7 @@ SkiaSharp.SKPath+Verb - To be added. + Line path, a call to the iterator’s Next() method will return two points. @@ -94,7 +94,7 @@ SkiaSharp.SKPath+Verb - To be added. + Move command, a call to the iterator’s Next() method will return a single point. @@ -108,7 +108,7 @@ SkiaSharp.SKPath+Verb - To be added. + Quad command, a call to the iterator’s Next() method will return three points. diff --git a/skia b/skia index 9bd4382e..2e4ace62 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 9bd4382e6d99a57b9c94fe9a3ff972f03a7f0f4e +Subproject commit 2e4ace6235c0515c65931e5c08b212f83e3081e4 From f5ff8b89f8844319773bba67af6923ff255a3aeb Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Wed, 6 Jul 2016 22:15:36 -0400 Subject: [PATCH 15/17] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 46dc0bc6..e69fe8c1 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ to create your native libraries. Check our getting [started guide](https://developer.xamarin.com/guides/cross-platform/drawing/) +# Extensions for SkiaSharp + +Windows/WPF users might find the [SkiaSharpWPFExtensions](https://github.com/impsnldavid/skiasharpwpfextensions) useful. + ## Building SkiaSharp First clone the repository: From b3e64fae056e9fde4a2d62daf57e8aa158ebe3a3 Mon Sep 17 00:00:00 2001 From: Takashi Kawasaki Date: Mon, 11 Jul 2016 03:55:18 +0900 Subject: [PATCH 16/17] CharsToGlyphs(SKEncoding) does not honor the specified encoding. --- binding/Binding/SKTypeface.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding/Binding/SKTypeface.cs b/binding/Binding/SKTypeface.cs index 829555f7..879b1172 100644 --- a/binding/Binding/SKTypeface.cs +++ b/binding/Binding/SKTypeface.cs @@ -107,7 +107,7 @@ namespace SkiaSharp glyphs = new ushort[n]; fixed (ushort *gp = &glyphs [0]){ - return SkiaApi.sk_typeface_chars_to_glyphs (Handle, str, SKEncoding.Utf16, (IntPtr) gp, n); + return SkiaApi.sk_typeface_chars_to_glyphs (Handle, str, encoding, (IntPtr) gp, n); } } } From e3e1b81d043c2cd8a7918ba7427da6c0ec937ed4 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 13 Jul 2016 21:57:42 +0200 Subject: [PATCH 17/17] Added path effects to the C# API --- binding/Binding/Binding.projitems | 1 + binding/Binding/SKPaint.cs | 9 +++ binding/Binding/SKPathEffect.cs | 84 +++++++++++++++++++++++++++ binding/Binding/SkiaApi.cs | 24 ++++++++ native-builds/src/SkiaKeeper.c | 2 + samples/SharedDemo/SkiaSharp.Demos.cs | 35 +++++++++++ skia | 2 +- 7 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 binding/Binding/SKPathEffect.cs diff --git a/binding/Binding/Binding.projitems b/binding/Binding/Binding.projitems index 9076bd84..35422f67 100644 --- a/binding/Binding/Binding.projitems +++ b/binding/Binding/Binding.projitems @@ -16,6 +16,7 @@ + diff --git a/binding/Binding/SKPaint.cs b/binding/Binding/SKPaint.cs index e794a487..7db255b6 100644 --- a/binding/Binding/SKPaint.cs +++ b/binding/Binding/SKPaint.cs @@ -227,6 +227,15 @@ namespace SkiaSharp } } + public SKPathEffect PathEffect { + get { + return GetObject (SkiaApi.sk_paint_get_path_effect(Handle)); + } + set { + SkiaApi.sk_paint_set_path_effect (Handle, value == null ? IntPtr.Zero : value.Handle); + } + } + public float MeasureText (string text) { if (text == null) diff --git a/binding/Binding/SKPathEffect.cs b/binding/Binding/SKPathEffect.cs new file mode 100644 index 00000000..8be53be4 --- /dev/null +++ b/binding/Binding/SKPathEffect.cs @@ -0,0 +1,84 @@ +// +// Bindings for SKPath +// +// Author: +// Matthew Leibowitz +// +// Copyright 2016 Xamarin Inc +// +using System; + +namespace SkiaSharp +{ + public enum SkPath1DPathEffectStyle + { + Translate, + Rotate, + Morph, + } + + public class SKPathEffect : SKObject + { + [Preserve] + internal SKPathEffect (IntPtr handle) + : base (handle) + { + } + + public static SKPathEffect CreateCompose(SKPathEffect outer, SKPathEffect inner) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + return GetObject(SkiaApi.sk_path_effect_create_compose(outer.Handle, inner.Handle)); + } + + public static SKPathEffect CreateSum(SKPathEffect first, SKPathEffect second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + return GetObject(SkiaApi.sk_path_effect_create_sum(first.Handle, second.Handle)); + } + + public static SKPathEffect CreateDiscrete(float segLength, float deviation, UInt32 seedAssist = 0) + { + return GetObject(SkiaApi.sk_path_effect_create_discrete(segLength, deviation, seedAssist)); + } + + public static SKPathEffect CreateCorner(float radius) + { + return GetObject(SkiaApi.sk_path_effect_create_corner(radius)); + } + + public static SKPathEffect Create1DPath(SKPath path, float advance, float phase, SkPath1DPathEffectStyle style) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + return GetObject(SkiaApi.sk_path_effect_create_1d_path(path.Handle, advance, phase, style)); + } + + public static SKPathEffect Create2DLine(float width, SKMatrix matrix) + { + return GetObject(SkiaApi.sk_path_effect_create_2d_line(width, matrix)); + } + + public static SKPathEffect Create2DPath(SKMatrix matrix, SKPath path) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + return GetObject(SkiaApi.sk_path_effect_create_2d_path(matrix, path.Handle)); + } + + public static SKPathEffect CreateDash(float[] intervals, float phase) + { + if (intervals == null) + throw new ArgumentNullException(nameof(intervals)); + return GetObject(SkiaApi.sk_path_effect_create_dash(intervals, intervals.Length, phase)); + } + + } +} + diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index 84484b15..58a4749a 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -38,6 +38,7 @@ using sk_imagefilter_t = System.IntPtr; using sk_colorfilter_t = System.IntPtr; using sk_document_t = System.IntPtr; using sk_path_iterator_t = System.IntPtr; +using sk_path_effect_t = System.IntPtr; namespace SkiaSharp { @@ -286,6 +287,11 @@ namespace SkiaSharp [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static float sk_paint_get_fontmetrics(sk_paint_t t, out SKFontMetrics fontMetrics, float scale); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_paint_get_path_effect(sk_paint_t cpaint); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static void sk_paint_set_path_effect(sk_paint_t cpaint, sk_path_effect_t effect); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_image_t sk_image_new_raster_copy(ref SKImageInfo info, IntPtr pixels, IntPtr rowBytes); @@ -851,6 +857,24 @@ namespace SkiaSharp public extern static bool sk_imagedecoder_decode_stream(sk_stream_streamrewindable_t cstream, sk_bitmap_t bitmap, SKColorType pref, SKImageDecoderMode mode, ref SKImageDecoderFormat format); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static int sk_matrix_try_invert(ref SKMatrix matrix, out SKMatrix result); + + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_compose(sk_path_effect_t outer, sk_path_effect_t inner); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_sum(sk_path_effect_t first, sk_path_effect_t second); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_discrete(float segLength, float deviation, UInt32 seedAssist /*0*/); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_corner(float radius); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_1d_path(sk_path_t path, float advance, float phase, SkPath1DPathEffectStyle style); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_2d_line(float width, SKMatrix matrix); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_2d_path(SKMatrix matrix, sk_path_t path); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_path_effect_t sk_path_effect_create_dash(float[] intervals, int count, float phase); + } } diff --git a/native-builds/src/SkiaKeeper.c b/native-builds/src/SkiaKeeper.c index ad0c6191..1affd3c9 100644 --- a/native-builds/src/SkiaKeeper.c +++ b/native-builds/src/SkiaKeeper.c @@ -31,6 +31,7 @@ #include "xamarin/sk_x_maskfilter.h" #include "xamarin/sk_x_paint.h" #include "xamarin/sk_x_path.h" +#include "xamarin/sk_x_patheffect.h" #include "xamarin/sk_x_shader.h" #include "xamarin/sk_x_stream.h" #include "xamarin/sk_x_typeface.h" @@ -75,6 +76,7 @@ void** KeepSkiaCSymbols () (void*)sk_string_new_empty, (void*)sk_document_unref, (void*)sk_wstream_write, + (void*)sk_path_effect_create_dash, // Xamarin (void*)sk_managedstream_new, diff --git a/samples/SharedDemo/SkiaSharp.Demos.cs b/samples/SharedDemo/SkiaSharp.Demos.cs index 03e9bfeb..942db187 100644 --- a/samples/SharedDemo/SkiaSharp.Demos.cs +++ b/samples/SharedDemo/SkiaSharp.Demos.cs @@ -948,6 +948,40 @@ namespace SkiaSharp OpenFileDelegate?.Invoke ("document.pdf"); } + public static void PathEffects (SKCanvas canvas, int width, int height) + { + canvas.Clear (SKColors.White); + + var step = height / 4; + + using (var paint = new SKPaint ()) + using (var effect = SKPathEffect.CreateDash (new [] { 15f, 5f }, 0)) { + paint.IsStroke = true; + paint.StrokeWidth = 4; + paint.PathEffect = effect; + canvas.DrawLine (10, step, width - 10 - 10, step, paint); + } + + using (var paint = new SKPaint ()) + using (var effect = SKPathEffect.CreateDiscrete (10, 10)) { + paint.IsStroke = true; + paint.StrokeWidth = 4; + paint.PathEffect = effect; + canvas.DrawLine (10, step * 2, width - 10 - 10, step * 2, paint); + } + + using (var paint = new SKPaint ()) + using (var dashEffect = SKPathEffect.CreateDash (new [] { 15f, 5f }, 0)) + using (var discreteEffect = SKPathEffect.CreateDiscrete (10, 10)) + using (var effect = SKPathEffect.CreateCompose (dashEffect, discreteEffect)) { + paint.IsStroke = true; + paint.StrokeWidth = 4; + paint.PathEffect = effect; + canvas.DrawLine (10, step * 3, width - 10 - 10, step * 3, paint); + } + + } + [Flags] public enum Platform @@ -1014,6 +1048,7 @@ namespace SkiaSharp new Sample {Title="Chained Image Filter", Method = ChainedImageFilter, Platform = Platform.All}, new Sample {Title="Measure Text Sample", Method = MeasureTextSample, Platform = Platform.All}, new Sample {Title="Create PDF", Method = CreatePdfSample, Platform = Platform.All, TapMethod = CreatePdfSampleTapped}, + new Sample {Title="Path Effects", Method = PathEffects, Platform = Platform.All}, }; } } diff --git a/skia b/skia index 2e4ace62..e31d35bc 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 2e4ace6235c0515c65931e5c08b212f83e3081e4 +Subproject commit e31d35bc32be52f8e2c9da9628c89ca5646ad975