-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ColorRenderingMode implementation (#138)
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |