Skip to content

Complete _ColorMatrix filter and ShapeStyle support - #985

Merged
Kyle-Ye merged 7 commits into
mainfrom
feature/color_matrix
Aug 9, 2026
Merged

Complete _ColorMatrix filter and ShapeStyle support#985
Kyle-Ye merged 7 commits into
mainfrom
feature/color_matrix

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Complete _ColorMatrix construction from colors and supported GraphicsFilter cases, including premultiplied handling.
  • Implement filter-specific matrix calculations, private ShapeStyle behavior, and full 20-element protobuf encoding and decoding.
  • Add availability annotations and documentation for the public matrix APIs.
  • Expand direct and dual tests for initialization, multiplication, filter conversion, identity checks, protobuf serialization, and float-array conversion.

Motivation

_ColorMatrix still had incomplete color, filter, and shape-style behavior, while protobuf serialization covered only part of the matrix. This prevented callers from consistently converting supported graphics filters and preserving complete matrix values.

Testing

  • ColorMatrixDualTests pass against the SwiftUI 6.5 compatibility runtime.

@github-actions github-actions Bot added area: graphics Color, shape, gradient, image, symbols, and graphics primitives. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. type: feature New API, behavior, platform support, or user-facing capability. labels Aug 9, 2026
@Kyle-Ye
Kyle-Ye marked this pull request as ready for review August 9, 2026 17:12
@Kyle-Ye
Kyle-Ye merged commit c343337 into main Aug 9, 2026
3 of 8 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/color_matrix branch August 9, 2026 17:12

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

Review completed with 2 suggestions.

Fix in Cosmos

Reviewed commit: b7adec5

/// component. You can use the matrix for tasks like creating a color
/// transformation ``GraphicsContext/Filter`` for a ``GraphicsContext`` using
/// the ``GraphicsContext/Filter/colorMatrix(_:)`` method.
@available(OpenSwiftUI_v3_0, *)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This availability annotation leaves the existing _ColorMatrix.init(_ m: ColorMatrix) declaration with only _ColorMatrix's OpenSwiftUI_v2_0 availability while its parameter type is now OpenSwiftUI_v3_0. Builds that honor the package availability macros can reject that declaration as referencing ColorMatrix before it is available.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

guard levels.lowerBound != levels.upperBound else {
break
}
shape.stylePack[name, levels.lowerBound] = .init(.vibrantMatrix(self))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new _ColorMatrix ShapeStyle implementation is not exercised by the added tests, which cover matrix construction, filters, and protobuf but not the .prepareText or .resolveStyle paths. A regression in the foregroundKeyColor result or the .vibrantMatrix pack write would pass this PR's coverage.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.93069% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.74%. Comparing base (565d0ca) to head (b7adec5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...es/OpenSwiftUICore/Graphic/Color/ColorMatrix.swift 6.93% 94 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #985      +/-   ##
==========================================
- Coverage   26.84%   26.74%   -0.11%     
==========================================
  Files         732      733       +1     
  Lines       54056    54303     +247     
==========================================
+ Hits        14514    14522       +8     
- Misses      39542    39781     +239     

☔ View full report in Codecov by Harness.
📢 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.

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

Labels

area: graphics Color, shape, gradient, image, symbols, and graphics primitives. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant