bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value) const
{
    // Default interpolation is used if the paths have different lengths,
    // or the paths have a segment with different types (ignoring "relativeness").

    const StylePath* toPath = toAnimatablePath(value)->path();
    if (!m_path || !toPath)
        return true;
    SVGPathByteStreamSource fromSource(path()->byteStream());
    SVGPathByteStreamSource toSource(toPath->byteStream());

    while (fromSource.hasMoreData()) {
        if (!toSource.hasMoreData())
            return true;

        PathSegmentData fromSeg = fromSource.parseSegment();
        PathSegmentData toSeg = toSource.parseSegment();
        ASSERT(fromSeg.command != PathSegUnknown);
        ASSERT(toSeg.command != PathSegUnknown);

        if (toAbsolutePathSegType(fromSeg.command) != toAbsolutePathSegType(toSeg.command))
            return true;
    }

    return toSource.hasMoreData();
}
    PT convert_script_value_f_point<PT>::operator()( QScriptEngine *,
						  const QScriptValue & args ) const
    {
	typedef typename point_valtype<PT>::value_type value_type;
	value_type x = 0;
	value_type y = 0;
	QScriptValue obj;
	bool smellArray = (args.isArray() || ! args.property("length").isUndefined());
	if( smellArray )
	{
	    if(0) qDebug() << "Looks like arguments array.";
	    obj = args.property(0);
	}
	else if( args.isObject() )
	{
	    if(0) qDebug() << "Looks like an object.";
	    obj = args;
	}

	if( smellArray && !obj.isObject() )
	{
	    if(0) qDebug() << "Trying arguments array.";
	    x = value_type(args.property(0).toNumber());
	    y = value_type(args.property(1).toNumber());
	}
	else
	{
	    if(0) qDebug() << "Trying object x/y:" << obj.toString() << ":" << toSource( obj );
	    if(0) qDebug() << "obj.property(x).toNumber():"<<obj.property("x").toNumber();
	    x = value_type(obj.property("x").toNumber());
	    y = value_type(obj.property("y").toNumber());
	}
	if(0) qDebug() << "PT:"<<PT(x,y);
	return PT(x,y);
    }
void SVGPathSegList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*)
{
    invalidateList();

    ASSERT(animationElement);
    bool isToAnimation = animationElement->animationMode() == ToAnimation;

    const RefPtr<SVGPathSegList> from = toSVGPathSegList(fromValue);
    const RefPtr<SVGPathSegList> to = toSVGPathSegList(toValue);
    const RefPtr<SVGPathSegList> toAtEndOfDuration = toSVGPathSegList(toAtEndOfDurationValue);

    const SVGPathByteStream* toStream = to->byteStream();
    const SVGPathByteStream* fromStream = from->byteStream();
    OwnPtr<SVGPathByteStream> copy;

    // If no 'to' value is given, nothing to animate.
    if (!toStream->size())
        return;

    if (isToAnimation) {
        copy = byteStream()->copy();
        fromStream = copy.get();
    }

    // If the 'from' value is given and it's length doesn't match the 'to' value list length, fallback to a discrete animation.
    if (fromStream->size() != toStream->size() && fromStream->size()) {
        if (percentage < 0.5) {
            if (!isToAnimation) {
                m_byteStream = fromStream->copy();
                return;
            }
        } else {
            m_byteStream = toStream->copy();
            return;
        }
    }

    OwnPtr<SVGPathByteStream> lastAnimatedStream = m_byteStream.release();

    m_byteStream = SVGPathByteStream::create();
    SVGPathByteStreamBuilder builder;
    builder.setCurrentByteStream(m_byteStream.get());

    SVGPathByteStreamSource fromSource(fromStream);
    SVGPathByteStreamSource toSource(toStream);

    SVGPathBlender blender;
    blender.blendAnimatedPath(percentage, &fromSource, &toSource, &builder);

    // Handle additive='sum'.
    if (!fromStream->size() || (animationElement->isAdditive() && !isToAnimation))
        addToSVGPathByteStream(m_byteStream.get(), lastAnimatedStream.get());

    // Handle accumulate='sum'.
    if (animationElement->isAccumulated() && repeatCount) {
        const SVGPathByteStream* toAtEndOfDurationStream = toAtEndOfDuration->byteStream();
        addToSVGPathByteStream(m_byteStream.get(), toAtEndOfDurationStream, repeatCount);
    }
}
    QString to_source_f_object::operator()( QScriptValue const & x ) const
    {
	if( ! x.isObject() ) return QString("undefined"); // should we return an empty string?
	if( x.isNull() ) return QString("null");
	if( x.isFunction() ) return x.toString(); // QString("('[toSource() cannot handle functions]',null)");
	if( scriptValList().contains(x) )
	{
	    return QString("('[toSource() skipping circular object reference!]',null)");
	}
	scriptValList().append(x);
	QScriptValueIterator it( x );
	QByteArray ba;
	QBuffer buf(&ba);
	// Note that we use QBuffer, instead of QDataStream because
	// writing to a QDataStream serializes in a custom binary format. :(
	// FIXME: replace this with QTextStream.
	buf.open(QIODevice::WriteOnly);
	bool isAr = x.isArray();
	char const * opener = (isAr ? "[" : "{");
	char const * closer = (isAr ? "]" : "}");
	char const * sep = ",";
	buf.write(opener);
	while( it.hasNext() )
	{
	    it.next();
	    if(0) qDebug() << "to_source_object_f: child:"<<it.name();
	    QString sub;
	    if( isAr )
	    {
		sub = toSource( it.value() );
	    }
	    else
	    {
		sub = QString("%1:%2").
		    arg(it.name()).
		    arg( toSource( it.value() ) );
	    }
	    buf.write( sub.toAscii().constData(), sub.size() );
	    if( it.hasNext() ) buf.write(sep);
	}
	buf.write(closer);
	buf.close();
	scriptValList().removeAll(x);
	QString ret(ba);
	return ret;
    }
