PassOwnPtrWillBeRawPtr<InterpolableValue> ColorStyleInterpolation::colorToInterpolableValue(const CSSValue& value) { ASSERT(value.isPrimitiveValue()); const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); RGBA32 color; if (primitive.isValueID()) { if (CSSPropertyParser::isSystemColor(primitive.getValueID())) { color = LayoutTheme::theme().systemColor(primitive.getValueID()).rgb(); } else { Color colorFromID; colorFromID.setNamedColor(getValueName(primitive.getValueID())); color = colorFromID.rgb(); } } else { color = primitive.getRGBA32Value(); } int alpha = alphaChannel(color); OwnPtrWillBeRawPtr<InterpolableList> list = InterpolableList::create(4); list->set(0, InterpolableNumber::create(redChannel(color) * alpha)); list->set(1, InterpolableNumber::create(greenChannel(color) * alpha)); list->set(2, InterpolableNumber::create(blueChannel(color) * alpha)); list->set(3, InterpolableNumber::create(alpha)); return list->clone(); }
Color colorFromPremultipliedARGB(RGBA32 pixelColor) { int alpha = alphaChannel(pixelColor); if (alpha && alpha < 255) { return Color::createUnchecked( redChannel(pixelColor) * 255 / alpha, greenChannel(pixelColor) * 255 / alpha, blueChannel(pixelColor) * 255 / alpha, alpha); } else return Color(pixelColor); }