Skip to content

Remove dead editing-canvas API stranded by the scaffold deletion - #325

Open
muukii wants to merge 1 commit into
v5from
chore/editing-canvas-api-purge
Open

Remove dead editing-canvas API stranded by the scaffold deletion#325
muukii wants to merge 1 commit into
v5from
chore/editing-canvas-api-purge

Conversation

@muukii

@muukii muukii commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

The standalone _EditingCanvasView development scaffold was deleted in 879c6c8 (-1853 lines). It was the only consumer of a number of EditingCanvas members, which survived as public/internal surface with no callers. This PR removes them.

Rule applied: every symbol, parameter, and conformance below was verified dead with a repo-wide grep over Sources/ and Dev/ before removal. Grep evidence is listed per item. Where a proposal reduced access control instead of deleting, behavior is identical. No item was skipped — all seven applied cleanly.

Renames use git mv, so history follows (both tracked as renames: 57% and 90% similarity).


EC-03 — Dead metrics apparatus (EditingCanvasMTKView.swift)

onMetricsChange was never assigned, and the four counters were never read. The demo diagnostics overlay that subscribed to them died with the scaffold; the DrawMetrics doc comment still advertised it.

Deleted: DrawMetrics, drawMetrics, activeStampCount, committedStampCount, strokeCount, framesPerSecond, onMetricsChange, recordDrawSample, publishLiveMetricsIfNeeded, and LiveRefreshState.lastMetricsPublishTime / .metricsPublishInterval (the struct collapses to a display-link holder). The onMetricsChange?() call sites in updateViewport, reset, finishCommittedStrokeRendering, the draw(in:) defer, and the display-link tick go with them, removing per-draw and per-tick work.

#if DEBUG PerformanceDiagnostics is untouched — it has real log output.

Grep evidence. grep -rnE '\b(onMetricsChange|activeStampCount|committedStampCount|strokeCount|framesPerSecond|DrawMetrics|recordDrawSample|publishLiveMetricsIfNeeded|lastMetricsPublishTime|metricsPublishInterval)\b' Sources/ Dev/ --include='*.swift' → 23 hits, all inside EditingCanvasMTKView.swift (definitions + internal call sites). Zero hits in Dev/, zero assignments to onMetricsChange.

EC-04 — Dead viewport API (EditingCanvasMTKView.swift)

Viewport.zoomScale was never read — updateViewport consumes only visibleContentRect and visibleCanvasFrame. A struct field the renderer ignores misleads: it suggests the render depends on zoom when zoom is in fact derived from the two rects.

Deleted: the zoomScale field on Viewport; the CropDisplayViewport.zoomScale that threaded it in (the bridge at CropView.swift:3085 was its only reader, so it would otherwise have become newly dead) and its two construction sites; and the unused 3-argument setViewport(visibleContentRect:visibleCanvasFrame:zoomScale:) overload. setViewport(_ viewport: Viewport) is now the single entry point.

