Skip to content

Commit

Permalink
[WIP] Add interop redirection layer
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jun 30, 2019
1 parent 4a65093 commit a904780
Show file tree
Hide file tree
Showing 14 changed files with 3,690 additions and 43 deletions.
14 changes: 7 additions & 7 deletions binding/Binding/SKCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public int SaveLayer (SKRect limit, SKPaint paint)

public int SaveLayer (SKPaint paint)
{
return SkiaApi.sk_canvas_save_layer (Handle, IntPtr.Zero, paint == null ? IntPtr.Zero : paint.Handle);
return SkiaApi.sk_canvas_save_layer_2 (Handle, IntPtr.Zero, paint == null ? IntPtr.Zero : paint.Handle);
}

public void DrawColor (SKColor color, SKBlendMode mode = SKBlendMode.Src)
Expand Down Expand Up @@ -369,7 +369,7 @@ public void DrawImage (SKImage image, SKRect dest, SKPaint paint = null)
{
if (image == null)
throw new ArgumentNullException (nameof (image));
SkiaApi.sk_canvas_draw_image_rect (Handle, image.Handle, IntPtr.Zero, ref dest, paint == null ? IntPtr.Zero : paint.Handle);
SkiaApi.sk_canvas_draw_image_rect_2 (Handle, image.Handle, IntPtr.Zero, ref dest, paint == null ? IntPtr.Zero : paint.Handle);
}

public void DrawImage (SKImage image, SKRect source, SKRect dest, SKPaint paint = null)
Expand Down Expand Up @@ -401,7 +401,7 @@ public void DrawPicture (SKPicture picture, SKPaint paint = null)
{
if (picture == null)
throw new ArgumentNullException (nameof (picture));
SkiaApi.sk_canvas_draw_picture (Handle, picture.Handle, IntPtr.Zero, paint == null ? IntPtr.Zero : paint.Handle);
SkiaApi.sk_canvas_draw_picture_2 (Handle, picture.Handle, IntPtr.Zero, paint == null ? IntPtr.Zero : paint.Handle);
}

public void DrawDrawable (SKDrawable drawable, ref SKMatrix matrix)
Expand Down Expand Up @@ -443,7 +443,7 @@ public void DrawBitmap (SKBitmap bitmap, SKRect dest, SKPaint paint = null)
{
if (bitmap == null)
throw new ArgumentNullException (nameof (bitmap));
SkiaApi.sk_canvas_draw_bitmap_rect (Handle, bitmap.Handle, IntPtr.Zero, ref dest, paint == null ? IntPtr.Zero : paint.Handle);
SkiaApi.sk_canvas_draw_bitmap_rect_2 (Handle, bitmap.Handle, IntPtr.Zero, ref dest, paint == null ? IntPtr.Zero : paint.Handle);
}

public void DrawBitmap (SKBitmap bitmap, SKRect source, SKRect dest, SKPaint paint = null)
Expand Down Expand Up @@ -546,7 +546,7 @@ public void DrawTextOnPath (IntPtr buffer, int length, SKPath path, float hOffse
if (paint == null)
throw new ArgumentNullException (nameof (paint));

SkiaApi.sk_canvas_draw_text_on_path (Handle, buffer, length, path.Handle, hOffset, vOffset, paint.Handle);
SkiaApi.sk_canvas_draw_text_on_path_2 (Handle, buffer, length, path.Handle, hOffset, vOffset, paint.Handle);
}

public void DrawText (IntPtr buffer, int length, SKPoint p, SKPaint paint)
Expand All @@ -561,7 +561,7 @@ public void DrawText (IntPtr buffer, int length, float x, float y, SKPaint paint
if (paint == null)
throw new ArgumentNullException (nameof (paint));

SkiaApi.sk_canvas_draw_text (Handle, buffer, length, x, y, paint.Handle);
SkiaApi.sk_canvas_draw_text_2 (Handle, buffer, length, x, y, paint.Handle);
}

public void DrawPositionedText (IntPtr buffer, int length, SKPoint[] points, SKPaint paint)
Expand All @@ -573,7 +573,7 @@ public void DrawPositionedText (IntPtr buffer, int length, SKPoint[] points, SKP
if (points == null)
throw new ArgumentNullException (nameof (points));

SkiaApi.sk_canvas_draw_pos_text (Handle, buffer, length, points, paint.Handle);
SkiaApi.sk_canvas_draw_pos_text_2 (Handle, buffer, length, points, paint.Handle);
}

