Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c252cac
Added the bits to support WinRT/UWP
mattleibow Apr 14, 2016
50e3914
Added methods to SkTypeface to read the actual name of the typeface f…
agallero May 1, 2016
32fc465
Changing the submodule schemes
mattleibow May 3, 2016
5ff18f1
Changing the submodule to https
mattleibow May 3, 2016
7d3f6f5
Get bits in place for UWP-master merge
mattleibow May 5, 2016
df15534
Merge branch 'master' into windows-uwp
mattleibow May 5, 2016
17436ad
Updated the native skia
mattleibow May 5, 2016
190919e
Updating Cake to fix NuGet resolver
mattleibow May 6, 2016
a03c96a
Use latest skia
mattleibow May 6, 2016
d28c77d
Binding does is AnyCPU - target includes vclibs
mattleibow May 6, 2016
37e1e50
Added UWP to the .nuspec
mattleibow May 6, 2016
3c02b8e
Copy the UWP outputs around
mattleibow May 6, 2016
d803ece
Native UWP:
mattleibow May 6, 2016
2012ffb
Update the UWP sample
mattleibow May 6, 2016
4338833
Fix typo in OSX demo.
bratsche May 8, 2016
795f4c2
Update NuGet so UWP builds
mattleibow May 10, 2016
aeaa18b
Removing the dot as this seems to be an issue...
mattleibow May 11, 2016
53d5436
Merge pull request #76 from mono/windows-uwp-merge
mattleibow May 12, 2016
fe23544
Update skia to the latest merge
mattleibow May 12, 2016
11685dc
Update README.md
mattleibow May 12, 2016
0c670d8
Merge pull request #80 from bratsche/fix-typo-skai
mattleibow May 12, 2016
272065c
Update README.md
mattleibow May 12, 2016
136d45e
Measure text now passes the correct byte array to the string methods
mattleibow May 12, 2016
b438db8
Demo showing measure text:
mattleibow May 12, 2016
328441c
Merge remote-tracking branch 'refs/remotes/mono/master' into typeface
agallero May 12, 2016
4c39b15
Merge remote-tracking branch 'mono/master' into typeface
agallero May 12, 2016
5b994dc
fixed whitespace
agallero May 12, 2016
22c721b
Added extended clipping features
mattleibow May 13, 2016
9434901
Add support for getting the clip bounds
mattleibow May 13, 2016
dcc8215
Merge branch 'typeface' of https://github.com/agallero/SkiaSharp into…
agallero May 13, 2016
c0cc2e1
update native skia
mattleibow May 13, 2016
024b5a9
update native skia
mattleibow May 13, 2016
5b90e16
update native skia
mattleibow May 13, 2016
9ada7e6
Changed sk_typeface_get_family_name to return an sk_string
agallero May 13, 2016
f6a0e7c
Rename Native Library [#77] (#81)
mattleibow May 13, 2016
c0c67cb
Corrected the targets file name
mattleibow May 14, 2016
641282f
added TryGetTableData to avoid Exceptions when a table doesn't exist
agallero May 14, 2016
602a75f
Updated the Windoews samples to use the nuew NuGet
mattleibow May 14, 2016
3cc8228
Updated the iOS/Android/Mac samples to use the new NuGet
mattleibow May 14, 2016
0178d55
Merge pull request #82 from mono/samples-update
mattleibow May 14, 2016
a0a2991
Added the Skia.Forms.Demo.UWP sample
mattleibow May 14, 2016
733264b
Make sure that if a method returns IntPtr.Zero, we return a NULL object
mattleibow May 14, 2016
03243d8
Added badges to the readme
mattleibow May 14, 2016
104a6d0
Merge remote-tracking branch 'mono/master' into typeface
agallero May 17, 2016
078fdb7
removed check for intptr.zero in SKTypeface constructor
agallero May 17, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ output/
binding/SkiaSharp.Portable/SkiaPortable.cs
docs/SkiaSharp.tree
docs/SkiaSharp.zip
*.VC.db

# User-specific files
*.suo
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "skia"]
path = skia
url = git@github.com:mono/skia.git
url = https://github.com/mono/skia.git
[submodule "depot_tools"]
path = depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SkiaSharp

[![Gitter.im](https://img.shields.io/badge/gitter.im-xamarin%2FXamarinComponents-E60256.svg)](https://gitter.im/xamarin/XamarinComponents) [![NuGet](https://img.shields.io/nuget/v/SkiaSharp.svg?maxAge=2592000)](https://www.nuget.org/packages/SkiaSharp) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/SkiaSharp.svg?maxAge=2592000)](https://www.nuget.org/packages/SkiaSharp)

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's
Skia Graphics Library (https://skia.org/). It provides a comprehensive 2D API that can
be used across mobile, server and desktop models to render images.
Expand All @@ -12,6 +14,7 @@ SkiaSharp provides a PCL and platform-specific bindings for:
- Xamarin.Android
- Xamarin.iOS
- Windows Desktop
- Windows UWP
- Mac Desktop

You can also build this on your particular variant of Unix
Expand Down Expand Up @@ -42,23 +45,16 @@ Run from Bash

### Windows

You need Python 2.7 in `PATH` environment variable. Then you need to run following commands from `skia` directory:

> ..\depot_tools\gclient.bat config --unmanaged https://github.com/mono/skia.git
> ..\depot_tools\gclient.bat sync

The process will take some time while gclient downloads Skia build dependencies.

Then you can finally build it:
You need Python 2.7 in `PATH` environment variable. Then you can build it:

> .\bootstrapper.ps1 -Target libs



There are several targets available:

- `externals` - builds all the native libraries
- [win] `externals-windows` - builds the native libraries for Windows
- [win] `externals-uwp` - builds the native libraries for Windows UWP
- [mac] `externals-osx` - builds the native libraries for Mac OS X
- [mac] `externals-ios` - builds the native libraries for iOS
- [mac] `externals-andoid` - builds the native libraries for Android
Expand All @@ -73,7 +69,7 @@ There are several targets available:
- `clean` - cleans everything
- `clean-externals` - cleans externals only

## Where is Windows Phone / Store / tvOS
## Where is Windows Phone 8 / Store 8 / tvOS

We are working to add binaries for these platforms, stay tuned for a future release
(or check the pull requests and branches, where we are working on those)
12 changes: 11 additions & 1 deletion binding/Binding/Definitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ public enum SKMatrixConvolutionTileMode
ClampToBlack,
}

public enum SKRegionOperation
{
Difference,
Intersect,
Union,
XOR,
ReverseDifference,
Replace,
}

[StructLayout(LayoutKind.Sequential)]
public struct SKImageInfo {
public static SKImageInfo Empty;
Expand Down Expand Up @@ -353,7 +363,7 @@ public SKRectI Rect {

[StructLayout(LayoutKind.Sequential)]
public struct SKSurfaceProps {
public SKPixelGeometry PixelGeometry { get; set; }
public SKPixelGeometry PixelGeometry;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down
3 changes: 3 additions & 0 deletions binding/Binding/SKBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ internal SKBitmap (IntPtr handle)
public SKBitmap ()
: this (SkiaApi.sk_bitmap_new ())
{
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException ("Unable to create a new SKBitmap instance.");
}
}

public SKBitmap (int width, int height, bool isOpaque = false)
Expand Down
18 changes: 14 additions & 4 deletions binding/Binding/SKCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,27 @@ public void Concat (ref SKMatrix m)
SkiaApi.sk_canvas_concat (Handle, ref m);
}

public void ClipRect (SKRect rect)
public void ClipRect (SKRect rect, SKRegionOperation operation = SKRegionOperation.Intersect, bool antialias = false)
{
SkiaApi.sk_canvas_clip_rect (Handle, ref rect);
SkiaApi.sk_canvas_clip_rect_with_operation (Handle, ref rect, operation, antialias);
}

public void ClipPath (SKPath path)
public void ClipPath (SKPath path, SKRegionOperation operation = SKRegionOperation.Intersect, bool antialias = false)
{
if (path == null)
throw new ArgumentNullException ("path");

SkiaApi.sk_canvas_clip_path (Handle, path.Handle);
SkiaApi.sk_canvas_clip_path_with_operation (Handle, path.Handle, operation, antialias);
}

public bool GetClipBounds (ref SKRect bounds)
{
return SkiaApi.sk_canvas_get_clip_bounds(Handle, ref bounds);
}

public bool GetClipDeviceBounds (ref SKRectI bounds)
{
return SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds);
}

public void DrawPaint (SKPaint paint)
Expand Down
16 changes: 8 additions & 8 deletions binding/Binding/SKColorFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ protected override void Dispose(bool disposing)

public static SKColorFilter CreateXferMode(SKColor c, SKXferMode mode)
{
return new SKColorFilter(SkiaApi.sk_colorfilter_new_mode(c, mode));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_mode(c, mode));
}

public static SKColorFilter CreateLighting(SKColor mul, SKColor add)
{
return new SKColorFilter(SkiaApi.sk_colorfilter_new_lighting(mul, add));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_lighting(mul, add));
}

