void SVGPath::add(RawPtr<SVGPropertyBase> other, SVGElement*)
{
    const SVGPathByteStream& otherPathByteStream = toSVGPath(other)->byteStream();
    if (byteStream().size() != otherPathByteStream.size()
        || byteStream().isEmpty()
        || otherPathByteStream.isEmpty())
        return;

    m_pathValue = CSSPathValue::create(addPathByteStreams(byteStream(), otherPathByteStream));
}
예제 #2
0
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);
    }
}
void SVGPath::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
{
    RefPtrWillBeRawPtr<SVGPath> otherList = toSVGPath(other);
    if (byteStream().size() != otherList->byteStream().size())
        return;

    addToSVGPathByteStream(mutableByteStream(), otherList->byteStream());
}
void SVGPath::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, RawPtr<SVGPropertyBase> fromValue, RawPtr<SVGPropertyBase> toValue, RawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*)
{
    ASSERT(animationElement);
    bool isToAnimation = animationElement->getAnimationMode() == ToAnimation;

    const SVGPath& to = toSVGPath(*toValue);
    const SVGPathByteStream& toStream = to.byteStream();

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

    const SVGPath& from = toSVGPath(*fromValue);
    const SVGPathByteStream* fromStream = &from.byteStream();

    OwnPtr<SVGPathByteStream> copy;
    if (isToAnimation) {
        copy = byteStream().clone();
        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_pathValue = from.pathValue();
                return;
            }
        } else {
            m_pathValue = to.pathValue();
            return;
        }
    }

    OwnPtr<SVGPathByteStream> newStream = blendPathByteStreams(*fromStream, toStream, percentage);

    // Handle additive='sum'.
    if (animationElement->isAdditive() && !isToAnimation)
        newStream = conditionallyAddPathByteStreams(newStream.release(), byteStream());

    // Handle accumulate='sum'.
    if (animationElement->isAccumulated() && repeatCount)
        newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPath(toAtEndOfDurationValue)->byteStream(), repeatCount);

    m_pathValue = CSSPathValue::create(newStream.release());
}
예제 #5
0
GTEST_TEST(Huffman, searchMaxLength) {
	Common::MemoryReadStream byteStream(kHuffmanData);
	Common::BitStream8MSB    bitStream (byteStream);

	Common::Huffman huffman(0, ARRAYSIZE(kCodes), kCodes, kLengths, kSymbols);

	for (size_t i = 0; i < ARRAYSIZE(kDeHuffmanDataSymbols); i++)
		EXPECT_EQ(huffman.getSymbol(bitStream), kDeHuffmanDataSymbols[i]) << "At index " << i;
}
예제 #6
0
void SVGPathSegList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
{
    RefPtr<SVGPathSegList> otherList = toSVGPathSegList(other);
    if (length() != otherList->length())
        return;

    byteStream(); // create |m_byteStream| if not exist.
    addToSVGPathByteStream(m_byteStream.get(), otherList->byteStream());
    invalidateList();
}
예제 #7
0
QByteArray ByteArrayConverter::fromBool(const bool value)
{
    QByteArray byteArray;

    QDataStream byteStream(&byteArray, QIODevice::WriteOnly);
    byteStream.setByteOrder(QDataStream::BigEndian);

    byteStream << value;

    return byteArray;
}
예제 #8
0
QByteArray ByteArrayConverter::fromQInt32(const qint32 number)
{
    QByteArray byteArray;

    QDataStream byteStream(&byteArray, QIODevice::WriteOnly);
    byteStream.setByteOrder(QDataStream::BigEndian);

    byteStream << number;

    return byteArray;
}
예제 #9
0
GTEST_TEST(Huffman, eos) {
	Common::MemoryReadStream byteStream(kHuffmanData);
	Common::BitStream8MSB    bitStream (byteStream);

	Common::Huffman huffman(kMaxLength, ARRAYSIZE(kCodes), kCodes, kLengths, kSymbols);

	for (size_t i = 0; i < ARRAYSIZE(kDeHuffmanDataSymbols); i++)
		huffman.getSymbol(bitStream);

	EXPECT_THROW(huffman.getSymbol(bitStream), Common::Exception);
}
예제 #10
0
/**
  * @brief send this packet out a socket.
  */
void OpenNICPacket::send(QTcpSocket* socket)
{
	if ( socket->isOpen() && socket->isValid() )
	{
		QByteArray bytes;
		QDataStream tcpStream(socket);
		QDataStream byteStream(&bytes,QIODevice::ReadWrite);
		byteStream << mData;
		tcpStream << bytes;
		socket->flush();
	}
}
예제 #11
0
GTEST_TEST(Huffman, invalidSymbol) {
	static const uint32 kInvalidCodes  [] = { 0, 4, 5, 6 };
	static const uint8  kInvalidLengths[] = { 1, 3, 3, 3 };
	static const uint8  kInvalidMaxLength = 3;

	static const byte   kInvalidHuffmanData[] = { 0x77 };

	Common::MemoryReadStream byteStream(kInvalidHuffmanData);
	Common::BitStream8MSB    bitStream (byteStream);

	Common::Huffman huffman(kInvalidMaxLength, ARRAYSIZE(kInvalidCodes), kInvalidCodes, kInvalidLengths, 0);

	EXPECT_EQ(huffman.getSymbol(bitStream), 0);

	EXPECT_THROW(huffman.getSymbol(bitStream), Common::Exception);
}
String SVGPath::valueAsString() const
{
    String string;
    buildStringFromByteStream(byteStream(), string, UnalteredParsing);
    return string;
}
PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const
{
    return adoptRefWillBeNoop(new SVGPath(byteStream().copy()));
}
예제 #14
0
PassRefPtr<SVGPathSegList> SVGPathSegList::clone()
{
    RefPtr<SVGPathSegList> svgPathSegList = adoptRef(new SVGPathSegList(m_contextElement, m_role, byteStream()->copy()));
    svgPathSegList->invalidateList();
    return svgPathSegList.release();
}
예제 #15
0
String SVGPath::valueAsString() const
{
    return buildStringFromByteStream(byteStream());
}