public void DrawTextOnPath (string text, SKPath path, SKPoint offset, SKPaint paint)
Expand Down
4 changes: 2 additions & 2 deletions binding/Binding/SKCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public SKCodecResult StartIncrementalDecode (SKImageInfo info, IntPtr pixels, in
public SKCodecResult StartIncrementalDecode (SKImageInfo info, IntPtr pixels, int rowBytes)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_incremental_decode (Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero);
return SkiaApi.sk_codec_start_incremental_decode_2 (Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero);
}

[Obsolete ("The Index8 color type and color table is no longer supported. Use StartIncrementalDecode(SKImageInfo, IntPtr, int, SKCodecOptions) instead.")]
Expand Down Expand Up @@ -235,7 +235,7 @@ public SKCodecResult StartScanlineDecode (SKImageInfo info, SKCodecOptions optio
public SKCodecResult StartScanlineDecode (SKImageInfo info)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_scanline_decode (Handle, ref cinfo, IntPtr.Zero);
return SkiaApi.sk_codec_start_scanline_decode_2 (Handle, ref cinfo, IntPtr.Zero);
}

[Obsolete ("The Index8 color type and color table is no longer supported. Use StartScanlineDecode(SKImageInfo, SKCodecOptions) instead.")]
Expand Down
4 changes: 2 additions & 2 deletions binding/Binding/SKColorSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ public static SKColorSpace CreateIcc (byte[] input, long length)
if (input == null)
throw new ArgumentNullException (nameof (input));

return GetObject<SKColorSpace> (SkiaApi.sk_colorspace_new_icc (input, (IntPtr)length));
return GetObject<SKColorSpace> (SkiaApi.sk_colorspace_new_icc_2 (input, (IntPtr)length));
}

public static SKColorSpace CreateIcc (byte[] input)
{
if (input == null)
throw new ArgumentNullException (nameof (input));

return GetObject<SKColorSpace> (SkiaApi.sk_colorspace_new_icc (input, (IntPtr)input.Length));
return GetObject<SKColorSpace> (SkiaApi.sk_colorspace_new_icc_2 (input, (IntPtr)input.Length));
}

[Obsolete ("Use CreateRgb (SKColorSpaceRenderTargetGamma, SKMatrix44) instead.")]
Expand Down
2 changes: 1 addition & 1 deletion binding/Binding/SKData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static SKData CreateCopy (byte[] bytes) =>
CreateCopy (bytes, (ulong)bytes.Length);

public static SKData CreateCopy (byte[] bytes, ulong length) =>
GetObject<SKData> (SkiaApi.sk_data_new_with_copy (bytes, (IntPtr)length));
GetObject<SKData> (SkiaApi.sk_data_new_with_copy_2 (bytes, (IntPtr)length));

public static SKData CreateCopy (ReadOnlySpan<byte> bytes)
{
Expand Down
2 changes: 1 addition & 1 deletion binding/Binding/SKDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Abort () =>
SkiaApi.sk_document_abort (Handle);

public SKCanvas BeginPage (float width, float height) =>
GetObject<SKCanvas> (SkiaApi.sk_document_begin_page (Handle, width, height, IntPtr.Zero), false);
GetObject<SKCanvas> (SkiaApi.sk_document_begin_page_2 (Handle, width, height, IntPtr.Zero), false);

public SKCanvas BeginPage (float width, float height, SKRect content) =>
GetObject<SKCanvas> (SkiaApi.sk_document_begin_page (Handle, width, height, ref content), false);
Expand Down
6 changes: 3 additions & 3 deletions binding/Binding/SKImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static SKImage FromEncodedData (SKData data)
if (data == null)
throw new ArgumentNullException (nameof (data));

var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, IntPtr.Zero);
var handle = SkiaApi.sk_image_new_from_encoded_2 (data.Handle, IntPtr.Zero);
return GetObject<SKImage> (handle);
}

Expand Down Expand Up @@ -458,7 +458,7 @@ public static SKImage FromPicture (SKPicture picture, SKSizeI dimensions, SKPain
throw new ArgumentNullException (nameof (picture));

var p = (paint == null ? IntPtr.Zero : paint.Handle);
return GetObject<SKImage> (SkiaApi.sk_image_new_from_picture (picture.Handle, ref dimensions, IntPtr.Zero, p));
return GetObject<SKImage> (SkiaApi.sk_image_new_from_picture_2 (picture.Handle, ref dimensions, IntPtr.Zero, p));
}

public static SKImage FromPicture (SKPicture picture, SKSizeI dimensions, SKMatrix matrix, SKPaint paint)
Expand Down Expand Up @@ -531,7 +531,7 @@ public SKData Encode (SKEncodedImageFormat format, int quality)

