[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

krit at webkit.org krit at webkit.org
Wed Dec 22 11:48:33 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9b476f362e3218482a9ee72ee6b9122c1ba48169
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Aug 7 15:17:47 2010 +0000

    2010-08-07  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            Come up with a more efficient way to represent Path segments
            https://bugs.webkit.org/show_bug.cgi?id=41159
    
            Introduce SVGPathByteStream as a fast and efficient way to organize the synchronization
            of Path, SVG path data string and SVGPathSegList in normalized and unaltered modes.
            Extended SVGPathParserFactory to accept SVGPathByteStreams as input source and to create
            a SVGPathByteStream from a SVG path data string.
    
            Doesn't affect any tests.
    
            * Android.mk:
            * CMakeLists.txt:
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * svg/SVGAllInOne.cpp:
            * svg/SVGPathByteStream.h: Added.
            (WebCore::):
            (WebCore::SVGPathByteStream::create):
            (WebCore::SVGPathByteStream::data):
            (WebCore::SVGPathByteStream::begin):
            (WebCore::SVGPathByteStream::end):
            (WebCore::SVGPathByteStream::append):
            (WebCore::SVGPathByteStream::clear):
            (WebCore::SVGPathByteStream::isEmpty):
            (WebCore::SVGPathByteStream::SVGPathByteStream):
            * svg/SVGPathByteStreamBuilder.cpp: Added.
            (WebCore::SVGPathByteStreamBuilder::SVGPathByteStreamBuilder):
            (WebCore::SVGPathByteStreamBuilder::moveTo):
            (WebCore::SVGPathByteStreamBuilder::lineTo):
            (WebCore::SVGPathByteStreamBuilder::lineToHorizontal):
            (WebCore::SVGPathByteStreamBuilder::lineToVertical):
            (WebCore::SVGPathByteStreamBuilder::curveToCubic):
            (WebCore::SVGPathByteStreamBuilder::curveToCubicSmooth):
            (WebCore::SVGPathByteStreamBuilder::curveToQuadratic):
            (WebCore::SVGPathByteStreamBuilder::curveToQuadraticSmooth):
            (WebCore::SVGPathByteStreamBuilder::arcTo):
            (WebCore::SVGPathByteStreamBuilder::closePath):
            * svg/SVGPathByteStreamBuilder.h: Added.
            (WebCore::SVGPathByteStreamBuilder::setCurrentByteStream):
            (WebCore::SVGPathByteStreamBuilder::writeType):
            (WebCore::SVGPathByteStreamBuilder::writeFlag):
            (WebCore::SVGPathByteStreamBuilder::writeFloat):
            (WebCore::SVGPathByteStreamBuilder::writeFloatPoint):
            (WebCore::SVGPathByteStreamBuilder::writeSegmentType):
            * svg/SVGPathByteStreamSource.cpp: Added.
            (WebCore::SVGPathByteStreamSource::SVGPathByteStreamSource):
            (WebCore::SVGPathByteStreamSource::~SVGPathByteStreamSource):
            (WebCore::SVGPathByteStreamSource::hasMoreData):
            (WebCore::SVGPathByteStreamSource::parseFloat):
            (WebCore::SVGPathByteStreamSource::parseFlag):
            (WebCore::SVGPathByteStreamSource::parseSVGSegmentType):
            (WebCore::SVGPathByteStreamSource::nextCommand):
            * svg/SVGPathByteStreamSource.h: Added.
            (WebCore::SVGPathByteStreamSource::create):
            (WebCore::SVGPathByteStreamSource::readType):
            (WebCore::SVGPathByteStreamSource::readFlag):
            (WebCore::SVGPathByteStreamSource::readFloat):
            (WebCore::SVGPathByteStreamSource::readSVGSegmentType):
            (WebCore::SVGPathByteStreamSource::readFloatPoint):
            * svg/SVGPathParserFactory.cpp:
            (WebCore::globalSVGPathByteStreamBuilder):
            (WebCore::SVGPathParserFactory::buildPathFromByteStream):
            (WebCore::SVGPathParserFactory::buildSVGPathSegListFromByteStream):
            (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromString):
            * svg/SVGPathParserFactory.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64909 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index a175626..29a91cc 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -871,6 +871,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
 	svg/SVGPaint.cpp \
 	svg/SVGParserUtilities.cpp \
 	svg/SVGPathBuilder.cpp \
+	svg/SVGPathByteStreamBuilder.cpp \
+	svg/SVGPathByteStreamSource.cpp \
 	svg/SVGPathElement.cpp \
 	svg/SVGPathParser.cpp \
 	svg/SVGPathParserFactory.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index a25714d..23bd7e8 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1679,6 +1679,8 @@ IF (ENABLE_SVG)
         svg/SVGPaint.cpp
         svg/SVGParserUtilities.cpp
         svg/SVGPathBuilder.cpp
+        svg/SVGPathByteStreamBuilder.cpp
+        svg/SVGPathByteStreamSource.cpp
         svg/SVGPathElement.cpp
         svg/SVGPathParser.cpp
         svg/SVGPathParserFactory.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 254bd65..f83799e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,77 @@
 2010-08-07  Dirk Schulze  <krit at webkit.org>
 
+        Reviewed by Nikolas Zimmermann.
+
+        Come up with a more efficient way to represent Path segments
+        https://bugs.webkit.org/show_bug.cgi?id=41159
+
+        Introduce SVGPathByteStream as a fast and efficient way to organize the synchronization
+        of Path, SVG path data string and SVGPathSegList in normalized and unaltered modes.
+        Extended SVGPathParserFactory to accept SVGPathByteStreams as input source and to create
+        a SVGPathByteStream from a SVG path data string.
+
+        Doesn't affect any tests.
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * svg/SVGAllInOne.cpp:
+        * svg/SVGPathByteStream.h: Added.
+        (WebCore::):
+        (WebCore::SVGPathByteStream::create):
+        (WebCore::SVGPathByteStream::data):
+        (WebCore::SVGPathByteStream::begin):
+        (WebCore::SVGPathByteStream::end):
+        (WebCore::SVGPathByteStream::append):
+        (WebCore::SVGPathByteStream::clear):
+        (WebCore::SVGPathByteStream::isEmpty):
+        (WebCore::SVGPathByteStream::SVGPathByteStream):
+        * svg/SVGPathByteStreamBuilder.cpp: Added.
+        (WebCore::SVGPathByteStreamBuilder::SVGPathByteStreamBuilder):
+        (WebCore::SVGPathByteStreamBuilder::moveTo):
+        (WebCore::SVGPathByteStreamBuilder::lineTo):
+        (WebCore::SVGPathByteStreamBuilder::lineToHorizontal):
+        (WebCore::SVGPathByteStreamBuilder::lineToVertical):
+        (WebCore::SVGPathByteStreamBuilder::curveToCubic):
+        (WebCore::SVGPathByteStreamBuilder::curveToCubicSmooth):
+        (WebCore::SVGPathByteStreamBuilder::curveToQuadratic):
+        (WebCore::SVGPathByteStreamBuilder::curveToQuadraticSmooth):
+        (WebCore::SVGPathByteStreamBuilder::arcTo):
+        (WebCore::SVGPathByteStreamBuilder::closePath):
+        * svg/SVGPathByteStreamBuilder.h: Added.
+        (WebCore::SVGPathByteStreamBuilder::setCurrentByteStream):
+        (WebCore::SVGPathByteStreamBuilder::writeType):
+        (WebCore::SVGPathByteStreamBuilder::writeFlag):
+        (WebCore::SVGPathByteStreamBuilder::writeFloat):
+        (WebCore::SVGPathByteStreamBuilder::writeFloatPoint):
+        (WebCore::SVGPathByteStreamBuilder::writeSegmentType):
+        * svg/SVGPathByteStreamSource.cpp: Added.
+        (WebCore::SVGPathByteStreamSource::SVGPathByteStreamSource):
+        (WebCore::SVGPathByteStreamSource::~SVGPathByteStreamSource):
+        (WebCore::SVGPathByteStreamSource::hasMoreData):
+        (WebCore::SVGPathByteStreamSource::parseFloat):
+        (WebCore::SVGPathByteStreamSource::parseFlag):
+        (WebCore::SVGPathByteStreamSource::parseSVGSegmentType):
+        (WebCore::SVGPathByteStreamSource::nextCommand):
+        * svg/SVGPathByteStreamSource.h: Added.
+        (WebCore::SVGPathByteStreamSource::create):
+        (WebCore::SVGPathByteStreamSource::readType):
+        (WebCore::SVGPathByteStreamSource::readFlag):
+        (WebCore::SVGPathByteStreamSource::readFloat):
+        (WebCore::SVGPathByteStreamSource::readSVGSegmentType):
+        (WebCore::SVGPathByteStreamSource::readFloatPoint):
+        * svg/SVGPathParserFactory.cpp:
+        (WebCore::globalSVGPathByteStreamBuilder):
+        (WebCore::SVGPathParserFactory::buildPathFromByteStream):
+        (WebCore::SVGPathParserFactory::buildSVGPathSegListFromByteStream):
+        (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromString):
+        * svg/SVGPathParserFactory.h:
+
+2010-08-07  Dirk Schulze  <krit at webkit.org>
+
         Not reviewed. Sort XCode project file.
 
         * WebCore.xcodeproj/project.pbxproj:
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 0e5ea3d..44f626f 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -4074,6 +4074,11 @@ webcore_sources += \
 	WebCore/svg/SVGParserUtilities.h \
 	WebCore/svg/SVGPathBuilder.cpp \
 	WebCore/svg/SVGPathBuilder.h \
+	WebCore/svg/SVGPathByteStream.h \
+	WebCore/svg/SVGPathByteStreamBuilder.cpp \
+	WebCore/svg/SVGPathByteStreamBuilder.h \
+	WebCore/svg/SVGPathByteStreamSource.cpp \
+	WebCore/svg/SVGPathByteStreamSource.h \
 	WebCore/svg/SVGPathConsumer.h \
 	WebCore/svg/SVGPathElement.cpp \
 	WebCore/svg/SVGPathElement.h \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 28bc124..a9659b1 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3828,6 +3828,11 @@
             'svg/SVGParserUtilities.h',
             'svg/SVGPathBuilder.cpp',
             'svg/SVGPathBuilder.h',
+            'svg/SVGPathByteStream.h',
+            'svg/SVGPathByteStreamBuilder.cpp',
+            'svg/SVGPathByteStreamBuilder.h',
+            'svg/SVGPathByteStreamSource.cpp',
+            'svg/SVGPathByteStreamSource.h',
             'svg/SVGPathConsumer.h',
             'svg/SVGPathElement.cpp',
             'svg/SVGPathElement.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 6d69ec6..df06ec9 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -2853,6 +2853,8 @@ contains(DEFINES, ENABLE_SVG=1) {
         svg/SVGPaint.cpp \
         svg/SVGParserUtilities.cpp \
         svg/SVGPathBuilder.cpp \
+        svg/SVGPathByteStreamBuilder.cpp \
+        svg/SVGPathByteStreamSource.cpp \
         svg/SVGPathElement.cpp \
         svg/SVGPathParser.cpp \
         svg/SVGPathParserFactory.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 2297fd9..5b5ae8e 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -49441,6 +49441,18 @@
 				>
 			</File>
 			<File
+				RelativePath="..\svg\SVGPathByteStream.h"
+				>
+			</File>
+			<File
+				RelativePath="..\svg\SVGPathByteStreamBuilder.h"
+				>
+			</File>
+			<File
+				RelativePath="..\svg\SVGPathByteStreamSource.h"
+				>
+			</File>
+			<File
 				RelativePath="..\svg\SVGPathConsumer.h"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index fe0336b..68a671b 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1432,6 +1432,11 @@
 		81BE20D311F4BC3200915DFA /* JSIDBCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 81BE20A811F4B66F00915DFA /* JSIDBCursor.h */; };
 		82B658981189E39200E052A1 /* InspectorCSSStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 82B658971189E39200E052A1 /* InspectorCSSStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		82B6589A1189E47600E052A1 /* InspectorCSSStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82B658991189E47600E052A1 /* InspectorCSSStore.cpp */; };
+		8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A4120D92D000141F8F /* SVGPathByteStream.h */; };
+		8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */; };
+		8419D2A9120D92D000141F8F /* SVGPathByteStreamBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */; };
+		8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2AA120D92FC00141F8F /* SVGPathByteStreamSource.cpp */; };
+		8419D2AD120D92FC00141F8F /* SVGPathByteStreamSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2AB120D92FC00141F8F /* SVGPathByteStreamSource.h */; };
 		841FDC261178C9BE00F8AC9B /* RenderSVGResourceFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841FDC241178C9BE00F8AC9B /* RenderSVGResourceFilter.cpp */; };
 		841FDC271178C9BE00F8AC9B /* RenderSVGResourceFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 841FDC251178C9BE00F8AC9B /* RenderSVGResourceFilter.h */; };
 		84224183107E77F400766A87 /* JSSVGFEMorphologyElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84224181107E77F400766A87 /* JSSVGFEMorphologyElement.cpp */; };
@@ -7261,6 +7266,11 @@
 		81BE20A811F4B66F00915DFA /* JSIDBCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBCursor.h; sourceTree = "<group>"; };
 		82B658971189E39200E052A1 /* InspectorCSSStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCSSStore.h; sourceTree = "<group>"; };
 		82B658991189E47600E052A1 /* InspectorCSSStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCSSStore.cpp; sourceTree = "<group>"; };
+		8419D2A4120D92D000141F8F /* SVGPathByteStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStream.h; sourceTree = "<group>"; };
+		8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamBuilder.cpp; sourceTree = "<group>"; };
+		8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStreamBuilder.h; sourceTree = "<group>"; };
+		8419D2AA120D92FC00141F8F /* SVGPathByteStreamSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamSource.cpp; sourceTree = "<group>"; };
+		8419D2AB120D92FC00141F8F /* SVGPathByteStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStreamSource.h; sourceTree = "<group>"; };
 		841FDC241178C9BE00F8AC9B /* RenderSVGResourceFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGResourceFilter.cpp; sourceTree = "<group>"; };
 		841FDC251178C9BE00F8AC9B /* RenderSVGResourceFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceFilter.h; sourceTree = "<group>"; };
 		84224181107E77F400766A87 /* JSSVGFEMorphologyElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGFEMorphologyElement.cpp; sourceTree = "<group>"; };
@@ -15301,6 +15311,11 @@
 				B22278C10D00BF200071B782 /* SVGParserUtilities.h */,
 				8476C9E711DF6A2900555B02 /* SVGPathBuilder.cpp */,
 				8476C9E811DF6A2900555B02 /* SVGPathBuilder.h */,
+				8419D2A4120D92D000141F8F /* SVGPathByteStream.h */,
+				8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */,
+				8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */,
+				8419D2AA120D92FC00141F8F /* SVGPathByteStreamSource.cpp */,
+				8419D2AB120D92FC00141F8F /* SVGPathByteStreamSource.h */,
 				8476C9E911DF6A2900555B02 /* SVGPathConsumer.h */,
 				B22278C20D00BF200071B782 /* SVGPathElement.cpp */,
 				B22278C30D00BF200071B782 /* SVGPathElement.h */,
@@ -19810,6 +19825,9 @@
 				B2227A540D00BF220071B782 /* SVGPaint.h in Headers */,
 				B2227A570D00BF220071B782 /* SVGParserUtilities.h in Headers */,
 				8476C9EB11DF6A2900555B02 /* SVGPathBuilder.h in Headers */,
+				8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */,
+				8419D2A9120D92D000141F8F /* SVGPathByteStreamBuilder.h in Headers */,
+				8419D2AD120D92FC00141F8F /* SVGPathByteStreamSource.h in Headers */,
 				8476C9EC11DF6A2900555B02 /* SVGPathConsumer.h in Headers */,
 				B2227A590D00BF220071B782 /* SVGPathElement.h in Headers */,
 				8476C9F011DF6A5800555B02 /* SVGPathParser.h in Headers */,
@@ -22273,6 +22291,8 @@
 				B2227A530D00BF220071B782 /* SVGPaint.cpp in Sources */,
 				B2227A560D00BF220071B782 /* SVGParserUtilities.cpp in Sources */,
 				8476C9EA11DF6A2900555B02 /* SVGPathBuilder.cpp in Sources */,
+				8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */,
+				8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */,
 				B2227A580D00BF220071B782 /* SVGPathElement.cpp in Sources */,
 				8476C9EF11DF6A5800555B02 /* SVGPathParser.cpp in Sources */,
 				84300BD3120C9A710021954A /* SVGPathParserFactory.cpp in Sources */,
diff --git a/WebCore/svg/SVGAllInOne.cpp b/WebCore/svg/SVGAllInOne.cpp
index a046492..43563b2 100644
--- a/WebCore/svg/SVGAllInOne.cpp
+++ b/WebCore/svg/SVGAllInOne.cpp
@@ -108,6 +108,8 @@
 #include "SVGPaint.cpp"
 #include "SVGParserUtilities.cpp"
 #include "SVGPathBuilder.cpp"
+#include "SVGPathByteStreamBuilder.cpp"
+#include "SVGPathByteStreamSource.cpp"
 #include "SVGPathElement.cpp"
 #include "SVGPathParser.cpp"
 #include "SVGPathParserFactory.cpp"
