You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
This changes how the transfer functions work a bit:
TransferFn has been split into FromLinear and IntoLinear.
The two traits take two type parameters; one for the linear encoding and one for the non-linear encoding.
The split is useful for cases when a conversion is irreversible, as mentioned in #245. The two type parameters makes it possible to convert between number types while encoding and decoding. This makes it possible to skip .into_format() in some cases (currently when converting between u8 and either f32 or f64). In addition to that, I made those special cases faster by using fast-srgb8, and a similar lookup table for f64.
TransferFn has been split into FromLinear and IntoLinear.
{Rgb, Luma}::{from, into}_linear and {Rgb, Luma}::{from, into}_encoding are now allowed to change the output type. This changes the API and type inference. The solution for the type inference is usually to remove into_format from the call chain.
{Rgb, Luma}::{from, into}_encoding will only convert from linear encoding, not "cross convert" between encodings.
The number type parameter and 'staticlifetime were removed from RgbStandard, LumaStandard and RgbSpace.
Some of those benchmark results don't make sense. I'll give them another spin and see if they are less noisy... But I may also reconsider the float -> byte conversion. The improvement wasn't so large anyway.
I had measured it in some weird way. 🤔 I have simply replaced my hack solution with fast-srgb8. It uses the same table as I had added for f32 and has a very fast algorithm for the reverse case.
Ogeon
changed the title
Split the TransferFn trait and add lookup tables for sRGB
Split the TransferFn trait and add lookup tables for sRGB
Mar 19, 2023
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes how the transfer functions work a bit:
TransferFn
has been split intoFromLinear
andIntoLinear
.The split is useful for cases when a conversion is irreversible, as mentioned in #245. The two type parameters makes it possible to convert between number types while encoding and decoding. This makes it possible to skip
.into_format()
in some cases (currently when converting betweenu8
and eitherf32
orf64
). In addition to that, I made those special cases faster by usingfast-srgb8
, and a similar lookup table forf64
.Closed Issues
Breaking Change
TransferFn
has been split intoFromLinear
andIntoLinear
.{Rgb, Luma}::{from, into}_linear
and{Rgb, Luma}::{from, into}_encoding
are now allowed to change the output type. This changes the API and type inference. The solution for the type inference is usually to removeinto_format
from the call chain.{Rgb, Luma}::{from, into}_encoding
will only convert from linear encoding, not "cross convert" between encodings.'static
lifetime were removed fromRgbStandard
,LumaStandard
andRgbSpace
.