public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY)
{
return GetObject<SKShader> (SkiaApi.sk_image_make_shader (Handle, tileX, tileY, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_image_make_shader_2 (Handle, tileX, tileY, IntPtr.Zero));
}

public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKMatrix localMatrix)
Expand Down
6 changes: 3 additions & 3 deletions binding/Binding/SKPaint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public SKPathEffect PathEffect {
}

public float FontSpacing =>
SkiaApi.sk_paint_get_fontmetrics (Handle, IntPtr.Zero, 0);
SkiaApi.sk_paint_get_fontmetrics_2 (Handle, IntPtr.Zero, 0);

public SKFontMetrics FontMetrics {
get {
Expand Down Expand Up @@ -234,7 +234,7 @@ public float MeasureText (IntPtr buffer, IntPtr length)
if (buffer == IntPtr.Zero && length != IntPtr.Zero)
throw new ArgumentNullException (nameof (buffer));

return SkiaApi.sk_paint_measure_text (Handle, buffer, length, IntPtr.Zero);
return SkiaApi.sk_paint_measure_text_2 (Handle, buffer, length, IntPtr.Zero);
}

public float MeasureText (string text, ref SKRect bounds)
Expand Down Expand Up @@ -436,7 +436,7 @@ public bool GetFillPath (SKPath src, SKPath dst, float resScale)
if (dst == null)
throw new ArgumentNullException (nameof (dst));

return SkiaApi.sk_paint_get_fill_path (Handle, src.Handle, dst.Handle, IntPtr.Zero, resScale);
return SkiaApi.sk_paint_get_fill_path_2 (Handle, src.Handle, dst.Handle, IntPtr.Zero, resScale);
}

public bool GetFillPath (SKPath src, SKPath dst, SKRect cullRect)
Expand Down
6 changes: 3 additions & 3 deletions binding/Binding/SKPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public SKPathConvexity Convexity {

public bool IsEmpty => VerbCount == 0;

public bool IsOval => SkiaApi.sk_path_is_oval (Handle, IntPtr.Zero);
public bool IsOval => SkiaApi.sk_path_is_oval_2 (Handle, IntPtr.Zero);

public bool IsRoundRect => SkiaApi.sk_path_is_rrect (Handle, IntPtr.Zero);

public bool IsLine => SkiaApi.sk_path_is_line (Handle, IntPtr.Zero);
public bool IsLine => SkiaApi.sk_path_is_line_2 (Handle, IntPtr.Zero);

public bool IsRect => SkiaApi.sk_path_is_rect (Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
public bool IsRect => SkiaApi.sk_path_is_rect_2 (Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

public SKPathSegmentMask SegmentMasks => SkiaApi.sk_path_get_segment_masks (Handle);

Expand Down
4 changes: 2 additions & 2 deletions binding/Binding/SKPathMeasure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public bool GetPositionAndTangent (float distance, out SKPoint position, out SKP

public bool GetPosition (float distance, out SKPoint position)
{
return SkiaApi.sk_pathmeasure_get_pos_tan (Handle, distance, out position, IntPtr.Zero);
return SkiaApi.sk_pathmeasure_get_pos_tan_3 (Handle, distance, out position, IntPtr.Zero);
}

public bool GetTangent (float distance, out SKPoint tangent)
{
return SkiaApi.sk_pathmeasure_get_pos_tan (Handle, distance, IntPtr.Zero, out tangent);
return SkiaApi.sk_pathmeasure_get_pos_tan_2 (Handle, distance, IntPtr.Zero, out tangent);
}

public bool GetMatrix (float distance, out SKMatrix matrix, SKPathMeasureMatrixFlags flags)
Expand Down
30 changes: 15 additions & 15 deletions binding/Binding/SKShader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShade
{
if (src == null)
throw new ArgumentNullException (nameof (src));
return GetObject<SKShader> (SkiaApi.sk_shader_new_bitmap (src.Handle, tmx, tmy, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_bitmap_2 (src.Handle, tmx, tmy, IntPtr.Zero));
}

public static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix)
Expand Down Expand Up @@ -64,11 +64,11 @@ public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient (new SKPoint [] { start, end }, colors, IntPtr.Zero, colors.Length, mode, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient_4 (new SKPoint [] { start, end }, colors, IntPtr.Zero, colors.Length, mode, IntPtr.Zero));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient (new SKPoint [] { start, end }, colors, colorPos, colors.Length, mode, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient_2 (new SKPoint [] { start, end }, colors, colorPos, colors.Length, mode, IntPtr.Zero));
}
}

Expand All @@ -77,7 +77,7 @@ public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient (new SKPoint [] { start, end }, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient_3 (new SKPoint [] { start, end }, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
Expand All @@ -90,11 +90,11 @@ public static SKShader CreateRadialGradient (SKPoint center, float radius, SKCol
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_radial_gradient (ref center, radius, colors, IntPtr.Zero, colors.Length, mode, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_radial_gradient_4 (ref center, radius, colors, IntPtr.Zero, colors.Length, mode, IntPtr.Zero));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
return GetObject<SKShader> (SkiaApi.sk_shader_new_radial_gradient (ref center, radius, colors, colorPos, colors.Length, mode, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_radial_gradient_2 (ref center, radius, colors, colorPos, colors.Length, mode, IntPtr.Zero));
}
}

Expand All @@ -103,7 +103,7 @@ public static SKShader CreateRadialGradient (SKPoint center, float radius, SKCol
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_radial_gradient (ref center, radius, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
return GetObject<SKShader> (SkiaApi.sk_shader_new_radial_gradient_3 (ref center, radius, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
Expand All @@ -126,7 +126,7 @@ public static SKShader CreateSweepGradient (SKPoint center, SKColor [] colors, f
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient (ref center, colors, IntPtr.Zero, colors.Length, tileMode, startAngle, endAngle, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient_3 (ref center, colors, IntPtr.Zero, colors.Length, tileMode, startAngle, endAngle, IntPtr.Zero));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
Expand All @@ -139,11 +139,11 @@ public static SKShader CreateSweepGradient (SKPoint center, SKColor [] colors, f
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient (ref center, colors, IntPtr.Zero, colors.Length, tileMode, startAngle, endAngle, ref localMatrix));
return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient_4 (ref center, colors, IntPtr.Zero, colors.Length, tileMode, startAngle, endAngle, ref localMatrix));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient (ref center, colors, colorPos, colors.Length, tileMode, startAngle, endAngle, ref localMatrix));
return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient_2 (ref center, colors, colorPos, colors.Length, tileMode, startAngle, endAngle, ref localMatrix));
}
}

Expand All @@ -152,11 +152,11 @@ public static SKShader CreateTwoPointConicalGradient (SKPoint start, float start
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, IntPtr.Zero, colors.Length, mode, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient_4 (ref start, startRadius, ref end, endRadius, colors, IntPtr.Zero, colors.Length, mode, IntPtr.Zero));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, colorPos, colors.Length, mode, IntPtr.Zero));
return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient_2 (ref start, startRadius, ref end, endRadius, colors, colorPos, colors.Length, mode, IntPtr.Zero));
}
}

