├── .github └── workflows │ ├── linux.yml │ └── macos.yml ├── .gitignore ├── .swiftpm └── xcode │ └── package.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── WorkspaceSettings.xcsettings ├── LICENSE ├── MacOSFramework └── Info.plist ├── Makefile ├── Package.swift ├── README.md ├── Samples └── SkiaKitSamplesiOS │ ├── README.md │ ├── SkiaKitSamplesiOS.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── swiftpm │ │ └── Package.resolved │ └── SkiaKitSamplesiOS │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── first.imageset │ │ ├── Contents.json │ │ └── first.pdf │ └── second.imageset │ │ ├── Contents.json │ │ └── second.pdf │ ├── ContentView.swift │ ├── Gallery │ ├── 2DPathSample.swift │ ├── AnimationSample.swift │ ├── FilledHeptagramSample.swift │ ├── FractalPerlinNoiseShaderSample.swift │ ├── GradientSample.swift │ ├── PathBoundsSample.swift │ ├── Sample.swift │ ├── SimplePathTest.swift │ ├── TextSample.swift │ └── XamagonSample.swift │ ├── Info.plist │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ └── SkiaKitSamplesiOSApp.swift ├── Sources ├── CSkiaSharp │ ├── dummy.m │ └── include │ │ ├── gr_context.h │ │ ├── module.modulemap │ │ ├── sk_bitmap.h │ │ ├── sk_canvas.h │ │ ├── sk_codec.h │ │ ├── sk_colorfilter.h │ │ ├── sk_colorspace.h │ │ ├── sk_colortable.h │ │ ├── sk_data.h │ │ ├── sk_document.h │ │ ├── sk_drawable.h │ │ ├── sk_font.h │ │ ├── sk_general.h │ │ ├── sk_graphics.h │ │ ├── sk_image.h │ │ ├── sk_imagefilter.h │ │ ├── sk_mask.h │ │ ├── sk_maskfilter.h │ │ ├── sk_matrix.h │ │ ├── sk_paint.h │ │ ├── sk_path.h │ │ ├── sk_patheffect.h │ │ ├── sk_picture.h │ │ ├── sk_pixmap.h │ │ ├── sk_region.h │ │ ├── sk_rrect.h │ │ ├── sk_runtimeeffect.h │ │ ├── sk_shader.h │ │ ├── sk_stream.h │ │ ├── sk_string.h │ │ ├── sk_surface.h │ │ ├── sk_svg.h │ │ ├── sk_textblob.h │ │ ├── sk_typeface.h │ │ ├── sk_types.h │ │ ├── sk_vertices.h │ │ ├── sk_xml.h │ │ ├── skottie_animation.h │ │ ├── sksg_invalidation_controller.h │ │ └── umbrella.h └── SkiaKit │ ├── Apple │ ├── SkiaCanvasLayer.swift │ └── SkiaView.swift │ ├── Bitmap.swift │ ├── Canvas.swift │ ├── Color.swift │ ├── ColorFilter.swift │ ├── ColorSpace.swift │ ├── Colors.swift │ ├── Data.swift │ ├── Definitions.swift │ ├── Font.swift │ ├── FontManager.swift │ ├── FontStyle.swift │ ├── FontStyleSet.swift │ ├── Image.swift │ ├── ImageFilter.swift │ ├── ImageInfo.swift │ ├── MaskFilter.swift │ ├── MathTypes.swift │ ├── Matrix.swift │ ├── Paint.swift │ ├── Path.swift │ ├── PathEffect.swift │ ├── Picture.swift │ ├── PictureRecorder.swift │ ├── Pixmap.swift │ ├── Region.swift │ ├── RoundRect.swift │ ├── SKObject.swift │ ├── SKStream.swift │ ├── SKString.swift │ ├── Shader.swift │ ├── Surface.swift │ ├── SurfaceProperties.swift │ ├── TextBlob.swift │ └── Typeface.swift ├── Tests ├── LinuxMain.swift └── SkiaKitTests │ └── SKCanvasTest.swift ├── docs ├── Classes.html ├── Classes │ ├── Bitmap.html │ ├── Canvas.html │ ├── ColorSpace.html │ ├── FontManager.html │ ├── FontStyle.html │ ├── FontStyleSet.html │ ├── Image.html │ ├── Image │ │ └── CachingHint.html │ ├── Paint.html │ ├── Paint │ │ ├── Hinting.html │ │ ├── StrokeCap.html │ │ ├── StrokeJoin.html │ │ └── Style.html │ ├── Path.html │ ├── Path │ │ ├── Convexity.html │ │ ├── Direction.html │ │ ├── FillType.html │ │ ├── Op.html │ │ ├── PathAddMode.html │ │ ├── SegmentMask.html │ │ └── Size.html │ ├── PathEffect.html │ ├── Picture.html │ ├── PictureRecorder.html │ ├── Pixmap.html │ ├── Region.html │ ├── RoundRect.html │ ├── SKData.html │ ├── SKDynamicMemoryWStream.html │ ├── SKFileStream.html │ ├── SKFileWStream.html │ ├── SKMemoryStream.html │ ├── SKStream.html │ ├── SKWStream.html │ ├── Shader.html │ ├── SkiaLayer.html │ ├── SkiaView.html │ ├── Surface.html │ ├── SurfaceProperties.html │ ├── TextBlob.html │ ├── TextBlobBuilder.html │ └── Typeface.html ├── Enums.html ├── Enums │ ├── AlphaType.html │ ├── BitmapError.html │ ├── BlendMode.html │ ├── ClipOperation.html │ ├── ColorType.html │ ├── EncodedImageFormat.html │ ├── FilterQuality.html │ ├── FontStyleSlant.html │ ├── FontStyleWeight.html │ ├── FontStyleWidth.html │ ├── PixelGeometry.html │ ├── PointMode.html │ ├── RegionOperation.html │ ├── SKSurfacePropsFlags.html │ ├── ShaderTileMode.html │ ├── TextAlign.html │ ├── TextEncoding.html │ └── TransferFunctionBehavior.html ├── Structs.html ├── Structs │ ├── Color.html │ ├── Colors.html │ ├── IPoint.html │ ├── IRect.html │ ├── ISize.html │ ├── ImageInfo.html │ ├── Matrix.html │ ├── Point.html │ ├── Rect.html │ └── Size.html ├── badge.svg ├── css │ ├── highlight.css │ └── jazzy.css ├── img │ ├── carat.png │ ├── dash.png │ └── gh.png ├── index.html ├── js │ ├── jazzy.js │ └── jquery.min.js ├── search.json └── undocumented.json ├── download-payload-linux.sh ├── make-release.sh └── make-xcframework.sh /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: Linux 2 | 3 | on: [push, workflow_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-18.04 8 | steps: 9 | - name: Checkout SkiaKit 10 | uses: actions/checkout@v2 11 | - name: Download payload (Linux) 12 | run: make download-payload-linux 13 | - name: Build with Swift command line 14 | run: swift build -v 15 | - name: Test Swift 16 | run: swift test 17 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macOS 2 | 3 | on: [push, workflow_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: macos-latest 8 | steps: 9 | - name: Checkout SkiaKit 10 | uses: actions/checkout@v2 11 | - name: Download payload (.xcframework) 12 | run: make download-payload 13 | - name: Download payload (Linux) 14 | run: make download-payload-linux 15 | - name: Build with Swift command line 16 | run: swift build -v 17 | - name: Test Swift 18 | run: swift test 19 | # - name: Deploy to 'generated' branch 20 | # uses: peaceiris/actions-gh-pages@v3 21 | # with: 22 | # github_token: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN is automatically added by GitHub Actions 23 | # publish_dir: ./ 24 | # publish_branch: generated 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .build 2 | DerivedData 3 | xcuserdata 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Swift bindings is Copyright (c) 2019 Miguel de Icaza. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | Based on SkiaSharp that is: 24 | 25 | Copyright (c) 2015-2016 Xamarin, Inc. 26 | Copyright (c) 2017-2018 Microsoft Corporation. 27 | 28 | Permission is hereby granted, free of charge, to any person obtaining 29 | a copy of this software and associated documentation files (the 30 | "Software"), to deal in the Software without restriction, including 31 | without limitation the rights to use, copy, modify, merge, publish, 32 | distribute, sublicense, and/or sell copies of the Software, and to 33 | permit persons to whom the Software is furnished to do so, subject to 34 | the following conditions: 35 | 36 | The above copyright notice and this permission notice shall be 37 | included in all copies or substantial portions of the Software. 38 | 39 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 40 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 41 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 42 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 43 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 44 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 45 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | 47 | 48 | Parts of the API documentation come from the original Skia 49 | documentation and have been adapted to SkiaKit, and they are licensed 50 | like this: 51 | 52 | // Copyright (c) 2011-2019 Google Inc. All rights reserved. 53 | // 54 | // Redistribution and use in source and binary forms, with or without 55 | // modification, are permitted provided that the following conditions are 56 | // met: 57 | // 58 | // * Redistributions of source code must retain the above copyright 59 | // notice, this list of conditions and the following disclaimer. 60 | // * Redistributions in binary form must reproduce the above 61 | // copyright notice, this list of conditions and the following disclaimer 62 | // in the documentation and/or other materials provided with the 63 | // distribution. 64 | // * Neither the name of Google Inc. nor the names of its 65 | // contributors may be used to endorse or promote products derived from 66 | // this software without specific prior written permission. 67 | // 68 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 69 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 70 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 71 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 72 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 73 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 74 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 75 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 76 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 77 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 78 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /MacOSFramework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 19F101 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | libSkiaSharp 11 | CFBundleIdentifier 12 | xamarin.libskia-macos 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | libSkiaSharp 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | DTCompiler 26 | com.apple.compilers.llvm.clang.1_0 27 | DTSDKBuild 28 | 10.15 29 | DTSDKName 30 | macosx10.15 31 | DTXcode 32 | 1160 33 | DTXcodeBuild 34 | 11E708 35 | NSPrincipalClass 36 | 37 | 38 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | make-docs: 2 | jazzy --clean --author "Miguel de Icaza" --author_url https://tirania.org/ --github_url https://github.com/migueldeicaza/SkiaKit --github-file-prefix https://github.com/migueldeicaza/SkiaKit/tree/master --module-version master --root-url https://migueldeicaza.github.io/SwiftKit --output docs 3 | 4 | download-payload: 5 | bash ./download-payload.sh 6 | 7 | download-payload-linux: 8 | bash ./download-payload-linux.sh 9 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | import Foundation 4 | import PackageDescription 5 | 6 | let dir = URL(fileURLWithPath: #file).deletingLastPathComponent().path 7 | var target: [Target] = [] 8 | 9 | #if os(Linux) 10 | target = [ 11 | .target ( 12 | name: "CSkiaSharp", 13 | cSettings: [ 14 | .headerSearchPath("include"), 15 | ], 16 | linkerSettings: [ 17 | .unsafeFlags(["-L" + dir]) 18 | ] 19 | ), 20 | .testTarget ( 21 | name: "SkiaKitTests", 22 | dependencies: ["SkiaKit"], 23 | linkerSettings: [ 24 | .unsafeFlags(["-L" + dir]) 25 | ] 26 | ), 27 | ] 28 | #else 29 | target = [ 30 | .target ( 31 | name: "CSkiaSharp", 32 | dependencies: ["CSkiaSharpBinary"], 33 | cSettings: [ 34 | .headerSearchPath("include") 35 | ] 36 | ), 37 | .binaryTarget ( 38 | name: "CSkiaSharpBinary", 39 | url: "https://github.com/migueldeicaza/SkiaKit/releases/download/1.2.5/SkiaSharp.xcframework.zip", 40 | checksum: "6aab048910bdd5a24f3321b2476ab6dd5306c1efb5729776d3a780a806b008b1" 41 | ), 42 | .testTarget ( 43 | name: "SkiaKitTests", 44 | dependencies: ["SkiaKit"] 45 | ), 46 | ] 47 | #endif 48 | 49 | let package = Package( 50 | name: "SkiaKit", 51 | platforms: [ 52 | .macOS(.v10_15), 53 | .iOS(.v13), 54 | .tvOS(.v13) 55 | ], 56 | products: [ 57 | .library(name: "SkiaKit", targets: ["SkiaKit"]) 58 | ], 59 | targets: [ 60 | .target ( 61 | name: "SkiaKit", 62 | dependencies: ["CSkiaSharp"], 63 | cSettings: [ 64 | .headerSearchPath("include") 65 | ] 66 | ) 67 | ] + target 68 | ) 69 | 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SkiaKit 2 | 3 | > [Go to macOS / iOS / tvOS](#apple) | [Go to Linux](#linux) 4 | 5 | SkiaKit is a 2D Graphics Library for use with Swift. It is powered by 6 | Google's [Skia](https://skia.org) graphics library, the same library 7 | that powers Google Chrome and Android graphics. 8 | 9 | You can review the [API Documentation](https://migueldeicaza.github.io/SkiaKit/) 10 | 11 | The Swift bindings are intended to be cross-platform, both to Apple 12 | platforms, Linux, and new platforms where Skia and Swift run. 13 | 14 | This work uses extensive code from Microsoft's SkiaSharp bindings 15 | authored by Matthew Leibowitz and dozens of contributors. SkiaSharp 16 | just happens to have a very advanced set of bridge APIs to the 17 | underlying Skia engine that does not existing in the upstream Google 18 | Skia project. 19 | 20 | ## Getting this to work 21 | 22 | ### Apple 23 | 24 | Supports: 25 | 26 | - `x86_64` Mac: anything from 2008 MacBook to M1 (using x86 emulation) 27 | - `arm64` iPhone: anything past iPhone 5S 28 | - `arm64` iPad: anything past iPad Air / iPad mini 2 (post-2013) 29 | - iPhone Simulator 30 | - iPad Simulator 31 | - tvOS 32 | 33 | Not currently supported: 34 | 35 | - Mac Catalyst 36 | 37 | #### Recommended usage 38 | 39 | You can add SkiaKit to your project by putting this dependency in your `Package.swift`: 40 | 41 | ```swift 42 | .package(url: "https://github.com/migueldeicaza/SkiaKit.git", from: "1.0.0") 43 | ``` 44 | 45 | #### Using manually 46 | 47 | If using manually, you'll need to download and assemble the `SkiaSharp.xcframework` required. 48 | 49 | This must be ran on macOS with the [Command Line Tools for XCode](https://developer.apple.com/downloads/) installed. 50 | 51 | ```sh 52 | git clone https://github.com/migueldeicaza/SkiaKit.git 53 | cd SkiaKit 54 | make download-payload 55 | ``` 56 | 57 | ### Linux 58 | 59 | SkiaKit is platform agnostic and makes a best-effort support for 60 | Linux. An `.so` for the SkiaSharp library is included and supports 61 | [the following Linux distributions](https://github.com/mono/SkiaSharp/issues/453). 62 | 63 | The `libSkiaSharp.so` file will need to be distributed alongside your project. 64 | 65 | #### Recommended usage 66 | 67 | You can add SkiaKit to your project by putting this dependency in your `Package.swift`: 68 | 69 | ```swift 70 | .package(url: "https://github.com/migueldeicaza/SkiaKit.git", .branch("generated")) 71 | ``` 72 | 73 | #### Using manually 74 | 75 | If using manually, you'll need to provide `libSkiaSharp.so` in the 76 | root of the `SkiaKit` folder. For [certain Linux distros](https://github.com/mono/SkiaSharp/issues/453), 77 | a convenience script is provided. 78 | 79 | This script requires `curl` and `unzip`. 80 | 81 | ```sh 82 | git clone https://github.com/migueldeicaza/SkiaKit.git 83 | cd SkiaKit 84 | make download-payload-linux 85 | ``` 86 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/README.md: -------------------------------------------------------------------------------- 1 | # SkiaKitSamplesiOS 2 | 3 | To use this project, open the project in XCode and run on your iOS device. 4 | 5 | # License 6 | 7 | ``` 8 | MIT License 9 | 10 | Swift bindings is Copyright (c) 2019-2023 Miguel de Icaza. 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in all 20 | copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | SOFTWARE. 29 | 30 | Based on SkiaSharp that is: 31 | 32 | Copyright (c) 2015-2016 Xamarin, Inc. 33 | Copyright (c) 2017-2018 Microsoft Corporation. 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining 36 | a copy of this software and associated documentation files (the 37 | "Software"), to deal in the Software without restriction, including 38 | without limitation the rights to use, copy, modify, merge, publish, 39 | distribute, sublicense, and/or sell copies of the Software, and to 40 | permit persons to whom the Software is furnished to do so, subject to 41 | the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be 44 | included in all copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 47 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 48 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 49 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 50 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 51 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 52 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 53 | 54 | 55 | Parts of the API documentation come from the original Skia 56 | documentation and have been adapted to SkiaKit, and they are licensed 57 | like this: 58 | 59 | // Copyright (c) 2011-2019 Google Inc. All rights reserved. 60 | // 61 | // Redistribution and use in source and binary forms, with or without 62 | // modification, are permitted provided that the following conditions are 63 | // met: 64 | // 65 | // * Redistributions of source code must retain the above copyright 66 | // notice, this list of conditions and the following disclaimer. 67 | // * Redistributions in binary form must reproduce the above 68 | // copyright notice, this list of conditions and the following disclaimer 69 | // in the documentation and/or other materials provided with the 70 | // distribution. 71 | // * Neither the name of Google Inc. nor the names of its 72 | // contributors may be used to endorse or promote products derived from 73 | // this software without specific prior written permission. 74 | // 75 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 76 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 77 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 78 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 79 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 80 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 81 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 82 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 83 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 84 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 85 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 86 | ``` 87 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "skiakit", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/migueldeicaza/SkiaKit", 7 | "state" : { 8 | "revision" : "04509392c8dc72f36159ddd44b6f58277cae8496", 9 | "version" : "1.0.0" 10 | } 11 | } 12 | ], 13 | "version" : 2 14 | } 15 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/first.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "first.pdf", 5 | "idiom" : "universal" 6 | } 7 | ], 8 | "info" : { 9 | "author" : "xcode", 10 | "version" : 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/first.imageset/first.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/migueldeicaza/SkiaKit/bad7d455aee89bc434b254aefd1518330662e23a/Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/first.imageset/first.pdf -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/second.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "second.pdf", 5 | "idiom" : "universal" 6 | } 7 | ], 8 | "info" : { 9 | "author" : "xcode", 10 | "version" : 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/second.imageset/second.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/migueldeicaza/SkiaKit/bad7d455aee89bc434b254aefd1518330662e23a/Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Assets.xcassets/second.imageset/second.pdf -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // SkiaKitSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 10/26/19. 6 | // 7 | 8 | import SwiftUI 9 | import SkiaKit 10 | 11 | 12 | struct Display : View where T: Sample { 13 | var body: some View { 14 | NavigationLink(destination: SampleRender (T())){ 15 | Text (T.title) 16 | } 17 | } 18 | } 19 | 20 | 21 | struct SampleChooserView : View { 22 | 23 | var body: some View { 24 | NavigationView { 25 | List { 26 | Display() 27 | Display() 28 | Display() 29 | Display () 30 | Display () 31 | Display () 32 | Display() 33 | Display() 34 | Display() 35 | Display() 36 | } 37 | } 38 | } 39 | } 40 | 41 | struct ContentView: View { 42 | @State private var selection = 0 43 | 44 | var body: some View { 45 | TabView(selection: $selection){ 46 | SampleChooserView () 47 | .font(.title) 48 | .tabItem { 49 | VStack { 50 | Image("first") 51 | Text("Gallery") 52 | } 53 | } 54 | .tag(0) 55 | SampleRender (sampleTest()) 56 | .font(.title) 57 | .tabItem { 58 | VStack { 59 | Image("second") 60 | Text("Default") 61 | } 62 | } 63 | .tag(1) 64 | } 65 | } 66 | } 67 | 68 | struct ContentView_Previews: PreviewProvider { 69 | static var previews: some View { 70 | ContentView() 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/2DPathSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // 2DPathSample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 11/8/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct TwoDPathSample: Sample { 12 | static var title = "2D Path Effect" 13 | 14 | public func draw(canvas: Canvas, width: Int32, height: Int32) { 15 | //let fwidth = Float(width) 16 | //let fheight = Float (height) 17 | 18 | canvas.clear(color: Colors.white) 19 | 20 | let blockSize : Float = 30 21 | 22 | // create the path 23 | let path = SkiaKit.Path() 24 | // the rect must be offset as the path uses the center 25 | let rect = Rect(x: blockSize / -2, y: blockSize / -2, width: blockSize, height: blockSize); 26 | path.addRect(rect) 27 | 28 | // move the path around: across 1 block 29 | var offsetMatrix = Matrix.makeScale(sx: 2 * blockSize, sy: blockSize); 30 | // each row, move across a bit / offset 31 | let skew = Matrix.makeSkew (sx: 0.5, sy: 0) 32 | Matrix.preConcat(target: &offsetMatrix, matrix: skew) 33 | 34 | // create the paint 35 | let paint = Paint () 36 | 37 | paint.pathEffect = PathEffect.make2DPath(matrix: &offsetMatrix, path: path) 38 | paint.color = Colors.lightGray 39 | 40 | // draw a rectangle 41 | //canvas.drawRect(Rect(width: fwidth + blockSize, height: fheight + blockSize), paint) 42 | canvas.drawRect(Rect (left: 100, top: 100, right: 200, bottom: 200), paint) 43 | 44 | let paint2 = Paint () 45 | paint2.color = Colors.blue 46 | canvas.drawRect(Rect (left: 400, top: 400, right: 200, bottom: 200), paint2) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/AnimationSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationSample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Sash Zats on 12/13/20. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct animationSample : Sample { 12 | static var title = "Animation" 13 | 14 | var isLoop: Bool { true } 15 | 16 | class AnimationViewModel { 17 | private let circleRadius: Float = 100 18 | private lazy var position = Point(x: circleRadius, y: circleRadius) 19 | private var velocity = Point(x: 10, y: 10) 20 | private var bounds = Rect() 21 | 22 | func update(width: Float, height: Float) { 23 | self.bounds = Rect(x: 0, 24 | y: 0, 25 | width: Float(width) - circleRadius * 2, 26 | height: Float(height) - circleRadius * 2) 27 | 28 | var nextPosition = Point(x: position.x + velocity.x, 29 | y: position.y + velocity.y) 30 | if nextPosition.x < bounds.left || nextPosition.x > bounds.right { 31 | velocity.x *= -1 32 | nextPosition = Point(x: position.x + velocity.x, 33 | y: position.y + velocity.y) 34 | } 35 | 36 | if nextPosition.y < bounds.top || nextPosition.y > bounds.bottom { 37 | velocity.y *= -1; 38 | nextPosition = Point(x: position.x + velocity.x, 39 | y: position.y + velocity.y) 40 | } 41 | 42 | position = nextPosition 43 | } 44 | 45 | var ovalBounds: Rect { 46 | return Rect(x: position.x, y: position.y, width: circleRadius * 2, height: circleRadius * 2) 47 | } 48 | } 49 | 50 | let viewModel = AnimationViewModel() 51 | 52 | func draw(canvas: Canvas, width: Int32, height: Int32) 53 | { 54 | viewModel.update(width: Float(width), height: Float(height)) 55 | 56 | canvas.clear (color: Colors.white) 57 | 58 | let paint = Paint() 59 | paint.isAntialias = true 60 | paint.color = Colors.darkGray 61 | paint.strokeCap = .round 62 | paint.strokeWidth = 10 63 | paint.isStroke = true 64 | 65 | let path = SkiaKit.Path() 66 | path.addOval(viewModel.ovalBounds) 67 | path.close() 68 | 69 | canvas.drawPath(path, paint) 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/FilledHeptagramSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FilledHeptagramSample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 11/8/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct filledHeptagramSample : Sample { 12 | static var title = "Filled Heptagram" 13 | 14 | func draw(canvas: Canvas, width: Int32, height: Int32) { 15 | let size = Float (height > width ? width : height) * 0.75 16 | let R = 0.45 * size 17 | let TAU = Float (6.2831853) 18 | 19 | let path = SkiaKit.Path() 20 | path.moveTo(R, 0) 21 | 22 | for i in 1..<7 { 23 | let theta = 3.0 * Float (i) * TAU / 7 24 | path.lineTo(R * cos(theta), R * sin(theta)) 25 | } 26 | path.close () 27 | 28 | let paint = Paint () 29 | paint.isAntialias = true 30 | 31 | 32 | canvas.clear(color: Colors.white) 33 | canvas.translate(dx: Float (width / 2), dy: Float (height / 2)) 34 | canvas.drawPath(path, paint) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/FractalPerlinNoiseShaderSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 11/8/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct fractalPerlinNoiseShaderSample : Sample { 12 | static var title = "Fractal Perlin Noise Shader" 13 | 14 | public func draw(canvas: Canvas, width: Int32, height: Int32) { 15 | canvas.clear(color: Colors.white) 16 | 17 | let paint = Paint() 18 | paint.shader = Shader.makePerlinNoiseFractalNoise(baseFrequencyX: 0.05, baseFrequencyY: 0.05, numOctaves: 4, seed: 0) 19 | canvas.draw(paint) 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/GradientSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 11/8/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct gradientSample: Sample { 12 | static var title = "Gradient" 13 | 14 | public func draw(canvas: Canvas, width: Int32, height: Int32) { 15 | let ltColor = Colors.white 16 | let dkColor = Colors.black 17 | 18 | var paint = Paint() 19 | paint.isAntialias = true 20 | let shader = Shader.makeLinearGradient(start: Point(x: 0, y: 0), end: Point(x:0, y: Float (height)), colors: [ltColor, dkColor], colorPos: nil, mode: .clamp) 21 | paint.shader = shader 22 | canvas.draw(paint) 23 | 24 | // Center and Scale the Surface 25 | let scale = (width < height ? width : height) / (240); 26 | canvas.translate(dx: Float (width) / 2, dy: Float (height) / 2); 27 | canvas.scale(Float (scale)) 28 | canvas.translate(dx: -128, dy: -128); 29 | 30 | paint = Paint() 31 | paint.isAntialias = true 32 | if let shader = Shader.makeTwoPointConicalGradient(start: Point(x: 115.2, y:102.4), startRadius: 25.6, end: Point(x:102.4, y: 102.4), endRadius: 128, colors: [ltColor, dkColor], colorPos: nil, mode: .clamp) { 33 | paint.shader = shader 34 | 35 | canvas.drawOval(Rect(left: 51.2, top: 51.2, right: 204.8, bottom: 204.8), paint: paint) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/PathBoundsSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PathBoundsSample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 10/27/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct samplePathBounds : Sample { 12 | static var title: String = "Path bounds" 13 | 14 | func draw (canvas: Canvas, width: Int32, height: Int32) 15 | { 16 | canvas.clear (color: Colors.white) 17 | canvas.scale(2) 18 | 19 | let paint = Paint () 20 | paint.style = .stroke 21 | paint.strokeWidth = 1 22 | paint.isAntialias = true 23 | paint.strokeCap = .round 24 | 25 | let textPaint = Paint () 26 | textPaint.isAntialias = true 27 | 28 | let path = Path () 29 | path.move(to: Point(x: -6.2157825e-7, y: -25.814698)) 30 | path.rcubic(to: Point(x: -34.64102137842175, y: 19.9999998), controlPoint1: Point(x:0, y: 40), controlPoint2: Point(x: 0, y: 40)) 31 | path.offset (Point (x: 50, y: 35)) 32 | 33 | // draw using getbounds 34 | paint.color = Colors.lightBlue 35 | canvas.drawPath (path, paint) 36 | let rect = path.bounds 37 | 38 | paint.color = Colors.darkBlue 39 | canvas.drawRect(rect, paint) 40 | 41 | let font = Font() 42 | canvas.draw(text: "Bounds", x: rect.left, y: rect.bottom + font.size, font: font, paint: paint) 43 | 44 | // move for next curve 45 | path.offset (Point (x: 100, y: 0)) 46 | 47 | // draw using getTightBounds 48 | paint.color = Colors.lightBlue 49 | canvas.drawPath(path, paint) 50 | 51 | if let rect = path.getTightBounds() { 52 | paint.color = Colors.darkBlue 53 | canvas.drawRect(rect, paint) 54 | canvas.draw(text: "TightBounds", x: rect.left, y: rect.bottom + font.size, font: font, paint: paint) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/Sample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 10/27/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | import SwiftUI 11 | 12 | protocol Sample { 13 | init () 14 | 15 | static var title: String { get } 16 | 17 | var isLoop: Bool { get } 18 | 19 | //var category: String { get } = 20 | func draw (canvas: SkiaKit.Canvas, width: Int32, height: Int32) 21 | } 22 | 23 | extension Sample { 24 | var isLoop: Bool { return false } 25 | } 26 | 27 | struct SampleRender : UIViewRepresentable { 28 | var sample: Sample 29 | init (_ sample: Sample) 30 | { 31 | self.sample = sample 32 | } 33 | 34 | func updateUIView(_ uiView: SkiaView, context: UIViewRepresentableContext) { 35 | uiView.setNeedsDisplay () 36 | } 37 | 38 | func makeUIView (context: Context) -> SkiaView 39 | { 40 | let sv = SkiaView () 41 | sv.loop = sample.isLoop 42 | sv.drawingCallback = draw 43 | 44 | return sv 45 | } 46 | 47 | func draw (surface: Surface, info: ImageInfo) 48 | { 49 | sample.draw (canvas: surface.canvas, width: info.width, height: info.height) 50 | } 51 | } 52 | 53 | struct sampleDraw : Sample { 54 | static var title = "Green text on aqua background" 55 | 56 | func draw (canvas: SkiaKit.Canvas, width: Int32, height: Int32) 57 | { 58 | canvas.clear (color: Colors.yellow) 59 | 60 | let font = Font() 61 | let paint = Paint() 62 | font.size = 64 63 | canvas.draw (text: "text", x: 150, y: 175, font: font, paint: paint) 64 | paint.strokeWidth = 10 65 | paint.color = Colors.green 66 | paint.style = .stroke 67 | canvas.drawRect(Rect(left: 0, top: 0, right: Float(width), bottom: Float(height)), paint) 68 | } 69 | } 70 | 71 | struct Sample_Previews: PreviewProvider { 72 | static var previews: some View { 73 | VStack { 74 | Text ("Hello") 75 | HStack { 76 | Text ("") 77 | SampleRender(sampleDraw()) 78 | } 79 | Text ("Good bye") 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/SimplePathTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimplePathTest.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 11/8/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct sampleTest : Sample { 12 | static var title = "Simple Path Test" 13 | 14 | func draw (canvas: Canvas, width: Int32, height: Int32) 15 | { 16 | let paint = Paint () 17 | 18 | paint.isAntialias = true 19 | paint.color = Colors.yellow 20 | paint.strokeCap = .round 21 | paint.strokeWidth = 5 22 | paint.isStroke = true 23 | 24 | canvas.draw (paint) 25 | 26 | var path = SkiaKit.Path() 27 | 28 | path.moveTo (0, 0) 29 | path.lineTo (Float (width), Float (height)) 30 | 31 | path.close() 32 | 33 | paint.color = Colors.black 34 | canvas.drawPath (path, paint) 35 | 36 | path = Path() 37 | 38 | path.close() 39 | 40 | paint.color = Colors.white 41 | canvas.drawPath(path, paint) 42 | 43 | let pp = Paint () 44 | pp.style = .fill 45 | pp.color = Colors.blue 46 | canvas.drawCircle(Float(width)/2, Float(height)/2, 100, pp) 47 | 48 | pp.style = .stroke 49 | pp.color = Colors.red 50 | pp.strokeWidth = 25 51 | canvas.drawCircle(Float(width)/2, Float(height)/2, 100, pp) 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/TextSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextSample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 10/27/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | 11 | struct sampleText : Sample { 12 | static var title = "Text" 13 | 14 | func draw (canvas: Canvas, width: Int32, height: Int32) 15 | { 16 | canvas.drawColor(Colors.white) 17 | 18 | let font = Font() 19 | font.size = 64 20 | var paint = Paint() 21 | paint.isAntialias = true 22 | paint.color = Color (0xff4281a4) 23 | paint.isStroke = false 24 | 25 | canvas.draw (text: "SkiaKit", x: Float (width/2), y: 64, font: font, paint: paint) 26 | 27 | paint = Paint() 28 | paint.isAntialias = true 29 | paint.color = Color (0xff9cafb7) 30 | paint.isStroke = true 31 | paint.strokeWidth = 3 32 | //paint.textAlign = .center 33 | 34 | canvas.draw (text: "SkiaKit", x: Float (width/2), y: 144, font: font, paint: paint) 35 | 36 | paint = Paint() 37 | 38 | paint.isAntialias = true 39 | paint.color = Color (0xffe6b89c) 40 | font.scaleX = 1.5 41 | //paint.textAlign = .right 42 | 43 | canvas.draw (text: "SkiaKit", x: Float (width/2), y: 224, font: font, paint: paint) 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Gallery/XamagonSample.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XamagonSample.swift 3 | // SkiaSamplesiOS 4 | // 5 | // Created by Miguel de Icaza on 10/27/19. 6 | // 7 | 8 | import Foundation 9 | import SkiaKit 10 | import SwiftUI 11 | 12 | struct sampleXamagon : Sample { 13 | static var title = "Xamagon" 14 | 15 | func draw (canvas: SkiaKit.Canvas, width: Int32, height: Int32) 16 | { 17 | // Width 41.6587026 => 144.34135 18 | // Height 56 => 147 19 | 20 | let paddingFactor : Float = 0.6 21 | let imageLeft : Float = 41.6587026 22 | let imageRight : Float = 144.34135 23 | //let imageTop : Float = 56 24 | //let imageBottom : Float = 147 25 | 26 | let imageWidth = imageRight - imageLeft 27 | 28 | let scale = (Float ((height > width ? width : height)) / imageWidth) * paddingFactor 29 | canvas.scale (scale) 30 | let paint = Paint () 31 | 32 | paint.isAntialias = true 33 | paint.color = Colors.white 34 | paint.strokeCap = .round 35 | 36 | canvas.draw (paint) 37 | 38 | var path = SkiaKit.Path() 39 | 40 | path.moveTo (71.4311121, 56) 41 | path.cubicTo(68.6763107, 56.0058575, 65.9796704, 57.5737917, 64.5928855, 59.965729) 42 | path.lineTo(43.0238921, 97.5342563) 43 | path.cubicTo(41.6587026, 99.9325978, 41.6587026, 103.067402, 43.0238921, 105.465744) 44 | path.lineTo(64.5928855, 143.034271) 45 | path.cubicTo(65.9798162, 145.426228, 68.6763107, 146.994582, 71.4311121, 147) 46 | path.lineTo(114.568946, 147) 47 | path.cubicTo(117.323748, 146.994143, 120.020241, 145.426228, 121.407172, 143.034271) 48 | path.lineTo(142.976161, 105.465744) 49 | path.cubicTo(144.34135, 103.067402, 144.341209, 99.9325978, 142.976161, 97.5342563) 50 | path.lineTo(121.407172, 59.965729) 51 | path.cubicTo(120.020241, 57.5737917, 117.323748, 56.0054182, 114.568946, 56) 52 | path.lineTo(71.4311121, 56) 53 | path.close() 54 | 55 | paint.color = Colors.darkBlue 56 | canvas.drawPath (path, paint) 57 | 58 | path = Path() 59 | path.moveTo (71.8225901, 77.9780432) 60 | path.cubicTo(71.8818491, 77.9721857, 71.9440029, 77.9721857, 72.0034464, 77.9780432) 61 | path.lineTo(79.444074, 77.9780432) 62 | path.cubicTo(79.773437, 77.9848769, 80.0929203, 78.1757336, 80.2573978, 78.4623994) 63 | path.lineTo(92.8795281, 101.015639) 64 | path.cubicTo(92.9430615, 101.127146, 92.9839987, 101.251384, 92.9995323, 101.378901) 65 | path.cubicTo(93.0150756, 101.251354, 93.055974, 101.127107, 93.1195365, 101.015639) 66 | path.lineTo(105.711456, 78.4623994) 67 | path.cubicTo(105.881153, 78.167045, 106.215602, 77.975134, 106.554853, 77.9780432) 68 | path.lineTo(113.995483, 77.9780432) 69 | path.cubicTo(114.654359, 77.9839007, 115.147775, 78.8160066, 114.839019, 79.4008677) 70 | path.lineTo(102.518299, 101.500005) 71 | path.lineTo(114.839019, 123.568869) 72 | path.cubicTo(115.176999, 124.157088, 114.671442, 125.027775, 113.995483, 125.021957) 73 | path.lineTo(106.554853, 125.021957) 74 | path.cubicTo(106.209673, 125.019028, 105.873247, 124.81384, 105.711456, 124.507327) 75 | path.lineTo(93.1195365, 101.954088) 76 | path.cubicTo(93.0560031, 101.84258, 93.0150659, 101.718333, 92.9995323, 101.590825) 77 | path.cubicTo(92.983989, 101.718363, 92.9430906, 101.842629, 92.8795281, 101.954088) 78 | path.lineTo(80.2573978, 124.507327) 79 | path.cubicTo(80.1004103, 124.805171, 79.7792269, 125.008397, 79.444074, 125.021957) 80 | path.lineTo(72.0034464, 125.021957) 81 | path.cubicTo(71.3274867, 125.027814, 70.8220664, 124.157088, 71.1600463, 123.568869) 82 | path.lineTo(83.4807624, 101.500005) 83 | path.lineTo(71.1600463, 79.400867) 84 | path.cubicTo(70.8647037, 78.86725, 71.2250368, 78.0919422, 71.8225901, 77.9780432) 85 | path.lineTo(71.8225901, 77.9780432) 86 | path.close() 87 | 88 | paint.color = Colors.white 89 | canvas.drawPath(path, paint) 90 | } 91 | } 92 | 93 | struct Xamarin_Preview: PreviewProvider { 94 | static var previews: some View { 95 | VStack { 96 | HStack { 97 | Text ("") 98 | SampleRender(sampleXamagon()) 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | 28 | UIApplicationSupportsIndirectInputEvents 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Samples/SkiaKitSamplesiOS/SkiaKitSamplesiOS/SkiaKitSamplesiOSApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SkiaKitSamplesiOSApp.swift 3 | // SkiaKitSamplesiOS 4 | // 5 | // Created by Michael Bullington on 9/6/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct SkiaKitSamplesiOSApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/dummy.m: -------------------------------------------------------------------------------- 1 | // 2 | // This dummy file is here to bring the SkiaKit.h header that has 3 | // all the definitions 4 | // 5 | // The entire module is exported as "CSkiaSharp" - this definition 6 | // is in include/module.modulemap. It is not clea 7 | // #include 8 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/gr_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef gr_context_DEFINED 11 | #define gr_context_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void gr_recording_context_unref(gr_recording_context_t* context); 18 | SK_C_API int gr_recording_context_get_max_surface_sample_count_for_color_type(gr_recording_context_t* context, sk_colortype_t colorType); 19 | SK_C_API gr_backend_t gr_recording_context_get_backend(gr_recording_context_t* context); 20 | 21 | // GrDirectContext 22 | 23 | SK_C_API gr_direct_context_t* gr_direct_context_make_gl(const gr_glinterface_t* glInterface); 24 | SK_C_API gr_direct_context_t* gr_direct_context_make_gl_with_options(const gr_glinterface_t* glInterface, const gr_context_options_t* options); 25 | SK_C_API gr_direct_context_t* gr_direct_context_make_vulkan(const gr_vk_backendcontext_t vkBackendContext); 26 | SK_C_API gr_direct_context_t* gr_direct_context_make_vulkan_with_options(const gr_vk_backendcontext_t vkBackendContext, const gr_context_options_t* options); 27 | SK_C_API gr_direct_context_t* gr_direct_context_make_metal(void* device, void* queue); 28 | SK_C_API gr_direct_context_t* gr_direct_context_make_metal_with_options(void* device, void* queue, const gr_context_options_t* options); 29 | 30 | // TODO: the overloads with GrContextOptions 31 | 32 | SK_C_API bool gr_direct_context_is_abandoned(gr_direct_context_t* context); 33 | SK_C_API void gr_direct_context_abandon_context(gr_direct_context_t* context); 34 | SK_C_API void gr_direct_context_release_resources_and_abandon_context(gr_direct_context_t* context); 35 | SK_C_API size_t gr_direct_context_get_resource_cache_limit(gr_direct_context_t* context); 36 | SK_C_API void gr_direct_context_set_resource_cache_limit(gr_direct_context_t* context, size_t maxResourceBytes); 37 | SK_C_API void gr_direct_context_get_resource_cache_usage(gr_direct_context_t* context, int* maxResources, size_t* maxResourceBytes); 38 | SK_C_API void gr_direct_context_flush(gr_direct_context_t* context); 39 | SK_C_API bool gr_direct_context_submit(gr_direct_context_t* context, bool syncCpu); 40 | SK_C_API void gr_direct_context_flush_and_submit(gr_direct_context_t* context, bool syncCpu); 41 | SK_C_API void gr_direct_context_reset_context(gr_direct_context_t* context, uint32_t state); 42 | SK_C_API void gr_direct_context_dump_memory_statistics(const gr_direct_context_t* context, sk_tracememorydump_t* dump); 43 | SK_C_API void gr_direct_context_free_gpu_resources(gr_direct_context_t* context); 44 | SK_C_API void gr_direct_context_perform_deferred_cleanup(gr_direct_context_t* context, long long ms); 45 | SK_C_API void gr_direct_context_purge_unlocked_resources_bytes(gr_direct_context_t* context, size_t bytesToPurge, bool preferScratchResources); 46 | SK_C_API void gr_direct_context_purge_unlocked_resources(gr_direct_context_t* context, bool scratchResourcesOnly); 47 | 48 | 49 | // GrGLInterface 50 | 51 | SK_C_API const gr_glinterface_t* gr_glinterface_create_native_interface(void); 52 | SK_C_API const gr_glinterface_t* gr_glinterface_assemble_interface(void* ctx, gr_gl_get_proc get); 53 | SK_C_API const gr_glinterface_t* gr_glinterface_assemble_gl_interface(void* ctx, gr_gl_get_proc get); 54 | SK_C_API const gr_glinterface_t* gr_glinterface_assemble_gles_interface(void* ctx, gr_gl_get_proc get); 55 | SK_C_API const gr_glinterface_t* gr_glinterface_assemble_webgl_interface(void* ctx, gr_gl_get_proc get); 56 | 57 | SK_C_API void gr_glinterface_unref(const gr_glinterface_t* glInterface); 58 | SK_C_API bool gr_glinterface_validate(const gr_glinterface_t* glInterface); 59 | SK_C_API bool gr_glinterface_has_extension(const gr_glinterface_t* glInterface, const char* extension); 60 | 61 | // GrVkExtensions 62 | 63 | SK_C_API gr_vk_extensions_t* gr_vk_extensions_new(void); 64 | SK_C_API void gr_vk_extensions_delete(gr_vk_extensions_t* extensions); 65 | SK_C_API void gr_vk_extensions_init(gr_vk_extensions_t* extensions, gr_vk_get_proc getProc, void* userData, vk_instance_t* instance, vk_physical_device_t* physDev, uint32_t instanceExtensionCount, const char** instanceExtensions, uint32_t deviceExtensionCount, const char** deviceExtensions); 66 | SK_C_API bool gr_vk_extensions_has_extension(gr_vk_extensions_t* extensions, const char* ext, uint32_t minVersion); 67 | 68 | // GrBackendTexture 69 | 70 | SK_C_API gr_backendtexture_t* gr_backendtexture_new_gl(int width, int height, bool mipmapped, const gr_gl_textureinfo_t* glInfo); 71 | SK_C_API gr_backendtexture_t* gr_backendtexture_new_vulkan(int width, int height, const gr_vk_imageinfo_t* vkInfo); 72 | SK_C_API gr_backendtexture_t* gr_backendtexture_new_metal(int width, int height, bool mipmapped, const gr_mtl_textureinfo_t* mtlInfo); 73 | SK_C_API void gr_backendtexture_delete(gr_backendtexture_t* texture); 74 | 75 | SK_C_API bool gr_backendtexture_is_valid(const gr_backendtexture_t* texture); 76 | SK_C_API int gr_backendtexture_get_width(const gr_backendtexture_t* texture); 77 | SK_C_API int gr_backendtexture_get_height(const gr_backendtexture_t* texture); 78 | SK_C_API bool gr_backendtexture_has_mipmaps(const gr_backendtexture_t* texture); 79 | SK_C_API gr_backend_t gr_backendtexture_get_backend(const gr_backendtexture_t* texture); 80 | SK_C_API bool gr_backendtexture_get_gl_textureinfo(const gr_backendtexture_t* texture, gr_gl_textureinfo_t* glInfo); 81 | 82 | 83 | // GrBackendRenderTarget 84 | 85 | SK_C_API gr_backendrendertarget_t* gr_backendrendertarget_new_gl(int width, int height, int samples, int stencils, const gr_gl_framebufferinfo_t* glInfo); 86 | SK_C_API gr_backendrendertarget_t* gr_backendrendertarget_new_vulkan(int width, int height, int samples, const gr_vk_imageinfo_t* vkImageInfo); 87 | SK_C_API gr_backendrendertarget_t* gr_backendrendertarget_new_metal(int width, int height, int samples, const gr_mtl_textureinfo_t* mtlInfo); 88 | 89 | SK_C_API void gr_backendrendertarget_delete(gr_backendrendertarget_t* rendertarget); 90 | 91 | SK_C_API bool gr_backendrendertarget_is_valid(const gr_backendrendertarget_t* rendertarget); 92 | SK_C_API int gr_backendrendertarget_get_width(const gr_backendrendertarget_t* rendertarget); 93 | SK_C_API int gr_backendrendertarget_get_height(const gr_backendrendertarget_t* rendertarget); 94 | SK_C_API int gr_backendrendertarget_get_samples(const gr_backendrendertarget_t* rendertarget); 95 | SK_C_API int gr_backendrendertarget_get_stencils(const gr_backendrendertarget_t* rendertarget); 96 | SK_C_API gr_backend_t gr_backendrendertarget_get_backend(const gr_backendrendertarget_t* rendertarget); 97 | SK_C_API bool gr_backendrendertarget_get_gl_framebufferinfo(const gr_backendrendertarget_t* rendertarget, gr_gl_framebufferinfo_t* glInfo); 98 | 99 | 100 | SK_C_PLUS_PLUS_END_GUARD 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/module.modulemap: -------------------------------------------------------------------------------- 1 | module CSkiaSharp [system] { 2 | umbrella header "umbrella.h" 3 | link "SkiaSharp" 4 | export * 5 | } 6 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_bitmap_DEFINED 11 | #define sk_bitmap_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_bitmap_destructor(sk_bitmap_t* cbitmap); 18 | SK_C_API sk_bitmap_t* sk_bitmap_new(void); 19 | SK_C_API void sk_bitmap_get_info(sk_bitmap_t* cbitmap, sk_imageinfo_t* info); 20 | SK_C_API void* sk_bitmap_get_pixels(sk_bitmap_t* cbitmap, size_t* length); 21 | SK_C_API size_t sk_bitmap_get_row_bytes(sk_bitmap_t* cbitmap); 22 | SK_C_API size_t sk_bitmap_get_byte_count(sk_bitmap_t* cbitmap); 23 | SK_C_API void sk_bitmap_reset(sk_bitmap_t* cbitmap); 24 | SK_C_API bool sk_bitmap_is_null(sk_bitmap_t* cbitmap); 25 | SK_C_API bool sk_bitmap_is_immutable(sk_bitmap_t* cbitmap); 26 | SK_C_API void sk_bitmap_set_immutable(sk_bitmap_t* cbitmap); 27 | SK_C_API void sk_bitmap_erase(sk_bitmap_t* cbitmap, sk_color_t color); 28 | SK_C_API void sk_bitmap_erase_rect(sk_bitmap_t* cbitmap, sk_color_t color, sk_irect_t* rect); 29 | SK_C_API uint8_t* sk_bitmap_get_addr_8(sk_bitmap_t* cbitmap, int x, int y); 30 | SK_C_API uint16_t* sk_bitmap_get_addr_16(sk_bitmap_t* cbitmap, int x, int y); 31 | SK_C_API uint32_t* sk_bitmap_get_addr_32(sk_bitmap_t* cbitmap, int x, int y); 32 | SK_C_API void* sk_bitmap_get_addr(sk_bitmap_t* cbitmap, int x, int y); 33 | SK_C_API sk_color_t sk_bitmap_get_pixel_color(sk_bitmap_t* cbitmap, int x, int y); 34 | SK_C_API bool sk_bitmap_ready_to_draw(sk_bitmap_t* cbitmap); 35 | SK_C_API void sk_bitmap_get_pixel_colors(sk_bitmap_t* cbitmap, sk_color_t* colors); 36 | SK_C_API bool sk_bitmap_install_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes, const sk_bitmap_release_proc releaseProc, void* context); 37 | SK_C_API bool sk_bitmap_install_pixels_with_pixmap(sk_bitmap_t* cbitmap, const sk_pixmap_t* cpixmap); 38 | SK_C_API bool sk_bitmap_install_mask_pixels(sk_bitmap_t* cbitmap, const sk_mask_t* cmask); 39 | SK_C_API bool sk_bitmap_try_alloc_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, size_t rowBytes); 40 | SK_C_API bool sk_bitmap_try_alloc_pixels_with_flags(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, uint32_t flags); 41 | SK_C_API void sk_bitmap_set_pixels(sk_bitmap_t* cbitmap, void* pixels); 42 | SK_C_API bool sk_bitmap_peek_pixels(sk_bitmap_t* cbitmap, sk_pixmap_t* cpixmap); 43 | SK_C_API bool sk_bitmap_extract_subset(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, sk_irect_t* subset); 44 | SK_C_API bool sk_bitmap_extract_alpha(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, const sk_paint_t* paint, sk_ipoint_t* offset); 45 | SK_C_API void sk_bitmap_notify_pixels_changed(sk_bitmap_t* cbitmap); 46 | SK_C_API void sk_bitmap_swap(sk_bitmap_t* cbitmap, sk_bitmap_t* cother); 47 | SK_C_API sk_shader_t* sk_bitmap_make_shader(sk_bitmap_t* cbitmap, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* cmatrix); 48 | 49 | SK_C_PLUS_PLUS_END_GUARD 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_canvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_canvas_DEFINED 11 | #define sk_canvas_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_canvas_destroy(sk_canvas_t*); 18 | SK_C_API int sk_canvas_save(sk_canvas_t*); 19 | SK_C_API int sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 20 | SK_C_API void sk_canvas_restore(sk_canvas_t*); 21 | SK_C_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy); 22 | SK_C_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy); 23 | SK_C_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees); 24 | SK_C_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians); 25 | SK_C_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy); 26 | SK_C_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*); 27 | SK_C_API bool sk_canvas_quick_reject(sk_canvas_t*, const sk_rect_t*); 28 | SK_C_API void sk_canvas_clip_region(sk_canvas_t* canvas, const sk_region_t* region, sk_clipop_t op); 29 | SK_C_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); 30 | SK_C_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 31 | SK_C_API void sk_canvas_draw_rrect(sk_canvas_t*, const sk_rrect_t*, const sk_paint_t*); 32 | SK_C_API void sk_canvas_draw_region(sk_canvas_t*, const sk_region_t*, const sk_paint_t*); 33 | SK_C_API void sk_canvas_draw_circle(sk_canvas_t*, float cx, float cy, float rad, const sk_paint_t*); 34 | SK_C_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 35 | SK_C_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*); 36 | SK_C_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, const sk_paint_t*); 37 | SK_C_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*, const sk_rect_t* src, const sk_rect_t* dst, const sk_paint_t*); 38 | SK_C_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*, const sk_matrix_t*, const sk_paint_t*); 39 | SK_C_API void sk_canvas_draw_drawable(sk_canvas_t*, sk_drawable_t*, const sk_matrix_t*); 40 | SK_C_API void sk_canvas_clear(sk_canvas_t*, sk_color_t); 41 | SK_C_API void sk_canvas_clear_color4f(sk_canvas_t*, sk_color4f_t); 42 | SK_C_API void sk_canvas_discard(sk_canvas_t*); 43 | SK_C_API int sk_canvas_get_save_count(sk_canvas_t*); 44 | SK_C_API void sk_canvas_restore_to_count(sk_canvas_t*, int saveCount); 45 | SK_C_API void sk_canvas_draw_color(sk_canvas_t* ccanvas, sk_color_t color, sk_blendmode_t mode); 46 | SK_C_API void sk_canvas_draw_color4f(sk_canvas_t* ccanvas, sk_color4f_t color, sk_blendmode_t mode); 47 | SK_C_API void sk_canvas_draw_points(sk_canvas_t*, sk_point_mode_t, size_t, const sk_point_t[], const sk_paint_t*); 48 | SK_C_API void sk_canvas_draw_point(sk_canvas_t*, float, float, const sk_paint_t*); 49 | SK_C_API void sk_canvas_draw_line(sk_canvas_t* ccanvas, float x0, float y0, float x1, float y1, sk_paint_t* cpaint); 50 | SK_C_API void sk_canvas_draw_simple_text(sk_canvas_t* ccanvas, const void* text, size_t byte_length, sk_text_encoding_t encoding, float x, float y, const sk_font_t* cfont, const sk_paint_t* cpaint); 51 | SK_C_API void sk_canvas_draw_text_blob (sk_canvas_t*, sk_textblob_t* text, float x, float y, const sk_paint_t* paint); 52 | SK_C_API void sk_canvas_reset_matrix(sk_canvas_t* ccanvas); 53 | SK_C_API void sk_canvas_set_matrix(sk_canvas_t* ccanvas, const sk_matrix_t* matrix); 54 | SK_C_API void sk_canvas_get_total_matrix(sk_canvas_t* ccanvas, sk_matrix_t* matrix); 55 | SK_C_API void sk_canvas_draw_round_rect(sk_canvas_t*, const sk_rect_t*, float rx, float ry, const sk_paint_t*); 56 | SK_C_API void sk_canvas_clip_rect_with_operation(sk_canvas_t* t, const sk_rect_t* crect, sk_clipop_t op, bool doAA); 57 | SK_C_API void sk_canvas_clip_path_with_operation(sk_canvas_t* t, const sk_path_t* crect, sk_clipop_t op, bool doAA); 58 | SK_C_API void sk_canvas_clip_rrect_with_operation(sk_canvas_t* t, const sk_rrect_t* crect, sk_clipop_t op, bool doAA); 59 | SK_C_API bool sk_canvas_get_local_clip_bounds(sk_canvas_t* t, sk_rect_t* cbounds); 60 | SK_C_API bool sk_canvas_get_device_clip_bounds(sk_canvas_t* t, sk_irect_t* cbounds); 61 | SK_C_API void sk_canvas_flush(sk_canvas_t* ccanvas); 62 | SK_C_API sk_canvas_t* sk_canvas_new_from_bitmap(const sk_bitmap_t* bitmap); 63 | SK_C_API void sk_canvas_draw_annotation(sk_canvas_t* t, const sk_rect_t* rect, const char* key, sk_data_t* value); 64 | SK_C_API void sk_canvas_draw_url_annotation(sk_canvas_t* t, const sk_rect_t* rect, sk_data_t* value); 65 | SK_C_API void sk_canvas_draw_named_destination_annotation(sk_canvas_t* t, const sk_point_t* point, sk_data_t* value); 66 | SK_C_API void sk_canvas_draw_link_destination_annotation(sk_canvas_t* t, const sk_rect_t* rect, sk_data_t* value); 67 | SK_C_API void sk_canvas_draw_image_lattice(sk_canvas_t* t, const sk_image_t* image, const sk_lattice_t* lattice, const sk_rect_t* dst, const sk_paint_t* paint); 68 | SK_C_API void sk_canvas_draw_image_nine(sk_canvas_t* t, const sk_image_t* image, const sk_irect_t* center, const sk_rect_t* dst, const sk_paint_t* paint); 69 | SK_C_API void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, const sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint); 70 | SK_C_API void sk_canvas_draw_arc(sk_canvas_t* ccanvas, const sk_rect_t* oval, float startAngle, float sweepAngle, bool useCenter, const sk_paint_t* paint); 71 | SK_C_API void sk_canvas_draw_drrect(sk_canvas_t* ccanvas, const sk_rrect_t* outer, const sk_rrect_t* inner, const sk_paint_t* paint); 72 | SK_C_API void sk_canvas_draw_atlas(sk_canvas_t* ccanvas, const sk_image_t* atlas, const sk_rsxform_t* xform, const sk_rect_t* tex, const sk_color_t* colors, int count, sk_blendmode_t mode, const sk_rect_t* cullRect, const sk_paint_t* paint); 73 | SK_C_API void sk_canvas_draw_patch(sk_canvas_t* ccanvas, const sk_point_t* cubics, const sk_color_t* colors, const sk_point_t* texCoords, sk_blendmode_t mode, const sk_paint_t* paint); 74 | SK_C_API bool sk_canvas_is_clip_empty(sk_canvas_t* ccanvas); 75 | SK_C_API bool sk_canvas_is_clip_rect(sk_canvas_t* ccanvas); 76 | 77 | SK_C_API sk_nodraw_canvas_t* sk_nodraw_canvas_new(int width, int height); 78 | SK_C_API void sk_nodraw_canvas_destroy(sk_nodraw_canvas_t*); 79 | 80 | SK_C_API sk_nway_canvas_t* sk_nway_canvas_new(int width, int height); 81 | SK_C_API void sk_nway_canvas_destroy(sk_nway_canvas_t*); 82 | SK_C_API void sk_nway_canvas_add_canvas(sk_nway_canvas_t*, sk_canvas_t* canvas); 83 | SK_C_API void sk_nway_canvas_remove_canvas(sk_nway_canvas_t*, sk_canvas_t* canvas); 84 | SK_C_API void sk_nway_canvas_remove_all(sk_nway_canvas_t*); 85 | 86 | SK_C_API sk_overdraw_canvas_t* sk_overdraw_canvas_new(sk_canvas_t* canvas); 87 | SK_C_API void sk_overdraw_canvas_destroy(sk_overdraw_canvas_t* canvas); 88 | 89 | SK_C_PLUS_PLUS_END_GUARD 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_codec_DEFINED 11 | #define sk_codec_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API size_t sk_codec_min_buffered_bytes_needed(void); 18 | 19 | SK_C_API sk_codec_t* sk_codec_new_from_stream(sk_stream_t* stream, sk_codec_result_t* result); 20 | SK_C_API sk_codec_t* sk_codec_new_from_data(sk_data_t* data); 21 | SK_C_API void sk_codec_destroy(sk_codec_t* codec); 22 | SK_C_API void sk_codec_get_info(sk_codec_t* codec, sk_imageinfo_t* info); 23 | SK_C_API sk_encodedorigin_t sk_codec_get_origin(sk_codec_t* codec); 24 | SK_C_API void sk_codec_get_scaled_dimensions(sk_codec_t* codec, float desiredScale, sk_isize_t* dimensions); 25 | SK_C_API bool sk_codec_get_valid_subset(sk_codec_t* codec, sk_irect_t* desiredSubset); 26 | SK_C_API sk_encoded_image_format_t sk_codec_get_encoded_format(sk_codec_t* codec); 27 | SK_C_API sk_codec_result_t sk_codec_get_pixels(sk_codec_t* codec, const sk_imageinfo_t* info, void* pixels, size_t rowBytes, const sk_codec_options_t* options); 28 | SK_C_API sk_codec_result_t sk_codec_start_incremental_decode(sk_codec_t* codec, const sk_imageinfo_t* info, void* pixels, size_t rowBytes, const sk_codec_options_t* options); 29 | SK_C_API sk_codec_result_t sk_codec_incremental_decode(sk_codec_t* codec, int* rowsDecoded); 30 | SK_C_API sk_codec_result_t sk_codec_start_scanline_decode(sk_codec_t* codec, const sk_imageinfo_t* info, const sk_codec_options_t* options); 31 | SK_C_API int sk_codec_get_scanlines(sk_codec_t* codec, void* dst, int countLines, size_t rowBytes); 32 | SK_C_API bool sk_codec_skip_scanlines(sk_codec_t* codec, int countLines); 33 | SK_C_API sk_codec_scanline_order_t sk_codec_get_scanline_order(sk_codec_t* codec); 34 | SK_C_API int sk_codec_next_scanline(sk_codec_t* codec); 35 | SK_C_API int sk_codec_output_scanline(sk_codec_t* codec, int inputScanline); 36 | SK_C_API int sk_codec_get_frame_count(sk_codec_t* codec); 37 | SK_C_API void sk_codec_get_frame_info(sk_codec_t* codec, sk_codec_frameinfo_t* frameInfo); 38 | SK_C_API bool sk_codec_get_frame_info_for_index(sk_codec_t* codec, int index, sk_codec_frameinfo_t* frameInfo); 39 | SK_C_API int sk_codec_get_repetition_count(sk_codec_t* codec); 40 | 41 | SK_C_PLUS_PLUS_END_GUARD 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_colorfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_colorfilter_DEFINED 11 | #define sk_colorfilter_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_colorfilter_unref(sk_colorfilter_t* filter); 18 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_mode(sk_color_t c, sk_blendmode_t mode); 19 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_lighting(sk_color_t mul, sk_color_t add); 20 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_compose(sk_colorfilter_t* outer, sk_colorfilter_t* inner); 21 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_color_matrix(const float array[20]); 22 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_luma_color(void); 23 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_high_contrast(const sk_highcontrastconfig_t* config); 24 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_table(const uint8_t table[256]); 25 | SK_C_API sk_colorfilter_t* sk_colorfilter_new_table_argb(const uint8_t tableA[256], const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256]); 26 | 27 | SK_C_PLUS_PLUS_END_GUARD 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_colorspace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_colorspace_DEFINED 11 | #define sk_colorspace_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | // TODO: skcms.h has things that may be useful 18 | 19 | // sk_colorspace_t 20 | 21 | SK_C_API void sk_colorspace_ref(sk_colorspace_t* colorspace); 22 | SK_C_API void sk_colorspace_unref(sk_colorspace_t* colorspace); 23 | SK_C_API sk_colorspace_t* sk_colorspace_new_srgb(void); 24 | SK_C_API sk_colorspace_t* sk_colorspace_new_srgb_linear(void); 25 | SK_C_API sk_colorspace_t* sk_colorspace_new_rgb(const sk_colorspace_transfer_fn_t* transferFn, const sk_colorspace_xyz_t* toXYZD50); 26 | SK_C_API sk_colorspace_t* sk_colorspace_new_icc(const sk_colorspace_icc_profile_t* profile); 27 | SK_C_API void sk_colorspace_to_profile(const sk_colorspace_t* colorspace, sk_colorspace_icc_profile_t* profile); 28 | SK_C_API bool sk_colorspace_gamma_close_to_srgb(const sk_colorspace_t* colorspace); 29 | SK_C_API bool sk_colorspace_gamma_is_linear(const sk_colorspace_t* colorspace); 30 | SK_C_API bool sk_colorspace_is_numerical_transfer_fn(const sk_colorspace_t* colorspace, sk_colorspace_transfer_fn_t* transferFn); 31 | SK_C_API bool sk_colorspace_to_xyzd50(const sk_colorspace_t* colorspace, sk_colorspace_xyz_t* toXYZD50); 32 | SK_C_API sk_colorspace_t* sk_colorspace_make_linear_gamma(const sk_colorspace_t* colorspace); 33 | SK_C_API sk_colorspace_t* sk_colorspace_make_srgb_gamma(const sk_colorspace_t* colorspace); 34 | SK_C_API bool sk_colorspace_is_srgb(const sk_colorspace_t* colorspace); 35 | SK_C_API bool sk_colorspace_equals(const sk_colorspace_t* src, const sk_colorspace_t* dst); 36 | 37 | // sk_colorspace_transfer_fn_t 38 | 39 | SK_C_API void sk_colorspace_transfer_fn_named_srgb(sk_colorspace_transfer_fn_t* transferFn); 40 | SK_C_API void sk_colorspace_transfer_fn_named_2dot2(sk_colorspace_transfer_fn_t* transferFn); 41 | SK_C_API void sk_colorspace_transfer_fn_named_linear(sk_colorspace_transfer_fn_t* transferFn); 42 | SK_C_API void sk_colorspace_transfer_fn_named_rec2020(sk_colorspace_transfer_fn_t* transferFn); 43 | SK_C_API void sk_colorspace_transfer_fn_named_pq(sk_colorspace_transfer_fn_t* transferFn); 44 | SK_C_API void sk_colorspace_transfer_fn_named_hlg(sk_colorspace_transfer_fn_t* transferFn); 45 | SK_C_API float sk_colorspace_transfer_fn_eval(const sk_colorspace_transfer_fn_t* transferFn, float x); 46 | SK_C_API bool sk_colorspace_transfer_fn_invert(const sk_colorspace_transfer_fn_t* src, sk_colorspace_transfer_fn_t* dst); 47 | 48 | // sk_colorspace_primaries_t 49 | 50 | SK_C_API bool sk_colorspace_primaries_to_xyzd50(const sk_colorspace_primaries_t* primaries, sk_colorspace_xyz_t* toXYZD50); 51 | 52 | // sk_colorspace_xyz_t 53 | 54 | SK_C_API void sk_colorspace_xyz_named_srgb(sk_colorspace_xyz_t* xyz); 55 | SK_C_API void sk_colorspace_xyz_named_adobe_rgb(sk_colorspace_xyz_t* xyz); 56 | SK_C_API void sk_colorspace_xyz_named_display_p3(sk_colorspace_xyz_t* xyz); 57 | SK_C_API void sk_colorspace_xyz_named_rec2020(sk_colorspace_xyz_t* xyz); 58 | SK_C_API void sk_colorspace_xyz_named_xyz(sk_colorspace_xyz_t* xyz); 59 | SK_C_API bool sk_colorspace_xyz_invert(const sk_colorspace_xyz_t* src, sk_colorspace_xyz_t* dst); 60 | SK_C_API void sk_colorspace_xyz_concat(const sk_colorspace_xyz_t* a, const sk_colorspace_xyz_t* b, sk_colorspace_xyz_t* result); 61 | 62 | // sk_colorspace_icc_profile_t 63 | 64 | SK_C_API void sk_colorspace_icc_profile_delete(sk_colorspace_icc_profile_t* profile); 65 | SK_C_API sk_colorspace_icc_profile_t* sk_colorspace_icc_profile_new(void); 66 | SK_C_API bool sk_colorspace_icc_profile_parse(const void* buffer, size_t length, sk_colorspace_icc_profile_t* profile); 67 | SK_C_API const uint8_t* sk_colorspace_icc_profile_get_buffer(const sk_colorspace_icc_profile_t* profile, uint32_t* size); 68 | SK_C_API bool sk_colorspace_icc_profile_get_to_xyzd50(const sk_colorspace_icc_profile_t* profile, sk_colorspace_xyz_t* toXYZD50); 69 | 70 | // sk_color4f_t 71 | 72 | SK_C_API sk_color_t sk_color4f_to_color(const sk_color4f_t* color4f); 73 | SK_C_API void sk_color4f_from_color(sk_color_t color, sk_color4f_t* color4f); 74 | 75 | SK_C_PLUS_PLUS_END_GUARD 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_colortable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_colortable_DEFINED 11 | #define sk_colortable_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_colortable_unref(sk_colortable_t* ctable); 18 | SK_C_API sk_colortable_t* sk_colortable_new(const sk_pmcolor_t* colors, int count); 19 | SK_C_API int sk_colortable_count(const sk_colortable_t* ctable); 20 | SK_C_API void sk_colortable_read_colors(const sk_colortable_t* ctable, sk_pmcolor_t** colors); 21 | 22 | SK_C_PLUS_PLUS_END_GUARD 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_data_DEFINED 11 | #define sk_data_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_data_t* sk_data_new_empty(void); 18 | SK_C_API sk_data_t* sk_data_new_with_copy(const void* src, size_t length); 19 | SK_C_API sk_data_t* sk_data_new_subset(const sk_data_t* src, size_t offset, size_t length); 20 | SK_C_API void sk_data_ref(const sk_data_t*); 21 | SK_C_API void sk_data_unref(const sk_data_t*); 22 | SK_C_API size_t sk_data_get_size(const sk_data_t*); 23 | SK_C_API const void* sk_data_get_data(const sk_data_t*); 24 | SK_C_API sk_data_t* sk_data_new_from_file(const char* path); 25 | SK_C_API sk_data_t* sk_data_new_from_stream(sk_stream_t* stream, size_t length); 26 | SK_C_API const uint8_t* sk_data_get_bytes(const sk_data_t*); 27 | SK_C_API sk_data_t* sk_data_new_with_proc(const void* ptr, size_t length, sk_data_release_proc proc, void* ctx); 28 | SK_C_API sk_data_t* sk_data_new_uninitialized(size_t size); 29 | 30 | SK_C_PLUS_PLUS_END_GUARD 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_document.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_document_DEFINED 11 | #define sk_document_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_document_unref(sk_document_t* document); 18 | 19 | SK_C_API sk_document_t* sk_document_create_pdf_from_stream(sk_wstream_t* stream); 20 | SK_C_API sk_document_t* sk_document_create_pdf_from_stream_with_metadata(sk_wstream_t* stream, const sk_document_pdf_metadata_t* metadata); 21 | 22 | SK_C_API sk_document_t* sk_document_create_xps_from_stream(sk_wstream_t* stream, float dpi); 23 | 24 | SK_C_API sk_canvas_t* sk_document_begin_page(sk_document_t* document, float width, float height, const sk_rect_t* content); 25 | SK_C_API void sk_document_end_page(sk_document_t* document); 26 | SK_C_API void sk_document_close(sk_document_t* document); 27 | SK_C_API void sk_document_abort(sk_document_t* document); 28 | 29 | SK_C_PLUS_PLUS_END_GUARD 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_drawable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Xamarin Inc. 3 | * Copyright 2017 Microsoft Corporation. All rights reserved. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | #ifndef sk_drawable_DEFINED 10 | #define sk_drawable_DEFINED 11 | 12 | #include "sk_types.h" 13 | 14 | SK_C_PLUS_PLUS_BEGIN_GUARD 15 | 16 | typedef struct sk_drawable_t sk_drawable_t; 17 | 18 | SK_C_API void sk_drawable_unref (sk_drawable_t*); 19 | SK_C_API uint32_t sk_drawable_get_generation_id (sk_drawable_t*); 20 | SK_C_API void sk_drawable_get_bounds (sk_drawable_t*, sk_rect_t*); 21 | SK_C_API void sk_drawable_draw (sk_drawable_t*, sk_canvas_t*, const sk_matrix_t*); 22 | SK_C_API sk_picture_t* sk_drawable_new_picture_snapshot(sk_drawable_t*); 23 | SK_C_API void sk_drawable_notify_drawing_changed (sk_drawable_t*); 24 | 25 | SK_C_PLUS_PLUS_END_GUARD 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_font_DEFINED 11 | #define sk_font_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | // sk_font_t 18 | 19 | SK_C_API sk_font_t* sk_font_new(void); 20 | SK_C_API sk_font_t* sk_font_new_with_values(sk_typeface_t* typeface, float size, float scaleX, float skewX); 21 | SK_C_API void sk_font_delete(sk_font_t* font); 22 | SK_C_API bool sk_font_is_force_auto_hinting(const sk_font_t* font); 23 | SK_C_API void sk_font_set_force_auto_hinting(sk_font_t* font, bool value); 24 | SK_C_API bool sk_font_is_embedded_bitmaps(const sk_font_t* font); 25 | SK_C_API void sk_font_set_embedded_bitmaps(sk_font_t* font, bool value); 26 | SK_C_API bool sk_font_is_subpixel(const sk_font_t* font); 27 | SK_C_API void sk_font_set_subpixel(sk_font_t* font, bool value); 28 | SK_C_API bool sk_font_is_linear_metrics(const sk_font_t* font); 29 | SK_C_API void sk_font_set_linear_metrics(sk_font_t* font, bool value); 30 | SK_C_API bool sk_font_is_embolden(const sk_font_t* font); 31 | SK_C_API void sk_font_set_embolden(sk_font_t* font, bool value); 32 | SK_C_API bool sk_font_is_baseline_snap(const sk_font_t* font); 33 | SK_C_API void sk_font_set_baseline_snap(sk_font_t* font, bool value); 34 | SK_C_API sk_font_edging_t sk_font_get_edging(const sk_font_t* font); 35 | SK_C_API void sk_font_set_edging(sk_font_t* font, sk_font_edging_t value); 36 | SK_C_API sk_font_hinting_t sk_font_get_hinting(const sk_font_t* font); 37 | SK_C_API void sk_font_set_hinting(sk_font_t* font, sk_font_hinting_t value); 38 | SK_C_API sk_typeface_t* sk_font_get_typeface(const sk_font_t* font); 39 | SK_C_API void sk_font_set_typeface(sk_font_t* font, sk_typeface_t* value); 40 | SK_C_API float sk_font_get_size(const sk_font_t* font); 41 | SK_C_API void sk_font_set_size(sk_font_t* font, float value); 42 | SK_C_API float sk_font_get_scale_x(const sk_font_t* font); 43 | SK_C_API void sk_font_set_scale_x(sk_font_t* font, float value); 44 | SK_C_API float sk_font_get_skew_x(const sk_font_t* font); 45 | SK_C_API void sk_font_set_skew_x(sk_font_t* font, float value); 46 | SK_C_API int sk_font_text_to_glyphs(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, uint16_t glyphs[], int maxGlyphCount); 47 | SK_C_API uint16_t sk_font_unichar_to_glyph(const sk_font_t* font, int32_t uni); 48 | SK_C_API void sk_font_unichars_to_glyphs(const sk_font_t* font, const int32_t uni[], int count, uint16_t glyphs[]); 49 | SK_C_API float sk_font_measure_text(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, sk_rect_t* bounds, const sk_paint_t* paint); 50 | // NOTE: it appears that .NET Framework 4.7 has an issue with returning float? 51 | // https://github.com/mono/SkiaSharp/issues/1409 52 | SK_C_API void sk_font_measure_text_no_return(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, sk_rect_t* bounds, const sk_paint_t* paint, float* measuredWidth); 53 | SK_C_API size_t sk_font_break_text(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, float maxWidth, float* measuredWidth, const sk_paint_t* paint); 54 | SK_C_API void sk_font_get_widths_bounds(const sk_font_t* font, const uint16_t glyphs[], int count, float widths[], sk_rect_t bounds[], const sk_paint_t* paint); 55 | SK_C_API void sk_font_get_pos(const sk_font_t* font, const uint16_t glyphs[], int count, sk_point_t pos[], sk_point_t* origin); 56 | SK_C_API void sk_font_get_xpos(const sk_font_t* font, const uint16_t glyphs[], int count, float xpos[], float origin); 57 | SK_C_API bool sk_font_get_path(const sk_font_t* font, uint16_t glyph, sk_path_t* path); 58 | SK_C_API void sk_font_get_paths(const sk_font_t* font, uint16_t glyphs[], int count, const sk_glyph_path_proc glyphPathProc, void* context); 59 | SK_C_API float sk_font_get_metrics(const sk_font_t* font, sk_fontmetrics_t* metrics); 60 | 61 | // sk_text_utils 62 | 63 | SK_C_API void sk_text_utils_get_path(const void* text, size_t length, sk_text_encoding_t encoding, float x, float y, const sk_font_t* font, sk_path_t* path); 64 | SK_C_API void sk_text_utils_get_pos_path(const void* text, size_t length, sk_text_encoding_t encoding, const sk_point_t pos[], const sk_font_t* font, sk_path_t* path); 65 | 66 | SK_C_PLUS_PLUS_END_GUARD 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_general.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Microsoft Corporation. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef sk_general_DEFINED 9 | #define sk_general_DEFINED 10 | 11 | #include "sk_types.h" 12 | 13 | SK_C_PLUS_PLUS_BEGIN_GUARD 14 | 15 | // ref counting 16 | 17 | SK_C_API bool sk_refcnt_unique(const sk_refcnt_t* refcnt); 18 | SK_C_API int sk_refcnt_get_ref_count(const sk_refcnt_t* refcnt); 19 | SK_C_API void sk_refcnt_safe_ref(sk_refcnt_t* refcnt); 20 | SK_C_API void sk_refcnt_safe_unref(sk_refcnt_t* refcnt); 21 | 22 | SK_C_API bool sk_nvrefcnt_unique(const sk_nvrefcnt_t* refcnt); 23 | SK_C_API int sk_nvrefcnt_get_ref_count(const sk_nvrefcnt_t* refcnt); 24 | SK_C_API void sk_nvrefcnt_safe_ref(sk_nvrefcnt_t* refcnt); 25 | SK_C_API void sk_nvrefcnt_safe_unref(sk_nvrefcnt_t* refcnt); 26 | 27 | // color type 28 | 29 | SK_C_API sk_colortype_t sk_colortype_get_default_8888(void); 30 | 31 | // library information 32 | 33 | SK_C_API int sk_version_get_milestone(void); 34 | SK_C_API int sk_version_get_increment(void); 35 | SK_C_API const char* sk_version_get_string(void); 36 | 37 | SK_C_PLUS_PLUS_END_GUARD 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_graphics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_graphics_DEFINED 11 | #define sk_graphics_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | 18 | SK_C_API void sk_graphics_init(void); 19 | 20 | // purge 21 | SK_C_API void sk_graphics_purge_font_cache(void); 22 | SK_C_API void sk_graphics_purge_resource_cache(void); 23 | SK_C_API void sk_graphics_purge_all_caches(void); 24 | 25 | // font cache 26 | SK_C_API size_t sk_graphics_get_font_cache_used(void); 27 | SK_C_API size_t sk_graphics_get_font_cache_limit(void); 28 | SK_C_API size_t sk_graphics_set_font_cache_limit(size_t bytes); 29 | SK_C_API int sk_graphics_get_font_cache_count_used(void); 30 | SK_C_API int sk_graphics_get_font_cache_count_limit(void); 31 | SK_C_API int sk_graphics_set_font_cache_count_limit(int count); 32 | SK_C_API int sk_graphics_get_font_cache_point_size_limit(void); 33 | SK_C_API int sk_graphics_set_font_cache_point_size_limit(int maxPointSize); 34 | 35 | // resource cache 36 | SK_C_API size_t sk_graphics_get_resource_cache_total_bytes_used(void); 37 | SK_C_API size_t sk_graphics_get_resource_cache_total_byte_limit(void); 38 | SK_C_API size_t sk_graphics_set_resource_cache_total_byte_limit(size_t newLimit); 39 | SK_C_API size_t sk_graphics_get_resource_cache_single_allocation_byte_limit(void); 40 | SK_C_API size_t sk_graphics_set_resource_cache_single_allocation_byte_limit(size_t newLimit); 41 | 42 | // dump 43 | SK_C_API void sk_graphics_dump_memory_statistics(sk_tracememorydump_t* dump); 44 | 45 | SK_C_PLUS_PLUS_END_GUARD 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_image_DEFINED 11 | #define sk_image_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes); 18 | SK_C_API sk_image_t* sk_image_new_raster_copy_with_pixmap(const sk_pixmap_t* pixmap); 19 | SK_C_API sk_image_t* sk_image_new_raster_data(const sk_imageinfo_t* cinfo, sk_data_t* pixels, size_t rowBytes); 20 | SK_C_API sk_image_t* sk_image_new_raster(const sk_pixmap_t* pixmap, sk_image_raster_release_proc releaseProc, void* context); 21 | SK_C_API sk_image_t* sk_image_new_from_bitmap(const sk_bitmap_t *cbitmap); 22 | SK_C_API sk_image_t* sk_image_new_from_encoded(sk_data_t* encoded); 23 | SK_C_API sk_image_t* sk_image_new_from_texture(gr_recording_context_t* context, const gr_backendtexture_t* texture, gr_surfaceorigin_t origin, sk_colortype_t colorType, sk_alphatype_t alpha, sk_colorspace_t* colorSpace, sk_image_texture_release_proc releaseProc, void* releaseContext); 24 | SK_C_API sk_image_t* sk_image_new_from_adopted_texture(gr_recording_context_t* context, const gr_backendtexture_t* texture, gr_surfaceorigin_t origin, sk_colortype_t colorType, sk_alphatype_t alpha, sk_colorspace_t* colorSpace); 25 | SK_C_API sk_image_t* sk_image_new_from_picture(sk_picture_t* picture, const sk_isize_t* dimensions, const sk_matrix_t* matrix, const sk_paint_t* paint); 26 | 27 | SK_C_API sk_image_t* sk_image_make_subset(const sk_image_t* cimage, const sk_irect_t* subset); 28 | SK_C_API sk_image_t* sk_image_make_texture_image(const sk_image_t* cimage, gr_direct_context_t* context, bool mipmapped); 29 | SK_C_API sk_image_t* sk_image_make_non_texture_image(const sk_image_t* cimage); 30 | SK_C_API sk_image_t* sk_image_make_raster_image(const sk_image_t* cimage); 31 | SK_C_API sk_image_t* sk_image_make_with_filter_legacy(const sk_image_t* cimage, const sk_imagefilter_t* filter, const sk_irect_t* subset, const sk_irect_t* clipBounds, sk_irect_t* outSubset, sk_ipoint_t* outOffset); 32 | SK_C_API sk_image_t* sk_image_make_with_filter(const sk_image_t* cimage, gr_recording_context_t* context, const sk_imagefilter_t* filter, const sk_irect_t* subset, const sk_irect_t* clipBounds, sk_irect_t* outSubset, sk_ipoint_t* outOffset); 33 | 34 | SK_C_API void sk_image_ref(const sk_image_t*); 35 | SK_C_API void sk_image_unref(const sk_image_t*); 36 | SK_C_API int sk_image_get_width(const sk_image_t*); 37 | SK_C_API int sk_image_get_height(const sk_image_t*); 38 | SK_C_API uint32_t sk_image_get_unique_id(const sk_image_t*); 39 | SK_C_API sk_alphatype_t sk_image_get_alpha_type(const sk_image_t*); 40 | SK_C_API sk_colortype_t sk_image_get_color_type(const sk_image_t*); 41 | SK_C_API sk_colorspace_t* sk_image_get_colorspace(const sk_image_t*); 42 | SK_C_API bool sk_image_is_alpha_only(const sk_image_t*); 43 | SK_C_API sk_shader_t* sk_image_make_shader(const sk_image_t*, sk_shader_tilemode_t tileX, sk_shader_tilemode_t tileY, const sk_matrix_t* localMatrix); 44 | SK_C_API bool sk_image_peek_pixels(const sk_image_t* image, sk_pixmap_t* pixmap); 45 | SK_C_API bool sk_image_is_texture_backed(const sk_image_t* image); 46 | SK_C_API bool sk_image_is_lazy_generated(const sk_image_t* image); 47 | SK_C_API bool sk_image_is_valid(const sk_image_t* image, gr_recording_context_t* context); 48 | SK_C_API bool sk_image_read_pixels(const sk_image_t* image, const sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, sk_image_caching_hint_t cachingHint); 49 | SK_C_API bool sk_image_read_pixels_into_pixmap(const sk_image_t* image, const sk_pixmap_t* dst, int srcX, int srcY, sk_image_caching_hint_t cachingHint); 50 | SK_C_API bool sk_image_scale_pixels(const sk_image_t* image, const sk_pixmap_t* dst, sk_filter_quality_t quality, sk_image_caching_hint_t cachingHint); 51 | SK_C_API sk_data_t* sk_image_ref_encoded(const sk_image_t*); 52 | SK_C_API sk_data_t* sk_image_encode(const sk_image_t*); 53 | SK_C_API sk_data_t* sk_image_encode_specific(const sk_image_t* cimage, sk_encoded_image_format_t encoder, int quality); 54 | 55 | SK_C_PLUS_PLUS_END_GUARD 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_imagefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_imagefilter_DEFINED 11 | #define sk_imagefilter_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | 18 | // sk_imagefilter_croprect_t 19 | 20 | SK_C_API sk_imagefilter_croprect_t* sk_imagefilter_croprect_new(void); 21 | SK_C_API sk_imagefilter_croprect_t* sk_imagefilter_croprect_new_with_rect(const sk_rect_t* rect, uint32_t flags); 22 | SK_C_API void sk_imagefilter_croprect_destructor(sk_imagefilter_croprect_t* cropRect); 23 | SK_C_API void sk_imagefilter_croprect_get_rect(sk_imagefilter_croprect_t* cropRect, sk_rect_t* rect); 24 | SK_C_API uint32_t sk_imagefilter_croprect_get_flags(sk_imagefilter_croprect_t* cropRect); 25 | 26 | 27 | // sk_imagefilter_t 28 | 29 | SK_C_API void sk_imagefilter_unref(sk_imagefilter_t*); 30 | 31 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_alpha_threshold(const sk_region_t* region, float innerThreshold, float outerThreshold, sk_imagefilter_t* input); 32 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_arithmetic(float k1, float k2, float k3, float k4, bool enforcePMColor, sk_imagefilter_t* background, sk_imagefilter_t* foreground, const sk_imagefilter_croprect_t* cropRect); 33 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_blur(float sigmaX, float sigmaY, sk_shader_tilemode_t tileMode, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 34 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_color_filter(sk_colorfilter_t* cf, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 35 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_compose(sk_imagefilter_t* outer, sk_imagefilter_t* inner); 36 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_displacement_map_effect(sk_color_channel_t xChannelSelector, sk_color_channel_t yChannelSelector, float scale, sk_imagefilter_t* displacement, sk_imagefilter_t* color, const sk_imagefilter_croprect_t* cropRect); 37 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_drop_shadow(float dx, float dy, float sigmaX, float sigmaY, sk_color_t color, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 38 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_drop_shadow_only(float dx, float dy, float sigmaX, float sigmaY, sk_color_t color, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 39 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_image_source(sk_image_t* image, const sk_rect_t* srcRect, const sk_rect_t* dstRect, sk_filter_quality_t filterQuality); 40 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_image_source_default(sk_image_t* image); 41 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_magnifier(const sk_rect_t* src, float inset, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 42 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_matrix_convolution(const sk_isize_t* kernelSize, const float kernel[], float gain, float bias, const sk_ipoint_t* kernelOffset, sk_shader_tilemode_t tileMode, bool convolveAlpha, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 43 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_matrix(const sk_matrix_t* matrix, sk_filter_quality_t quality, sk_imagefilter_t* input); 44 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_merge(sk_imagefilter_t* filters[], int count, const sk_imagefilter_croprect_t* cropRect); 45 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_offset(float dx, float dy, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 46 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_paint(const sk_paint_t* paint, const sk_imagefilter_croprect_t* cropRect); 47 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_picture(sk_picture_t* picture); 48 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_picture_with_croprect(sk_picture_t* picture, const sk_rect_t* cropRect); 49 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_tile(const sk_rect_t* src, const sk_rect_t* dst, sk_imagefilter_t* input); 50 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_xfermode(sk_blendmode_t mode, sk_imagefilter_t* background, sk_imagefilter_t* foreground, const sk_imagefilter_croprect_t* cropRect); 51 | 52 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_dilate(float radiusX, float radiusY, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 53 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_erode(float radiusX, float radiusY, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 54 | 55 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_distant_lit_diffuse(const sk_point3_t* direction, sk_color_t lightColor, float surfaceScale, float kd, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 56 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_point_lit_diffuse(const sk_point3_t* location, sk_color_t lightColor, float surfaceScale, float kd, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 57 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_spot_lit_diffuse(const sk_point3_t* location, const sk_point3_t* target, float specularExponent, float cutoffAngle, sk_color_t lightColor, float surfaceScale, float kd, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 58 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_distant_lit_specular(const sk_point3_t* direction, sk_color_t lightColor, float surfaceScale, float ks, float shininess, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 59 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_point_lit_specular(const sk_point3_t* location, sk_color_t lightColor, float surfaceScale, float ks, float shininess, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 60 | SK_C_API sk_imagefilter_t* sk_imagefilter_new_spot_lit_specular(const sk_point3_t* location, const sk_point3_t* target, float specularExponent, float cutoffAngle, sk_color_t lightColor, float surfaceScale, float ks, float shininess, sk_imagefilter_t* input, const sk_imagefilter_croprect_t* cropRect); 61 | 62 | 63 | SK_C_PLUS_PLUS_END_GUARD 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Bluebeam Inc. 5 | * Copyright 2017 Microsoft Corporation. All rights reserved. 6 | * 7 | * Use of this source code is governed by a BSD-style license that can be 8 | * found in the LICENSE file. 9 | */ 10 | 11 | #ifndef sk_mask_DEFINED 12 | #define sk_mask_DEFINED 13 | 14 | #include "sk_types.h" 15 | 16 | SK_C_PLUS_PLUS_BEGIN_GUARD 17 | 18 | SK_C_API uint8_t* sk_mask_alloc_image(size_t bytes); 19 | SK_C_API void sk_mask_free_image(void* image); 20 | SK_C_API bool sk_mask_is_empty(sk_mask_t* cmask); 21 | SK_C_API size_t sk_mask_compute_image_size(sk_mask_t* cmask); 22 | SK_C_API size_t sk_mask_compute_total_image_size(sk_mask_t* cmask); 23 | SK_C_API uint8_t* sk_mask_get_addr_1(sk_mask_t* cmask, int x, int y); 24 | SK_C_API uint8_t* sk_mask_get_addr_8(sk_mask_t* cmask, int x, int y); 25 | SK_C_API uint16_t* sk_mask_get_addr_lcd_16(sk_mask_t* cmask, int x, int y); 26 | SK_C_API uint32_t* sk_mask_get_addr_32(sk_mask_t* cmask, int x, int y); 27 | SK_C_API void* sk_mask_get_addr(sk_mask_t* cmask, int x, int y); 28 | 29 | SK_C_PLUS_PLUS_END_GUARD 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_maskfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_maskfilter_DEFINED 11 | #define sk_maskfilter_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_maskfilter_ref(sk_maskfilter_t*); 18 | SK_C_API void sk_maskfilter_unref(sk_maskfilter_t*); 19 | SK_C_API sk_maskfilter_t* sk_maskfilter_new_blur(sk_blurstyle_t, float sigma); 20 | SK_C_API sk_maskfilter_t* sk_maskfilter_new_blur_with_flags(sk_blurstyle_t, float sigma, bool respectCTM); 21 | SK_C_API sk_maskfilter_t* sk_maskfilter_new_table(const uint8_t table[256]); 22 | SK_C_API sk_maskfilter_t* sk_maskfilter_new_gamma(float gamma); 23 | SK_C_API sk_maskfilter_t* sk_maskfilter_new_clip(uint8_t min, uint8_t max); 24 | SK_C_API sk_maskfilter_t* sk_maskfilter_new_shader(sk_shader_t* cshader); 25 | 26 | SK_C_PLUS_PLUS_END_GUARD 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_matrix_DEFINED 11 | #define sk_matrix_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | 18 | SK_C_API bool sk_matrix_try_invert (sk_matrix_t *matrix, sk_matrix_t *result); 19 | SK_C_API void sk_matrix_concat (sk_matrix_t *result, sk_matrix_t *first, sk_matrix_t *second); 20 | SK_C_API void sk_matrix_pre_concat (sk_matrix_t *result, sk_matrix_t *matrix); 21 | SK_C_API void sk_matrix_post_concat (sk_matrix_t *result, sk_matrix_t *matrix); 22 | SK_C_API void sk_matrix_map_rect (sk_matrix_t *matrix, sk_rect_t *dest, sk_rect_t *source); 23 | SK_C_API void sk_matrix_map_points (sk_matrix_t *matrix, sk_point_t *dst, sk_point_t *src, int count); 24 | SK_C_API void sk_matrix_map_vectors (sk_matrix_t *matrix, sk_point_t *dst, sk_point_t *src, int count); 25 | SK_C_API void sk_matrix_map_xy (sk_matrix_t *matrix, float x, float y, sk_point_t* result); 26 | SK_C_API void sk_matrix_map_vector (sk_matrix_t *matrix, float x, float y, sk_point_t* result); 27 | SK_C_API float sk_matrix_map_radius (sk_matrix_t *matrix, float radius); 28 | 29 | 30 | SK_C_API sk_3dview_t* sk_3dview_new (void); 31 | SK_C_API void sk_3dview_destroy (sk_3dview_t* cview); 32 | SK_C_API void sk_3dview_save (sk_3dview_t* cview); 33 | SK_C_API void sk_3dview_restore (sk_3dview_t* cview); 34 | SK_C_API void sk_3dview_translate (sk_3dview_t* cview, float x, float y, float z); 35 | SK_C_API void sk_3dview_rotate_x_degrees (sk_3dview_t* cview, float degrees); 36 | SK_C_API void sk_3dview_rotate_y_degrees (sk_3dview_t* cview, float degrees); 37 | SK_C_API void sk_3dview_rotate_z_degrees (sk_3dview_t* cview, float degrees); 38 | SK_C_API void sk_3dview_rotate_x_radians (sk_3dview_t* cview, float radians); 39 | SK_C_API void sk_3dview_rotate_y_radians (sk_3dview_t* cview, float radians); 40 | SK_C_API void sk_3dview_rotate_z_radians (sk_3dview_t* cview, float radians); 41 | SK_C_API void sk_3dview_get_matrix (sk_3dview_t* cview, sk_matrix_t* cmatrix); 42 | SK_C_API void sk_3dview_apply_to_canvas (sk_3dview_t* cview, sk_canvas_t* ccanvas); 43 | SK_C_API float sk_3dview_dot_with_normal (sk_3dview_t* cview, float dx, float dy, float dz); 44 | 45 | 46 | SK_C_API void sk_matrix44_destroy (sk_matrix44_t* matrix); 47 | SK_C_API sk_matrix44_t* sk_matrix44_new (void); 48 | SK_C_API sk_matrix44_t* sk_matrix44_new_identity (void); 49 | SK_C_API sk_matrix44_t* sk_matrix44_new_copy (const sk_matrix44_t* src); 50 | SK_C_API sk_matrix44_t* sk_matrix44_new_concat (const sk_matrix44_t* a, const sk_matrix44_t* b); 51 | SK_C_API sk_matrix44_t* sk_matrix44_new_matrix (const sk_matrix_t* src); 52 | SK_C_API bool sk_matrix44_equals (sk_matrix44_t* matrix, const sk_matrix44_t* other); 53 | SK_C_API void sk_matrix44_to_matrix (sk_matrix44_t* matrix, sk_matrix_t* dst); 54 | SK_C_API sk_matrix44_type_mask_t sk_matrix44_get_type (sk_matrix44_t* matrix); 55 | SK_C_API void sk_matrix44_set_identity (sk_matrix44_t* matrix); 56 | SK_C_API float sk_matrix44_get (sk_matrix44_t* matrix, int row, int col); 57 | SK_C_API void sk_matrix44_set (sk_matrix44_t* matrix, int row, int col, float value); 58 | SK_C_API void sk_matrix44_as_col_major (sk_matrix44_t* matrix, float* dst); 59 | SK_C_API void sk_matrix44_as_row_major (sk_matrix44_t* matrix, float* dst); 60 | SK_C_API void sk_matrix44_set_col_major (sk_matrix44_t* matrix, float* dst); 61 | SK_C_API void sk_matrix44_set_row_major (sk_matrix44_t* matrix, float* dst); 62 | SK_C_API void sk_matrix44_set_3x3_row_major (sk_matrix44_t* matrix, float* dst); 63 | SK_C_API void sk_matrix44_set_translate (sk_matrix44_t* matrix, float dx, float dy, float dz); 64 | SK_C_API void sk_matrix44_pre_translate (sk_matrix44_t* matrix, float dx, float dy, float dz); 65 | SK_C_API void sk_matrix44_post_translate (sk_matrix44_t* matrix, float dx, float dy, float dz); 66 | SK_C_API void sk_matrix44_set_scale (sk_matrix44_t* matrix, float sx, float sy, float sz); 67 | SK_C_API void sk_matrix44_pre_scale (sk_matrix44_t* matrix, float sx, float sy, float sz); 68 | SK_C_API void sk_matrix44_post_scale (sk_matrix44_t* matrix, float sx, float sy, float sz); 69 | SK_C_API void sk_matrix44_set_rotate_about_degrees (sk_matrix44_t* matrix, float x, float y, float z, float degrees); 70 | SK_C_API void sk_matrix44_set_rotate_about_radians (sk_matrix44_t* matrix, float x, float y, float z, float radians); 71 | SK_C_API void sk_matrix44_set_rotate_about_radians_unit (sk_matrix44_t* matrix, float x, float y, float z, float radians); 72 | SK_C_API void sk_matrix44_set_concat (sk_matrix44_t* matrix, const sk_matrix44_t* a, const sk_matrix44_t* b); 73 | SK_C_API void sk_matrix44_pre_concat (sk_matrix44_t* matrix, const sk_matrix44_t* m); 74 | SK_C_API void sk_matrix44_post_concat (sk_matrix44_t* matrix, const sk_matrix44_t* m); 75 | SK_C_API bool sk_matrix44_invert (sk_matrix44_t* matrix, sk_matrix44_t* inverse); 76 | SK_C_API void sk_matrix44_transpose (sk_matrix44_t* matrix); 77 | SK_C_API void sk_matrix44_map_scalars (sk_matrix44_t* matrix, const float* src, float* dst); 78 | SK_C_API void sk_matrix44_map2 (sk_matrix44_t* matrix, const float* src2, int count, float* dst4); 79 | SK_C_API bool sk_matrix44_preserves_2d_axis_alignment (sk_matrix44_t* matrix, float epsilon); 80 | SK_C_API double sk_matrix44_determinant (sk_matrix44_t* matrix); 81 | 82 | 83 | SK_C_PLUS_PLUS_END_GUARD 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_paint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_paint_DEFINED 11 | #define sk_paint_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_paint_t* sk_paint_new(void); 18 | SK_C_API sk_paint_t* sk_paint_clone(sk_paint_t*); 19 | SK_C_API void sk_paint_delete(sk_paint_t*); 20 | SK_C_API void sk_paint_reset(sk_paint_t*); 21 | SK_C_API bool sk_paint_is_antialias(const sk_paint_t*); 22 | SK_C_API void sk_paint_set_antialias(sk_paint_t*, bool); 23 | SK_C_API sk_color_t sk_paint_get_color(const sk_paint_t*); 24 | SK_C_API void sk_paint_get_color4f(const sk_paint_t* paint, sk_color4f_t* color); 25 | SK_C_API void sk_paint_set_color(sk_paint_t*, sk_color_t); 26 | SK_C_API void sk_paint_set_color4f(sk_paint_t* paint, sk_color4f_t* color, sk_colorspace_t* colorspace); 27 | SK_C_API sk_paint_style_t sk_paint_get_style(const sk_paint_t*); 28 | SK_C_API void sk_paint_set_style(sk_paint_t*, sk_paint_style_t); 29 | SK_C_API float sk_paint_get_stroke_width(const sk_paint_t*); 30 | SK_C_API void sk_paint_set_stroke_width(sk_paint_t*, float width); 31 | SK_C_API float sk_paint_get_stroke_miter(const sk_paint_t*); 32 | SK_C_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter); 33 | SK_C_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*); 34 | SK_C_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t); 35 | SK_C_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*); 36 | SK_C_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t); 37 | SK_C_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*); 38 | SK_C_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*); 39 | SK_C_API void sk_paint_set_blendmode(sk_paint_t*, sk_blendmode_t); 40 | SK_C_API bool sk_paint_is_dither(const sk_paint_t*); 41 | SK_C_API void sk_paint_set_dither(sk_paint_t*, bool); 42 | SK_C_API sk_shader_t* sk_paint_get_shader(sk_paint_t*); 43 | SK_C_API sk_maskfilter_t* sk_paint_get_maskfilter(sk_paint_t*); 44 | SK_C_API void sk_paint_set_colorfilter(sk_paint_t*, sk_colorfilter_t*); 45 | SK_C_API sk_colorfilter_t* sk_paint_get_colorfilter(sk_paint_t*); 46 | SK_C_API void sk_paint_set_imagefilter(sk_paint_t*, sk_imagefilter_t*); 47 | SK_C_API sk_imagefilter_t* sk_paint_get_imagefilter(sk_paint_t*); 48 | SK_C_API sk_blendmode_t sk_paint_get_blendmode(sk_paint_t*); 49 | SK_C_API void sk_paint_set_filter_quality(sk_paint_t*, sk_filter_quality_t); 50 | SK_C_API sk_filter_quality_t sk_paint_get_filter_quality(sk_paint_t *); 51 | SK_C_API sk_path_effect_t* sk_paint_get_path_effect(sk_paint_t* cpaint); 52 | SK_C_API void sk_paint_set_path_effect(sk_paint_t* cpaint, sk_path_effect_t* effect); 53 | SK_C_API bool sk_paint_get_fill_path(const sk_paint_t*, const sk_path_t* src, sk_path_t* dst, const sk_rect_t* cullRect, float resScale); 54 | 55 | SK_C_PLUS_PLUS_END_GUARD 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_patheffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_patheffect_DEFINED 11 | #define sk_patheffect_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_path_effect_unref(sk_path_effect_t* t); 18 | SK_C_API sk_path_effect_t* sk_path_effect_create_compose(sk_path_effect_t* outer, sk_path_effect_t* inner); 19 | SK_C_API sk_path_effect_t* sk_path_effect_create_sum(sk_path_effect_t* first, sk_path_effect_t* second); 20 | SK_C_API sk_path_effect_t* sk_path_effect_create_discrete(float segLength, float deviation, uint32_t seedAssist /*0*/); 21 | SK_C_API sk_path_effect_t* sk_path_effect_create_corner(float radius); 22 | SK_C_API sk_path_effect_t* sk_path_effect_create_1d_path(const sk_path_t* path, float advance, float phase, sk_path_effect_1d_style_t style); 23 | SK_C_API sk_path_effect_t* sk_path_effect_create_2d_line(float width, const sk_matrix_t* matrix); 24 | SK_C_API sk_path_effect_t* sk_path_effect_create_2d_path(const sk_matrix_t* matrix, const sk_path_t* path); 25 | SK_C_API sk_path_effect_t* sk_path_effect_create_dash(const float intervals[], int count, float phase); 26 | SK_C_API sk_path_effect_t* sk_path_effect_create_trim(float start, float stop, sk_path_effect_trim_mode_t mode); 27 | 28 | SK_C_PLUS_PLUS_END_GUARD 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_picture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_picture_DEFINED 11 | #define sk_picture_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_picture_recorder_t* sk_picture_recorder_new(void); 18 | SK_C_API void sk_picture_recorder_delete(sk_picture_recorder_t*); 19 | SK_C_API sk_canvas_t* sk_picture_recorder_begin_recording(sk_picture_recorder_t*, const sk_rect_t*); 20 | SK_C_API sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t*); 21 | SK_C_API sk_drawable_t* sk_picture_recorder_end_recording_as_drawable(sk_picture_recorder_t*); 22 | SK_C_API sk_canvas_t* sk_picture_get_recording_canvas(sk_picture_recorder_t* crec); 23 | 24 | SK_C_API void sk_picture_ref(sk_picture_t*); 25 | SK_C_API void sk_picture_unref(sk_picture_t*); 26 | SK_C_API uint32_t sk_picture_get_unique_id(sk_picture_t*); 27 | SK_C_API void sk_picture_get_cull_rect(sk_picture_t*, sk_rect_t*); 28 | SK_C_API sk_shader_t* sk_picture_make_shader(sk_picture_t* src, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* localMatrix, const sk_rect_t* tile); 29 | SK_C_API sk_data_t* sk_picture_serialize_to_data(const sk_picture_t* picture); 30 | SK_C_API void sk_picture_serialize_to_stream(const sk_picture_t* picture, sk_wstream_t* stream); 31 | SK_C_API sk_picture_t* sk_picture_deserialize_from_stream(sk_stream_t* stream); 32 | SK_C_API sk_picture_t* sk_picture_deserialize_from_data(sk_data_t* data); 33 | SK_C_API sk_picture_t* sk_picture_deserialize_from_memory(void* buffer, size_t length); 34 | 35 | SK_C_PLUS_PLUS_END_GUARD 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_pixmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_pixmap_DEFINED 11 | #define sk_pixmap_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_pixmap_destructor(sk_pixmap_t* cpixmap); 18 | SK_C_API sk_pixmap_t* sk_pixmap_new(void); 19 | SK_C_API sk_pixmap_t* sk_pixmap_new_with_params(const sk_imageinfo_t* cinfo, const void* addr, size_t rowBytes); 20 | SK_C_API void sk_pixmap_reset(sk_pixmap_t* cpixmap); 21 | SK_C_API void sk_pixmap_reset_with_params(sk_pixmap_t* cpixmap, const sk_imageinfo_t* cinfo, const void* addr, size_t rowBytes); 22 | SK_C_API void sk_pixmap_get_info(const sk_pixmap_t* cpixmap, sk_imageinfo_t* cinfo); 23 | SK_C_API size_t sk_pixmap_get_row_bytes(const sk_pixmap_t* cpixmap); 24 | SK_C_API void* sk_pixmap_get_writable_addr(const sk_pixmap_t* cpixmap); 25 | SK_C_API const void* sk_pixmap_get_pixels(const sk_pixmap_t* cpixmap); 26 | SK_C_API const void* sk_pixmap_get_pixels_with_xy(const sk_pixmap_t* cpixmap, int x, int y); 27 | SK_C_API sk_color_t sk_pixmap_get_pixel_color(const sk_pixmap_t* cpixmap, int x, int y); 28 | SK_C_API bool sk_pixmap_encode_image(sk_wstream_t* dst, const sk_pixmap_t* src, sk_encoded_image_format_t encoder, int quality); 29 | SK_C_API bool sk_pixmap_read_pixels(const sk_pixmap_t* cpixmap, const sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY); 30 | SK_C_API bool sk_pixmap_scale_pixels(const sk_pixmap_t* cpixmap, const sk_pixmap_t* dst, sk_filter_quality_t quality); 31 | SK_C_API bool sk_pixmap_extract_subset(const sk_pixmap_t* cpixmap, sk_pixmap_t* result, const sk_irect_t* subset); 32 | SK_C_API bool sk_pixmap_erase_color(const sk_pixmap_t* cpixmap, sk_color_t color, const sk_irect_t* subset); 33 | SK_C_API bool sk_pixmap_erase_color4f(const sk_pixmap_t* cpixmap, const sk_color4f_t* color, sk_colorspace_t* colorspace, const sk_irect_t* subset); 34 | 35 | SK_C_API sk_color_t sk_color_unpremultiply(const sk_pmcolor_t pmcolor); 36 | SK_C_API sk_pmcolor_t sk_color_premultiply(const sk_color_t color); 37 | SK_C_API void sk_color_unpremultiply_array(const sk_pmcolor_t* pmcolors, int size, sk_color_t* colors); 38 | SK_C_API void sk_color_premultiply_array(const sk_color_t* colors, int size, sk_pmcolor_t* pmcolors); 39 | SK_C_API void sk_color_get_bit_shift(int* a, int* r, int* g, int* b); 40 | 41 | SK_C_API void sk_swizzle_swap_rb(uint32_t* dest, const uint32_t* src, int count); 42 | 43 | SK_C_API bool sk_webpencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_webpencoder_options_t* options); 44 | SK_C_API bool sk_jpegencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_jpegencoder_options_t* options); 45 | SK_C_API bool sk_pngencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_pngencoder_options_t* options); 46 | 47 | SK_C_PLUS_PLUS_END_GUARD 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_region.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2016 Bluebeam Inc. 5 | * Copyright 2017 Microsoft Corporation. All rights reserved. 6 | * 7 | * Use of this source code is governed by a BSD-style license that can be 8 | * found in the LICENSE file. 9 | */ 10 | 11 | #ifndef sk_region_DEFINED 12 | #define sk_region_DEFINED 13 | 14 | #include "sk_types.h" 15 | 16 | SK_C_PLUS_PLUS_BEGIN_GUARD 17 | 18 | // sk_region_t 19 | 20 | SK_C_API sk_region_t* sk_region_new(void); 21 | SK_C_API void sk_region_delete(sk_region_t* r); 22 | SK_C_API bool sk_region_is_empty(const sk_region_t* r); 23 | SK_C_API bool sk_region_is_rect(const sk_region_t* r); 24 | SK_C_API bool sk_region_is_complex(const sk_region_t* r); 25 | SK_C_API void sk_region_get_bounds(const sk_region_t* r, sk_irect_t* rect); 26 | SK_C_API bool sk_region_get_boundary_path(const sk_region_t* r, sk_path_t* path); 27 | SK_C_API bool sk_region_set_empty(sk_region_t* r); 28 | SK_C_API bool sk_region_set_rect(sk_region_t* r, const sk_irect_t* rect); 29 | SK_C_API bool sk_region_set_rects(sk_region_t* r, const sk_irect_t* rects, int count); 30 | SK_C_API bool sk_region_set_region(sk_region_t* r, const sk_region_t* region); 31 | SK_C_API bool sk_region_set_path(sk_region_t* r, const sk_path_t* t, const sk_region_t* clip); 32 | SK_C_API bool sk_region_intersects_rect(const sk_region_t* r, const sk_irect_t* rect); 33 | SK_C_API bool sk_region_intersects(const sk_region_t* r, const sk_region_t* src); 34 | SK_C_API bool sk_region_contains_point(const sk_region_t* r, int x, int y); 35 | SK_C_API bool sk_region_contains_rect(const sk_region_t* r, const sk_irect_t* rect); 36 | SK_C_API bool sk_region_contains(const sk_region_t* r, const sk_region_t* region); 37 | SK_C_API bool sk_region_quick_contains(const sk_region_t* r, const sk_irect_t* rect); 38 | SK_C_API bool sk_region_quick_reject_rect(const sk_region_t* r, const sk_irect_t* rect); 39 | SK_C_API bool sk_region_quick_reject(const sk_region_t* r, const sk_region_t* region); 40 | SK_C_API void sk_region_translate(sk_region_t* r, int x, int y); 41 | SK_C_API bool sk_region_op_rect(sk_region_t* r, const sk_irect_t* rect, sk_region_op_t op); 42 | SK_C_API bool sk_region_op(sk_region_t* r, const sk_region_t* region, sk_region_op_t op); 43 | 44 | // sk_region_iterator_t 45 | 46 | SK_C_API sk_region_iterator_t* sk_region_iterator_new(const sk_region_t* region); 47 | SK_C_API void sk_region_iterator_delete(sk_region_iterator_t* iter); 48 | SK_C_API bool sk_region_iterator_rewind(sk_region_iterator_t* iter); 49 | SK_C_API bool sk_region_iterator_done(const sk_region_iterator_t* iter); 50 | SK_C_API void sk_region_iterator_next(sk_region_iterator_t* iter); 51 | SK_C_API void sk_region_iterator_rect(const sk_region_iterator_t* iter, sk_irect_t* rect); 52 | 53 | // sk_region_cliperator_t 54 | 55 | SK_C_API sk_region_cliperator_t* sk_region_cliperator_new(const sk_region_t* region, const sk_irect_t* clip); 56 | SK_C_API void sk_region_cliperator_delete(sk_region_cliperator_t* iter); 57 | SK_C_API bool sk_region_cliperator_done(sk_region_cliperator_t* iter); 58 | SK_C_API void sk_region_cliperator_next(sk_region_cliperator_t* iter); 59 | SK_C_API void sk_region_cliperator_rect(const sk_region_cliperator_t* iter, sk_irect_t* rect); 60 | 61 | // sk_region_spanerator_t 62 | 63 | SK_C_API sk_region_spanerator_t* sk_region_spanerator_new(const sk_region_t* region, int y, int left, int right); 64 | SK_C_API void sk_region_spanerator_delete(sk_region_spanerator_t* iter); 65 | SK_C_API bool sk_region_spanerator_next(sk_region_spanerator_t* iter, int* left, int* right); 66 | 67 | SK_C_PLUS_PLUS_END_GUARD 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_rrect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2016 Xamarin Inc. 4 | * Copyright 2018 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_rrect_DEFINED 11 | #define sk_rrect_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_rrect_t* sk_rrect_new(void); 18 | SK_C_API sk_rrect_t* sk_rrect_new_copy(const sk_rrect_t* rrect); 19 | SK_C_API void sk_rrect_delete(const sk_rrect_t* rrect); 20 | SK_C_API sk_rrect_type_t sk_rrect_get_type(const sk_rrect_t* rrect); 21 | SK_C_API void sk_rrect_get_rect(const sk_rrect_t* rrect, sk_rect_t* rect); 22 | SK_C_API void sk_rrect_get_radii(const sk_rrect_t* rrect, sk_rrect_corner_t corner, sk_vector_t* radii); 23 | SK_C_API float sk_rrect_get_width(const sk_rrect_t* rrect); 24 | SK_C_API float sk_rrect_get_height(const sk_rrect_t* rrect); 25 | SK_C_API void sk_rrect_set_empty(sk_rrect_t* rrect); 26 | SK_C_API void sk_rrect_set_rect(sk_rrect_t* rrect, const sk_rect_t* rect); 27 | SK_C_API void sk_rrect_set_oval(sk_rrect_t* rrect, const sk_rect_t* rect); 28 | SK_C_API void sk_rrect_set_rect_xy(sk_rrect_t* rrect, const sk_rect_t* rect, float xRad, float yRad); 29 | SK_C_API void sk_rrect_set_nine_patch(sk_rrect_t* rrect, const sk_rect_t* rect, float leftRad, float topRad, float rightRad, float bottomRad); 30 | SK_C_API void sk_rrect_set_rect_radii(sk_rrect_t* rrect, const sk_rect_t* rect, const sk_vector_t* radii); 31 | SK_C_API void sk_rrect_inset(sk_rrect_t* rrect, float dx, float dy); 32 | SK_C_API void sk_rrect_outset(sk_rrect_t* rrect, float dx, float dy); 33 | SK_C_API void sk_rrect_offset(sk_rrect_t* rrect, float dx, float dy); 34 | SK_C_API bool sk_rrect_contains(const sk_rrect_t* rrect, const sk_rect_t* rect); 35 | SK_C_API bool sk_rrect_is_valid(const sk_rrect_t* rrect); 36 | SK_C_API bool sk_rrect_transform(sk_rrect_t* rrect, const sk_matrix_t* matrix, sk_rrect_t* dest); 37 | 38 | SK_C_PLUS_PLUS_END_GUARD 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_runtimeeffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Microsoft Corporation. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef sk_runtimeeffect_DEFINED 9 | #define sk_runtimeeffect_DEFINED 10 | 11 | #include "sk_types.h" 12 | 13 | SK_C_PLUS_PLUS_BEGIN_GUARD 14 | 15 | // sk_runtimeeffect_t 16 | 17 | SK_C_API sk_runtimeeffect_t* sk_runtimeeffect_make(sk_string_t* sksl, sk_string_t* error); 18 | SK_C_API void sk_runtimeeffect_unref(sk_runtimeeffect_t* effect); 19 | SK_C_API sk_shader_t* sk_runtimeeffect_make_shader(sk_runtimeeffect_t* effect, sk_data_t* uniforms, sk_shader_t** children, size_t childCount, const sk_matrix_t* localMatrix, bool isOpaque); 20 | SK_C_API sk_colorfilter_t* sk_runtimeeffect_make_color_filter(sk_runtimeeffect_t* effect, sk_data_t* uniforms, sk_colorfilter_t** children, size_t childCount); 21 | SK_C_API size_t sk_runtimeeffect_get_uniform_size(const sk_runtimeeffect_t* effect); 22 | SK_C_API size_t sk_runtimeeffect_get_uniforms_count(const sk_runtimeeffect_t* effect); 23 | SK_C_API void sk_runtimeeffect_get_uniform_name(const sk_runtimeeffect_t* effect, int index, sk_string_t* name); 24 | SK_C_API const sk_runtimeeffect_uniform_t* sk_runtimeeffect_get_uniform_from_index(const sk_runtimeeffect_t* effect, int index); 25 | SK_C_API const sk_runtimeeffect_uniform_t* sk_runtimeeffect_get_uniform_from_name(const sk_runtimeeffect_t* effect, const char* name, size_t len); 26 | SK_C_API size_t sk_runtimeeffect_get_children_count(const sk_runtimeeffect_t* effect); 27 | SK_C_API void sk_runtimeeffect_get_child_name(const sk_runtimeeffect_t* effect, int index, sk_string_t* name); 28 | 29 | // sk_runtimeeffect_uniform_t 30 | 31 | SK_C_API size_t sk_runtimeeffect_uniform_get_offset(const sk_runtimeeffect_uniform_t* variable); 32 | SK_C_API size_t sk_runtimeeffect_uniform_get_size_in_bytes(const sk_runtimeeffect_uniform_t* variable); 33 | 34 | SK_C_PLUS_PLUS_END_GUARD 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_shader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_shader_DEFINED 11 | #define sk_shader_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | // SkShader 18 | 19 | SK_C_API void sk_shader_ref(sk_shader_t* shader); 20 | SK_C_API void sk_shader_unref(sk_shader_t* shader); 21 | SK_C_API sk_shader_t* sk_shader_with_local_matrix(const sk_shader_t* shader, const sk_matrix_t* localMatrix); 22 | SK_C_API sk_shader_t* sk_shader_with_color_filter(const sk_shader_t* shader, const sk_colorfilter_t* filter); 23 | 24 | // SkShaders 25 | 26 | SK_C_API sk_shader_t* sk_shader_new_empty(void); 27 | SK_C_API sk_shader_t* sk_shader_new_color(sk_color_t color); 28 | SK_C_API sk_shader_t* sk_shader_new_color4f(const sk_color4f_t* color, const sk_colorspace_t* colorspace); 29 | SK_C_API sk_shader_t* sk_shader_new_blend(sk_blendmode_t mode, const sk_shader_t* dst, const sk_shader_t* src); 30 | SK_C_API sk_shader_t* sk_shader_new_lerp(float t, const sk_shader_t* dst, const sk_shader_t* src); 31 | 32 | // SkGradientShader 33 | 34 | SK_C_API sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2], const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); 35 | SK_C_API sk_shader_t* sk_shader_new_linear_gradient_color4f(const sk_point_t points[2], const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); 36 | SK_C_API sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center, float radius, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); 37 | SK_C_API sk_shader_t* sk_shader_new_radial_gradient_color4f(const sk_point_t* center, float radius, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); 38 | SK_C_API sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, float startAngle, float endAngle, const sk_matrix_t* localMatrix); 39 | SK_C_API sk_shader_t* sk_shader_new_sweep_gradient_color4f(const sk_point_t* center, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, float startAngle, float endAngle, const sk_matrix_t* localMatrix); 40 | SK_C_API sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); 41 | SK_C_API sk_shader_t* sk_shader_new_two_point_conical_gradient_color4f(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); 42 | 43 | // SkPerlinNoiseShader 44 | 45 | SK_C_API sk_shader_t* sk_shader_new_perlin_noise_fractal_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* tileSize); 46 | SK_C_API sk_shader_t* sk_shader_new_perlin_noise_turbulence(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* tileSize); 47 | SK_C_API sk_shader_t* sk_shader_new_perlin_noise_improved_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float z); 48 | 49 | SK_C_PLUS_PLUS_END_GUARD 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_stream_DEFINED 11 | #define sk_stream_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_stream_asset_destroy(sk_stream_asset_t* cstream); 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | SK_C_API sk_stream_filestream_t* sk_filestream_new(const char* path); 22 | SK_C_API void sk_filestream_destroy(sk_stream_filestream_t* cstream); 23 | SK_C_API bool sk_filestream_is_valid(sk_stream_filestream_t* cstream); 24 | 25 | //////////////////////////////////////////////////////////////////////////////// 26 | 27 | SK_C_API sk_stream_memorystream_t* sk_memorystream_new(void); 28 | SK_C_API sk_stream_memorystream_t* sk_memorystream_new_with_length(size_t length); 29 | SK_C_API sk_stream_memorystream_t* sk_memorystream_new_with_data(const void* data, size_t length, bool copyData); 30 | SK_C_API sk_stream_memorystream_t* sk_memorystream_new_with_skdata(sk_data_t* data); 31 | SK_C_API void sk_memorystream_set_memory(sk_stream_memorystream_t* cmemorystream, const void* data, size_t length, bool copyData); 32 | SK_C_API void sk_memorystream_destroy(sk_stream_memorystream_t* cstream); 33 | 34 | //////////////////////////////////////////////////////////////////////////////// 35 | 36 | SK_C_API size_t sk_stream_read(sk_stream_t* cstream, void* buffer, size_t size); 37 | SK_C_API size_t sk_stream_peek(sk_stream_t* cstream, void* buffer, size_t size); 38 | SK_C_API size_t sk_stream_skip(sk_stream_t* cstream, size_t size); 39 | SK_C_API bool sk_stream_is_at_end(sk_stream_t* cstream); 40 | SK_C_API bool sk_stream_read_s8(sk_stream_t* cstream, int8_t* buffer); 41 | SK_C_API bool sk_stream_read_s16(sk_stream_t* cstream, int16_t* buffer); 42 | SK_C_API bool sk_stream_read_s32(sk_stream_t* cstream, int32_t* buffer); 43 | SK_C_API bool sk_stream_read_u8(sk_stream_t* cstream, uint8_t* buffer); 44 | SK_C_API bool sk_stream_read_u16(sk_stream_t* cstream, uint16_t* buffer); 45 | SK_C_API bool sk_stream_read_u32(sk_stream_t* cstream, uint32_t* buffer); 46 | SK_C_API bool sk_stream_read_bool(sk_stream_t* cstream, bool* buffer); 47 | SK_C_API bool sk_stream_rewind(sk_stream_t* cstream); 48 | SK_C_API bool sk_stream_has_position(sk_stream_t* cstream); 49 | SK_C_API size_t sk_stream_get_position(sk_stream_t* cstream); 50 | SK_C_API bool sk_stream_seek(sk_stream_t* cstream, size_t position); 51 | SK_C_API bool sk_stream_move(sk_stream_t* cstream, long offset); 52 | SK_C_API bool sk_stream_has_length(sk_stream_t* cstream); 53 | SK_C_API size_t sk_stream_get_length(sk_stream_t* cstream); 54 | SK_C_API const void* sk_stream_get_memory_base(sk_stream_t* cstream); 55 | SK_C_API sk_stream_t* sk_stream_fork(sk_stream_t* cstream); 56 | SK_C_API sk_stream_t* sk_stream_duplicate(sk_stream_t* cstream); 57 | SK_C_API void sk_stream_destroy(sk_stream_t* cstream); 58 | 59 | //////////////////////////////////////////////////////////////////////////////// 60 | 61 | SK_C_API sk_wstream_filestream_t* sk_filewstream_new(const char* path); 62 | SK_C_API void sk_filewstream_destroy(sk_wstream_filestream_t* cstream); 63 | SK_C_API bool sk_filewstream_is_valid(sk_wstream_filestream_t* cstream); 64 | 65 | SK_C_API sk_wstream_dynamicmemorystream_t* sk_dynamicmemorywstream_new(void); 66 | SK_C_API sk_stream_asset_t* sk_dynamicmemorywstream_detach_as_stream(sk_wstream_dynamicmemorystream_t* cstream); 67 | SK_C_API sk_data_t* sk_dynamicmemorywstream_detach_as_data(sk_wstream_dynamicmemorystream_t* cstream); 68 | SK_C_API void sk_dynamicmemorywstream_copy_to(sk_wstream_dynamicmemorystream_t* cstream, void* data); 69 | SK_C_API bool sk_dynamicmemorywstream_write_to_stream(sk_wstream_dynamicmemorystream_t* cstream, sk_wstream_t* dst); 70 | SK_C_API void sk_dynamicmemorywstream_destroy(sk_wstream_dynamicmemorystream_t* cstream); 71 | 72 | //////////////////////////////////////////////////////////////////////////////// 73 | 74 | SK_C_API bool sk_wstream_write(sk_wstream_t* cstream, const void* buffer, size_t size); 75 | SK_C_API bool sk_wstream_newline(sk_wstream_t* cstream); 76 | SK_C_API void sk_wstream_flush(sk_wstream_t* cstream); 77 | SK_C_API size_t sk_wstream_bytes_written(sk_wstream_t* cstream); 78 | SK_C_API bool sk_wstream_write_8(sk_wstream_t* cstream, uint8_t value); 79 | SK_C_API bool sk_wstream_write_16(sk_wstream_t* cstream, uint16_t value); 80 | SK_C_API bool sk_wstream_write_32(sk_wstream_t* cstream, uint32_t value); 81 | SK_C_API bool sk_wstream_write_text(sk_wstream_t* cstream, const char* value); 82 | SK_C_API bool sk_wstream_write_dec_as_text(sk_wstream_t* cstream, int32_t value); 83 | SK_C_API bool sk_wstream_write_bigdec_as_text(sk_wstream_t* cstream, int64_t value, int minDigits); 84 | SK_C_API bool sk_wstream_write_hex_as_text(sk_wstream_t* cstream, uint32_t value, int minDigits); 85 | SK_C_API bool sk_wstream_write_scalar_as_text(sk_wstream_t* cstream, float value); 86 | SK_C_API bool sk_wstream_write_bool(sk_wstream_t* cstream, bool value); 87 | SK_C_API bool sk_wstream_write_scalar(sk_wstream_t* cstream, float value); 88 | SK_C_API bool sk_wstream_write_packed_uint(sk_wstream_t* cstream, size_t value); 89 | SK_C_API bool sk_wstream_write_stream(sk_wstream_t* cstream, sk_stream_t* input, size_t length); 90 | SK_C_API int sk_wstream_get_size_of_packed_uint(size_t value); 91 | 92 | SK_C_PLUS_PLUS_END_GUARD 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_string_DEFINED 11 | #define sk_string_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_string_t* sk_string_new_empty(void); 18 | SK_C_API sk_string_t* sk_string_new_with_copy(const char* src, size_t length); 19 | SK_C_API void sk_string_destructor(const sk_string_t*); 20 | SK_C_API size_t sk_string_get_size(const sk_string_t*); 21 | SK_C_API const char* sk_string_get_c_str(const sk_string_t*); 22 | 23 | SK_C_PLUS_PLUS_END_GUARD 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_surface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_surface_DEFINED 11 | #define sk_surface_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | // surface 18 | 19 | SK_C_API sk_surface_t* sk_surface_new_null(int width, int height); 20 | SK_C_API sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*, size_t rowBytes, const sk_surfaceprops_t*); 21 | SK_C_API sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*, void* pixels, size_t rowBytes, const sk_surface_raster_release_proc releaseProc, void* context, const sk_surfaceprops_t* props); 22 | 23 | SK_C_API sk_surface_t* sk_surface_new_backend_texture(gr_recording_context_t* context, const gr_backendtexture_t* texture, gr_surfaceorigin_t origin, int samples, sk_colortype_t colorType, sk_colorspace_t* colorspace, const sk_surfaceprops_t* props); 24 | SK_C_API sk_surface_t* sk_surface_new_backend_render_target(gr_recording_context_t* context, const gr_backendrendertarget_t* target, gr_surfaceorigin_t origin, sk_colortype_t colorType, sk_colorspace_t* colorspace, const sk_surfaceprops_t* props); 25 | SK_C_API sk_surface_t* sk_surface_new_render_target(gr_recording_context_t* context, bool budgeted, const sk_imageinfo_t* cinfo, int sampleCount, gr_surfaceorigin_t origin, const sk_surfaceprops_t* props, bool shouldCreateWithMips); 26 | 27 | SK_C_API sk_surface_t* sk_surface_new_metal_layer(gr_recording_context_t* context, gr_mtl_handle_t layer, gr_surfaceorigin_t origin, int sampleCount, sk_colortype_t colorType, sk_colorspace_t* colorspace, const sk_surfaceprops_t* props, gr_mtl_handle_t* drawable); 28 | SK_C_API sk_surface_t* sk_surface_new_metal_view(gr_recording_context_t* context, gr_mtl_handle_t mtkView, gr_surfaceorigin_t origin, int sampleCount, sk_colortype_t colorType, sk_colorspace_t* colorspace, const sk_surfaceprops_t* props); 29 | 30 | SK_C_API void sk_surface_unref(sk_surface_t*); 31 | SK_C_API sk_canvas_t* sk_surface_get_canvas(sk_surface_t*); 32 | SK_C_API sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*); 33 | SK_C_API sk_image_t* sk_surface_new_image_snapshot_with_crop(sk_surface_t* surface, const sk_irect_t* bounds); 34 | SK_C_API void sk_surface_draw(sk_surface_t* surface, sk_canvas_t* canvas, float x, float y, const sk_paint_t* paint); 35 | SK_C_API bool sk_surface_peek_pixels(sk_surface_t* surface, sk_pixmap_t* pixmap); 36 | SK_C_API bool sk_surface_read_pixels(sk_surface_t* surface, sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY); 37 | SK_C_API const sk_surfaceprops_t* sk_surface_get_props(sk_surface_t* surface); 38 | SK_C_API void sk_surface_flush(sk_surface_t* surface); 39 | SK_C_API void sk_surface_flush_and_submit(sk_surface_t* surface, bool syncCpu); 40 | SK_C_API gr_recording_context_t* sk_surface_get_recording_context(sk_surface_t* surface); 41 | 42 | // surface props 43 | 44 | SK_C_API sk_surfaceprops_t* sk_surfaceprops_new(uint32_t flags, sk_pixelgeometry_t geometry); 45 | SK_C_API void sk_surfaceprops_delete(sk_surfaceprops_t* props); 46 | SK_C_API uint32_t sk_surfaceprops_get_flags(sk_surfaceprops_t* props); 47 | SK_C_API sk_pixelgeometry_t sk_surfaceprops_get_pixel_geometry(sk_surfaceprops_t* props); 48 | 49 | SK_C_PLUS_PLUS_END_GUARD 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_svg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_svg_DEFINED 11 | #define sk_svg_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_canvas_t* sk_svgcanvas_create_with_stream(const sk_rect_t* bounds, sk_wstream_t* stream); 18 | SK_C_API sk_canvas_t* sk_svgcanvas_create_with_writer(const sk_rect_t* bounds, sk_xmlwriter_t* writer); 19 | 20 | SK_C_PLUS_PLUS_END_GUARD 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_textblob.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_textblob_DEFINED 11 | #define sk_textblob_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | // sk_textblob_t 18 | 19 | SK_C_API void sk_textblob_ref(const sk_textblob_t* blob); 20 | SK_C_API void sk_textblob_unref(const sk_textblob_t* blob); 21 | SK_C_API uint32_t sk_textblob_get_unique_id(const sk_textblob_t* blob); 22 | SK_C_API void sk_textblob_get_bounds(const sk_textblob_t* blob, sk_rect_t* bounds); 23 | SK_C_API int sk_textblob_get_intercepts(const sk_textblob_t* blob, const float bounds[2], float intervals[], const sk_paint_t* paint); 24 | 25 | // sk_textblob_builder_t 26 | 27 | SK_C_API sk_textblob_builder_t* sk_textblob_builder_new(void); 28 | SK_C_API void sk_textblob_builder_delete(sk_textblob_builder_t* builder); 29 | SK_C_API sk_textblob_t* sk_textblob_builder_make(sk_textblob_builder_t* builder); 30 | SK_C_API void sk_textblob_builder_alloc_run(sk_textblob_builder_t* builder, const sk_font_t* font, int count, float x, float y, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); 31 | SK_C_API void sk_textblob_builder_alloc_run_pos_h(sk_textblob_builder_t* builder, const sk_font_t* font, int count, float y, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); 32 | SK_C_API void sk_textblob_builder_alloc_run_pos(sk_textblob_builder_t* builder, const sk_font_t* font, int count, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); 33 | SK_C_API void sk_textblob_builder_alloc_run_rsxform(sk_textblob_builder_t* builder, const sk_font_t* font, int count, sk_textblob_builder_runbuffer_t* runbuffer); 34 | // (obsolete) 35 | SK_C_API void sk_textblob_builder_alloc_run_text(sk_textblob_builder_t* builder, const sk_font_t* font, int count, float x, float y, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); 36 | SK_C_API void sk_textblob_builder_alloc_run_text_pos_h(sk_textblob_builder_t* builder, const sk_font_t* font, int count, float y, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); 37 | SK_C_API void sk_textblob_builder_alloc_run_text_pos(sk_textblob_builder_t* builder, const sk_font_t* font, int count, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); 38 | 39 | SK_C_PLUS_PLUS_END_GUARD 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_typeface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_typeface_DEFINED 11 | #define sk_typeface_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | // typeface 18 | 19 | SK_C_API void sk_typeface_unref(sk_typeface_t* typeface); 20 | SK_C_API sk_fontstyle_t* sk_typeface_get_fontstyle(const sk_typeface_t* typeface); 21 | SK_C_API int sk_typeface_get_font_weight(const sk_typeface_t* typeface); 22 | SK_C_API int sk_typeface_get_font_width(const sk_typeface_t* typeface); 23 | SK_C_API sk_font_style_slant_t sk_typeface_get_font_slant(const sk_typeface_t* typeface); 24 | SK_C_API bool sk_typeface_is_fixed_pitch(const sk_typeface_t* typeface); 25 | SK_C_API sk_typeface_t* sk_typeface_create_default(void); 26 | SK_C_API sk_typeface_t* sk_typeface_ref_default(void); 27 | SK_C_API sk_typeface_t* sk_typeface_create_from_name(const char* familyName, const sk_fontstyle_t* style); 28 | SK_C_API sk_typeface_t* sk_typeface_create_from_file(const char* path, int index); 29 | SK_C_API sk_typeface_t* sk_typeface_create_from_stream(sk_stream_asset_t* stream, int index); 30 | SK_C_API sk_typeface_t* sk_typeface_create_from_data(sk_data_t* data, int index); 31 | SK_C_API void sk_typeface_unichars_to_glyphs(const sk_typeface_t* typeface, const int32_t unichars[], int count, uint16_t glyphs[]); 32 | SK_C_API uint16_t sk_typeface_unichar_to_glyph(const sk_typeface_t* typeface, const int32_t unichar); 33 | SK_C_API int sk_typeface_count_glyphs(const sk_typeface_t* typeface); 34 | SK_C_API int sk_typeface_count_tables(const sk_typeface_t* typeface); 35 | SK_C_API int sk_typeface_get_table_tags(const sk_typeface_t* typeface, sk_font_table_tag_t tags[]); 36 | SK_C_API size_t sk_typeface_get_table_size(const sk_typeface_t* typeface, sk_font_table_tag_t tag); 37 | SK_C_API size_t sk_typeface_get_table_data(const sk_typeface_t* typeface, sk_font_table_tag_t tag, size_t offset, size_t length, void* data); 38 | SK_C_API sk_data_t* sk_typeface_copy_table_data(const sk_typeface_t* typeface, sk_font_table_tag_t tag); 39 | SK_C_API int sk_typeface_get_units_per_em(const sk_typeface_t* typeface); 40 | SK_C_API bool sk_typeface_get_kerning_pair_adjustments(const sk_typeface_t* typeface, const uint16_t glyphs[], int count, int32_t adjustments[]); 41 | // TODO: createFamilyNameIterator 42 | SK_C_API sk_string_t* sk_typeface_get_family_name(const sk_typeface_t* typeface); 43 | SK_C_API sk_stream_asset_t* sk_typeface_open_stream(const sk_typeface_t* typeface, int* ttcIndex); 44 | 45 | 46 | // font manager 47 | 48 | SK_C_API sk_fontmgr_t* sk_fontmgr_create_default(void); 49 | SK_C_API sk_fontmgr_t* sk_fontmgr_ref_default(void); 50 | SK_C_API void sk_fontmgr_unref(sk_fontmgr_t*); 51 | SK_C_API int sk_fontmgr_count_families(sk_fontmgr_t*); 52 | SK_C_API void sk_fontmgr_get_family_name(sk_fontmgr_t*, int index, sk_string_t* familyName); 53 | SK_C_API sk_fontstyleset_t* sk_fontmgr_create_styleset(sk_fontmgr_t*, int index); 54 | SK_C_API sk_fontstyleset_t* sk_fontmgr_match_family(sk_fontmgr_t*, const char* familyName); 55 | SK_C_API sk_typeface_t* sk_fontmgr_match_family_style(sk_fontmgr_t*, const char* familyName, sk_fontstyle_t* style); 56 | SK_C_API sk_typeface_t* sk_fontmgr_match_family_style_character(sk_fontmgr_t*, const char* familyName, sk_fontstyle_t* style, const char** bcp47, int bcp47Count, int32_t character); 57 | SK_C_API sk_typeface_t* sk_fontmgr_match_face_style(sk_fontmgr_t*, const sk_typeface_t* face, sk_fontstyle_t* style); 58 | SK_C_API sk_typeface_t* sk_fontmgr_create_from_data(sk_fontmgr_t*, sk_data_t* data, int index); 59 | SK_C_API sk_typeface_t* sk_fontmgr_create_from_stream(sk_fontmgr_t*, sk_stream_asset_t* stream, int index); 60 | SK_C_API sk_typeface_t* sk_fontmgr_create_from_file(sk_fontmgr_t*, const char* path, int index); 61 | 62 | // font style 63 | 64 | SK_C_API sk_fontstyle_t* sk_fontstyle_new(int weight, int width, sk_font_style_slant_t slant); 65 | SK_C_API void sk_fontstyle_delete(sk_fontstyle_t* fs); 66 | SK_C_API int sk_fontstyle_get_weight(const sk_fontstyle_t* fs); 67 | SK_C_API int sk_fontstyle_get_width(const sk_fontstyle_t* fs); 68 | SK_C_API sk_font_style_slant_t sk_fontstyle_get_slant(const sk_fontstyle_t* fs); 69 | 70 | // font style set 71 | 72 | SK_C_API sk_fontstyleset_t* sk_fontstyleset_create_empty(void); 73 | SK_C_API void sk_fontstyleset_unref(sk_fontstyleset_t* fss); 74 | SK_C_API int sk_fontstyleset_get_count(sk_fontstyleset_t* fss); 75 | SK_C_API void sk_fontstyleset_get_style(sk_fontstyleset_t* fss, int index, sk_fontstyle_t* fs, sk_string_t* style); 76 | SK_C_API sk_typeface_t* sk_fontstyleset_create_typeface(sk_fontstyleset_t* fss, int index); 77 | SK_C_API sk_typeface_t* sk_fontstyleset_match_style(sk_fontstyleset_t* fss, sk_fontstyle_t* style); 78 | 79 | SK_C_PLUS_PLUS_END_GUARD 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_vertices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_vertices_DEFINED 11 | #define sk_vertices_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API void sk_vertices_unref(sk_vertices_t* cvertices); 18 | SK_C_API void sk_vertices_ref(sk_vertices_t* cvertices); 19 | SK_C_API sk_vertices_t* sk_vertices_make_copy(sk_vertices_vertex_mode_t vmode, int vertexCount, const sk_point_t* positions, const sk_point_t* texs, const sk_color_t* colors, int indexCount, const uint16_t* indices); 20 | 21 | SK_C_PLUS_PLUS_END_GUARD 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sk_xml.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sk_xml_DEFINED 11 | #define sk_xml_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sk_xmlstreamwriter_t* sk_xmlstreamwriter_new(sk_wstream_t* stream); 18 | SK_C_API void sk_xmlstreamwriter_delete(sk_xmlstreamwriter_t* writer); 19 | 20 | SK_C_PLUS_PLUS_END_GUARD 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/skottie_animation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef skottie_DEFINED 11 | #define skottie_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | /* 18 | * skottie::Animation 19 | */ 20 | SK_C_API void skottie_animation_keepalive(); 21 | 22 | SK_C_API skottie_animation_t* skottie_animation_make_from_string(const char* data, size_t length); 23 | SK_C_API skottie_animation_t* skottie_animation_make_from_data(const char* data, size_t length); 24 | SK_C_API skottie_animation_t* skottie_animation_make_from_stream(sk_stream_t* stream); 25 | SK_C_API skottie_animation_t* skottie_animation_make_from_file(const char* path); 26 | 27 | SK_C_API void skottie_animation_ref(skottie_animation_t* instance); 28 | SK_C_API void skottie_animation_unref(skottie_animation_t* instance); 29 | 30 | SK_C_API void skottie_animation_delete(skottie_animation_t *instance); 31 | 32 | SK_C_API void skottie_animation_render(skottie_animation_t *instance, sk_canvas_t *canvas, sk_rect_t *dst); 33 | SK_C_API void skottie_animation_render_with_flags(skottie_animation_t *instance, sk_canvas_t *canvas, sk_rect_t *dst, skottie_animation_renderflags_t flags); 34 | 35 | SK_C_API void skottie_animation_seek(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic); 36 | SK_C_API void skottie_animation_seek_frame(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic); 37 | SK_C_API void skottie_animation_seek_frame_time(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic); 38 | 39 | SK_C_API double skottie_animation_get_duration(skottie_animation_t *instance); 40 | SK_C_API double skottie_animation_get_fps(skottie_animation_t *instance); 41 | SK_C_API double skottie_animation_get_in_point(skottie_animation_t *instance); 42 | SK_C_API double skottie_animation_get_out_point(skottie_animation_t *instance); 43 | 44 | SK_C_API void skottie_animation_get_version(skottie_animation_t *instance, sk_string_t* version); 45 | SK_C_API void skottie_animation_get_size(skottie_animation_t *instance, sk_size_t* size); 46 | 47 | SK_C_PLUS_PLUS_END_GUARD 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/sksg_invalidation_controller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * Copyright 2015 Xamarin Inc. 4 | * Copyright 2017 Microsoft Corporation. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE file. 8 | */ 9 | 10 | #ifndef sksg_invalidationcontroller_DEFINED 11 | #define sksg_invalidationcontroller_DEFINED 12 | 13 | #include "sk_types.h" 14 | 15 | SK_C_PLUS_PLUS_BEGIN_GUARD 16 | 17 | SK_C_API sksg_invalidation_controller_t* sksg_invalidation_controller_new(); 18 | SK_C_API void sksg_invalidation_controller_delete(sksg_invalidation_controller_t* instance); 19 | 20 | SK_C_API void sksg_invalidation_controller_inval(sksg_invalidation_controller_t* instance, sk_rect_t* rect, sk_matrix_t* matrix); 21 | SK_C_API void sksg_invalidation_controller_get_bounds(sksg_invalidation_controller_t* instance, sk_rect_t* bounds); 22 | SK_C_API void sksg_invalidation_controller_begin(sksg_invalidation_controller_t* instance); 23 | SK_C_API void sksg_invalidation_controller_end(sksg_invalidation_controller_t* instance); 24 | SK_C_API void sksg_invalidation_controller_reset(sksg_invalidation_controller_t* instance); 25 | 26 | SK_C_PLUS_PLUS_END_GUARD 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Sources/CSkiaSharp/include/umbrella.h: -------------------------------------------------------------------------------- 1 | // 2 | // SkiaKit.h 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/25/19. 6 | // 7 | 8 | #ifndef SkiaKit_h 9 | #define SkiaKit_h 10 | 11 | #include "sk_types.h" 12 | #include "gr_context.h" 13 | #include "sk_bitmap.h" 14 | #include "sk_canvas.h" 15 | #include "sk_codec.h" 16 | #include "sk_colorfilter.h" 17 | #include "sk_colorspace.h" 18 | #include "sk_colortable.h" 19 | #include "sk_data.h" 20 | #include "sk_document.h" 21 | #include "sk_drawable.h" 22 | #include "sk_font.h" 23 | #include "sk_general.h" 24 | #include "sk_image.h" 25 | #include "sk_imagefilter.h" 26 | #include "sk_mask.h" 27 | #include "sk_maskfilter.h" 28 | #include "sk_matrix.h" 29 | #include "sk_paint.h" 30 | #include "sk_path.h" 31 | #include "sk_patheffect.h" 32 | #include "sk_picture.h" 33 | #include "sk_pixmap.h" 34 | #include "sk_region.h" 35 | #include "sk_rrect.h" 36 | #include "sk_shader.h" 37 | #include "sk_stream.h" 38 | #include "sk_string.h" 39 | #include "sk_surface.h" 40 | #include "sk_svg.h" 41 | #include "sk_textblob.h" 42 | #include "sk_typeface.h" 43 | 44 | #include "sk_vertices.h" 45 | #include "sk_xml.h" 46 | #include "sk_graphics.h" 47 | #include "sk_runtimeeffect.h" 48 | #include "skottie_animation.h" 49 | #include "sksg_invalidation_controller.h" 50 | 51 | #endif /* SkiaKit_h */ 52 | -------------------------------------------------------------------------------- /Sources/SkiaKit/Apple/SkiaCanvasLayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SkiaCanvasLayer.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/26/19. 6 | // 7 | 8 | #if canImport(QuartzCore) 9 | 10 | import Foundation 11 | import CoreGraphics 12 | import QuartzCore 13 | 14 | public class SkiaLayer : CALayer { 15 | public var drawingCallback: (_ surface: Surface, _ imageInfo: ImageInfo) -> () 16 | 17 | /// Cache bitmap data until next render or deinit. 18 | private var oldBitmapData: UnsafeMutableRawPointer? = nil 19 | 20 | static func emptyCallback (surface: Surface, imageInfo: ImageInfo) 21 | { 22 | // Does nothing 23 | } 24 | 25 | public override init () 26 | { 27 | ignorePixelScaling = false 28 | drawingCallback = SkiaLayer.emptyCallback 29 | super.init () 30 | setNeedsDisplay() 31 | needsDisplayOnBoundsChange = true 32 | } 33 | 34 | public required init? (coder: NSCoder) 35 | { 36 | ignorePixelScaling = false 37 | drawingCallback = SkiaLayer.emptyCallback 38 | super.init (coder: coder) 39 | } 40 | 41 | deinit { 42 | if oldBitmapData != nil { 43 | free (oldBitmapData) 44 | } 45 | } 46 | 47 | /// If true, this will ignore the pixel scaling of the device, otherwise some virtual pixels might use the number of physical pixels specified in the system 48 | public var ignorePixelScaling: Bool { 49 | didSet { 50 | setNeedsDisplay() 51 | } 52 | } 53 | 54 | public override func draw(in ctx: CGContext) { 55 | super.draw(in: ctx) 56 | 57 | // Create the Skia Context 58 | let scale = ignorePixelScaling ? 1 : contentsScale 59 | let info = ImageInfo(width: Int32 (bounds.width * scale), height: Int32 (bounds.height * scale), colorType: .bgra8888, alphaType: .premul) 60 | if info.width == 0 || info.height == 0 { 61 | return 62 | } 63 | 64 | if oldBitmapData != nil { 65 | free (oldBitmapData) 66 | } 67 | guard let bitmapData = malloc(info.bytesSize) else { 68 | return 69 | } 70 | // Store so we don't free early. 71 | oldBitmapData = bitmapData 72 | 73 | guard let surface = Surface.make (info, bitmapData, info.rowBytes) else { 74 | return 75 | } 76 | drawingCallback (surface, info) 77 | surface.canvas.flush () 78 | 79 | guard let dataProvider = CGDataProvider(dataInfo: nil, data: bitmapData, size: info.bytesSize, releaseData: {ctx, ptr, size in }) else { 80 | return 81 | } 82 | let colorSpace = CGColorSpaceCreateDeviceRGB() 83 | let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedFirst.rawValue).union(.byteOrder32Little) 84 | if let image = CGImage(width: Int(info.width), height: Int(info.height), bitsPerComponent: 8, bitsPerPixel: Int(info.bytesPerPixel*8), bytesPerRow: info.rowBytes, space: colorSpace, bitmapInfo: bitmapInfo, provider: dataProvider, decode: nil, shouldInterpolate: false, intent: .defaultIntent) { 85 | #if os(OSX) 86 | ctx.draw(image, in: bounds) 87 | #else 88 | // in iOS, WatchOS and tvOS we need to flip the image on 89 | // https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW26 90 | ctx.saveGState() 91 | ctx.translateBy(x: 0, y: bounds.height) 92 | ctx.scaleBy(x: 1, y: -1) 93 | ctx.draw(image, in: bounds) 94 | ctx.restoreGState() 95 | #endif 96 | } 97 | } 98 | } 99 | 100 | #endif -------------------------------------------------------------------------------- /Sources/SkiaKit/Apple/SkiaView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SkiaView.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/26/19. 6 | // 7 | 8 | #if canImport(UIKit) 9 | 10 | import Foundation 11 | import UIKit 12 | 13 | /** 14 | * `SkiaView` is a UIView that you can add to your programs that can render some Skia content for you. 15 | * To do this, create an instance of this class, and then set the `drawingCallback` property to point 16 | * to a function that takes a `Surface` and an `ImageInfo` as parameter, and this will be called when 17 | * the view needs to render itself. 18 | * 19 | * You can set the `ignorePixelScaling` to ignore the built-in scaling that uses the `UIView`'s 20 | * `contentScaleFactor` 21 | */ 22 | public class SkiaView: UIView { 23 | /// This property when set points to the method to invoke when drawing. The method 24 | /// receives a surface and the ImageInfo where it should draw its contents. 25 | public var drawingCallback: (_ surface: Surface, _ imageInfo: ImageInfo) -> () = emptyCallback(surface:imageInfo:) 26 | 27 | /// Cache bitmap data until next render or deinit. 28 | private var oldBitmapData: UnsafeMutableRawPointer? = nil 29 | 30 | private lazy var displayLink: CADisplayLink = 31 | { 32 | let link = CADisplayLink(target: self, selector: #selector(onDisplayLink(_:))) 33 | link.isPaused = true 34 | return link 35 | }() 36 | 37 | private func commonInit() 38 | { 39 | displayLink.add(to: .main, forMode: .common) 40 | } 41 | 42 | public var loop: Bool = false 43 | { 44 | didSet { 45 | displayLink.isPaused = !loop 46 | } 47 | } 48 | 49 | @objc private func onDisplayLink(_ sender: CADisplayLink) 50 | { 51 | setNeedsDisplay() 52 | } 53 | 54 | static func emptyCallback (surface: Surface, imageInfo: ImageInfo) 55 | { 56 | // Does nothing 57 | } 58 | 59 | /// If true, this will ignore the pixel scaling of the device, otherwise some virtual pixels might use the number of physical pixels specified in the system 60 | public var ignorePixelScaling: Bool = false { 61 | didSet { 62 | setNeedsDisplay() 63 | } 64 | } 65 | 66 | override init(frame: CGRect) 67 | { 68 | super.init(frame: frame) 69 | commonInit() 70 | } 71 | 72 | required init? (coder: NSCoder) 73 | { 74 | super.init (coder: coder) 75 | commonInit() 76 | } 77 | 78 | deinit { 79 | if oldBitmapData != nil { 80 | free (oldBitmapData) 81 | } 82 | } 83 | 84 | override public func draw(_ rect: CGRect) { 85 | super.draw (rect) 86 | 87 | // Create the Skia Context 88 | let scale = ignorePixelScaling ? 1 : contentScaleFactor 89 | let info = ImageInfo(width: Int32 (bounds.width * scale), height: Int32 (bounds.height * scale), colorType: .bgra8888, alphaType: .premul) 90 | if info.width == 0 || info.height == 0 { 91 | return 92 | } 93 | 94 | if oldBitmapData != nil { 95 | free (oldBitmapData) 96 | } 97 | guard let bitmapData = malloc(info.bytesSize) else { 98 | return 99 | } 100 | // Store so we don't free early. 101 | oldBitmapData = bitmapData 102 | 103 | guard let surface = Surface.make (info, bitmapData, info.rowBytes) else { 104 | return 105 | } 106 | drawingCallback (surface, info) 107 | surface.canvas.flush () 108 | 109 | guard let dataProvider = CGDataProvider(dataInfo: nil, data: bitmapData, size: info.bytesSize, releaseData: {ctx, ptr, size in }) else { 110 | return 111 | } 112 | let colorSpace = CGColorSpaceCreateDeviceRGB() 113 | let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedFirst.rawValue).union(.byteOrder32Little) 114 | if let image = CGImage(width: Int(info.width), height: Int(info.height), bitsPerComponent: 8, bitsPerPixel: Int(info.bytesPerPixel*8), bytesPerRow: info.rowBytes, space: colorSpace, bitmapInfo: bitmapInfo, provider: dataProvider, decode: nil, shouldInterpolate: false, intent: .defaultIntent) { 115 | if let ctx = UIGraphicsGetCurrentContext() { 116 | #if os(OSX) 117 | ctx.draw(image, in: bounds) 118 | #else 119 | // in iOS, WatchOS and tvOS we need to flip the image on 120 | // https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW26 121 | ctx.saveGState() 122 | ctx.translateBy(x: 0, y: bounds.height) 123 | ctx.scaleBy(x: 1, y: -1) 124 | ctx.draw(image, in: bounds) 125 | ctx.restoreGState() 126 | #endif 127 | } 128 | } 129 | } 130 | } 131 | 132 | #endif -------------------------------------------------------------------------------- /Sources/SkiaKit/Color.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Color.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/17/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public struct Color : Equatable { 15 | var color : UInt32 16 | 17 | public init (_ value: UInt32) 18 | { 19 | color = value 20 | } 21 | 22 | public init (r: UInt8, g: UInt8, b: UInt8, a: UInt8 = 0xff) 23 | { 24 | color = ((UInt32(a) << 24) | (UInt32(r) << 16) | (UInt32(g) << 8) | UInt32 (b)) 25 | } 26 | 27 | public init (hue: Float, saturation: Float, lightness: Float, alpha: UInt8 = 0xff) 28 | { 29 | // convert from percentages 30 | let h = hue / 360.0 31 | let s = saturation / 100.0 32 | let l = lightness / 100.0 33 | 34 | // RGB results from 0 to 255 35 | var r = l * 255.0 36 | var g = l * 255.0 37 | var b = l * 255.0 38 | 39 | // HSL from 0 to 1 40 | if (fabsf (s) > 0.001) { 41 | var v2 : Float 42 | if l < 0.5 { 43 | v2 = l * (1.0 + s); 44 | } else { 45 | v2 = (l + s) - (s * l) 46 | } 47 | let v1 = 2.0 * l - v2 48 | 49 | r = 255 * Color.hueToRgb (v1, v2, h + (1.0 / 3.0)) 50 | g = 255 * Color.hueToRgb (v1, v2, h) 51 | b = 255 * Color.hueToRgb (v1, v2, h - (1.0 / 3.0)) 52 | } 53 | 54 | color = (UInt32)((alpha << 24) | (UInt8 (r) << 16) | (UInt8(g) << 8) | UInt8(b)) 55 | } 56 | 57 | static func hueToRgb (_ v1: Float, _ v2: Float, _ vh: Float) -> Float 58 | { 59 | var vH = vh 60 | if vH < 0 { 61 | vH = vH + 1 62 | } 63 | if vH > 1 { 64 | vH = vH - 1 65 | } 66 | 67 | if (6 * vH) < 1 { 68 | return v1 + (v2 - v1) * 6 * vH 69 | } 70 | if (2 * vH) < 1 { 71 | return v2 72 | } 73 | if (3 * vH) < 2 { 74 | return v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6 75 | } 76 | return v1 77 | } 78 | 79 | public var alpha : UInt8 { 80 | get { 81 | (UInt8)((color >> 24) & 0xff) 82 | } 83 | } 84 | 85 | public var red : UInt8 { 86 | get { 87 | (UInt8)((color >> 16) & 0xff) 88 | } 89 | } 90 | 91 | public var green : UInt8 { 92 | get { 93 | (UInt8)((color >> 8) & 0xff) 94 | } 95 | } 96 | 97 | public var blue : UInt8 { 98 | get { 99 | (UInt8)(color & 0xff) 100 | } 101 | } 102 | //sk_color_get_bit_shift 103 | //sk_color_premultiply 104 | //sk_color_premultiply_array 105 | //sk_color_unpremultiply 106 | //sk_color_unpremultiply_array 107 | 108 | } 109 | -------------------------------------------------------------------------------- /Sources/SkiaKit/ColorFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorFilter.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/17/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public final class ColorFilter { 15 | var handle : OpaquePointer 16 | init (handle: OpaquePointer) 17 | { 18 | self.handle = handle 19 | } 20 | 21 | deinit 22 | { 23 | sk_colorfilter_unref(handle) 24 | } 25 | // sk_colorfilter_new_color_matrix 26 | // sk_colorfilter_new_compose 27 | // sk_colorfilter_new_high_contrast 28 | // sk_colorfilter_new_lighting 29 | // sk_colorfilter_new_luma_color 30 | // sk_colorfilter_new_mode 31 | // sk_colorfilter_new_table 32 | // sk_colorfilter_new_table_argb 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Sources/SkiaKit/ColorSpace.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorSpace.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/16/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public final class ColorSpace { 15 | var handle: OpaquePointer 16 | 17 | public init () 18 | { 19 | handle = OpaquePointer(bitPattern: 0)! 20 | } 21 | 22 | init (handle: OpaquePointer) 23 | { 24 | self.handle = handle 25 | } 26 | 27 | deinit { 28 | sk_colorspace_unref(handle) 29 | } 30 | 31 | //sk_color4f_from_color 32 | //sk_color4f_t 33 | //sk_color4f_to_color 34 | //sk_colorspace_DEFINED 35 | //sk_colorspace_equals 36 | //sk_colorspace_gamma_close_to_srgb 37 | //sk_colorspace_gamma_is_linear 38 | //sk_colorspace_icc_profile_delete 39 | //sk_colorspace_icc_profile_get_buffer 40 | //sk_colorspace_icc_profile_get_to_xyzd50 41 | //sk_colorspace_icc_profile_new 42 | //sk_colorspace_icc_profile_parse 43 | //sk_colorspace_icc_profile_t 44 | //sk_colorspace_is_numerical_transfer_fn 45 | //sk_colorspace_is_srgb 46 | //sk_colorspace_make_linear_gamma 47 | //sk_colorspace_make_srgb_gamma 48 | //sk_colorspace_new_icc 49 | //sk_colorspace_new_rgb 50 | //sk_colorspace_new_srgb 51 | //sk_colorspace_new_srgb_linear 52 | //sk_colorspace_primaries_t 53 | //sk_colorspace_primaries_to_xyzd50 54 | //sk_colorspace_ref 55 | //sk_colorspace_t 56 | //sk_colorspace_to_profile 57 | //sk_colorspace_to_xyzd50 58 | //sk_colorspace_transfer_fn_eval 59 | //sk_colorspace_transfer_fn_invert 60 | //sk_colorspace_transfer_fn_named_2dot2 61 | //sk_colorspace_transfer_fn_named_hlg 62 | //sk_colorspace_transfer_fn_named_linear 63 | //sk_colorspace_transfer_fn_named_pq 64 | //sk_colorspace_transfer_fn_named_rec2020 65 | //sk_colorspace_transfer_fn_named_srgb 66 | //sk_colorspace_transfer_fn_t 67 | //sk_colorspace_xyz_concat 68 | //sk_colorspace_xyz_invert 69 | //sk_colorspace_xyz_named_adobe_rgb 70 | //sk_colorspace_xyz_named_dcip3 71 | //sk_colorspace_xyz_named_rec2020 72 | //sk_colorspace_xyz_named_srgb 73 | //sk_colorspace_xyz_named_xyz 74 | //sk_colorspace_xyz_t 75 | 76 | } 77 | -------------------------------------------------------------------------------- /Sources/SkiaKit/Data.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Data.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/18/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | /** 15 | * `SKData` holds an immutable data buffer. Not only is the data immutable, 16 | * but the actual ptr that is returned (by `data`)) is guaranteed 17 | * to always be the same for the life of this instance. 18 | */ 19 | public final class SKData { 20 | var handle: OpaquePointer 21 | 22 | /** 23 | * Initializes a new instance of SKData, if `size` is zero, this creates an empty SKData, otherwise it 24 | * creates an uninitialized SKData with the specified number of bytes 25 | * - Parameter size: number of bytes to allocate for this SKData, or zero for an empty one. 26 | */ 27 | public init (size: Int = 0) 28 | { 29 | if size == 0 { 30 | handle = sk_data_new_empty() 31 | } else { 32 | handle = sk_data_new_uninitialized(size) 33 | } 34 | } 35 | 36 | /** 37 | * Initializes a new instance of SKData with the contents of the provided array `data` 38 | * - Parameter data: contains the initial data to load, the contents are copied. 39 | */ 40 | public init (data: [UInt8]) 41 | { 42 | handle = sk_data_new_with_copy(data, data.count) 43 | } 44 | 45 | /** 46 | * Creates a subset SKData that reprents the specified range. 47 | * - Parameter range: the range of bytes that will be extracted 48 | * - Returns: the new SKData object, if the values of the range are beyond the boundaries of the SKData, an empty SKData is returned. 49 | */ 50 | public subscript (_ range: Range) -> SKData { 51 | get { 52 | return SKData (handle:sk_data_new_subset(handle, range.startIndex, range.count)) 53 | } 54 | } 55 | 56 | /** 57 | * Creates a new `Data` with the contents of the specified file 58 | * - Parameter file: the file to load 59 | * - Returns: if the file is present, a new `SKData` with the contents of the file, or nil on failure 60 | */ 61 | public static func fromFile (file: String) -> SKData? 62 | { 63 | if let x = sk_data_new_from_file(file) { 64 | return SKData(handle: x) 65 | } 66 | return nil 67 | } 68 | 69 | init (handle: OpaquePointer) 70 | { 71 | self.handle = handle 72 | } 73 | 74 | deinit{ 75 | sk_data_unref(handle) 76 | } 77 | 78 | /// Returns the number of bytes stored. 79 | public var size: Int { 80 | get { 81 | return sk_data_get_size(handle) 82 | } 83 | } 84 | 85 | public var isEmpty: Bool { 86 | get { 87 | return size == 0 88 | } 89 | } 90 | 91 | /// Returns the ptr to the data. 92 | public var data: UnsafeRawPointer! { 93 | get { 94 | sk_data_get_data(handle) 95 | } 96 | } 97 | 98 | //sk_data_get_bytes 99 | //sk_data_new_from_stream 100 | //sk_data_new_with_proc 101 | //sk_data_ref 102 | 103 | } 104 | -------------------------------------------------------------------------------- /Sources/SkiaKit/Font.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SKFont.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 6/12/20. 6 | // 7 | 8 | import Foundation 9 | #if canImport(CSkiaSharp) 10 | import CSkiaSharp 11 | #endif 12 | 13 | public final class Font { 14 | var handle : OpaquePointer 15 | var owns: Bool 16 | 17 | init (handle: OpaquePointer, owns: Bool) 18 | { 19 | self.handle = handle 20 | self.owns = owns 21 | } 22 | 23 | public init () 24 | { 25 | handle = sk_font_new() 26 | owns = true 27 | } 28 | 29 | public init (typeface: Typeface, size: Float, scaleX: Float, skewX: Float){ 30 | handle = sk_font_new_with_values(typeface.handle, size, scaleX, skewX) 31 | owns = true 32 | } 33 | 34 | deinit { 35 | sk_font_delete(handle) 36 | } 37 | 38 | public var subpixelText : Bool { 39 | get { 40 | sk_font_is_subpixel(handle) 41 | } 42 | set { 43 | sk_font_set_subpixel(handle, newValue) 44 | } 45 | } 46 | 47 | 48 | public var isForceAutoHinting: Bool { 49 | get { 50 | sk_font_is_force_auto_hinting(handle) 51 | } 52 | set { 53 | sk_font_set_force_auto_hinting(handle, newValue) 54 | } 55 | } 56 | public var isEmbeddedBitmaps: Bool { 57 | get { 58 | sk_font_is_embedded_bitmaps(handle) 59 | } 60 | set { 61 | sk_font_set_embedded_bitmaps(handle, newValue) 62 | } 63 | } 64 | public var isLinearMetrics: Bool { 65 | get { 66 | sk_font_is_linear_metrics(handle) 67 | } 68 | set { 69 | sk_font_set_linear_metrics(handle, newValue) 70 | } 71 | } 72 | public var isEmbolden: Bool { 73 | get { 74 | sk_font_is_embolden(handle) 75 | } 76 | set { 77 | sk_font_set_embolden(handle, newValue) 78 | } 79 | } 80 | public var isBaselineSnap: Bool { 81 | get { 82 | sk_font_is_baseline_snap(handle) 83 | } 84 | set { 85 | sk_font_set_baseline_snap(handle, newValue) 86 | } 87 | } 88 | 89 | public var edging: FontEdging { 90 | get { sk_font_get_edging(handle) 91 | } 92 | set { 93 | sk_font_set_edging(handle, newValue) 94 | } 95 | } 96 | 97 | public var fontHinting: FontHinting { 98 | get { 99 | sk_font_get_hinting(handle) 100 | } 101 | set { 102 | sk_font_set_hinting(handle, newValue) 103 | } 104 | } 105 | public var typeface: Typeface { 106 | get { 107 | Typeface (handle: sk_font_get_typeface(handle), owns: true) 108 | } 109 | 110 | set { 111 | sk_font_set_typeface(handle, newValue.handle) 112 | } 113 | } 114 | public var size: Float { 115 | get { 116 | sk_font_get_size(handle) 117 | } 118 | set { 119 | sk_font_set_size(handle, newValue) 120 | } 121 | } 122 | public var scaleX: Float { 123 | get { 124 | sk_font_get_scale_x(handle) 125 | } 126 | set { 127 | sk_font_set_scale_x(handle, newValue) 128 | } 129 | } 130 | public var skewX: Float { 131 | get { 132 | sk_font_get_skew_x(handle) 133 | } 134 | set { 135 | sk_font_set_skew_x(handle, newValue) 136 | } 137 | } 138 | 139 | /// Retrieve the corresponding glyph IDs of a string of characters. 140 | /// - Returns: the array of glyphs, or nil if there is an error 141 | public func getGlyphs (str: String) -> [UInt16]? 142 | { 143 | let utflen = str.utf8.count 144 | let nglyphs = sk_font_text_to_glyphs(handle, str, utflen, UTF8_SK_TEXT_ENCODING, nil, Int32 (utflen)) 145 | if nglyphs <= 0 { 146 | return nil 147 | } 148 | var glyphs = Array.init (repeating: 0, count: Int(nglyphs)) 149 | sk_font_text_to_glyphs(handle, str, utflen, UTF8_SK_TEXT_ENCODING, &glyphs, nglyphs) 150 | return glyphs 151 | } 152 | 153 | /// The number of glyphs necessary to render this string with this font 154 | public func countGlyphs (str: String) -> Int32 155 | { 156 | let utflen = str.utf8.count 157 | return sk_font_text_to_glyphs(handle, str, utflen, UTF8_SK_TEXT_ENCODING, nil, Int32 (utflen)) 158 | } 159 | 160 | public func getGlyphPositions (glyphs: inout [UInt16], origin: Point = Point(x: 0, y: 0)) -> [Point] { 161 | var positions: [Point] = Array.init (repeating: Point(x:0, y:0), count: glyphs.count) 162 | var o = origin 163 | sk_font_get_pos(handle, &glyphs, Int32 (glyphs.count), &positions, &o) 164 | return positions 165 | } 166 | 167 | 168 | //sk_font_break_text 169 | //sk_font_get_metrics 170 | //sk_font_get_path 171 | //sk_font_get_paths 172 | //sk_font_get_widths_bounds 173 | //sk_font_get_xpos 174 | //sk_font_measure_text 175 | //sk_font_unichar_to_glyph 176 | //sk_font_unichars_to_glyphs 177 | //SK_C_API void sk_text_utils_get_path(const void* text, size_t length, sk_text_encoding_t //encoding, float x, float y, const sk_font_t* font, sk_path_t* path); 178 | //SK_C_API void sk_text_utils_get_pos_path(const void* text, size_t length, sk_text_encoding_t //encoding, const sk_point_t pos[], const sk_font_t* font, sk_path_t* path); 179 | 180 | 181 | } 182 | -------------------------------------------------------------------------------- /Sources/SkiaKit/FontStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontStyle.swift 3 | // SkiaKit iOS 4 | // 5 | // Created by Miguel de Icaza on 10/29/19. 6 | // 7 | 8 | import Foundation 9 | #if canImport(CSkiaSharp) 10 | import CSkiaSharp 11 | #endif 12 | 13 | /// Represents a particular style (bold, italic, condensed) of a typeface. 14 | public final class FontStyle { 15 | var handle: OpaquePointer 16 | var owns: Bool 17 | 18 | init (handle: OpaquePointer, owns: Bool) 19 | { 20 | self.handle = handle 21 | self.owns = owns 22 | } 23 | 24 | public convenience init () 25 | { 26 | self.init(weight: .normal, width: .normal, slant: .upright) 27 | } 28 | 29 | /// Creates a new SKFontStyle with the specified weight, width and slant. 30 | public init (weight: Int32, width: Int32, slant: FontStyleSlant) 31 | { 32 | handle = sk_fontstyle_new(weight, width, slant.toNative()) 33 | owns = true 34 | } 35 | 36 | /// Creates a new SKFontStyle with the specified weight, width and slant. 37 | public init (weight: FontStyleWeight, width: FontStyleWidth, slant: FontStyleSlant) 38 | { 39 | handle = sk_fontstyle_new(weight.rawValue, width.rawValue, slant.toNative()) 40 | owns = true 41 | } 42 | 43 | deinit { 44 | if owns { 45 | sk_fontstyle_delete(handle) 46 | } 47 | } 48 | 49 | /// Gets the weight of this style. 50 | public var weight: Int32 { sk_fontstyle_get_weight(handle) } 51 | /// Gets the width of this style. 52 | public var width: Int32 { sk_fontstyle_get_width(handle) } 53 | /// Gets the slant of this style. 54 | public var slant: FontStyleSlant { FontStyleSlant.fromNative (sk_fontstyle_get_slant(handle)) } 55 | 56 | /// Gets a new normal (upright and not bold) font style. 57 | public static var normal: FontStyle = FontStyle(weight: .normal, width: .normal, slant: .upright) 58 | /// Gets a new upright font style that is bold. 59 | public static var bold: FontStyle = FontStyle(weight: .bold, width: .normal, slant: .upright) 60 | /// Gets a new italic font style. 61 | public static var italic: FontStyle = FontStyle(weight: .normal, width: .normal, slant: .italic) 62 | /// Gets a new italic font style that is bold. 63 | public static var boldItalic: FontStyle = FontStyle(weight: .bold, width: .normal, slant: .italic) 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Sources/SkiaKit/FontStyleSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontStyleSet.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 11/4/19. 6 | // 7 | 8 | import Foundation 9 | #if canImport(CSkiaSharp) 10 | import CSkiaSharp 11 | #endif 12 | 13 | /// Represets the set of styles for a particular font family. 14 | public final class FontStyleSet { 15 | var handle: OpaquePointer 16 | 17 | init (handle: OpaquePointer) { 18 | self.handle = handle 19 | } 20 | 21 | deinit { 22 | sk_fontstyleset_unref(handle) 23 | } 24 | /// Creates an empty font style set 25 | public init () 26 | { 27 | handle = sk_fontstyleset_create_empty() 28 | } 29 | 30 | /// Returns the number of font stypes in this set. 31 | public var count: Int32 { 32 | get { 33 | sk_fontstyleset_get_count(handle) 34 | } 35 | } 36 | 37 | func getStyle (index: Int32) -> FontStyle { 38 | let x = FontStyle () 39 | sk_fontstyleset_get_style(handle, index, x.handle, nil) 40 | return x 41 | } 42 | 43 | /// Returns an array of FontStyles in this set 44 | public var styles: [FontStyle] { 45 | get { 46 | var ret : [FontStyle] = [] 47 | for x in 0.. Typeface? { 57 | let x = sk_fontstyleset_match_style(handle, style.handle) 58 | if x == nil { 59 | return nil 60 | } 61 | return Typeface(handle: x!, owns: true) 62 | } 63 | 64 | /// Creates a new SKTypeface with a style that is the closest match to the specified font style. 65 | /// - Returns: the typeface if available, nil if the index is invalid 66 | public func createTypeface (index: Int32) -> Typeface? { 67 | let x = sk_fontstyleset_create_typeface(handle, index) 68 | if x == nil { 69 | return nil 70 | } 71 | return Typeface(handle: x!, owns: true) 72 | } 73 | 74 | /// Returns the name of the font style. 75 | public func getStyleName (index: Int32) -> String 76 | { 77 | let str = SKString () 78 | sk_fontstyleset_get_style(handle, index, nil, str.handle) 79 | return str.getStr() 80 | } 81 | //sk_fontstyleset_create_empty 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Sources/SkiaKit/ImageFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFilter.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/17/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public final class ImageFilter { 15 | var handle : OpaquePointer 16 | init (handle: OpaquePointer) 17 | { 18 | self.handle = handle 19 | } 20 | 21 | deinit 22 | { 23 | sk_imagefilter_unref(handle) 24 | } 25 | // sk_imagefilter_croprect_new 26 | //sk_imagefilter_croprect_new_with_rect 27 | //sk_imagefilter_croprect_destructor 28 | //sk_imagefilter_croprect_get_rect 29 | //sk_imagefilter_croprect_get_flags 30 | //sk_imagefilter_unref 31 | //sk_imagefilter_new_matrix 32 | //sk_imagefilter_new_alpha_threshold 33 | //sk_imagefilter_new_blur 34 | //sk_imagefilter_new_color_filter 35 | //sk_imagefilter_new_compose 36 | //sk_imagefilter_new_displacement_map_effect 37 | //sk_imagefilter_new_drop_shadow 38 | //sk_imagefilter_new_distant_lit_diffuse 39 | //sk_imagefilter_new_point_lit_diffuse 40 | //sk_imagefilter_new_spot_lit_diffuse 41 | //sk_imagefilter_new_distant_lit_specular 42 | //sk_imagefilter_new_point_lit_specular 43 | //sk_imagefilter_new_spot_lit_specular 44 | //sk_imagefilter_new_magnifier 45 | //sk_imagefilter_new_matrix_convolution 46 | //sk_imagefilter_new_merge 47 | //sk_imagefilter_new_dilate 48 | //sk_imagefilter_new_erode 49 | //sk_imagefilter_new_offset 50 | //sk_imagefilter_new_picture 51 | //sk_imagefilter_new_picture_with_croprect 52 | //sk_imagefilter_new_tile 53 | //sk_imagefilter_new_xfermode 54 | //sk_imagefilter_new_arithmetic 55 | //sk_imagefilter_new_image_source 56 | //sk_imagefilter_new_image_source_default 57 | //sk_imagefilter_new_paint 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Sources/SkiaKit/MaskFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MaskFilter.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/17/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public final class MaskFilter { 15 | var handle : OpaquePointer 16 | init (handle: OpaquePointer) 17 | { 18 | self.handle = handle 19 | } 20 | 21 | deinit 22 | { 23 | sk_maskfilter_unref(handle) 24 | } 25 | //sk_maskfilter_new_blur 26 | //sk_maskfilter_new_blur_with_flags 27 | //sk_maskfilter_new_clip 28 | //sk_maskfilter_new_gamma 29 | //sk_maskfilter_new_shader 30 | //sk_maskfilter_new_table 31 | //sk_maskfilter_ref 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Sources/SkiaKit/MathTypes.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Mathtypes.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/17/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public typealias Point = sk_point_t 15 | public extension Point { 16 | var length : Float { sqrtf(x*x+y*y)} 17 | 18 | mutating func offset (dx: Float, dy: Float) 19 | { 20 | x = x + dx 21 | y = y + dy 22 | } 23 | 24 | mutating func offset (point: Point) 25 | { 26 | x = x + point.x 27 | y = y + point.y 28 | } 29 | 30 | func normalize (_ point: Point) -> Point 31 | { 32 | let ls = point.x * point.x + point.y * point.y 33 | let invNorm = 1.0 / sqrtf(ls) 34 | return Point (x: point.x * invNorm, y: point.y * invNorm) 35 | } 36 | 37 | func distance (_ first: Point, _ second: Point) -> Float 38 | { 39 | let dx = first.x - second.x 40 | let dy = first.y - second.y 41 | return sqrtf (dx*dx + dy*dy) 42 | } 43 | 44 | static func + (ls: Point, rs: Point) -> Point 45 | { 46 | Point (x: ls.x + rs.x, y: ls.y + rs.y) 47 | } 48 | 49 | static func - (ls: Point, rs: Point) -> Point 50 | { 51 | Point (x: ls.x - rs.x, y: ls.y - rs.y) 52 | } 53 | 54 | static prefix func - (pt: Point) -> Point 55 | { 56 | Point (x: -pt.x, y: -pt.y) 57 | } 58 | } 59 | 60 | public typealias IPoint = sk_ipoint_t 61 | public extension IPoint { 62 | var length : Float { sqrtf(Float (x*x+y*y)) } 63 | 64 | mutating func offset (dx: Int32, dy: Int32) 65 | { 66 | x = x + dx 67 | y = y + dy 68 | } 69 | 70 | mutating func offset (point: IPoint) 71 | { 72 | x = x + point.x 73 | y = y + point.y 74 | } 75 | 76 | static func + (ls: IPoint, rs: IPoint) -> IPoint 77 | { 78 | IPoint (x: ls.x + rs.x, y: ls.y + rs.y) 79 | } 80 | 81 | static func - (ls: IPoint, rs: IPoint) -> IPoint 82 | { 83 | IPoint (x: ls.x - rs.x, y: ls.y - rs.y) 84 | } 85 | 86 | static prefix func - (pt: IPoint) -> IPoint 87 | { 88 | IPoint (x: -pt.x, y: -pt.y) 89 | } 90 | 91 | // func toNative () -> sk_ipoint_t 92 | // { 93 | // sk_ipoint_t(x: x, y: y) 94 | // } 95 | // 96 | // static func fromNative (v: sk_ipoint_t) -> IPoint 97 | // { 98 | // return IPoint (x: v.x, y: v.y) 99 | // } 100 | 101 | } 102 | 103 | public typealias Rect = sk_rect_t 104 | public extension Rect { 105 | init (x: Float, y: Float, width: Float, height: Float) 106 | { 107 | self.init(left: x, top: y, right: x+width, bottom: y+height) 108 | } 109 | 110 | init (width: Float, height: Float) 111 | { 112 | self.init(left: 0, top: 0, right: width, bottom: height) 113 | } 114 | 115 | var midX : Float { left + (right - left) / 2.0} 116 | var midY : Float { top + (bottom - top) / 2.0} 117 | var width: Float { right - left } 118 | var height: Float { bottom - top } 119 | 120 | static var empty: Rect { Rect(left: 0, top: 0, right: 0, bottom: 0)} 121 | 122 | var ceiling: IRect { 123 | get { 124 | IRect.ceiling (value: self, outwards: false) 125 | } 126 | } 127 | 128 | } 129 | 130 | public typealias IRect = sk_irect_t 131 | public extension IRect { 132 | init (x: Int32, y: Int32, width: Int32, height: Int32) 133 | { 134 | self.init(left: x, top: y, right: x+width, bottom: y+height) 135 | } 136 | 137 | init (width: Int32, height: Int32) 138 | { 139 | self.init(left: 0, top: 0, right: width, bottom: height) 140 | } 141 | 142 | var midX : Int32 { left + (right - left) / 2} 143 | var midY : Int32 { top + (bottom - top) / 2} 144 | var width: Int32 { right - left } 145 | var height: Int32 { bottom - top } 146 | 147 | static func ceiling (value: Rect, outwards: Bool) -> IRect { 148 | var x, y, r, b : Int32 149 | 150 | x = Int32 ((outwards && value.width > 0) ? floor (Float (value.left)) : ceil (Float (value.left))); 151 | y = Int32 ((outwards && value.height > 0) ? floor (Float (value.top)) : ceil (Float (value.top))); 152 | r = Int32 ((outwards && value.width < 0) ? floor (Float (value.right)) : ceil (Float (value.right))); 153 | b = Int32 ((outwards && value.height < 0) ? floor (Float (value.bottom)) : ceil (Float (value.bottom))); 154 | 155 | return IRect (left: x, top: y, right: r, bottom: b) 156 | } 157 | 158 | var isEmpty: Bool { 159 | get { 160 | return left == 0 && top == 0 && right == 0 && bottom == 0 161 | } 162 | } 163 | } 164 | 165 | public typealias Size = sk_size_t 166 | public extension Size { 167 | var width: Float { return self.w } 168 | var height: Float { return self.h } 169 | var isEmpty : Bool { 170 | get { width == 0 && height == 0 } 171 | } 172 | 173 | func toPoint () -> Point 174 | { 175 | return Point (x: Float (width), y: Float (height)) 176 | } 177 | 178 | func toIPoint () -> IPoint 179 | { 180 | return IPoint (x: Int32(width), y: Int32(height)) 181 | } 182 | } 183 | 184 | public typealias ISize = sk_isize_t 185 | public extension ISize{ 186 | var width: Int32 { return self.w } 187 | var height: Int32 { return self.h } 188 | var isEmpty : Bool { 189 | get { width == 0 && height == 0 } 190 | } 191 | 192 | func toPoint () -> Point 193 | { 194 | return Point (x: Float (width), y: Float (height)) 195 | } 196 | 197 | func toIPoint () -> IPoint 198 | { 199 | return IPoint (x: width, y: height) 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /Sources/SkiaKit/Matrix.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Matrix.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/18/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | /** 15 | * `Matrix` holds a 3x3 matrix for transforming coordinates. This allows mapping 16 | * `Point` and vectors with translation, scaling, skewing, rotation, and 17 | * perspective. 18 | * `Matrix` elements are in row major order. `Matrix` does not have a constructor, 19 | * so it must be explicitly initialized. setIdentity() initializes `Matrix` 20 | * so it has no effect. setTranslate(), setScale(), set`ew`(), setRotate(), set9 and setAll() 21 | * initializes all `Matrix` elements with the corresponding mapping. 22 | * `Matrix` includes a hidden variable that classifies the type of matrix to 23 | * improve performance. `Matrix` is not thread safe unless getType() is called first. 24 | * 25 | * You can either create the matrix by using one of the constuctors, or using some of the 26 | * convenience static methods that start with `make` 27 | */ 28 | public struct Matrix { 29 | var back: sk_matrix_t 30 | var mask: typeMask 31 | 32 | enum typeMask : UInt32 { 33 | case identity = 0 34 | case translate = 1 35 | case scale = 2 36 | case affine = 4 37 | case perspective = 8 38 | case rectStaysRect = 0x10 39 | case onlyPerspectiveValid = 0x40 40 | case unknown = 0x80 41 | } 42 | 43 | public init (scaleX: Float = 0, skewX: Float = 0, transX: Float = 0, scaleY: Float = 0, skewY: Float = 0, transY: Float = 0, persp0: Float = 0, persp1: Float = 0, persp2: Float = 0) 44 | { 45 | back = sk_matrix_t (scaleX: scaleX, skewX: skewX, transX: transX, skewY: skewY, scaleY: scaleY, transY: transY, persp0: persp0, persp1: persp1, persp2: persp2) 46 | mask = .unknown 47 | } 48 | 49 | init (scaleX: Float = 0, skewX: Float = 0, transX: Float = 0, scaleY: Float = 0, skewY: Float = 0, transY: Float = 0, persp0: Float = 0, persp1: Float = 0, persp2: Float = 0, mask: typeMask) 50 | { 51 | back = sk_matrix_t (scaleX: scaleX, skewX: skewX, transX: transX, skewY: skewY, scaleY: scaleY, transY: transY, persp0: persp0, persp1: persp1, persp2: persp2) 52 | self.mask = mask 53 | } 54 | 55 | func toNative () -> sk_matrix_t 56 | { 57 | back 58 | } 59 | 60 | /** 61 | * The identity matrix 62 | */ 63 | public static var identity : Matrix { Matrix (scaleX: 1, skewX: 0, transX: 0, scaleY: 1, skewY: 0, transY: 0, persp0: 0, persp1: 0, persp2: 1, mask: .rectStaysRect)} 64 | 65 | /** 66 | * Creates a translation matrix (dx, dy). 67 | * - Parameter dx: horizontal translation 68 | * - Parameter dy: vertical translation 69 | * - Returns: `Matrix` with translation 70 | */ 71 | public static func makeTranslation (sx: Float, sy: Float) -> Matrix 72 | { 73 | if sx == 1 && sy == 1 { 74 | return identity 75 | } 76 | return Matrix (scaleX: sx, skewX: 0, transX: 0, scaleY: sy, skewY: 0, transY: 0, persp0: 0, persp1: 0, persp2: 1) 77 | } 78 | 79 | /** 80 | * Creates a new scale matrix. 81 | * - Parameter sx: The scaling in the x direction 82 | * - Parameter sy: The scaling in the y direction 83 | */ 84 | public static func makeScale (sx: Float, sy: Float) -> Matrix 85 | { 86 | if sx == 1 && sy == 1 { 87 | return identity 88 | } 89 | return Matrix (scaleX: sx, scaleY: sy, persp1: 1) 90 | } 91 | 92 | public static func makeSkew (sx: Float, sy: Float) -> Matrix 93 | { 94 | return Matrix (scaleX: 1, skewX: sx, scaleY: 1, skewY: sy, persp2: 1) 95 | } 96 | 97 | public static func concat (target: inout Matrix, first: Matrix, second: Matrix) 98 | { 99 | var fcopy = first 100 | var scopy = second 101 | sk_matrix_concat(&target.back, &fcopy.back, &scopy.back) 102 | } 103 | 104 | public static func preConcat (target: inout Matrix, matrix: Matrix) 105 | { 106 | var mcopy = matrix 107 | sk_matrix_pre_concat(&target.back, &mcopy.back) 108 | } 109 | 110 | public static func postConcat (target: inout Matrix, matrix: Matrix) 111 | { 112 | var mcopy = matrix 113 | sk_matrix_post_concat(&target.back, &mcopy.back) 114 | } 115 | 116 | 117 | static func fromNative (m: sk_matrix_t) -> Matrix 118 | { 119 | return Matrix(scaleX: m.scaleX, skewX: m.skewX, transX: m.transX, scaleY: m.scaleY, skewY: m.skewY, transY: m.transY, persp0: m.persp0, persp1: m.persp1, persp2: m.persp2) 120 | } 121 | 122 | //sk_3dview_apply_to_canvas 123 | //sk_3dview_destroy 124 | //sk_3dview_dot_with_normal 125 | //sk_3dview_get_matrix 126 | //sk_3dview_new 127 | //sk_3dview_restore 128 | //sk_3dview_rotate_x_degrees 129 | //sk_3dview_rotate_x_radians 130 | //sk_3dview_rotate_y_degrees 131 | //sk_3dview_rotate_y_radians 132 | //sk_3dview_rotate_z_degrees 133 | //sk_3dview_rotate_z_radians 134 | //sk_3dview_save 135 | //sk_3dview_translate 136 | //sk_matrix44_as_col_major 137 | //sk_matrix44_as_row_major 138 | //sk_matrix44_destroy 139 | //sk_matrix44_determinant 140 | //sk_matrix44_equals 141 | //sk_matrix44_get 142 | //sk_matrix44_get_type 143 | //sk_matrix44_invert 144 | //sk_matrix44_map2 145 | //sk_matrix44_map_scalars 146 | //sk_matrix44_new 147 | //sk_matrix44_new_concat 148 | //sk_matrix44_new_copy 149 | //sk_matrix44_new_identity 150 | //sk_matrix44_new_matrix 151 | //sk_matrix44_post_concat 152 | //sk_matrix44_post_scale 153 | //sk_matrix44_post_translate 154 | //sk_matrix44_pre_concat 155 | //sk_matrix44_pre_scale 156 | //sk_matrix44_pre_translate 157 | //sk_matrix44_preserves_2d_axis_alignment 158 | //sk_matrix44_set 159 | //sk_matrix44_set_3x3_row_major 160 | //sk_matrix44_set_col_major 161 | //sk_matrix44_set_concat 162 | //sk_matrix44_set_identity 163 | //sk_matrix44_set_rotate_about_degrees 164 | //sk_matrix44_set_rotate_about_radians 165 | //sk_matrix44_set_rotate_about_radians_unit 166 | //sk_matrix44_set_row_major 167 | //sk_matrix44_set_scale 168 | //sk_matrix44_set_translate 169 | //sk_matrix44_to_matrix 170 | //sk_matrix44_transpose 171 | //sk_matrix_DEFINED 172 | //sk_matrix_map_points 173 | //sk_matrix_map_radius 174 | //sk_matrix_map_rect 175 | //sk_matrix_map_vector 176 | //sk_matrix_map_vectors 177 | //sk_matrix_map_xy 178 | //sk_matrix_try_invert 179 | 180 | } 181 | -------------------------------------------------------------------------------- /Sources/SkiaKit/PathEffect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PathEffect.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/17/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | /** 15 | * `PathEffect` is the base class for objects in the `Paint` that affect 16 | * the geometry of a drawing primitive before it is transformed by the 17 | * canvas' matrix and drawn. 18 | * Dashing is implemented as a subclass of `PathEffect`. 19 | */ 20 | public final class PathEffect { 21 | var handle : OpaquePointer 22 | init (handle: OpaquePointer) 23 | { 24 | self.handle = handle 25 | } 26 | 27 | /** 28 | * Stamp the specified path to fill the shape, using the matrix to define the latice. 29 | * - Parameter matrix: <#matrix description#> 30 | * - Parameter path: <#path description#> 31 | */ 32 | public static func make2DPath (matrix: inout Matrix, path: Path) -> PathEffect 33 | { 34 | PathEffect (handle: sk_path_effect_create_2d_path(&matrix.back, path.handle)) 35 | } 36 | 37 | deinit 38 | { 39 | sk_path_effect_unref(handle) 40 | } 41 | 42 | //sk_path_effect_create_1d_path 43 | //sk_path_effect_create_2d_line 44 | //sk_path_effect_create_2d_path 45 | //sk_path_effect_create_compose 46 | //sk_path_effect_create_corner 47 | //sk_path_effect_create_dash 48 | //sk_path_effect_create_discrete 49 | //sk_path_effect_create_sum 50 | //sk_path_effect_create_trim 51 | //sk_path_effect_unref 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Sources/SkiaKit/Picture.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Picture.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 11/6/19. 6 | // 7 | 8 | import Foundation 9 | #if canImport(CSkiaSharp) 10 | import CSkiaSharp 11 | #endif 12 | 13 | public final class Picture { 14 | var handle: OpaquePointer 15 | 16 | init (handle: OpaquePointer) 17 | { 18 | self.handle = handle 19 | } 20 | 21 | /// Gets the non-zero value unique among all pictures. 22 | public var uniqueId: UInt32 { 23 | get { 24 | sk_picture_get_unique_id(handle) 25 | } 26 | } 27 | 28 | /// Gets the culling rectangle for this picture. 29 | public var cullRect: Rect { 30 | get { 31 | var r = sk_rect_t () 32 | sk_picture_get_cull_rect(handle, &r) 33 | return r 34 | } 35 | } 36 | 37 | deinit { 38 | sk_picture_unref(handle) 39 | } 40 | //sk_picture_get_recording_canvas 41 | //sk_picture_make_shader 42 | //sk_picture_ref 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SkiaKit/PictureRecorder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PictureRecorder.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 11/6/19. 6 | // 7 | 8 | import Foundation 9 | #if canImport(CSkiaSharp) 10 | import CSkiaSharp 11 | #endif 12 | 13 | /// The picture recorder is used to record drawing operations made to a SKCanvas and stored in a SKPicture. 14 | /// call the `beginRecording` method to start, issue your commands into the returned `Canvas` 15 | /// and then call the `endRecording` method to get the `Picture` that has the recording on it. 16 | /// 17 | public final class PictureRecorder { 18 | var handle: OpaquePointer 19 | var owns: Bool 20 | 21 | init (handle: OpaquePointer, owns: Bool) { 22 | self.handle = handle 23 | self.owns = owns 24 | } 25 | 26 | /// Creates a new instance of the SKPictureRecorder. 27 | public init () 28 | { 29 | handle = sk_picture_recorder_new() 30 | owns = true 31 | } 32 | 33 | /// Start the recording process and return the recording canvas. 34 | /// - Parameter cullRect: The culling rectangle for the new picture. 35 | /// - Returns: a `Canvas` that you can issue draw operations on, and that will be recorded 36 | public func beginRecording (cullRect: Rect) -> Canvas { 37 | var r = cullRect 38 | return Canvas (handle: sk_picture_recorder_begin_recording(handle, &r), owns: .doesNotOwn) 39 | } 40 | 41 | /// Signal that the caller is done recording. 42 | /// - Returns: the picture with the recording on it 43 | public func endRecording () -> Picture 44 | { 45 | Picture (handle: sk_picture_recorder_end_recording(handle)) 46 | } 47 | 48 | /// Returns the recording canvas if one is active, or nil if recording is 49 | /// not active. 50 | public var recordingCanvas: Canvas { 51 | get { 52 | return Canvas (handle: sk_picture_get_recording_canvas(handle), owns: .doesNotOwn) 53 | } 54 | } 55 | deinit { 56 | if owns { 57 | sk_picture_recorder_delete(handle) 58 | } 59 | } 60 | //sk_picture_recorder_end_recording_as_drawable 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Sources/SkiaKit/Region.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Region.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/18/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | /** 15 | * `Region` describes the set of pixels used to clip `Canvas`. `Region` is compact, 16 | * efficiently storing a single integer rectangle, or a run length encoded array 17 | * of rectangles. `Region` may reduce the current `Canvas` clip, or may be drawn as 18 | * one or more integer rectangles. `Region` iterator returns the scan lines or 19 | * rectangles contained by it, optionally intersecting a bounding rectangle. 20 | */ 21 | public final class Region { 22 | var handle: OpaquePointer 23 | 24 | /** 25 | * Constructs an empty `Region`. `Region` is set to empty bounds 26 | * at (0, 0) with zero width and height. 27 | */ 28 | public init () 29 | { 30 | handle = sk_region_new() 31 | } 32 | 33 | public convenience init (rect: IRect) 34 | { 35 | self.init () 36 | setRect (rect) 37 | } 38 | 39 | public convenience init (path: Path) 40 | { 41 | self.init (rect: path.bounds.ceiling) 42 | setPath (path) 43 | } 44 | 45 | /** 46 | * Constructs a rectangular `Region` matching the bounds of rect. 47 | * If rect is empty, constructs empty and returns false. 48 | * - Parameter rect: bounds of constructed `Region` 49 | * - Returns: true if rect is not empty 50 | */ 51 | @discardableResult 52 | public func setRect (_ rect: IRect) -> Bool 53 | { 54 | var r = rect 55 | return sk_region_set_rect(handle, &r) 56 | } 57 | 58 | /** 59 | * Constructs `Region` to match outline of path within clip. 60 | * Returns false if constructed `Region` is empty. 61 | * Constructed `Region` draws the same pixels as path through clip when 62 | * anti-aliasing is disabled. 63 | * - Parameter path: `Path` providing outline 64 | * - Parameter clip: `Region` containing path 65 | * - Returns: true if constructed `Region` is not empty 66 | */ 67 | public func setPath (_ path: Path, clip: Region) 68 | { 69 | sk_region_set_path(handle, path.handle, clip.handle) 70 | } 71 | 72 | /** 73 | * Set this region to the area described by the path, clipped to the current region. 74 | * - Parameter path: The replacement path. 75 | * - Returns: true if constructed `Region` is not empty 76 | */ 77 | public func setPath (_ path: Path) 78 | { 79 | let clip = Region () 80 | let rect = path.bounds.ceiling 81 | if !rect.isEmpty { 82 | clip.setRect(rect) 83 | } 84 | sk_region_set_path(handle, path.handle, clip.handle) 85 | } 86 | 87 | /** 88 | * Replaces `Region` with the result of `Region` op rect. 89 | * Returns true if replaced `Region` is not empty. 90 | * - Parameter rect: `IRect` operand 91 | * - Parameter op: operator to apply 92 | * - Returns: false if result is empty 93 | */ 94 | public func op (rect: IRect, op: RegionOperation) -> Bool 95 | { 96 | var r = rect 97 | return sk_region_op_rect (handle, &r, op.toNative ()) 98 | } 99 | 100 | deinit { 101 | sk_region_delete(handle) 102 | } 103 | 104 | /** 105 | * Returns minimum and maximum axes values of `IRect` array. 106 | * Returns (0, 0, 0, 0) if `Region` is empty. 107 | */ 108 | public var bounds: IRect { 109 | get { 110 | var r = sk_irect_t() 111 | 112 | sk_region_get_bounds(handle, &r) 113 | return r 114 | } 115 | } 116 | 117 | public func contains (region: Region) -> Bool 118 | { 119 | return sk_region_contains(handle, region.handle) 120 | } 121 | 122 | /** 123 | * Returns true if `Region` intersects other. 124 | * Returns false if either other or `Region` is empty, or do not intersect. 125 | * - Parameter other: `Region` to intersect 126 | * - Returns: true if other and `Region` have area in common 127 | * 128 | */ 129 | public func intersects (region: Region) -> Bool { 130 | sk_region_intersects(handle, region.handle) 131 | } 132 | 133 | /** 134 | * Returns true if `Region` intersects rect. 135 | * Returns false if either rect or `Region` is empty, or do not intersect. 136 | * - Parameter rect: `IRect` to intersect 137 | * - Returns: true if rect and `Region` have area in common 138 | */ 139 | public func intersects (rect: IRect) -> Bool { 140 | var r = rect 141 | return sk_region_intersects_rect(handle, &r); 142 | } 143 | //sk_region_cliperator_delete 144 | //sk_region_cliperator_done 145 | //sk_region_cliperator_new 146 | //sk_region_cliperator_next 147 | //sk_region_cliperator_rect 148 | //sk_region_cliperator_t 149 | //sk_region_contains_point 150 | //sk_region_contains_rect 151 | //sk_region_get_boundary_path 152 | //sk_region_is_complex 153 | //sk_region_is_empty 154 | //sk_region_is_rect 155 | //sk_region_iterator_delete 156 | //sk_region_iterator_done 157 | //sk_region_iterator_new 158 | //sk_region_iterator_next 159 | //sk_region_iterator_rect 160 | //sk_region_iterator_rewind 161 | //sk_region_iterator_t 162 | //sk_region_op 163 | //sk_region_quick_contains 164 | //sk_region_quick_reject 165 | //sk_region_quick_reject_rect 166 | //sk_region_set_empty 167 | //sk_region_set_rects 168 | //sk_region_set_region 169 | //sk_region_spanerator_delete 170 | //sk_region_spanerator_new 171 | //sk_region_spanerator_next 172 | //sk_region_spanerator_t 173 | //sk_region_t 174 | //sk_region_translate 175 | 176 | } 177 | -------------------------------------------------------------------------------- /Sources/SkiaKit/RoundRect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RoundRect.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/18/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public final class RoundRect { 15 | var handle: OpaquePointer 16 | 17 | init (handle: OpaquePointer) 18 | { 19 | self.handle = handle 20 | } 21 | 22 | public init () 23 | { 24 | handle = sk_rrect_new() 25 | sk_rrect_set_empty(handle) 26 | } 27 | 28 | public init (rect: Rect) 29 | { 30 | handle = sk_rrect_new() 31 | set (rect: rect) 32 | } 33 | 34 | public init (rect: Rect, xradius: Float, yradius: Float) 35 | { 36 | handle = sk_rrect_new() 37 | set (rect: rect, xradius: xradius, yradius: yradius) 38 | } 39 | 40 | public init (rr: RoundRect) 41 | { 42 | handle = sk_rrect_new_copy(rr.handle) 43 | } 44 | 45 | public var rect : Rect { 46 | get { 47 | let ptr = UnsafeMutablePointer.allocate(capacity: 1) 48 | 49 | sk_rrect_get_rect(handle, ptr); 50 | return ptr.pointee 51 | } 52 | } 53 | public func setEmpty () 54 | { 55 | sk_rrect_set_empty(handle) 56 | } 57 | 58 | public func set (rect: Rect) 59 | { 60 | withUnsafePointer(to: rect) { 61 | sk_rrect_set_rect(handle, $0) 62 | } 63 | } 64 | 65 | public func set (rect: Rect, xradius: Float, yradius: Float) 66 | { 67 | withUnsafePointer(to: rect) { 68 | sk_rrect_set_rect_xy(handle, $0, xradius, yradius) 69 | } 70 | } 71 | 72 | deinit { 73 | sk_rrect_delete(handle) 74 | } 75 | //sk_rrect_contains 76 | //sk_rrect_delete 77 | //sk_rrect_get_height 78 | //sk_rrect_get_radii 79 | //sk_rrect_get_rect 80 | //sk_rrect_get_type 81 | //sk_rrect_get_width 82 | //sk_rrect_inset 83 | //sk_rrect_is_valid 84 | //sk_rrect_new 85 | //sk_rrect_new_copy 86 | //sk_rrect_offset 87 | //sk_rrect_outset 88 | //sk_rrect_set_empty 89 | //sk_rrect_set_nine_patch 90 | //sk_rrect_set_oval 91 | //sk_rrect_set_rect 92 | //sk_rrect_set_rect_radii 93 | //sk_rrect_set_rect_xy 94 | //sk_rrect_transform 95 | 96 | } 97 | -------------------------------------------------------------------------------- /Sources/SkiaKit/SKObject.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SKObject.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/15/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | public class SKObject { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Sources/SkiaKit/SKString.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SKString.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 10/21/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if canImport(CSkiaSharp) 11 | import CSkiaSharp 12 | #endif 13 | 14 | final class SKString { 15 | var handle: OpaquePointer 16 | 17 | init (str: String) 18 | { 19 | handle = sk_string_new_with_copy(str, str.utf8CString.count) 20 | } 21 | 22 | init () 23 | { 24 | handle = sk_string_new_empty() 25 | } 26 | 27 | public func getStr () -> String 28 | { 29 | return String (cString: sk_string_get_c_str(handle)) 30 | } 31 | 32 | deinit { 33 | sk_string_destructor(handle) 34 | } 35 | 36 | // sk_string_get_size 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Sources/SkiaKit/SurfaceProperties.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SurfaceProps.swift 3 | // SkiaKit 4 | // 5 | // Created by Miguel de Icaza on 11/2/19. 6 | // 7 | 8 | import Foundation 9 | #if canImport(CSkiaSharp) 10 | import CSkiaSharp 11 | #endif 12 | 13 | /** 14 | * Describes properties and constraints of a given `Surface`. The rendering engine can parse these 15 | * during drawing, and can sometimes optimize its performance (e.g. disabling an expensive 16 | * feature). 17 | */ 18 | public final class SurfaceProperties { 19 | var handle: OpaquePointer 20 | var owns: Bool 21 | 22 | init (handle: OpaquePointer, owns: Bool) 23 | { 24 | self.handle = handle 25 | self.owns = owns 26 | } 27 | 28 | 29 | public init (_ pixelGeometry: PixelGeometry) 30 | { 31 | handle = sk_surfaceprops_new(0, pixelGeometry.toNative()) 32 | owns = true 33 | } 34 | 35 | deinit { 36 | if owns { 37 | sk_surfaceprops_delete(handle) 38 | } 39 | } 40 | 41 | /// The pixel geometry for the surface 42 | public var pixelGeometry: PixelGeometry { PixelGeometry.fromNative (sk_surfaceprops_get_pixel_geometry(handle)) } 43 | //sk_surfaceprops_get_flags 44 | } 45 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/migueldeicaza/SkiaKit/bad7d455aee89bc434b254aefd1518330662e23a/Tests/LinuxMain.swift -------------------------------------------------------------------------------- /Tests/SkiaKitTests/SKCanvasTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SKCanvasTest.swift 3 | // SkiaKitTests 4 | // 5 | // Created by Miguel de Icaza on 10/16/19. 6 | // Copyright © 2019 Miguel de Icaza. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | import XCTest 12 | @testable import SkiaKit 13 | 14 | class SKCanvasTest : XCTestCase { 15 | override func setUp() { 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | print ("Starting SKCanvasTest") 18 | } 19 | 20 | override func tearDown() { 21 | // Put teardown code here. This method is called after the invocation of each test method in the class. 22 | } 23 | 24 | func testCanDrawText () 25 | { 26 | let bmp = try! Bitmap(ImageInfo (300, 300)) 27 | let canvas = Canvas(bmp) 28 | let paint = Paint() 29 | 30 | let fontSet = FontManager.system.getFontStyles(familyName: "Arial") 31 | let fontStyle = fontSet.getStyle(index: 0) 32 | let typeface = fontSet.createTypeface(style: fontStyle)! 33 | let font = Font(typeface: typeface, size: 16.0, scaleX: 1.0, skewX: 0.0) 34 | 35 | canvas.draw (text: "text", x: 150, y: 175, font: font, paint: paint) 36 | } 37 | } 38 | 39 | // 40 | //func sampleDrawMatrix (canvas: Canvas, width: Int, height: Int) 41 | //{ 42 | // let size = (height > width ? width : height) / 2 43 | // 44 | // let center = Point(x: Float((width-size)/2), y: Float((height-size) / 2)) 45 | // 46 | // //var leftRect = Rect(left: center.x - size / 2, top: center.Y, right: size, bottom: size) 47 | // //var rightRect = Rect(left: center.x + size / 2, top: center.Y, right: size, bottom: size 48 | // // 49 | // //var rotatedRect = Rect(0,0,size,size) 50 | // //var paint = Paint() 51 | // //paint.isAntialias = true 52 | // //canvas.clear(color: Colors.purple) 53 | // //paint.color = Colors.darkBlue 54 | // //canvas.drawRect(leftRect, paint) 55 | // 56 | //} 57 | //let bmp = try! Bitmap(ImageInfo (300, 300)) 58 | //let canvas = Canvas(bmp) 59 | //let paint = Paint() 60 | //canvas.drawText (text: "text", x: 150, y: 175, paint: paint) 61 | // 62 | //print("Hello, Skia!") 63 | -------------------------------------------------------------------------------- /docs/badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | documentation 17 | 18 | 19 | documentation 20 | 21 | 22 | 52% 23 | 24 | 25 | 52% 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/migueldeicaza/SkiaKit/bad7d455aee89bc434b254aefd1518330662e23a/docs/img/carat.png -------------------------------------------------------------------------------- /docs/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/migueldeicaza/SkiaKit/bad7d455aee89bc434b254aefd1518330662e23a/docs/img/dash.png -------------------------------------------------------------------------------- /docs/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/migueldeicaza/SkiaKit/bad7d455aee89bc434b254aefd1518330662e23a/docs/img/gh.png -------------------------------------------------------------------------------- /docs/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | function toggleItem($link, $content) { 12 | var animationDuration = 300; 13 | $link.toggleClass('token-open'); 14 | $content.slideToggle(animationDuration); 15 | } 16 | 17 | function itemLinkToContent($link) { 18 | return $link.parent().parent().next(); 19 | } 20 | 21 | // On doc load + hash-change, open any targetted item 22 | function openCurrentItemIfClosed() { 23 | if (window.jazzy.docset) { 24 | return; 25 | } 26 | var $link = $(`.token[href="${location.hash}"]`); 27 | $content = itemLinkToContent($link); 28 | if ($content.is(':hidden')) { 29 | toggleItem($link, $content); 30 | } 31 | } 32 | 33 | $(openCurrentItemIfClosed); 34 | $(window).on('hashchange', openCurrentItemIfClosed); 35 | 36 | // On item link ('token') click, toggle its discussion 37 | $('.token').on('click', function(event) { 38 | if (window.jazzy.docset) { 39 | return; 40 | } 41 | var $link = $(this); 42 | toggleItem($link, itemLinkToContent($link)); 43 | 44 | // Keeps the document from jumping to the hash. 45 | var href = $link.attr('href'); 46 | if (history.pushState) { 47 | history.pushState({}, '', href); 48 | } else { 49 | location.hash = href; 50 | } 51 | event.preventDefault(); 52 | }); 53 | 54 | // Clicks on links to the current, closed, item need to open the item 55 | $("a:not('.token')").on('click', function() { 56 | if (location == this.href) { 57 | openCurrentItemIfClosed(); 58 | } 59 | }); 60 | -------------------------------------------------------------------------------- /download-payload-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | V=2.80.3-preview.40 4 | DIR=skiasharp-$V 5 | FILE=skiasharp-$V.zip 6 | URL=https://www.nuget.org/api/v2/package/SkiaSharp.NativeAssets.Linux/$V 7 | 8 | download_nuget() { 9 | if test ! -e $FILE; then 10 | curl -L -o skiasharp-$V.zip $URL 11 | fi 12 | unzip -d skiasharp-$V $FILE 13 | } 14 | download_nuget 15 | 16 | mv $DIR/runtimes/linux-x64/native/libSkiaSharp.so . 17 | rm -rf skiasharp-* 18 | -------------------------------------------------------------------------------- /make-release.sh: -------------------------------------------------------------------------------- 1 | if test x$2 = x; then 2 | echo usage is: make-release TAG RELEASE_NOTE_FILE 3 | exit 1 4 | fi 5 | if test -e $2; then 6 | echo release file found 7 | else 8 | echo The release notes file does not exist 9 | exit 1 10 | fi 11 | 12 | TAG=$1 13 | ZIPNAME=SkiaSharp.xcframework.zip 14 | GIT_REMOTE_URL_UNFINISHED=`git config --get remote.origin.url|sed "s=^ssh://==; s=^https://==; s=:=/=; s/git@//; s/.git$//;"` 15 | DOWNLOAD_URL=https://$GIT_REMOTE_URL_UNFINISHED/releases/download/$TAG/$ZIPNAME 16 | 17 | perl -pi -e "s,url: \"https:.*SkiaSharp.xcframework.zip\",url: \"$DOWNLOAD_URL\"," Package.swift 18 | 19 | git commit -m "Release version $TAG" -a 20 | git tag -f $TAG 21 | git push 22 | git push --tags --force 23 | gh release create "$TAG" $ZIPNAME --title "$TAG" --notes-file $2 24 | -------------------------------------------------------------------------------- /make-xcframework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | download=false 3 | out=SkiaSharp.xcframework 4 | 5 | while test x$1 != x; do 6 | case x in 7 | --download) 8 | download=true 9 | ;; 10 | --help) 11 | echo "Usage is: $0 [--download] [--out=FILE]" 12 | echo Output defaults to SkiaSharp.xcframework 13 | exit 0 14 | ;; 15 | --out=*) 16 | ;; 17 | esac 18 | done 19 | 20 | if $download; then 21 | V=2.88.4-preview.70 22 | https://www.nuget.org/api/v2/package/SkiaSharp.NativeAssets.macOS/ 23 | 24 | base=https://www.nuget.org/api/v2/package/SkiaSharp.NativeAssets 25 | 26 | for x in tvOS macOS iOS; do 27 | curl -L -o $x.zip $base.{$x}/$V 28 | unzip -d $x $x.zip 29 | done 30 | fi 31 | 32 | # used below in build methods 33 | lipo_skiasharp() { 34 | local folder_name="$1" 35 | local arch="$2" 36 | local path=$folder_name/libSkiaSharp.framework/libSkiaSharp 37 | 38 | lipo -extract $arch $path -output $path 39 | } 40 | 41 | rm -rf build 42 | mkdir build 43 | 44 | # iOS 45 | build_ios() { 46 | mkdir build/iOS 47 | cp -a iOS/runtimes/ios/native/libSkiaSharp.framework build/iOS/libSkiaSharp.framework 48 | 49 | # Painfully separate all architectures. 50 | cp -a build/iOS build/iOS-x86_64 51 | cp -a build/iOS build/iOS-arm64 52 | rm -rf build/iOS 53 | 54 | # Remove other architectures. 55 | lipo_skiasharp build/iOS-x86_64 x86_64 56 | lipo_skiasharp build/iOS-arm64 arm64 57 | } 58 | build_ios 59 | 60 | # tvOS 61 | build_tvos() { 62 | mkdir build/tvOS 63 | cp -a tvOS/runtimes/tvos/native/libSkiaSharp.framework build/tvOS/libSkiaSharp.framework 64 | 65 | # Painfully separate all architectures. 66 | cp -a build/tvOS build/tvOS-x86_64 67 | cp -a build/tvOS build/tvOS-arm64 68 | rm -rf build/tvOS 69 | 70 | # Remove other architectures. 71 | lipo_skiasharp build/tvOS-x86_64 x86_64 72 | lipo_skiasharp build/tvOS-arm64 arm64 73 | } 74 | build_tvos 75 | 76 | # macOS 77 | build_macos() { 78 | mkdir -p build/macOS-x86_64/libSkiaSharp.framework 79 | 80 | cp macOS/runtimes/osx/native/libSkiaSharp.dylib . 81 | # https://stackoverflow.com/questions/57755276/create-ios-framework-with-dylib 82 | lipo libSkiaSharp.dylib -output libSkiaSharp -create 83 | install_name_tool -id @rpath/libSkiaSharp.framework/libSkiaSharp libSkiaSharp 84 | 85 | mv libSkiaSharp build/macOS-x86_64/libSkiaSharp.framework/ 86 | rm libSkiaSharp.dylib 87 | 88 | cp MacOSFramework/Info.plist build/macOS-x86_64/libSkiaSharp.framework/Info.plist 89 | } 90 | build_macos 91 | 92 | rm -rf $out 93 | 94 | create_xcframework() { 95 | # Create XCFramework. 96 | xcodebuild -create-xcframework \ 97 | -framework build/iOS-x86_64/libSkiaSharp.framework \ 98 | -framework build/iOS-arm64/libSkiaSharp.framework \ 99 | -framework build/tvOS-x86_64/libSkiaSharp.framework \ 100 | -framework build/tvOS-arm64/libSkiaSharp.framework \ 101 | -framework build/macOS-x86_64/libSkiaSharp.framework \ 102 | -output SkiaSharp.xcframework 103 | } 104 | create_xcframework 105 | rm -rf build 106 | --------------------------------------------------------------------------------