Skip to content

Commit

Permalink
Add ColorRenderingMode implementation (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye authored Oct 7, 2024
1 parent 667fdbc commit 1129537
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Sources/OpenSwiftUICore/Render/ColorRenderingMode.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// ColorRenderingMode.swift
// OpenSwiftUICore
//
// Audited for RELEASE_2024
// Status: Complete

/// The set of possible working color spaces for color-compositing operations.
///
/// Each color space guarantees the preservation of a particular range of color
/// values.
public enum ColorRenderingMode: Sendable {
/// The non-linear sRGB working color space.
///
/// Color component values outside the range `[0, 1]` produce undefined
/// results. This color space is gamma corrected.
case nonLinear

/// The linear sRGB working color space.
///
/// Color component values outside the range `[0, 1]` produce undefined
/// results. This color space isn't gamma corrected.
case linear

/// The extended linear sRGB working color space.
///
/// Color component values outside the range `[0, 1]` are preserved.
/// This color space isn't gamma corrected.
case extendedLinear
}

extension ColorRenderingMode: Equatable {}
extension ColorRenderingMode: Hashable {}

extension ColorRenderingMode: ProtobufEnum {
package var protobufValue: UInt {
switch self {
case .nonLinear:
return 0
case .linear:
return 1
case .extendedLinear:
return 2
}
}
package init?(protobufValue value: UInt) {
switch value {
case 0:
self = .nonLinear
case 1:
self = .linear
case 2:
self = .extendedLinear
default:
return nil
}
}
}

0 comments on commit 1129537

Please sign in to comment.