示例#1
0
bool SVGFETurbulenceElement::build(FilterBuilder* builder)
{
    RefPtr<FilterEffect> addedEffect = FETurbulence::create(static_cast<TurbulanceType> (type()), baseFrequencyX(), 
                                        baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVG_STITCHTYPE_STITCH);
    builder->add(result(), addedEffect.release());

    return true;
}
sk_sp<SkShader> FETurbulence::createShader() const
{
    const SkISize size = SkISize::Make(effectBoundaries().width(), effectBoundaries().height());
    // Frequency should be scaled by page zoom, but not by primitiveUnits.
    // So we apply only the transform scale (as Filter::apply*Scale() do)
    // and not the target bounding box scale (as SVGFilter::apply*Scale()
    // would do). Note also that we divide by the scale since this is
    // a frequency, not a period.
    float baseFrequencyX = m_baseFrequencyX / getFilter()->scale();
    float baseFrequencyY = m_baseFrequencyY / getFilter()->scale();
    return (type() == FETURBULENCE_TYPE_FRACTALNOISE) ?
        SkPerlinNoiseShader::MakeFractalNoise(SkFloatToScalar(baseFrequencyX),
            SkFloatToScalar(baseFrequencyY), numOctaves(), SkFloatToScalar(seed()),
            stitchTiles() ? &size : 0) :
        SkPerlinNoiseShader::MakeTurbulence(SkFloatToScalar(baseFrequencyX),
            SkFloatToScalar(baseFrequencyY), numOctaves(), SkFloatToScalar(seed()),
            stitchTiles() ? &size : 0);
}
示例#3
0
TextStream& FETurbulence::externalRepresentation(TextStream& ts, int indent) const
{
    writeIndent(ts, indent);
    ts << "[feTurbulence";
    FilterEffect::externalRepresentation(ts);
    ts << " type=\"" << type() << "\" "
       << "baseFrequency=\"" << baseFrequencyX() << ", " << baseFrequencyY() << "\" "
       << "seed=\"" << seed() << "\" "
       << "numOctaves=\"" << numOctaves() << "\" "
       << "stitchTiles=\"" << stitchTiles() << "\"]\n";
    return ts;
}
示例#4
0
TextStream& SVGFETurbulence::externalRepresentation(TextStream& ts) const
{
    ts << "[type=TURBULENCE] ";
    SVGFilterEffect::externalRepresentation(ts);
    ts << " [turbulence type=" << type() << "]"
        << " [base frequency x=" << baseFrequencyX() << " y=" << baseFrequencyY() << "]"
        << " [seed=" << seed() << "]"
        << " [num octaves=" << numOctaves() << "]"
        << " [stitch tiles=" << stitchTiles() << "]";
    return ts;

}
PassRefPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuilder*)
{
    return FETurbulence::create(static_cast<TurbulanceType>(type()), baseFrequencyX(), 
                baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVG_STITCHTYPE_STITCH);
}