From c53ab2b03bdbb3a18eacd8812b93bdea16f4b583 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 28 Jun 2016 20:03:13 -0400 Subject: [PATCH] [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 44cb82fa0..eb376c277 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 eb1c6f426..eefacb20a 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 ea2567c21..78c7094fd 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 68a830fa1..c3441cb66 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 d47602f54..bd3e16310 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 b74846785..9372b7d0a 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 1298747f1..dc36a6813 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 4cd61dc5e..2d35987d8 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 4cd61dc5e7f5b7b79b3a2815798c4d7479aad51d +Subproject commit 2d35987d8ad6e25e2126998d8585fbb7a1b20fd2