diff --git a/WebCore/svg/SVGPathByteStream.h b/WebCore/svg/SVGPathByteStream.h
new file mode 100644
index 0000000..b8882b6
--- /dev/null
+++ b/WebCore/svg/SVGPathByteStream.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGPathByteStream_h
+#define SVGPathByteStream_h
+
+#if ENABLE(SVG)
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+// Type definitions for the byte stream data
+typedef union {
+    bool value;
+    unsigned char bytes[sizeof(bool)];
+} BoolByte;
+
+typedef union {
+    float value;
+    unsigned char bytes[sizeof(float)];
+} FloatByte;
+
+typedef union {
+    unsigned short value;
+    unsigned char bytes[sizeof(unsigned short)];
+} UnsignedShortByte;
+
+class SVGPathByteStream : public Noncopyable {
+public:
+    static PassOwnPtr<SVGPathByteStream> create()
+    {
+        return adoptPtr(new SVGPathByteStream);
+    }
+
+    typedef Vector<unsigned char> Data;
+    typedef Data::const_iterator DataIterator;
+
+    DataIterator begin() { return m_data.begin(); }
+    DataIterator end() { return m_data.end(); }
+    void append(unsigned char byte) { m_data.append(byte); }
+    void clear() { m_data.clear(); }
+    bool isEmpty() const { return !m_data.size(); }
+
+private:
+    SVGPathByteStream() { }
+    Data m_data;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGPathByteStream_h
diff --git a/WebCore/svg/SVGPathByteStreamBuilder.cpp b/WebCore/svg/SVGPathByteStreamBuilder.cpp
new file mode 100644
index 0000000..cf939f0
--- /dev/null
+++ b/WebCore/svg/SVGPathByteStreamBuilder.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathByteStreamBuilder.h"
+
+#include "SVGPathParser.h"
+#include "SVGPathSeg.h"
+#include "SVGPathStringSource.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+SVGPathByteStreamBuilder::SVGPathByteStreamBuilder()
+    : m_byteStream(0)
+{
+}
+
+void SVGPathByteStreamBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ?  PathSegMoveToRel : PathSegMoveToAbs);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegLineToRel : PathSegLineToAbs);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::lineToHorizontal(float x, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegLineToHorizontalRel : PathSegLineToHorizontalAbs);
+    writeFloat(x);
+}
+
+void SVGPathByteStreamBuilder::lineToVertical(float y, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegLineToVerticalRel : PathSegLineToVerticalAbs);
+    writeFloat(y);
+}
+
+void SVGPathByteStreamBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToCubicRel : PathSegCurveToCubicAbs);
+    writeFloatPoint(point1);
+    writeFloatPoint(point2);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToCubicSmoothRel : PathSegCurveToCubicSmoothAbs);
+    writeFloatPoint(point2);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToQuadraticRel : PathSegCurveToQuadraticAbs);
+    writeFloatPoint(point1);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToQuadraticSmoothRel : PathSegCurveToQuadraticSmoothAbs);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode)
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(mode == RelativeCoordinates ? PathSegArcRel : PathSegArcAbs);
+    writeFloat(r1);
+    writeFloat(r2);
+    writeFloat(angle);
+    writeFlag(largeArcFlag);
+    writeFlag(sweepFlag);
+    writeFloatPoint(targetPoint);
+}
+
+void SVGPathByteStreamBuilder::closePath()
+{
+    ASSERT(m_byteStream);
+    writeSegmentType(PathSegClosePath);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPathByteStreamBuilder.h b/WebCore/svg/SVGPathByteStreamBuilder.h
new file mode 100644
index 0000000..13a08b7
--- /dev/null
+++ b/WebCore/svg/SVGPathByteStreamBuilder.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGPathByteStreamBuilder_h
+#define SVGPathByteStreamBuilder_h
+
+#if ENABLE(SVG)
+#include "FloatPoint.h"
+#include "PlatformString.h"
+#include "SVGPathByteStream.h"
+#include "SVGPathConsumer.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class SVGPathByteStreamBuilder : public SVGPathConsumer {
+public:
+    SVGPathByteStreamBuilder();
+
+    void setCurrentByteStream(SVGPathByteStream* byteStream) { m_byteStream = byteStream; }
+
+private:
+    // Used in UnalteredParsing/NormalizedParsing modes.
+    virtual void moveTo(const FloatPoint&, bool closed, PathCoordinateMode);
+    virtual void lineTo(const FloatPoint&, PathCoordinateMode);
+    virtual void curveToCubic(const FloatPoint&, const FloatPoint&, const FloatPoint&, PathCoordinateMode);
+    virtual void closePath();
+
+private:
+    // Only used in UnalteredParsing mode.
+    virtual void lineToHorizontal(float, PathCoordinateMode);
+    virtual void lineToVertical(float, PathCoordinateMode);
+    virtual void curveToCubicSmooth(const FloatPoint&, const FloatPoint&, PathCoordinateMode);
+    virtual void curveToQuadratic(const FloatPoint&, const FloatPoint&, PathCoordinateMode);
+    virtual void curveToQuadraticSmooth(const FloatPoint&, PathCoordinateMode);
+    virtual void arcTo(float, float, float, bool largeArcFlag, bool sweepFlag, const FloatPoint&, PathCoordinateMode);
+
+private:
+    template<typename ByteType>
+    void writeType(const ByteType& type)
+    {
+        size_t typeSize = sizeof(ByteType);
+        for (size_t i = 0; i < typeSize; ++i)
+            m_byteStream->append(type.bytes[i]);
+    }
+
+    void writeFlag(bool value)
+    {
+        BoolByte data;
+        data.value = value;
+        writeType(data);
+    }
+
+    void writeFloat(float value)
+    {
+        FloatByte data;
+        data.value = value;
+        writeType(data);
+    }
+
+    void writeFloatPoint(const FloatPoint& point)
+    {
+        writeFloat(point.x());
+        writeFloat(point.y());
+    }
+
+    void writeSegmentType(unsigned short value)
+    {
+        UnsignedShortByte data;
+        data.value = value;
+        writeType(data);
+    }
+
+    SVGPathByteStream* m_byteStream;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGPathByteStreamBuilder_h
diff --git a/WebCore/svg/SVGPathByteStreamSource.cpp b/WebCore/svg/SVGPathByteStreamSource.cpp
new file mode 100644
index 0000000..3c2b2bb
--- /dev/null
+++ b/WebCore/svg/SVGPathByteStreamSource.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathByteStreamSource.h"
+
+#include "PlatformString.h"
+
+namespace WebCore {
+
+SVGPathByteStreamSource::SVGPathByteStreamSource(SVGPathByteStream* stream)
+    : m_stream(stream)
+    , m_streamCurrent(stream->begin())
+    , m_streamEnd(stream->end())
+{
+    ASSERT(stream);
+}
+
+SVGPathByteStreamSource::~SVGPathByteStreamSource()
+{
+}
+
+bool SVGPathByteStreamSource::hasMoreData() const
+{
+    return (m_streamCurrent < m_streamEnd);
+}
+
+bool SVGPathByteStreamSource::parseFloat(float& result)
+{
+    result = readFloat();
+    return true;
+}
+
+bool SVGPathByteStreamSource::parseFlag(bool& result)
+{
+    result = readFlag();
+    return true;
+}
+
+bool SVGPathByteStreamSource::parseSVGSegmentType(SVGPathSegType& pathSegType)
+{
+    pathSegType = static_cast<SVGPathSegType>(readSVGSegmentType());
+    return true;
+}
+
+SVGPathSegType SVGPathByteStreamSource::nextCommand(SVGPathSegType)
+{
+    return static_cast<SVGPathSegType>(readSVGSegmentType());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPathByteStreamSource.h b/WebCore/svg/SVGPathByteStreamSource.h
new file mode 100644
index 0000000..c3a85ea
--- /dev/null
+++ b/WebCore/svg/SVGPathByteStreamSource.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGPathByteStreamSource_h
+#define SVGPathByteStreamSource_h
+
+#if ENABLE(SVG)
+#include "FloatPoint.h"
+#include "SVGPathByteStream.h"
+#include "SVGPathSource.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class SVGPathByteStreamSource : public SVGPathSource {
+public:
+    static PassOwnPtr<SVGPathByteStreamSource> create(SVGPathByteStream* stream)
+    {
+        return adoptPtr(new SVGPathByteStreamSource(stream));
+    }
+
+    virtual ~SVGPathByteStreamSource();
+
+    virtual bool hasMoreData() const;
+    virtual bool moveToNextToken();
+    virtual bool parseFloat(float& result);
+    virtual bool parseFlag(bool& result);
+    virtual bool parseSVGSegmentType(SVGPathSegType&);
+    virtual SVGPathSegType nextCommand(SVGPathSegType);
+
+private:
+    SVGPathByteStreamSource(SVGPathByteStream*);
+
+    template<typename DataType, typename ByteType>
+    DataType readType()
+    {
+        ByteType data;
+        size_t typeSize = sizeof(ByteType);
+
+        for (size_t i = 0; i < typeSize; ++i) {
+            ASSERT(m_streamCurrent < m_streamEnd);
+            data.bytes[i] = *m_streamCurrent;
+            ++m_streamCurrent;
+        }
+
+        return data.value;
+    }
+
+    bool readFlag()
+    {
+        return readType<bool, BoolByte>();
+    }
+
+    float readFloat()
+    {
+        return readType<float, FloatByte>();
+    }
+
+    unsigned short readSVGSegmentType()
+    {
+        return readType<unsigned short, UnsignedShortByte>();
+    }
+
+    FloatPoint readFloatPoint()
+    {
+        float x = readType<float, FloatByte>();
+        float y = readType<float, FloatByte>();
+        return FloatPoint(x, y);
+    }
+
+    SVGPathByteStream* m_stream;
+    SVGPathByteStream::DataIterator m_streamCurrent;
+    SVGPathByteStream::DataIterator m_streamEnd;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGPathByteStreamSource_h
diff --git a/WebCore/svg/SVGPathParserFactory.cpp b/WebCore/svg/SVGPathParserFactory.cpp
index de381a9..9d32e89 100644
--- a/WebCore/svg/SVGPathParserFactory.cpp
+++ b/WebCore/svg/SVGPathParserFactory.cpp
@@ -23,6 +23,8 @@
 #include "SVGPathParserFactory.h"
 
 #include "SVGPathBuilder.h"
+#include "SVGPathByteStreamBuilder.h"
+#include "SVGPathByteStreamSource.h"
 #include "SVGPathParser.h"
 #include "SVGPathSegListBuilder.h"
 #include "SVGPathStringSource.h"
@@ -47,6 +49,15 @@ static SVGPathSegListBuilder* globalSVGPathSegListBuilder()
     return s_builder;
 }
 
+static SVGPathByteStreamBuilder* globalSVGPathByteStreamBuilder()
+{
+    static SVGPathByteStreamBuilder* s_builder = 0;
+    if (!s_builder)
+        s_builder = new SVGPathByteStreamBuilder;
+
+    return s_builder;
+}
+
 static SVGPathParser* globalSVGPathParser()
 {
     static SVGPathParser* s_parser = 0;
@@ -94,6 +105,28 @@ bool SVGPathParserFactory::buildPathFromString(const String& d, Path& result)
     return ok;
 }
 
+bool SVGPathParserFactory::buildPathFromByteStream(SVGPathByteStream* stream, Path& result)
+{
+    ASSERT(stream);
+    if (stream->isEmpty())
+        return false;
+
+    SVGPathBuilder* builder = globalSVGPathBuilder();
+    builder->setCurrentPath(&result);
+
+    SVGPathParser* parser = globalSVGPathParser();
+    parser->setCurrentConsumer(builder);
+
+    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream);
+    parser->setCurrentSource(source.get());
+
+    bool ok = parser->parsePathDataFromSource(NormalizedParsing);
+    parser->setCurrentConsumer(0);
+    parser->setCurrentSource(0);
+    builder->setCurrentPath(0);
+    return ok;
+}
+
 bool SVGPathParserFactory::buildSVGPathSegListFromString(const String& d, SVGPathSegList* result, PathParsingMode parsingMode)
 {
     ASSERT(result);
@@ -116,6 +149,49 @@ bool SVGPathParserFactory::buildSVGPathSegListFromString(const String& d, SVGPat
     return ok;
 }
 
+bool SVGPathParserFactory::buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathSegList* result, PathParsingMode parsingMode)
+{
+    ASSERT(stream);
+    ASSERT(result);
+
+    SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder();
+    builder->setCurrentSVGPathSegList(result);
+
+    SVGPathParser* parser = globalSVGPathParser();
+    parser->setCurrentConsumer(builder);
+
+    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream);
+    parser->setCurrentSource(source.get());
+
+    bool ok = parser->parsePathDataFromSource(parsingMode);
+    parser->setCurrentConsumer(0);
+    parser->setCurrentSource(0);
+    builder->setCurrentSVGPathSegList(0);
+    return ok;
+}
+
+PassOwnPtr<SVGPathByteStream> SVGPathParserFactory::createSVGPathByteStreamFromString(const String& d, PathParsingMode parsingMode, bool& ok)
+{
+    if (d.isEmpty())
+        return false;
+
+    SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder();
+    OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create();
+    builder->setCurrentByteStream(stream.get());
+
+    SVGPathParser* parser = globalSVGPathParser();
+    parser->setCurrentConsumer(builder);
+
+    OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d);
+    parser->setCurrentSource(source.get());
+
+    ok = parser->parsePathDataFromSource(parsingMode);
+    parser->setCurrentConsumer(0);
+    parser->setCurrentSource(0);
+    builder->setCurrentByteStream(0);
+    return stream.release();
+}
+
 }
 
 #endif
diff --git a/WebCore/svg/SVGPathParserFactory.h b/WebCore/svg/SVGPathParserFactory.h
index 419f20a..5954562 100644
--- a/WebCore/svg/SVGPathParserFactory.h
+++ b/WebCore/svg/SVGPathParserFactory.h
@@ -25,6 +25,8 @@
 #include "PlatformString.h"
 #include "SVGPathConsumer.h"
 #include "SVGPathSegList.h"
+#include "SVGPathByteStream.h"
+#include <OwnPtr.h>
 
 namespace WebCore {
 
@@ -33,8 +35,12 @@ public:
     static SVGPathParserFactory* self();
 
     bool buildPathFromString(const String&, Path&);
+    bool buildPathFromByteStream(SVGPathByteStream*, Path& result);
 
     bool buildSVGPathSegListFromString(const String&, SVGPathSegList*, PathParsingMode);
+    bool buildSVGPathSegListFromByteStream(SVGPathByteStream*, SVGPathSegList*, PathParsingMode);
+
+    PassOwnPtr<SVGPathByteStream> createSVGPathByteStreamFromString(const String&, PathParsingMode, bool& ok);
 
 private:
     SVGPathParserFactory();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list