/* * Copyright 2021 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "modules/svg/include/SkSVGAttributeParser.h" #include "modules/svg/include/SkSVGFeLightSource.h" #include "modules/svg/include/SkSVGValue.h" SkPoint3 SkSVGFeDistantLight::computeDirection() const { // Computing direction from azimuth+elevation is two 3D rotations: // - Rotate [1,0,0] about y axis first (elevation) // - Rotate result about z axis (azimuth) // Which is just the first column vector in the 3x3 matrix Rz*Ry. const float azimuthRad = SkDegreesToRadians(fAzimuth); const float elevationRad = SkDegreesToRadians(fElevation); const float sinAzimuth = sinf(azimuthRad), cosAzimuth = cosf(azimuthRad); const float sinElevation = sinf(elevationRad), cosElevation = cosf(elevationRad); return SkPoint3::Make(cosAzimuth * cosElevation, sinAzimuth * cosElevation, sinElevation); } bool SkSVGFeDistantLight::parseAndSetAttribute(const char* n, const char* v) { return INHERITED::parseAndSetAttribute(n, v) || this->setAzimuth(SkSVGAttributeParser::parse("azimuth", n, v)) || this->setElevation(SkSVGAttributeParser::parse("elevation", n, v)); } bool SkSVGFePointLight::parseAndSetAttribute(const char* n, const char* v) { return INHERITED::parseAndSetAttribute(n, v) || this->setX(SkSVGAttributeParser::parse("x", n, v)) || this->setY(SkSVGAttributeParser::parse("y", n, v)) || this->setZ(SkSVGAttributeParser::parse("z", n, v)); } bool SkSVGFeSpotLight::parseAndSetAttribute(const char* n, const char* v) { return INHERITED::parseAndSetAttribute(n, v) || this->setX(SkSVGAttributeParser::parse("x", n, v)) || this->setY(SkSVGAttributeParser::parse("y", n, v)) || this->setZ(SkSVGAttributeParser::parse("z", n, v)) || this->setPointsAtX(SkSVGAttributeParser::parse("pointsAtX", n, v)) || this->setPointsAtY(SkSVGAttributeParser::parse("pointsAtY", n, v)) || this->setPointsAtZ(SkSVGAttributeParser::parse("pointsAtZ", n, v)) || this->setSpecularExponent( SkSVGAttributeParser::parse("specularExponent", n, v)) || this->setLimitingConeAngle( SkSVGAttributeParser::parse("limitingConeAngle", n, v)); }