Skip to content

Add ImageLayer#763

Merged
Kyle-Ye merged 2 commits intomainfrom
feature/image_layer
Feb 7, 2026
Merged

Add ImageLayer#763
Kyle-Ye merged 2 commits intomainfrom
feature/image_layer

Conversation

@Kyle-Ye
Copy link
Collaborator

@Kyle-Ye Kyle-Ye commented Feb 7, 2026

No description provided.

@github-actions github-actions bot added enhancement New feature or request test Test related issue platform: iOS platform: macOS labels Feb 7, 2026
@augmentcode
Copy link

augmentcode bot commented Feb 7, 2026

🤖 Augment PR Summary

Summary: Adds a new QuartzCore-backed ImageLayer for rendering GraphicsImage content via CALayer, including resizing/tinting and HDR/EDR configuration.

Changes:

  • Introduce ImageLayer (Darwin-only) to map GraphicsImage.Contents into layer contents/backgroundColor and configure edge antialiasing and interpolation.
  • Implement GraphicsImage helpers to compute contentsCenter and tiling vs stretching (layerStretchInPixels, contentStretchInPixels, isTiledWhenStretchedToSize).
  • Add template-image handling using private CoreAnimation SPI (contentsSwizzle + contentsMultiplyColor) via a new helper _CALayerSetSplatsContentsAlpha.
  • Expose additional private CALayer SPI in shims (contentsScaling, EDR properties, swizzle/scaling/filter constants).
  • Configure extended dynamic range rendering by setting wantsExtendedDynamicRangeContent and animating contentsMaximumDesiredEDR transitions.
  • Refactor GraphicsImage.size to reuse the existing pixelSize computed property.
  • Add unit tests for the new stretch/tile rectangle calculations.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

contents = layerContents
backgroundColor = bgColor
allowsEdgeAntialiasing = image.isAntialiased
guard contents != nil else { return }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update(image:size:) returns early when contents is nil, but that leaves prior image-related state (e.g. contentsMultiplyColor, contentsScaling, filters, EDR flags) untouched and potentially leaking across updates (e.g. when switching to .color). Consider explicitly resetting any stateful content-related properties before returning so the layer can’t carry stale configuration forward.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

let currentMaxEDR = wasUsingEDR ? contentsMaximumDesiredEDR : 1.0

// Enable EDR if needed
if headroom > .standard {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When headroom drops back to .standard, wantsExtendedDynamicRangeContent is never set back to false, so a layer that previously displayed HDR content may remain in EDR mode. That can make subsequent SDR (or background-color-only) updates behave differently than intended.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


struct GraphicsImageLayerStretchTests {
// Helper to create a basic GraphicsImage for testing
private func makeImage(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new stretch/tile math depends on scale and orientation (via bitmapOrientation), but the current argument sets mostly exercise .up and scale 1. Adding at least one non-.up orientation case and a non-1.0 scale case would help catch regressions in the normalization logic.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 44.24242% with 92 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.75%. Comparing base (0c0d938) to head (70bd57f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ources/OpenSwiftUICore/View/Image/ImageLayer.swift 43.90% 92 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #763       +/-   ##
===========================================
+ Coverage   13.43%   26.75%   +13.32%     
===========================================
  Files         617      647       +30     
  Lines       35960    39386     +3426     
===========================================
+ Hits         4832    10539     +5707     
+ Misses      31128    28847     -2281     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye Kyle-Ye merged commit 957315b into main Feb 7, 2026
11 of 13 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/image_layer branch February 7, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request platform: iOS platform: macOS test Test related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant