Skip to content

Swift wrapper for SkiaSharp's C API. Support Android

Notifications You must be signed in to change notification settings

Guang1234567/Skia_Swift_CrossPlatform

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Changed

  • Support Android platform. see android_api_21 branch.

Usage

# uncompress the jniLibs to the `host_swift_project/.build` directory
# `host_swift_project` is the project that depends on `skia_swift_cross_platform`

tar -zxvf jniLibs.7z -C host_swift_project/.build
let package = Package(
    name: packageName,
    products: addGenerated([
    ]),
    dependencies: [
        .package(url: "https://github.com/Guang1234567/Skia_Swift_CrossPlatform.git", .branch("android_api_21"))
    ],

    targets: addGenerated([
        .target(name: packageName,
                dependencies: [
                    "SkiaSwift"
                ]),
    ])
)

Build skia.a for Android

bin/gn gen out/Release/android/arm64-v8a --args='ndk="/tmp/ndk-bundle-16" target_cpu="arm64" extra_cflags_cc=["-frtti", "-Wno-shadow-field"] ndk_api=21 target_os="android" is_debug=false skia_use_system_expat=false skia_use_system_libjpeg_turbo=true skia_use_system_libpng=false skia_use_system_libwebp=true skia_use_system_zlib=true skia_use_system_icu=true skia_use_icu=false skia_use_libjpeg_turbo=false skia_use_system_freetype2=false skia_use_system_jsoncpp=true skia_use_libwebp=false skia_use_system_lua=false skia_use_icu=false skia_use_egl=true skia_use_angle=false skia_enable_pdf=false skia_enable_skottie=false skia_enable_effects=true skia_enable_vulkan_debug_layers=false skia_use_dng_sdk=true skia_use_lua=false skia_use_metal=false skia_enable_flutter_defines=true'

https://www.skiatest.org/user/build#android

Example

Swift_Android_Skia_EGl_Example

=============================

SkiaSwift

Swift wrapper for SkiaSharp's C API

See:

This project uses Swift Package Manager:

Build SkiaSharp's Skia fork

Download SkiaSharp's Skia fork, then see these doc to build:

Build static libraries:

bin/gn gen out --args="is_debug=false is_official_build=true \
skia_use_system_expat=false skia_use_system_libjpeg_turbo=false \
skia_use_system_libpng=false skia_use_system_libwebp=false \
skia_use_system_zlib=false skia_use_system_icu=false \
skia_use_system_harfbuzz=false"

ninja -C out

Build CSkiaSwift

Create symlinks to the built Skia above (only include/c and out directories are used):

cd Sources/CSkia/include
ln -s /path/to/skia/include/c

cd Sources/CSkia
ln -s /path/to/skia/out

Build:

swift build
swift build -c release

Run:

swift run Demo
.build/debug/Demo
.build/release/Demo

Generate doc

Install jazzy, then run:

jazzy --module SkiaSwift

Releases

No releases published

Packages

No packages published

Languages

  • C 45.9%
  • Swift 45.1%
  • C++ 8.7%
  • Objective-C 0.3%