Expand All @@ -165,7 +165,7 @@ public static SKShader CreateTwoPointConicalGradient (SKPoint start, float start
if (colors == null)
throw new ArgumentNullException (nameof (colors));
if (colorPos == null) {
return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient_3 (ref start, startRadius, ref end, endRadius, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
} else {
if (colors.Length != colorPos.Length)
throw new ArgumentException ("The number of colors must match the number of color positions.");
Expand All @@ -180,7 +180,7 @@ public static SKShader CreatePerlinNoiseFractalNoise(float baseFrequencyX, float

public static SKShader CreatePerlinNoiseFractalNoise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKPointI tileSize)
{
return GetObject<SKShader>(SkiaApi.sk_shader_new_perlin_noise_fractal_noise(baseFrequencyX, baseFrequencyY, numOctaves, seed, ref tileSize));
return GetObject<SKShader>(SkiaApi.sk_shader_new_perlin_noise_fractal_noise_2(baseFrequencyX, baseFrequencyY, numOctaves, seed, ref tileSize));
}

public static SKShader CreatePerlinNoiseTurbulence(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed)
Expand All @@ -190,7 +190,7 @@ public static SKShader CreatePerlinNoiseTurbulence(float baseFrequencyX, float b

public static SKShader CreatePerlinNoiseTurbulence(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, SKPointI tileSize)
{
return GetObject<SKShader>(SkiaApi.sk_shader_new_perlin_noise_turbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, ref tileSize));
return GetObject<SKShader>(SkiaApi.sk_shader_new_perlin_noise_turbulence_2(baseFrequencyX, baseFrequencyY, numOctaves, seed, ref tileSize));
}

public static SKShader CreateCompose (SKShader shaderA, SKShader shaderB)
Expand Down
2 changes: 1 addition & 1 deletion binding/Binding/SKStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ internal void SetMemory (IntPtr data, IntPtr length, bool copyData = false)

internal void SetMemory (byte[] data, IntPtr length, bool copyData = false)
{
SkiaApi.sk_memorystream_set_memory (Handle, data, length, copyData);
SkiaApi.sk_memorystream_set_memory_2 (Handle, data, length, copyData);
}

public void SetMemory (byte[] data)
Expand Down
Loading

0 comments on commit a904780

Please sign in to comment.