---
description: Project architecture and crate structure for skia-rs
globs: ["**/*.rs", "**/Cargo.toml"]
alwaysApply: true
---

# Skia-RS Architecture

Skia-RS is a 100% Rust implementation of Google's Skia 2D graphics library, designed for API compatibility with the original C++ Skia library. The project provides both a native Rust API and C FFI bindings for cross-language interoperability.

## Workspace Structure

```
skia-rs/
├── crates/
│   ├── skia-rs-core/     # Foundation: Scalar, Point, Rect, Color, Matrix, ImageInfo
│   ├── skia-rs-path/     # Path geometry: Path, PathBuilder, PathOps, PathEffects
│   ├── skia-rs-paint/    # Styling: Paint, Shaders, BlendModes, Filters
│   ├── skia-rs-canvas/   # Drawing: Canvas, Surface, Picture recording
│   ├── skia-rs-text/     # Typography: Font loading, text shaping, layout
│   ├── skia-rs-gpu/      # GPU backends: Vulkan, OpenGL, WebGPU
│   ├── skia-rs-codec/    # Image I/O: PNG, JPEG, GIF, WebP
│   ├── skia-rs-svg/      # SVG support: parsing and rendering
│   ├── skia-rs-pdf/      # PDF generation
│   ├── skia-rs-ffi/      # C API bindings for FFI
│   ├── skia-rs-safe/     # High-level ergonomic Rust API
│   └── skia-rs-bench/    # Performance benchmarks
├── fuzz/                 # Fuzz testing with cargo-fuzz/libFuzzer
├── skia/                 # Official Skia submodule (reference)
└── TODO.md              # Development roadmap
```

## Crate Dependencies

```
skia-rs-core (no internal deps)
    ↓
skia-rs-path (depends on: core)
    ↓
skia-rs-paint (depends on: core, path)
    ↓
skia-rs-canvas (depends on: core, path, paint)
    ↓
skia-rs-text (depends on: core, path, paint)
    ↓
skia-rs-gpu (depends on: core, path, paint, canvas)
skia-rs-codec (depends on: core)
skia-rs-svg (depends on: core, path, paint, canvas)
skia-rs-pdf (depends on: core, path, paint, canvas, text)
    ↓
skia-rs-ffi (depends on: all above)
skia-rs-safe (depends on: all above, re-exports)
```

## File Organization

Each crate should follow this structure:

```
crates/skia-rs-{name}/
├── Cargo.toml
├── src/
│   ├── lib.rs          # Module declarations and re-exports
│   ├── {feature}.rs    # Feature implementations
│   └── ...
```

## Re-exports

- `lib.rs` should re-export all public types
- Use `pub use module::*;` for complete re-exports
- Group related items in modules

```rust
// lib.rs
pub mod color;
pub mod geometry;
pub mod matrix;

pub use color::*;
pub use geometry::*;
pub use matrix::*;
```
