diff --git a/binding/Binding/SKCanvas.cs b/binding/Binding/SKCanvas.cs index ff5f2946..17e2e404 100644 --- a/binding/Binding/SKCanvas.cs +++ b/binding/Binding/SKCanvas.cs @@ -415,7 +415,16 @@ namespace SkiaSharp { if (drawable == null) throw new ArgumentNullException (nameof (drawable)); - SkiaApi.sk_canvas_draw_drawable (Handle, drawable.Handle, x, y); + var matrix = SKMatrix.MakeTranslation (x, y); + DrawDrawable (drawable, ref matrix); + } + + public void DrawDrawable (SKDrawable drawable, SKPoint p) + { + if (drawable == null) + throw new ArgumentNullException (nameof (drawable)); + var matrix = SKMatrix.MakeTranslation (p.X, p.Y); + DrawDrawable (drawable, ref matrix); } public void DrawBitmap (SKBitmap bitmap, SKPoint p, SKPaint paint = null) diff --git a/binding/Binding/SKDrawable.cs b/binding/Binding/SKDrawable.cs index 641c2df2..87fa227b 100644 --- a/binding/Binding/SKDrawable.cs +++ b/binding/Binding/SKDrawable.cs @@ -86,35 +86,26 @@ namespace SkiaSharp } } - public void Draw (SKCanvas canvas, ref SKMatrix matrix) - { + public void Draw (SKCanvas canvas, ref SKMatrix matrix) => SkiaApi.sk_drawable_draw (Handle, canvas.Handle, ref matrix); - } public void Draw (SKCanvas canvas, float x, float y) { var matrix = SKMatrix.MakeTranslation (x, y); - SkiaApi.sk_drawable_draw (Handle, canvas.Handle, ref matrix); + Draw (canvas, ref matrix); } - public SKPicture Snapshot () - { - return GetObject (SkiaApi.sk_drawable_new_picture_snapshot (Handle)); - } + public SKPicture Snapshot () => + GetObject (SkiaApi.sk_drawable_new_picture_snapshot (Handle)); - public void NotifyDrawingChanged () - { + public void NotifyDrawingChanged () => SkiaApi.sk_drawable_notify_drawing_changed (Handle); - } protected virtual void OnDraw (SKCanvas canvas) { } - protected virtual SKRect OnGetBounds () - { - return new SKRect (); - } + protected virtual SKRect OnGetBounds () => new SKRect (); protected virtual SKPicture OnSnapshot () { @@ -132,13 +123,13 @@ namespace SkiaSharp AsManagedDrawable (managedDrawablePtr).OnDraw (GetObject (canvas)); } - [MonoPInvokeCallback(typeof(getBounds_delegate))] + [MonoPInvokeCallback (typeof (getBounds_delegate))] private static void GetBoundsInternal (IntPtr managedDrawablePtr, out SKRect rect) { rect = AsManagedDrawable (managedDrawablePtr).OnGetBounds (); } - [MonoPInvokeCallback(typeof(newPictureSnapshot_delegate))] + [MonoPInvokeCallback (typeof (newPictureSnapshot_delegate))] private static IntPtr NewPictureSnapshotInternal (IntPtr managedDrawablePtr) { return AsManagedDrawable (managedDrawablePtr).OnSnapshot ().Handle; diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index 66003943..fc5d38bb 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -252,8 +252,6 @@ namespace SkiaSharp [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_canvas_draw_drawable (sk_canvas_t t, sk_manageddrawable_t drawable, ref SKMatrix mat); [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static void sk_canvas_draw_drawable (sk_canvas_t t, sk_manageddrawable_t drawable, float x, float y); - [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_canvas_draw_color (sk_canvas_t t, SKColor color, SKBlendMode mode); [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_canvas_draw_points (sk_canvas_t t, SKPointMode mode, size_t count, [In] SKPoint[] points, sk_paint_t paint); diff --git a/externals/skia b/externals/skia index 8cdd3f37..1277dec3 160000 --- a/externals/skia +++ b/externals/skia @@ -1 +1 @@ -Subproject commit 8cdd3f3790dbb78ebbbc42ff0b85711693fb5fb2 +Subproject commit 1277dec3a2554163a18b3ec87d801edec12929d0 diff --git a/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj b/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj index 17f59423..59e1c30f 100644 --- a/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj +++ b/native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 3419BFDF21D405AA0067DAFB /* SkManagedDrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3419BFDD21D405AA0067DAFB /* SkManagedDrawable.h */; }; + 3419BFE021D405AA0067DAFB /* sk_manageddrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3419BFDE21D405AA0067DAFB /* sk_manageddrawable.h */; }; + 3419BFE321D405B20067DAFB /* SkManagedDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3419BFE121D405B20067DAFB /* SkManagedDrawable.cpp */; }; + 3419BFE421D405B20067DAFB /* sk_manageddrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3419BFE221D405B20067DAFB /* sk_manageddrawable.cpp */; }; 345A7E581E7635B10046F543 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 345A7E571E7635B10046F543 /* CoreGraphics.framework */; }; 345A7E5A1E7635B50046F543 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 345A7E591E7635B50046F543 /* CoreFoundation.framework */; }; 345A7E5C1E7635B90046F543 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 345A7E5B1E7635B90046F543 /* CoreText.framework */; }; @@ -25,6 +29,10 @@ /* Begin PBXFileReference section */ 21FD2B301C014C000023CFAE /* libSkiaSharp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = libSkiaSharp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 21FD2B351C014C000023CFAE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3419BFDD21D405AA0067DAFB /* SkManagedDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkManagedDrawable.h; path = ../../../externals/skia/include/xamarin/SkManagedDrawable.h; sourceTree = ""; }; + 3419BFDE21D405AA0067DAFB /* sk_manageddrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_manageddrawable.h; path = ../../../externals/skia/include/xamarin/sk_manageddrawable.h; sourceTree = ""; }; + 3419BFE121D405B20067DAFB /* SkManagedDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkManagedDrawable.cpp; path = ../../../externals/skia/src/xamarin/SkManagedDrawable.cpp; sourceTree = ""; }; + 3419BFE221D405B20067DAFB /* sk_manageddrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sk_manageddrawable.cpp; path = ../../../externals/skia/src/xamarin/sk_manageddrawable.cpp; sourceTree = ""; }; 345A7E571E7635B10046F543 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 345A7E591E7635B50046F543 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 345A7E5B1E7635B90046F543 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; @@ -76,11 +84,15 @@ children = ( 21FD2B351C014C000023CFAE /* Info.plist */, 34C0C90320573CBE00DFDB22 /* libSkiaSharp.h */, + 3419BFE221D405B20067DAFB /* sk_manageddrawable.cpp */, + 3419BFDE21D405AA0067DAFB /* sk_manageddrawable.h */, 34CB9AC4205699BC00BACCBA /* sk_managedstream.cpp */, 34CB9AD3205699C400BACCBA /* sk_managedstream.h */, 34CB9AC6205699BC00BACCBA /* sk_xamarin.cpp */, 34CB9AD5205699C400BACCBA /* sk_xamarin.h */, 34CB9AC8205699BC00BACCBA /* SkiaKeeper.c */, + 3419BFE121D405B20067DAFB /* SkManagedDrawable.cpp */, + 3419BFDD21D405AA0067DAFB /* SkManagedDrawable.h */, 34CB9AC5205699BC00BACCBA /* SkManagedStream.cpp */, 34CB9AD2205699C300BACCBA /* SkManagedStream.h */, 34CB9AC3205699BC00BACCBA /* WinRTCompat.cpp */, @@ -107,8 +119,10 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 3419BFDF21D405AA0067DAFB /* SkManagedDrawable.h in Headers */, 34CB9ADC205699C400BACCBA /* WinRTCompat.h in Headers */, 34C0C90420573CBE00DFDB22 /* libSkiaSharp.h in Headers */, + 3419BFE021D405AA0067DAFB /* sk_manageddrawable.h in Headers */, 34CB9AD8205699C400BACCBA /* SkManagedStream.h in Headers */, 34CB9ADB205699C400BACCBA /* sk_xamarin.h in Headers */, 34CB9AD9205699C400BACCBA /* sk_managedstream.h in Headers */, @@ -183,9 +197,11 @@ buildActionMask = 2147483647; files = ( 34CB9ACD205699BC00BACCBA /* sk_xamarin.cpp in Sources */, + 3419BFE321D405B20067DAFB /* SkManagedDrawable.cpp in Sources */, 34CB9ACA205699BC00BACCBA /* WinRTCompat.cpp in Sources */, 34CB9ACC205699BC00BACCBA /* SkManagedStream.cpp in Sources */, 34CB9ACB205699BC00BACCBA /* sk_managedstream.cpp in Sources */, + 3419BFE421D405B20067DAFB /* sk_manageddrawable.cpp in Sources */, 34CB9ACF205699BC00BACCBA /* SkiaKeeper.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/native-builds/libSkiaSharp_osx/libSkiaSharp.xcodeproj/project.pbxproj b/native-builds/libSkiaSharp_osx/libSkiaSharp.xcodeproj/project.pbxproj index c79671ad..5a1135c9 100644 --- a/native-builds/libSkiaSharp_osx/libSkiaSharp.xcodeproj/project.pbxproj +++ b/native-builds/libSkiaSharp_osx/libSkiaSharp.xcodeproj/project.pbxproj @@ -20,6 +20,10 @@ 3459E852205698D2003EAD17 /* sk_managedstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459E84C205698D2003EAD17 /* sk_managedstream.h */; }; 3459E854205698D2003EAD17 /* sk_xamarin.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459E84E205698D2003EAD17 /* sk_xamarin.h */; }; 3459E855205698D2003EAD17 /* WinRTCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459E84F205698D2003EAD17 /* WinRTCompat.h */; }; + 346D1BC321D405D30066C82D /* SkManagedDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 346D1BBF21D405D30066C82D /* SkManagedDrawable.cpp */; }; + 346D1BC421D405D30066C82D /* sk_manageddrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 346D1BC021D405D30066C82D /* sk_manageddrawable.h */; }; + 346D1BC521D405D30066C82D /* sk_manageddrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 346D1BC121D405D30066C82D /* sk_manageddrawable.cpp */; }; + 346D1BC621D405D30066C82D /* SkManagedDrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 346D1BC221D405D30066C82D /* SkManagedDrawable.h */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -39,6 +43,10 @@ 3459E84C205698D2003EAD17 /* sk_managedstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_managedstream.h; path = ../../../externals/skia/include/xamarin/sk_managedstream.h; sourceTree = ""; }; 3459E84E205698D2003EAD17 /* sk_xamarin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_xamarin.h; path = ../../../externals/skia/include/xamarin/sk_xamarin.h; sourceTree = ""; }; 3459E84F205698D2003EAD17 /* WinRTCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WinRTCompat.h; path = ../../../externals/skia/include/xamarin/WinRTCompat.h; sourceTree = ""; }; + 346D1BBF21D405D30066C82D /* SkManagedDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkManagedDrawable.cpp; path = ../../../externals/skia/src/xamarin/SkManagedDrawable.cpp; sourceTree = ""; }; + 346D1BC021D405D30066C82D /* sk_manageddrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_manageddrawable.h; path = ../../../externals/skia/include/xamarin/sk_manageddrawable.h; sourceTree = ""; }; + 346D1BC121D405D30066C82D /* sk_manageddrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sk_manageddrawable.cpp; path = ../../../externals/skia/src/xamarin/sk_manageddrawable.cpp; sourceTree = ""; }; + 346D1BC221D405D30066C82D /* SkManagedDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkManagedDrawable.h; path = ../../../externals/skia/include/xamarin/SkManagedDrawable.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -89,11 +97,15 @@ 3459E8202056989E003EAD17 /* Source */ = { isa = PBXGroup; children = ( + 346D1BC121D405D30066C82D /* sk_manageddrawable.cpp */, + 346D1BC021D405D30066C82D /* sk_manageddrawable.h */, 3459E83D205698C6003EAD17 /* sk_managedstream.cpp */, 3459E84C205698D2003EAD17 /* sk_managedstream.h */, 3459E83F205698C6003EAD17 /* sk_xamarin.cpp */, 3459E84E205698D2003EAD17 /* sk_xamarin.h */, 3459E841205698C7003EAD17 /* SkiaKeeper.c */, + 346D1BBF21D405D30066C82D /* SkManagedDrawable.cpp */, + 346D1BC221D405D30066C82D /* SkManagedDrawable.h */, 3459E83E205698C6003EAD17 /* SkManagedStream.cpp */, 3459E84B205698D2003EAD17 /* SkManagedStream.h */, 3459E83C205698C6003EAD17 /* WinRTCompat.cpp */, @@ -109,7 +121,9 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 346D1BC621D405D30066C82D /* SkManagedDrawable.h in Headers */, 3459E851205698D2003EAD17 /* SkManagedStream.h in Headers */, + 346D1BC421D405D30066C82D /* sk_manageddrawable.h in Headers */, 3459E852205698D2003EAD17 /* sk_managedstream.h in Headers */, 3459E855205698D2003EAD17 /* WinRTCompat.h in Headers */, 3459E854205698D2003EAD17 /* sk_xamarin.h in Headers */, @@ -173,9 +187,11 @@ buildActionMask = 2147483647; files = ( 3459E846205698C7003EAD17 /* sk_xamarin.cpp in Sources */, + 346D1BC321D405D30066C82D /* SkManagedDrawable.cpp in Sources */, 3459E843205698C7003EAD17 /* WinRTCompat.cpp in Sources */, 3459E845205698C7003EAD17 /* SkManagedStream.cpp in Sources */, 3459E844205698C7003EAD17 /* sk_managedstream.cpp in Sources */, + 346D1BC521D405D30066C82D /* sk_manageddrawable.cpp in Sources */, 3459E848205698C7003EAD17 /* SkiaKeeper.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/native-builds/libSkiaSharp_tizen/project_def.prop b/native-builds/libSkiaSharp_tizen/project_def.prop index 10d14915..96ab4fc2 100755 --- a/native-builds/libSkiaSharp_tizen/project_def.prop +++ b/native-builds/libSkiaSharp_tizen/project_def.prop @@ -45,4 +45,6 @@ USER_CPP_OPTS = $(USER_C_OPTS) -std=c++11 -fno-threadsafe-statics -Wnon-virtual- USER_SRCS = ../../externals/skia/src/xamarin/sk_xamarin.cpp \ ../../externals/skia/src/xamarin/SkiaKeeper.c \ ../../externals/skia/src/xamarin/sk_managedstream.cpp \ - ../../externals/skia/src/xamarin/SkManagedStream.cpp + ../../externals/skia/src/xamarin/SkManagedStream.cpp \ + ../../externals/skia/src/xamarin/sk_manageddrawable.cpp \ + ../../externals/skia/src/xamarin/SkManagedDrawable.cpp diff --git a/native-builds/libSkiaSharp_tvos/libSkiaSharp.xcodeproj/project.pbxproj b/native-builds/libSkiaSharp_tvos/libSkiaSharp.xcodeproj/project.pbxproj index a4ef8ea5..0e40a302 100644 --- a/native-builds/libSkiaSharp_tvos/libSkiaSharp.xcodeproj/project.pbxproj +++ b/native-builds/libSkiaSharp_tvos/libSkiaSharp.xcodeproj/project.pbxproj @@ -19,6 +19,10 @@ 34838CFF20569A1A009CB8D9 /* sk_managedstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 34838CF920569A1A009CB8D9 /* sk_managedstream.h */; }; 34838D0120569A1A009CB8D9 /* sk_xamarin.h in Headers */ = {isa = PBXBuildFile; fileRef = 34838CFB20569A1A009CB8D9 /* sk_xamarin.h */; }; 34838D0220569A1A009CB8D9 /* WinRTCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 34838CFC20569A1A009CB8D9 /* WinRTCompat.h */; }; + 34A5548421D405F000F06E1B /* SkManagedDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34A5548021D405F000F06E1B /* SkManagedDrawable.cpp */; }; + 34A5548521D405F000F06E1B /* sk_manageddrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 34A5548121D405F000F06E1B /* sk_manageddrawable.h */; }; + 34A5548621D405F000F06E1B /* sk_manageddrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34A5548221D405F000F06E1B /* sk_manageddrawable.cpp */; }; + 34A5548721D405F000F06E1B /* SkManagedDrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 34A5548321D405F000F06E1B /* SkManagedDrawable.h */; }; 34C0C90620573CD300DFDB22 /* libSkiaSharp.h in Headers */ = {isa = PBXBuildFile; fileRef = 34C0C90520573CD300DFDB22 /* libSkiaSharp.h */; }; /* End PBXBuildFile section */ @@ -37,6 +41,10 @@ 34838CF920569A1A009CB8D9 /* sk_managedstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_managedstream.h; path = ../../../externals/skia/include/xamarin/sk_managedstream.h; sourceTree = ""; }; 34838CFB20569A1A009CB8D9 /* sk_xamarin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_xamarin.h; path = ../../../externals/skia/include/xamarin/sk_xamarin.h; sourceTree = ""; }; 34838CFC20569A1A009CB8D9 /* WinRTCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WinRTCompat.h; path = ../../../externals/skia/include/xamarin/WinRTCompat.h; sourceTree = ""; }; + 34A5548021D405F000F06E1B /* SkManagedDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkManagedDrawable.cpp; path = ../../../externals/skia/src/xamarin/SkManagedDrawable.cpp; sourceTree = ""; }; + 34A5548121D405F000F06E1B /* sk_manageddrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_manageddrawable.h; path = ../../../externals/skia/include/xamarin/sk_manageddrawable.h; sourceTree = ""; }; + 34A5548221D405F000F06E1B /* sk_manageddrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sk_manageddrawable.cpp; path = ../../../externals/skia/src/xamarin/sk_manageddrawable.cpp; sourceTree = ""; }; + 34A5548321D405F000F06E1B /* SkManagedDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkManagedDrawable.h; path = ../../../externals/skia/include/xamarin/SkManagedDrawable.h; sourceTree = ""; }; 34C0C90520573CD300DFDB22 /* libSkiaSharp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libSkiaSharp.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -76,11 +84,15 @@ children = ( 21FD2B351C014C000023CFAE /* Info.plist */, 34C0C90520573CD300DFDB22 /* libSkiaSharp.h */, + 34A5548221D405F000F06E1B /* sk_manageddrawable.cpp */, + 34A5548121D405F000F06E1B /* sk_manageddrawable.h */, 34838CEA20569A14009CB8D9 /* sk_managedstream.cpp */, 34838CF920569A1A009CB8D9 /* sk_managedstream.h */, 34838CEC20569A14009CB8D9 /* sk_xamarin.cpp */, 34838CFB20569A1A009CB8D9 /* sk_xamarin.h */, 34838CEE20569A14009CB8D9 /* SkiaKeeper.c */, + 34A5548021D405F000F06E1B /* SkManagedDrawable.cpp */, + 34A5548321D405F000F06E1B /* SkManagedDrawable.h */, 34838CEB20569A14009CB8D9 /* SkManagedStream.cpp */, 34838CF820569A1A009CB8D9 /* SkManagedStream.h */, 34838CE920569A14009CB8D9 /* WinRTCompat.cpp */, @@ -108,9 +120,11 @@ buildActionMask = 2147483647; files = ( 34838CFE20569A1A009CB8D9 /* SkManagedStream.h in Headers */, + 34A5548721D405F000F06E1B /* SkManagedDrawable.h in Headers */, 34C0C90620573CD300DFDB22 /* libSkiaSharp.h in Headers */, 34838CFF20569A1A009CB8D9 /* sk_managedstream.h in Headers */, 34838D0220569A1A009CB8D9 /* WinRTCompat.h in Headers */, + 34A5548521D405F000F06E1B /* sk_manageddrawable.h in Headers */, 34838D0120569A1A009CB8D9 /* sk_xamarin.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -183,9 +197,11 @@ buildActionMask = 2147483647; files = ( 34838CF320569A14009CB8D9 /* sk_xamarin.cpp in Sources */, + 34A5548421D405F000F06E1B /* SkManagedDrawable.cpp in Sources */, 34838CF020569A14009CB8D9 /* WinRTCompat.cpp in Sources */, 34838CF220569A14009CB8D9 /* SkManagedStream.cpp in Sources */, 34838CF120569A14009CB8D9 /* sk_managedstream.cpp in Sources */, + 34A5548621D405F000F06E1B /* sk_manageddrawable.cpp in Sources */, 34838CF520569A14009CB8D9 /* SkiaKeeper.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/native-builds/libSkiaSharp_watchos/libSkiaSharp.xcodeproj/project.pbxproj b/native-builds/libSkiaSharp_watchos/libSkiaSharp.xcodeproj/project.pbxproj index 3cb40d16..4b44d28d 100644 --- a/native-builds/libSkiaSharp_watchos/libSkiaSharp.xcodeproj/project.pbxproj +++ b/native-builds/libSkiaSharp_watchos/libSkiaSharp.xcodeproj/project.pbxproj @@ -11,6 +11,10 @@ 344D83FC1E76CF0700C6D598 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 344D83FB1E76CF0700C6D598 /* CoreText.framework */; }; 344D83FE1E76CF0C00C6D598 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 344D83FD1E76CF0C00C6D598 /* CoreGraphics.framework */; }; 34C0C90820573CE000DFDB22 /* libSkiaSharp.h in Headers */ = {isa = PBXBuildFile; fileRef = 34C0C90720573CE000DFDB22 /* libSkiaSharp.h */; }; + 34EA43E921D4060600F9A3DA /* SkManagedDrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 34EA43E521D4060600F9A3DA /* SkManagedDrawable.h */; }; + 34EA43EA21D4060600F9A3DA /* sk_manageddrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 34EA43E621D4060600F9A3DA /* sk_manageddrawable.h */; }; + 34EA43EB21D4060600F9A3DA /* sk_manageddrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EA43E721D4060600F9A3DA /* sk_manageddrawable.cpp */; }; + 34EA43EC21D4060600F9A3DA /* SkManagedDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EA43E821D4060600F9A3DA /* SkManagedDrawable.cpp */; }; 34EC5FF820569A4C00F57982 /* WinRTCompat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EC5FF120569A4B00F57982 /* WinRTCompat.cpp */; }; 34EC5FF920569A4C00F57982 /* sk_managedstream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EC5FF220569A4B00F57982 /* sk_managedstream.cpp */; }; 34EC5FFA20569A4C00F57982 /* SkManagedStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EC5FF320569A4B00F57982 /* SkManagedStream.cpp */; }; @@ -29,6 +33,10 @@ 344D83FB1E76CF0700C6D598 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; 344D83FD1E76CF0C00C6D598 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 34C0C90720573CE000DFDB22 /* libSkiaSharp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libSkiaSharp.h; sourceTree = ""; }; + 34EA43E521D4060600F9A3DA /* SkManagedDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkManagedDrawable.h; path = ../../../externals/skia/include/xamarin/SkManagedDrawable.h; sourceTree = ""; }; + 34EA43E621D4060600F9A3DA /* sk_manageddrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sk_manageddrawable.h; path = ../../../externals/skia/include/xamarin/sk_manageddrawable.h; sourceTree = ""; }; + 34EA43E721D4060600F9A3DA /* sk_manageddrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sk_manageddrawable.cpp; path = ../../../externals/skia/src/xamarin/sk_manageddrawable.cpp; sourceTree = ""; }; + 34EA43E821D4060600F9A3DA /* SkManagedDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkManagedDrawable.cpp; path = ../../../externals/skia/src/xamarin/SkManagedDrawable.cpp; sourceTree = ""; }; 34EC5FF120569A4B00F57982 /* WinRTCompat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WinRTCompat.cpp; path = ../../../externals/skia/src/xamarin/WinRTCompat.cpp; sourceTree = ""; }; 34EC5FF220569A4B00F57982 /* sk_managedstream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sk_managedstream.cpp; path = ../../../externals/skia/src/xamarin/sk_managedstream.cpp; sourceTree = ""; }; 34EC5FF320569A4B00F57982 /* SkManagedStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkManagedStream.cpp; path = ../../../externals/skia/src/xamarin/SkManagedStream.cpp; sourceTree = ""; }; @@ -76,11 +84,15 @@ children = ( 21FD2B351C014C000023CFAE /* Info.plist */, 34C0C90720573CE000DFDB22 /* libSkiaSharp.h */, + 34EA43E721D4060600F9A3DA /* sk_manageddrawable.cpp */, + 34EA43E621D4060600F9A3DA /* sk_manageddrawable.h */, 34EC5FF220569A4B00F57982 /* sk_managedstream.cpp */, 34EC600120569A5000F57982 /* sk_managedstream.h */, 34EC5FF420569A4B00F57982 /* sk_xamarin.cpp */, 34EC600320569A5000F57982 /* sk_xamarin.h */, 34EC5FF620569A4B00F57982 /* SkiaKeeper.c */, + 34EA43E821D4060600F9A3DA /* SkManagedDrawable.cpp */, + 34EA43E521D4060600F9A3DA /* SkManagedDrawable.h */, 34EC5FF320569A4B00F57982 /* SkManagedStream.cpp */, 34EC600020569A5000F57982 /* SkManagedStream.h */, 34EC5FF120569A4B00F57982 /* WinRTCompat.cpp */, @@ -107,8 +119,10 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 34EA43E921D4060600F9A3DA /* SkManagedDrawable.h in Headers */, 34EC600620569A5100F57982 /* SkManagedStream.h in Headers */, 34C0C90820573CE000DFDB22 /* libSkiaSharp.h in Headers */, + 34EA43EA21D4060600F9A3DA /* sk_manageddrawable.h in Headers */, 34EC600720569A5100F57982 /* sk_managedstream.h in Headers */, 34EC600A20569A5100F57982 /* WinRTCompat.h in Headers */, 34EC600920569A5100F57982 /* sk_xamarin.h in Headers */, @@ -183,6 +197,8 @@ buildActionMask = 2147483647; files = ( 34EC5FFB20569A4C00F57982 /* sk_xamarin.cpp in Sources */, + 34EA43EC21D4060600F9A3DA /* SkManagedDrawable.cpp in Sources */, + 34EA43EB21D4060600F9A3DA /* sk_manageddrawable.cpp in Sources */, 34EC5FF820569A4C00F57982 /* WinRTCompat.cpp in Sources */, 34EC5FFA20569A4C00F57982 /* SkManagedStream.cpp in Sources */, 34EC5FF920569A4C00F57982 /* sk_managedstream.cpp in Sources */, diff --git a/tests/Tests/SKDrawableTest.cs b/tests/Tests/SKDrawableTest.cs new file mode 100644 index 00000000..f0564d83 --- /dev/null +++ b/tests/Tests/SKDrawableTest.cs @@ -0,0 +1,90 @@ +using Xunit; + +namespace SkiaSharp.Tests +{ + public class SKDrawableTest : SKTest + { + [SkippableFact] + public void CanCreateFromRecorder() + { + var cullRect = SKRect.Create(100, 100); + + using (var recorder = new SKPictureRecorder()) + using (var canvas = recorder.BeginRecording(cullRect)) + { + canvas.DrawColor(SKColors.Blue); + + using (var drawable = recorder.EndRecordingAsDrawable()) + { + Assert.NotNull(drawable); + Assert.Equal(cullRect, drawable.Bounds); + } + } + } + + [SkippableFact] + public void CanInstantiateDrawable() + { + using (var drawable = new TestDrawable()) + { + Assert.Equal(SKRect.Create(100, 100), drawable.Bounds); + Assert.Equal(1, drawable.BoundsFireCount); + + using (var bmp = new SKBitmap(100, 100)) + using (var canvas = new SKCanvas(bmp)) + { + drawable.Draw(canvas, 0, 0); + Assert.Equal(1, drawable.DrawFireCount); + + canvas.DrawDrawable(drawable, 0, 0); + Assert.Equal(2, drawable.DrawFireCount); + } + + var picture = drawable.Snapshot(); + Assert.NotNull(picture); + Assert.Equal(1, drawable.SnapshotFireCount); + } + } + + [SkippableFact] + public void DrawableDrawDraws() + { + using (var drawable = new TestDrawable()) + using (var bmp = new SKBitmap(100, 100)) + using (var canvas = new SKCanvas(bmp)) + { + drawable.Draw(canvas, 0, 0); + + Assert.Equal(SKColors.Blue, bmp.GetPixel(50, 50)); + } + } + } + + class TestDrawable : SKDrawable + { + public int DrawFireCount; + public int BoundsFireCount; + public int SnapshotFireCount; + + protected override void OnDraw(SKCanvas canvas) + { + DrawFireCount++; + + canvas.DrawColor(SKColors.Blue); + } + + protected override SKRect OnGetBounds() + { + BoundsFireCount++; + + return SKRect.Create(100, 100); + } + + protected override SKPicture OnSnapshot() + { + SnapshotFireCount++; + + return base.OnSnapshot(); + } + } +}