public static SKColorFilter CreateCompose(SKColorFilter outer, SKColorFilter inner)
Expand All @@ -55,7 +55,7 @@ public static SKColorFilter CreateCompose(SKColorFilter outer, SKColorFilter inn
throw new ArgumentNullException("outer");
if (inner == null)
throw new ArgumentNullException("inner");
return new SKColorFilter(SkiaApi.sk_colorfilter_new_compose(outer.Handle, inner.Handle));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_compose(outer.Handle, inner.Handle));
}

public static SKColorFilter CreateColorCube(byte[] cubeData, int cubeDimension)
Expand All @@ -67,7 +67,7 @@ public static SKColorFilter CreateColorCube(SKData cubeData, int cubeDimension)
{
if (!IsValid3DColorCube(cubeData, cubeDimension))
throw new ArgumentNullException("cubeData");
return new SKColorFilter(SkiaApi.sk_colorfilter_new_color_cube(cubeData.Handle, cubeDimension));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_color_cube(cubeData.Handle, cubeDimension));
}

public static SKColorFilter CreateColorMatrix(float[] matrix)
Expand All @@ -76,12 +76,12 @@ public static SKColorFilter CreateColorMatrix(float[] matrix)
throw new ArgumentNullException("matrix");
if (matrix.Length != 20)
throw new ArgumentException("Matrix must have a length of 20.", "matrix");
return new SKColorFilter(SkiaApi.sk_colorfilter_new_color_matrix(matrix));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_color_matrix(matrix));
}

public static SKColorFilter CreateLumaColor()
{
return new SKColorFilter(SkiaApi.sk_colorfilter_new_luma_color());
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_luma_color());
}

public static SKColorFilter CreateTable(byte[] table)
Expand All @@ -90,7 +90,7 @@ public static SKColorFilter CreateTable(byte[] table)
throw new ArgumentNullException("table");
if (table.Length != 256)
throw new ArgumentException("Table must have a length of 256.", "table");
return new SKColorFilter(SkiaApi.sk_colorfilter_new_table(table));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_table(table));
}

public static SKColorFilter CreateTable(byte[] tableA, byte[] tableR, byte[] tableG, byte[] tableB)
Expand All @@ -103,7 +103,7 @@ public static SKColorFilter CreateTable(byte[] tableA, byte[] tableR, byte[] tab
throw new ArgumentException("Table G must have a length of 256.", "tableG");
if (tableB != null && tableB.Length != 256)
throw new ArgumentException("Table B must have a length of 256.", "tableB");
return new SKColorFilter(SkiaApi.sk_colorfilter_new_table_argb(tableA, tableR, tableG, tableB));
return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_table_argb(tableA, tableR, tableG, tableB));
}
}
}
13 changes: 11 additions & 2 deletions binding/Binding/SKData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ internal SKData (IntPtr x)
public SKData ()
: this (SkiaApi.sk_data_new_empty ())
{
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException ("Unable to create a new SKData instance.");
}
}

