| 818 | |
| 819 | template<typename Ramp> |
| 820 | int expandRamp( const InternedString &name, const Ramp &ramp, CompoundDataMap &newParameters, const std::string &shaderName ) |
| 821 | { |
| 822 | StringDataPtr basisData = new StringData(); |
| 823 | std::string &basis = basisData->writable(); |
| 824 | |
| 825 | typedef TypedData< vector<typename Ramp::XType> > XTypedVectorData; |
| 826 | typename XTypedVectorData::Ptr positionsData = new XTypedVectorData(); |
| 827 | auto &positions = positionsData->writable(); |
| 828 | positions.reserve( ramp.points.size() ); |
| 829 | typedef TypedData< vector<typename Ramp::YType> > YTypedVectorData; |
| 830 | typename YTypedVectorData::Ptr valuesData = new YTypedVectorData(); |
| 831 | auto &values = valuesData->writable(); |
| 832 | |
| 833 | ramp.toOSL( basis, positions, values ); |
| 834 | |
| 835 | auto [ positionsSuffix, floatValuesSuffix, colorValuesSuffix, basisSuffix, countSuffix ] = lookupRampParameterSuffixes( shaderName ); |
| 836 | |
| 837 | newParameters[ name.string() + *positionsSuffix ] = positionsData; |
| 838 | if constexpr( std::is_same_v< typename Ramp::YType, float > ) |
| 839 | { |
| 840 | newParameters[ name.string() + *floatValuesSuffix ] = valuesData; |
| 841 | } |
| 842 | else |
| 843 | { |
| 844 | newParameters[ name.string() + *colorValuesSuffix ] = valuesData; |
| 845 | } |
| 846 | newParameters[ name.string() + *basisSuffix ] = basisData; |
| 847 | |
| 848 | if( countSuffix ) |
| 849 | { |
| 850 | newParameters[ name.string() + *countSuffix ] = new IntData( positionsData->readable().size() ); |
| 851 | } |
| 852 | |
| 853 | return positionsData->readable().size(); |
| 854 | } |
| 855 | |
| 856 | void ensureParametersCopy( |
| 857 | const IECore::CompoundDataMap ¶meters, |
no test coverage detected