Grep evidence. grep -rnE '\b(zoomScale|setViewport)\b' Sources/ Dev/ --include='*.swift' → the only setViewport call site anywhere is canvasView.setViewport(viewport.editingCanvasViewport) (CropView.swift:409), i.e. the 1-arg form; the 3-arg overload has zero callers. Every other zoomScale hit is UIScrollView.zoomScale (UIKit's own property) or Dev/Sources/SwiftUIDemo/PencilKitReferenceSandboxView.swift (an unrelated local struct). Viewport.zoomScale was read nowhere; CropDisplayViewport.zoomScale was read only at CropView.swift:3089.

EC-05 — EditingCanvasPublicTypes.swift drift

'PublicTypes' was neither an honest name nor shape.

  • Deleted EditingCanvasMode.localEffect and .activeLocalEffect — zero callers.
  • Deleted the stale doc line Use this mode with .interactionMode(.view) — that API no longer exists anywhere (deleted with the scaffold).
  • Demoted EditingCanvasMode and EditingCanvasBrush to internal — neither appears in any public signature (the actual public brush API is CropViewMaskingBrush).
  • Stripped CaseIterable, Identifiable, id, and title (picker copy: "Catmull"/"Avg") from EditingCanvasStrokeSmoothingAlgorithm — they existed for the scaffold's debug picker. The enum and EditingCanvasStrokeSmoothingConfiguration stay public: they are reachable via SwiftUICropView.strokeSmoothing(_:).
  • Renamed the file to EditingCanvasConfiguration.swift.

Grep evidence. localEffect/activeLocalEffect as EditingCanvasMode members: zero call sites (the other localEffect hits are the unrelated EditingCanvasRenderImages.localEffect field and case let .localAdjustment(localEffect) pattern bindings). EditingCanvasMode → only CropView.swift and EditingCanvasRenderImageFactory.swift; EditingCanvasBrush → only CropView.swift, EditingCanvasStroke.swift, EditingCanvasMTKView.swift — all inside Sources/BrightroomUI, zero hits in Dev/, so demotion is source-compatible. interactionMode → the doc comment only. .title/.allCases on the smoothing algorithm → zero (grep -rnE '\.(algorithm|allCases)\b' shows .allCases only on PhotosCropEditingMode, PhotosCropAdjustmentParameter, QuarterTurn, and demo enums; .algorithm is only read in switch configuration.algorithm in EditingCanvasStroke.swift).

EC-06 — Dead displayedContentRect (EditingCanvasRenderImageFactory.swift)

The parameter was threaded through all three makeRenderImages signatures but never passed by any caller, so sanitizedRenderBounds always took its guard let rect else { return canvasRect } exit and renderBounds was always canvasRect — ~25 lines sanitizing a value that could not occur, making the factory look viewport-aware when it is not.

Deleted the parameter from all three signatures and deleted sanitizedRenderBounds; the five renderBounds uses now read canvasRect directly. Behavior-identical. Also updated a stale comment in MaskedPreviewExportScaleConsistencyTests.swift:151 that referenced the removed parameter.

Grep evidence. grep -rn 'displayedContentRect' Sources/ Dev/ --include='*.swift' → only the factory's own declarations/forwarding (6 hits) plus one comment in MaskedPreviewExportScaleConsistencyTests.swift. CropView.swift:492 and every test call the factory without it.

EC-10 — EditingCanvasStrokeCommitPipeline surface

Speculative API on the single owner of commit semantics is where drift starts: the class doc promises frozen pipelines, and an uncalled mutator of those pipelines is the loophole.

  • Deleted updateEffect(_:in:insertingBefore:) — zero callers; it existed on the strength of its own doc comment, which is also removed.
  • Made replaceLocalAdjustments and the layer lookup private — both are called only from inside the class.
  • Renamed layerIndex(in:matching:)adoptedLayerIndex(in:matching:): it read as a pure lookup but mutates layerID on the fallback path. The doc now states the adoption.
  • Moved editingCanvasEffectIdentity out of the rendering file (EditingCanvasRenderImageFactory.swift) into this file, next to its identity-matching use.

Behavior of the pipeline is unchanged — only its unused surface and access control.

Grep evidence. updateEffect → the definition + its own doc comment only. replaceLocalAdjustments on the pipeline → called only at its two in-class sites (the other hits are the separate EditingFeatureTree.replaceLocalAdjustments static in the engine and a private same-named method in PhotosCropEditingModel). layerIndex → four in-class call sites only. External consumers (CropViewDocument.swift:115-155) use only resetLayerTracking/adoptLayer/append/committedEffect/committedRecords, all still internal. editingCanvasEffectIdentity keeps its three consumers (CropView.swift:3226, PhotosCropEditingModel.swift:166,169) — same module, unaffected by the move.

EC-11 — Geometry file drift

Deleted five dead diagnostics extensions left behind when the [ToolZoomDiag]/chase logging was removed: CGSize.simdFloat2, CGFloat.logString, Double.logString, CGRect.logDescription, CGPoint.simdFloat2.

Renamed the file EditingCanvasGeometry.swiftEditingCanvasImageProcessing.swift (via git mv) after what it actually holds: EditingCanvasImageProcessing, the canvas color/pixel-format contract whose comments carry the P3-clamp postmortem. The color contract itself is unchanged. The CGPoint math used by stroke smoothing stays.

Grep evidence. grep -rnE '\b(simdFloat2|logString|logDescription)\b' Sources/ Dev/ --include='*.swift' → 6 hits, all inside the file: the definitions plus logDescription's own internal use of logString. Zero external users.

EC-12 — Copy-pasted imports

Trimmed each file to the imports it uses:

  • EditingCanvasStroke.swift: was CoreImage, BrightroomEngine, BrightroomParametric, IOSurface, MetalKit, os, simd, SwiftUI, UIKit → now BrightroomParametric, CoreGraphics, Foundation (pure CGPoint math plus one BrushMaskStroke bridge).
  • EditingCanvasDrawingGestureRecognizer.swift: was CoreImage, BrightroomEngine, IOSurface, MetalKit, os, simd, SwiftUI, UIKit → now UIKit (a UIKit-only gesture recognizer).
  • The renamed image-processing file: was CoreImage, BrightroomEngine, IOSurface, MetalKit, os, simd, SwiftUI, UIKit → now CoreGraphics, CoreImage, Metal (simd dropped as unused once EC-11's SIMD2 extensions went).

Grep evidence. grep -nE '\b(CI[A-Z]|MTL|MTK|IOSurface|os_|Logger|SIMD|simd_|View|Color)\b' EditingCanvasStroke.swift → the sole hit was the import IOSurface line itself. The gesture recognizer uses only UIGestureRecognizer/UITouch/UIEvent/CGPoint/NSNumber. Confirmed by a clean build.


Skipped items

None. All seven proposals had zero live users and applied as written.

Verification

  • Build: xcodebuild -project Brightroom.xcodeproj -scheme SwiftUIDemo -destination 'generic/platform=iOS Simulator' build** BUILD SUCCEEDED **, with no warnings in any touched file.
  • Tests: scheme BrightroomEngineTests on a freshly created private simulator with -parallel-testing-enabled NO** TEST SUCCEEDED **, 153 tests in 36 suites passed (43.5s). Simulator deleted afterwards.
  • Post-removal sweep: a repo-wide grep for every deleted symbol returns zero hits.

Diff stat

 10 files changed, 43 insertions(+), 266 deletions(-)

🤖 Generated with Claude Code

The standalone `_EditingCanvasView` development scaffold was deleted in
879c6c8. It was the only consumer of several EditingCanvas members, which
survived as public/internal surface with no callers. Each item below was
verified dead with a repo-wide grep over Sources/ and Dev/ before removal.

EC-03 Dead metrics apparatus (EditingCanvasMTKView)
  `onMetricsChange` was never assigned and the four counters never read;
  the demo diagnostics overlay that subscribed died with the scaffold.
  Deletes `DrawMetrics`, `activeStampCount`, `committedStampCount`,
  `strokeCount`, `framesPerSecond`, `onMetricsChange`, `recordDrawSample`,
  `publishLiveMetricsIfNeeded`, and the two metrics fields of
  `LiveRefreshState` (now a display-link holder), plus the per-draw and
  per-display-link-tick work that fed them. `#if DEBUG`
  `PerformanceDiagnostics` is untouched — it still logs.

EC-04 Dead viewport API (EditingCanvasMTKView)
  `Viewport.zoomScale` was never read: `updateViewport` consumes only
  `visibleContentRect` and `visibleCanvasFrame`. Removes the field, the
  now-unused `CropDisplayViewport.zoomScale` that fed it through the
  `editingCanvasViewport` bridge, and the 3-argument `setViewport`
  overload that had zero callers, leaving `setViewport(_:)` as the single
  entry point.

EC-05 PublicTypes drift
  Deletes the unused `EditingCanvasMode.localEffect`/`activeLocalEffect`
  and the stale `.interactionMode(.view)` doc reference (that API was
  deleted with the scaffold). Demotes `EditingCanvasMode` and
  `EditingCanvasBrush` to internal — neither appears in a public
  signature. Strips `CaseIterable`/`Identifiable`/`title` from
  `EditingCanvasStrokeSmoothingAlgorithm` (scaffold debug-picker
  support); the enum and `EditingCanvasStrokeSmoothingConfiguration` stay
  public, reachable via `SwiftUICropView.strokeSmoothing`. Renames the
  file to EditingCanvasConfiguration.swift.

EC-06 Dead displayedContentRect (EditingCanvasRenderImageFactory)
  No caller ever passed it, so `sanitizedRenderBounds` always took its
  `guard let` exit and `renderBounds` was always `canvasRect`. Drops the
  parameter from all three signatures, deletes the sanitizer, and uses
  `canvasRect` directly. Behavior-identical.

EC-10 StrokeCommitPipeline surface
  Deletes `updateEffect(_:in:insertingBefore:)` (zero callers). Makes
  `replaceLocalAdjustments` and the layer lookup private — both are
  called only from inside the class. Renames `layerIndex` to
  `adoptedLayerIndex` to state the `layerID` mutation it performs behind
  an index-getter name. Moves `editingCanvasEffectIdentity` here from the
  rendering file, next to its identity-matching use.

EC-11 Geometry file drift
  Deletes five dead diagnostics extensions (`CGSize.simdFloat2`,
  `CGFloat/Double.logString`, `CGRect.logDescription`,
  `CGPoint.simdFloat2`) left by the removed [ToolZoomDiag] logging, and
  renames the file to EditingCanvasImageProcessing.swift after what it
  actually holds: the canvas color/pixel-format contract. The contract
  itself is unchanged.

EC-12 Copy-pasted imports
  Trims EditingCanvasStroke.swift, EditingCanvasDrawingGestureRecognizer
  .swift, and the renamed image-processing file to the imports they use.

Verified: SwiftUIDemo builds clean (no new warnings in the touched
files); the full BrightroomEngineTests suite passes, 153 tests in 36
suites.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@muukii
muukii force-pushed the chore/editing-canvas-api-purge branch from 22a222d to 9578be7 Compare August 27, 2026 12:06
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.

1 participant