public SKData (IntPtr bytes, ulong length)
Expand All @@ -41,18 +44,24 @@ public SKData (IntPtr bytes, ulong length)
if (Marshal.SizeOf (typeof(IntPtr)) == 4 && length > UInt32.MaxValue)
throw new ArgumentException ("length", "The length exceeds the size of pointers");
Handle = SkiaApi.sk_data_new_with_copy (bytes, (IntPtr) length);
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException ("Unable to copy the SKData instance.");
}
}

public SKData (byte[] bytes)
: this (SkiaApi.sk_data_new_with_copy (bytes, (IntPtr) bytes.Length))
{
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException ("Unable to copy the SKData instance.");
}
}

public static SKData FromMallocMemory (IntPtr bytes, ulong length)
{
if (Marshal.SizeOf (typeof(IntPtr)) == 4 && length > UInt32.MaxValue)
throw new ArgumentException ("length", "The length exceeds the size of pointers");
return new SKData (SkiaApi.sk_data_new_from_malloc (bytes, (IntPtr) length));
return GetObject<SKData> (SkiaApi.sk_data_new_from_malloc (bytes, (IntPtr) length));
}

public SKData Subset (ulong offset, ulong length)
Expand All @@ -63,7 +72,7 @@ public SKData Subset (ulong offset, ulong length)
if (offset > UInt32.MaxValue)
throw new ArgumentException ("offset", "The length exceeds the size of pointers");
}
return new SKData (SkiaApi.sk_data_new_subset (Handle, (IntPtr) offset, (IntPtr) length));
return GetObject<SKData> (SkiaApi.sk_data_new_subset (Handle, (IntPtr) offset, (IntPtr) length));
}

public long Size => (long)SkiaApi.sk_data_get_size (Handle);
Expand Down
16 changes: 5 additions & 11 deletions binding/Binding/SKImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ internal SKImage (IntPtr x)
public static SKImage FromPixels (SKImageInfo info, IntPtr pixels, int rowBytes)
{
var handle = SkiaApi.sk_image_new_raster_copy (ref info, pixels, (IntPtr) rowBytes);
if (handle == IntPtr.Zero)
return null;
return new SKImage (handle);
return GetObject<SKImage> (handle);
}

public static SKImage FromData (SKData data, SKRectI subset)
Expand All @@ -53,9 +51,7 @@ public static SKImage FromData (SKData data, SKRectI subset)
throw new ArgumentNullException ("data");

var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, ref subset);
if (handle == IntPtr.Zero)
return null;
return new SKImage (handle);
return GetObject<SKImage> (handle);
}

public static SKImage FromData (SKData data)
Expand All @@ -64,19 +60,17 @@ public static SKImage FromData (SKData data)
throw new ArgumentNullException ("data");

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

public SKData Encode ()
{
return new SKData (SkiaApi.sk_image_encode (Handle));
return GetObject<SKData> (SkiaApi.sk_image_encode (Handle));
}

public SKData Encode (SKImageEncodeFormat format, int quality)
{
return new SKData (SkiaApi.sk_image_encode_specific (Handle, format, quality));
return GetObject<SKData> (SkiaApi.sk_image_encode_specific (Handle, format, quality));
}

public int Width => SkiaApi.sk_image_get_width (Handle);
Expand Down
2 changes: 1 addition & 1 deletion binding/Binding/SKImageDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public SKImageDecoder(SKStreamRewindable stream)
: this(SkiaApi.sk_imagedecoder_factory(stream.Handle))
{
if (Handle == IntPtr.Zero) {
throw new ArgumentException ("Unable to find a decoder for the sream.", "stream");
throw new ArgumentException ("Unable to find a decoder for the stream.", "stream");
}
}

Expand Down
Loading