-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix color space conversion test #3332
Fix color space conversion test #3332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ nits
}); | ||
|
||
// Convert the data via our conversion functions | ||
const convertedData = new Uint8ClampedArray( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not a comment Just for curious).
Would you mind to explain a bit about how this test could detect the behaviour change from =
assignment to Object.assign
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It detects it because makeInPlaceColorConversion
, at least by name, is supposed to make an object that is updated "in place"
const floatColor = { R, G, B, A: 1 };
conversionFn(floatColor);
return [
floatToU8(floatColor.R),
floatToU8(floatColor.G),
floatToU8(floatColor.B),
floatToU8(floatColor.A),
];
This code expects that floatColor
is updated. In the assignment (=
) version, a new object is created inside the conversion function, That object is then discarded. The function out here is still looking at floatColor
with the original unconverted values. When it goes to compare them to the values converted via 2D canvas, they don't match since they're still the unconverted values.
In order to work as it was, this code would need to change to this
const floatColor = { R, G, B, A: 1 };
const convertedColor = conversionFn(floatColor);
return [
floatToU8(convertedColor.R),
floatToU8(convertedColor.G),
floatToU8(convertedColor.B),
floatToU8(convertedColor.A),
];
I'm happy to change it to this style. I was just going from the momentum given that the function is called makeInPlaceColorConversion
The issue was makeInPlaceColorConversion was not actually doing the conversion "in place". To find this I wrote a test to test makeInPlaceColorConversion
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
d9e1ad3
to
8cde87a
Compare
The issue was makeInPlaceColorConversion was not actually doing the conversion "in place". To find this I wrote a test to test makeInPlaceColorConversion
Note: I removed a maintenance_todo because
colorSpace
is in the IDL but it's required so it will never beundefined
except on old browsers and so TS things comparing it toundefined
is an error.Requirements for PR author:
.unimplemented()
./** documented */
and new helper files are found inhelper_index.txt
.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.