bool buildAnimatedSVGPathByteStream(const SVGPathByteStream& fromStream, const SVGPathByteStream& toStream, SVGPathByteStream& result, float progress)
{
    ASSERT(&toStream != &result);
    result.clear();
    if (toStream.isEmpty())
        return true;

    SVGPathByteStreamBuilder builder(result);

    SVGPathByteStreamSource fromSource(fromStream);
    SVGPathByteStreamSource toSource(toStream);
    return SVGPathBlender::blendAnimatedPath(fromSource, toSource, builder, progress);
}
Exemple #6
0
t_Th9xLogicalSwitchData::operator LogicalSwitchData ()
{
  LogicalSwitchData c9x;
  c9x.func = opCmp;
  c9x.val1 = val1;
  c9x.val2 = val2;

  if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
    c9x.val1 = toSource(val1).toValue();
  }

  if (c9x.func >= LS_FN_EQUAL) {
    c9x.val2 = toSource(val2).toValue();
  }

  if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
    c9x.val1 = th9xToSwitch(val1).toValue();
    c9x.val2 = th9xToSwitch(val2).toValue();
  }

  return c9x;
}
PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    std::unique_ptr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
    SVGPathByteStreamBuilder builder(*byteStream);

    SVGPathByteStreamSource fromSource(path()->byteStream());
    SVGPathByteStreamSource toSource(toAnimatablePath(value)->path()->byteStream());

    SVGPathBlender blender(&fromSource, &toSource, &builder);
    bool ok = blender.blendAnimatedPath(fraction);
    ASSERT_UNUSED(ok, ok);
    return AnimatablePath::create(StylePath::create(std::move(byteStream)));
}
Exemple #8
0
void OfflineDataModel::cancel( int index )
{
    m_newstuffModel.cancel( toSource( index ) );
}
Exemple #9
0
void OfflineDataModel::uninstall( int index )
{
    m_newstuffModel.uninstall( toSource( index ) );
}
Exemple #10
0
	gvl::octet_reader toOctetReader() const
	{
		return gvl::octet_reader(toSource());
	}
bool canBlendSVGPathByteStreams(const SVGPathByteStream& fromStream, const SVGPathByteStream& toStream)
{
    SVGPathByteStreamSource fromSource(fromStream);
    SVGPathByteStreamSource toSource(toStream);
    return SVGPathBlender::canBlendPaths(fromSource, toSource);
}