Skip to content

Instantly share code, notes, and snippets.

@jezell
Created June 10, 2026 07:50
Show Gist options
  • Select an option

  • Save jezell/8701bd385f9071b1ae7b86569593537c to your computer and use it in GitHub Desktop.

Select an option

Save jezell/8701bd385f9071b1ae7b86569593537c to your computer and use it in GitHub Desktop.

Vendored Skia Dart Modifications

This file records local changes made under third_party/skia_dart so we can track the delta from the published package and avoid losing rendering-critical API work during future vendor refreshes.

2026-06-10: Dart Gradient Shader API Surface

Purpose:

  • Keep missing Skia APIs in the vendored implementation instead of adding renderer-side workarounds.
  • Expose Skia gradient shader creation through typed Dart APIs so the rendering port can call Skia directly.

Files changed:

  • third_party/skia_dart/packages/skia_dart/lib/src/shader.dart
  • third_party/skia_dart/packages/skia_dart/lib/src/skia.g.dart

Changes:

  • Added Dart FFI bindings for:
    • sk_shader_new_linear_gradient
    • sk_shader_new_radial_gradient
    • sk_shader_new_sweep_gradient
    • sk_shader_new_two_point_conical_gradient
  • Added typed SkShader factories for:
    • SkShader.linearGradient
    • SkShader.radialGradient
    • SkShader.sweepGradient
    • SkShader.twoPointConicalGradient
  • Added shared gradient color/position pointer plumbing for the new factories.

Notes:

  • This API surface was added before the native dylib had matching exported symbols. The native wrapper work below makes the Dart bindings resolvable at runtime.

2026-06-10: Native Gradient Shader Wrapper and Rebuild

Purpose:

  • Enable full Skia-backed gradient rendering from Dart without pre-rasterizing gradient pixels in the rendering port.
  • Make the existing Dart gradient shader API resolve against the vendored native dylib.

Files changed:

  • third_party/skia_dart/src/wrapper/include/sk_shader.h
  • third_party/skia_dart/src/wrapper/sk_shader.cpp
  • third_party/skia_dart/src/wrapper/sk_surface.cpp

Changes:

  • Re-enabled the native C wrapper declarations for Skia gradient shader creation so the dylib exports unmangled C symbols.
  • Ported the native gradient wrapper from the older SkGradientShader::Make* API to current Skia's SkShaders::*Gradient API using SkGradient, SkGradient::Colors, SkSpan, and SkColor4f.
  • Preserved the existing C ABI shape by converting legacy SkColor arrays to SkColor4f arrays inside the native wrapper.
  • Updated sk_surface_write_pixels for current Skia, replacing the removed five-argument SkSurface::writePixels overload with SkPixmap construction plus the current three-argument call.

Native rebuild:

  • Synced Skia third-party dependencies with python3 bin/sync.
  • Rebuilt third_party/skia_dart/out/mac_arm64_graphite/libskia_dart.dylib using third_party/ninja/ninja -C ../out/mac_arm64_graphite libskia_dart.dylib.
  • Copied the rebuilt dylib to third_party/skia_dart/packages/skia_dart/.dart_tool/lib/libskia_dart.dylib for local Dart test execution.

Verification:

  • nm -gU third_party/skia_dart/out/mac_arm64_graphite/libskia_dart.dylib | rg "sk_shader_new_(linear|radial|sweep|two_point)"
  • nm -gU third_party/skia_dart/packages/skia_dart/.dart_tool/lib/libskia_dart.dylib | rg "sk_shader_new_(linear|radial|sweep|two_point)"

Both dylibs export:

  • _sk_shader_new_linear_gradient
  • _sk_shader_new_linear_gradient_color4f
  • _sk_shader_new_radial_gradient
  • _sk_shader_new_radial_gradient_color4f
  • _sk_shader_new_sweep_gradient
  • _sk_shader_new_sweep_gradient_color4f
  • _sk_shader_new_two_point_conical_gradient
  • _sk_shader_new_two_point_conical_gradient_color4f

Generated/Local Build Artifacts

The following paths are local build outputs or dependency checkouts created to rebuild the vendored native library; they are not hand-authored source changes:

  • third_party/skia_dart/skia/
  • third_party/skia_dart/out/
  • third_party/skia_dart/packages/skia_dart/.dart_tool/lib/libskia_dart.dylib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment