Skip to content

feat: add native non-destructive adjustment layers (#183) - #200

Open
Rejessx wants to merge 1 commit into
artcraft-android:mainfrom
Rejessx:feat/adjustment-layers
Open

Rejessx wants to merge 1 commit into
artcraft-android:mainfrom
Rejessx:feat/adjustment-layers

Conversation

@Rejessx

@Rejessx Rejessx commented Nov 14, 2026

Copy link
Copy Markdown

Closes #183

Summary

Adds native non-destructive Adjustment Layers (HSB, Color Balance, Curves, and Gradient Map) with full support for built-in layer masks, opacity, blend modes, clipping masks, stack reordering, live re-editing, undo/redo, and Merge Down / Flatten.

Changes

Engine (crates/engine)

  • Added LayerAdjustment (Hsb, ColorBalance, Curves, GradientMap), AdjustmentGradientStop, and Layer::adjustment: Option<LayerAdjustment> with sanitized() validation and serialization in crates/engine/src/document.rs.
  • Added Document::add_adjustment_layer, Document::set_adjustment, cleanup on Document::rasterize, and repair sanitization in Document::repaired.
  • Updated Layer initializers in native.rs, psd.rs, and project.rs.
  • Added unit test adjustment_layers_sanitize_serialize_and_rasterize.

GPU Compositing (crates/gpu)

  • Extended LayerUniform in crates/gpu/src/shaders/composite.wgsl and crates/gpu/src/canvas.rs with an adjustment flag and added layer_weight(p) + fs_blend handling (mix(backdrop, blended, w)) so semi-transparent backdrops preserve alpha without premultiplied-over darkening.
  • Implemented Canvas::composite_adjustment, run_adjustment_filter, adjustment_pass, and per-layer cached 256x1 RGBA8 LUT textures (adjustment_tables) for Curves and GradientMap.
  • Updated plain(doc, id) cache partitioning and blend_layer_into so Merge Down and Flatten work with adjustment layers.
  • Added headless GPU tests in crates/gpu/tests/layers.rs:
    • adjustment_layer_hsb_mask_opacity_and_live_edit
    • adjustment_layer_curves_and_merge_down

Core Session (crates/core)

  • Added AdjustmentLayerData, CanvasSession::add_adjustment_layer, CanvasSession::adjust_layer_begin, live parameter updates in adjust_hsb / adjust_color_balance / adjust_curves / adjust_gradient_map, and undo/cancel handling in adjust_end.
  • Added CanvasSession::adjustment_layer_start in crates/core/src/adjusting.rs to populate UI controls from saved layer parameters.
  • Added LayerInfo::adjustment and LayerOption::EditAdjustment in crates/core/src/layers.rs.

Desktop & Android UI (desktop, android)

  • Desktop (desktop/src/layers.rs, desktop/src/ui.rs): added adjustment layer creation options to the Layers + menu, Edit Adjustment option, ADJ thumbnail badge, and live panel opening.
  • Android (CanvasViewModel.kt, LayersPanel.kt): added adjustment layer options to the + menu and LayerOption.EDIT_ADJUSTMENT handling.

Verification

  • cargo fmt --all --check — passed
  • cargo clippy --workspace --all-targets -- -D warnings — passed (0 warnings)
  • procraft-engine: 439 passed, 8 ignored, 0 failed
  • procraft-gpu --test layers: 32 passed, 0 failed
  • procraft-core: 849 passed, 16 ignored, 0 failed
  • procraft-desktop: 105 passed, 2 ignored, 0 failed (test binary exited with STATUS_ACCESS_VIOLATION during Windows driver teardown after all tests passed)
  • Android release APK (.\gradlew.bat --no-daemon :app:assembleRelease) — built (arm64-v8a + x86_64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Adjustment layers

1 participant