Fabric: Fixed `colorComponentsFromColor` to able to accept empty color object
Summary: @public Empty (nullptr) color should be treated as `Clear` color ({0, 0, 0, 0} - black, fully tranparent), so `colorComponentsFromColor()` was changed to accomodate this (previously it crashed). Reviewed By: rsnara Differential Revision: D9631865 fbshipit-source-id: e211f34a89e9f5f86d9fca2789c7163db4feaab1
This commit is contained in:
parent
16bd95b689
commit
44fb60938a
|
@ -27,6 +27,11 @@ SharedColor colorFromComponents(ColorComponents components) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorComponents colorComponentsFromColor(SharedColor color) {
|
ColorComponents colorComponentsFromColor(SharedColor color) {
|
||||||
|
if (!color) {
|
||||||
|
// Empty color object can be considered as `clear` (black, fully transparent) color.
|
||||||
|
return ColorComponents {0, 0, 0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
int numberOfComponents = CGColorGetNumberOfComponents(color.get());
|
int numberOfComponents = CGColorGetNumberOfComponents(color.get());
|
||||||
assert(numberOfComponents == 4);
|
assert(numberOfComponents == 4);
|
||||||
const CGFloat *components = CGColorGetComponents(color.get());
|
const CGFloat *components = CGColorGetComponents(color.get());
|
||||||
|
|
Loading…
Reference in New Issue