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:
Valentin Shergin 2018-09-07 11:12:23 -07:00 committed by Facebook Github Bot
parent 16bd95b689
commit 44fb60938a
1 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,11 @@ SharedColor colorFromComponents(ColorComponents components) {
}
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());
assert(numberOfComponents == 4);
const CGFloat *components = CGColorGetComponents(color.get());