Changeset 64909 in webkit


Ignore:
Timestamp:
Aug 7, 2010 8:17:47 AM (14 years ago)
Author:
krit@webkit.org
Message:

2010-08-07 Dirk Schulze <krit@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:
Location:
trunk/WebCore
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.mk

    r64898 r64909  
    872872        svg/SVGParserUtilities.cpp \
    873873        svg/SVGPathBuilder.cpp \
     874        svg/SVGPathByteStreamBuilder.cpp \
     875        svg/SVGPathByteStreamSource.cpp \
    874876        svg/SVGPathElement.cpp \
    875877        svg/SVGPathParser.cpp \
  • trunk/WebCore/CMakeLists.txt

    r64898 r64909  
    16801680        svg/SVGParserUtilities.cpp
    16811681        svg/SVGPathBuilder.cpp
     1682        svg/SVGPathByteStreamBuilder.cpp
     1683        svg/SVGPathByteStreamSource.cpp
    16821684        svg/SVGPathElement.cpp
    16831685        svg/SVGPathParser.cpp
  • trunk/WebCore/ChangeLog

    r64908 r64909  
     12010-08-07  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        Come up with a more efficient way to represent Path segments
     6        https://bugs.webkit.org/show_bug.cgi?id=41159
     7
     8        Introduce SVGPathByteStream as a fast and efficient way to organize the synchronization
     9        of Path, SVG path data string and SVGPathSegList in normalized and unaltered modes.
     10        Extended SVGPathParserFactory to accept SVGPathByteStreams as input source and to create
     11        a SVGPathByteStream from a SVG path data string.
     12
     13        Doesn't affect any tests.
     14
     15        * Android.mk:
     16        * CMakeLists.txt:
     17        * GNUmakefile.am:
     18        * WebCore.gypi:
     19        * WebCore.pro:
     20        * WebCore.vcproj/WebCore.vcproj:
     21        * svg/SVGAllInOne.cpp:
     22        * svg/SVGPathByteStream.h: Added.
     23        (WebCore::):
     24        (WebCore::SVGPathByteStream::create):
     25        (WebCore::SVGPathByteStream::data):
     26        (WebCore::SVGPathByteStream::begin):
     27        (WebCore::SVGPathByteStream::end):
     28        (WebCore::SVGPathByteStream::append):
     29        (WebCore::SVGPathByteStream::clear):
     30        (WebCore::SVGPathByteStream::isEmpty):
     31        (WebCore::SVGPathByteStream::SVGPathByteStream):
     32        * svg/SVGPathByteStreamBuilder.cpp: Added.
     33        (WebCore::SVGPathByteStreamBuilder::SVGPathByteStreamBuilder):
     34        (WebCore::SVGPathByteStreamBuilder::moveTo):
     35        (WebCore::SVGPathByteStreamBuilder::lineTo):
     36        (WebCore::SVGPathByteStreamBuilder::lineToHorizontal):
     37        (WebCore::SVGPathByteStreamBuilder::lineToVertical):
     38        (WebCore::SVGPathByteStreamBuilder::curveToCubic):
     39        (WebCore::SVGPathByteStreamBuilder::curveToCubicSmooth):
     40        (WebCore::SVGPathByteStreamBuilder::curveToQuadratic):
     41        (WebCore::SVGPathByteStreamBuilder::curveToQuadraticSmooth):
     42        (WebCore::SVGPathByteStreamBuilder::arcTo):
     43        (WebCore::SVGPathByteStreamBuilder::closePath):
     44        * svg/SVGPathByteStreamBuilder.h: Added.
     45        (WebCore::SVGPathByteStreamBuilder::setCurrentByteStream):
     46        (WebCore::SVGPathByteStreamBuilder::writeType):
     47        (WebCore::SVGPathByteStreamBuilder::writeFlag):
     48        (WebCore::SVGPathByteStreamBuilder::writeFloat):
     49        (WebCore::SVGPathByteStreamBuilder::writeFloatPoint):
     50        (WebCore::SVGPathByteStreamBuilder::writeSegmentType):
     51        * svg/SVGPathByteStreamSource.cpp: Added.
     52        (WebCore::SVGPathByteStreamSource::SVGPathByteStreamSource):
     53        (WebCore::SVGPathByteStreamSource::~SVGPathByteStreamSource):
     54        (WebCore::SVGPathByteStreamSource::hasMoreData):
     55        (WebCore::SVGPathByteStreamSource::parseFloat):
     56        (WebCore::SVGPathByteStreamSource::parseFlag):
     57        (WebCore::SVGPathByteStreamSource::parseSVGSegmentType):
     58        (WebCore::SVGPathByteStreamSource::nextCommand):
     59        * svg/SVGPathByteStreamSource.h: Added.
     60        (WebCore::SVGPathByteStreamSource::create):
     61        (WebCore::SVGPathByteStreamSource::readType):
     62        (WebCore::SVGPathByteStreamSource::readFlag):
     63        (WebCore::SVGPathByteStreamSource::readFloat):
     64        (WebCore::SVGPathByteStreamSource::readSVGSegmentType):
     65        (WebCore::SVGPathByteStreamSource::readFloatPoint):
     66        * svg/SVGPathParserFactory.cpp:
     67        (WebCore::globalSVGPathByteStreamBuilder):
     68        (WebCore::SVGPathParserFactory::buildPathFromByteStream):
     69        (WebCore::SVGPathParserFactory::buildSVGPathSegListFromByteStream):
     70        (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromString):
     71        * svg/SVGPathParserFactory.h:
     72
    1732010-08-07  Dirk Schulze  <krit@webkit.org>
    274
  • trunk/WebCore/GNUmakefile.am

    r64898 r64909  
    40754075        WebCore/svg/SVGPathBuilder.cpp \
    40764076        WebCore/svg/SVGPathBuilder.h \
     4077        WebCore/svg/SVGPathByteStream.h \
     4078        WebCore/svg/SVGPathByteStreamBuilder.cpp \
     4079        WebCore/svg/SVGPathByteStreamBuilder.h \
     4080        WebCore/svg/SVGPathByteStreamSource.cpp \
     4081        WebCore/svg/SVGPathByteStreamSource.h \
    40774082        WebCore/svg/SVGPathConsumer.h \
    40784083        WebCore/svg/SVGPathElement.cpp \
  • trunk/WebCore/WebCore.gypi

    r64898 r64909  
    38293829            'svg/SVGPathBuilder.cpp',
    38303830            'svg/SVGPathBuilder.h',
     3831            'svg/SVGPathByteStream.h',
     3832            'svg/SVGPathByteStreamBuilder.cpp',
     3833            'svg/SVGPathByteStreamBuilder.h',
     3834            'svg/SVGPathByteStreamSource.cpp',
     3835            'svg/SVGPathByteStreamSource.h',
    38313836            'svg/SVGPathConsumer.h',
    38323837            'svg/SVGPathElement.cpp',
  • trunk/WebCore/WebCore.pro

    r64906 r64909  
    28542854        svg/SVGParserUtilities.cpp \
    28552855        svg/SVGPathBuilder.cpp \
     2856        svg/SVGPathByteStreamBuilder.cpp \
     2857        svg/SVGPathByteStreamSource.cpp \
    28562858        svg/SVGPathElement.cpp \
    28572859        svg/SVGPathParser.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r64898 r64909  
    4944249442                        </File>
    4944349443                        <File
     49444                                RelativePath="..\svg\SVGPathByteStream.h"
     49445                                >
     49446                        </File>
     49447                        <File
     49448                                RelativePath="..\svg\SVGPathByteStreamBuilder.h"
     49449                                >
     49450                        </File>
     49451                        <File
     49452                                RelativePath="..\svg\SVGPathByteStreamSource.h"
     49453                                >
     49454                        </File>
     49455                        <File
    4944449456                                RelativePath="..\svg\SVGPathConsumer.h"
    4944549457                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r64908 r64909  
    14331433                82B658981189E39200E052A1 /* InspectorCSSStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 82B658971189E39200E052A1 /* InspectorCSSStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
    14341434                82B6589A1189E47600E052A1 /* InspectorCSSStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82B658991189E47600E052A1 /* InspectorCSSStore.cpp */; };
     1435                8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A4120D92D000141F8F /* SVGPathByteStream.h */; };
     1436                8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */; };
     1437                8419D2A9120D92D000141F8F /* SVGPathByteStreamBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */; };
     1438                8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2AA120D92FC00141F8F /* SVGPathByteStreamSource.cpp */; };
     1439                8419D2AD120D92FC00141F8F /* SVGPathByteStreamSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2AB120D92FC00141F8F /* SVGPathByteStreamSource.h */; };
    14351440                841FDC261178C9BE00F8AC9B /* RenderSVGResourceFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841FDC241178C9BE00F8AC9B /* RenderSVGResourceFilter.cpp */; };
    14361441                841FDC271178C9BE00F8AC9B /* RenderSVGResourceFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 841FDC251178C9BE00F8AC9B /* RenderSVGResourceFilter.h */; };
     
    72627267                82B658971189E39200E052A1 /* InspectorCSSStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCSSStore.h; sourceTree = "<group>"; };
    72637268                82B658991189E47600E052A1 /* InspectorCSSStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCSSStore.cpp; sourceTree = "<group>"; };
     7269                8419D2A4120D92D000141F8F /* SVGPathByteStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStream.h; sourceTree = "<group>"; };
     7270                8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamBuilder.cpp; sourceTree = "<group>"; };
     7271                8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStreamBuilder.h; sourceTree = "<group>"; };
     7272                8419D2AA120D92FC00141F8F /* SVGPathByteStreamSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamSource.cpp; sourceTree = "<group>"; };
     7273                8419D2AB120D92FC00141F8F /* SVGPathByteStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStreamSource.h; sourceTree = "<group>"; };
    72647274                841FDC241178C9BE00F8AC9B /* RenderSVGResourceFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGResourceFilter.cpp; sourceTree = "<group>"; };
    72657275                841FDC251178C9BE00F8AC9B /* RenderSVGResourceFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceFilter.h; sourceTree = "<group>"; };
     
    1530215312                                8476C9E711DF6A2900555B02 /* SVGPathBuilder.cpp */,
    1530315313                                8476C9E811DF6A2900555B02 /* SVGPathBuilder.h */,
     15314                                8419D2A4120D92D000141F8F /* SVGPathByteStream.h */,
     15315                                8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */,
     15316                                8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */,
     15317                                8419D2AA120D92FC00141F8F /* SVGPathByteStreamSource.cpp */,
     15318                                8419D2AB120D92FC00141F8F /* SVGPathByteStreamSource.h */,
    1530415319                                8476C9E911DF6A2900555B02 /* SVGPathConsumer.h */,
    1530515320                                B22278C20D00BF200071B782 /* SVGPathElement.cpp */,
     
    1981119826                                B2227A570D00BF220071B782 /* SVGParserUtilities.h in Headers */,
    1981219827                                8476C9EB11DF6A2900555B02 /* SVGPathBuilder.h in Headers */,
     19828                                8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */,
     19829                                8419D2A9120D92D000141F8F /* SVGPathByteStreamBuilder.h in Headers */,
     19830                                8419D2AD120D92FC00141F8F /* SVGPathByteStreamSource.h in Headers */,
    1981319831                                8476C9EC11DF6A2900555B02 /* SVGPathConsumer.h in Headers */,
    1981419832                                B2227A590D00BF220071B782 /* SVGPathElement.h in Headers */,
     
    2227422292                                B2227A560D00BF220071B782 /* SVGParserUtilities.cpp in Sources */,
    2227522293                                8476C9EA11DF6A2900555B02 /* SVGPathBuilder.cpp in Sources */,
     22294                                8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */,
     22295                                8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */,
    2227622296                                B2227A580D00BF220071B782 /* SVGPathElement.cpp in Sources */,
    2227722297                                8476C9EF11DF6A5800555B02 /* SVGPathParser.cpp in Sources */,
  • trunk/WebCore/svg/SVGAllInOne.cpp

    r64898 r64909  
    109109#include "SVGParserUtilities.cpp"
    110110#include "SVGPathBuilder.cpp"
     111#include "SVGPathByteStreamBuilder.cpp"
     112#include "SVGPathByteStreamSource.cpp"
    111113#include "SVGPathElement.cpp"
    112114#include "SVGPathParser.cpp"
  • trunk/WebCore/svg/SVGPathParserFactory.cpp

    r64898 r64909  
    2424
    2525#include "SVGPathBuilder.h"
     26#include "SVGPathByteStreamBuilder.h"
     27#include "SVGPathByteStreamSource.h"
    2628#include "SVGPathParser.h"
    2729#include "SVGPathSegListBuilder.h"
     
    4446    if (!s_builder)
    4547        s_builder = new SVGPathSegListBuilder;
     48
     49    return s_builder;
     50}
     51
     52static SVGPathByteStreamBuilder* globalSVGPathByteStreamBuilder()
     53{
     54    static SVGPathByteStreamBuilder* s_builder = 0;
     55    if (!s_builder)
     56        s_builder = new SVGPathByteStreamBuilder;
    4657
    4758    return s_builder;
     
    95106}
    96107
     108bool SVGPathParserFactory::buildPathFromByteStream(SVGPathByteStream* stream, Path& result)
     109{
     110    ASSERT(stream);
     111    if (stream->isEmpty())
     112        return false;
     113
     114    SVGPathBuilder* builder = globalSVGPathBuilder();
     115    builder->setCurrentPath(&result);
     116
     117    SVGPathParser* parser = globalSVGPathParser();
     118    parser->setCurrentConsumer(builder);
     119
     120    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream);
     121    parser->setCurrentSource(source.get());
     122
     123    bool ok = parser->parsePathDataFromSource(NormalizedParsing);
     124    parser->setCurrentConsumer(0);
     125    parser->setCurrentSource(0);
     126    builder->setCurrentPath(0);
     127    return ok;
     128}
     129
    97130bool SVGPathParserFactory::buildSVGPathSegListFromString(const String& d, SVGPathSegList* result, PathParsingMode parsingMode)
    98131{
     
    117150}
    118151
     152bool SVGPathParserFactory::buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathSegList* result, PathParsingMode parsingMode)
     153{
     154    ASSERT(stream);
     155    ASSERT(result);
     156
     157    SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder();
     158    builder->setCurrentSVGPathSegList(result);
     159
     160    SVGPathParser* parser = globalSVGPathParser();
     161    parser->setCurrentConsumer(builder);
     162
     163    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream);
     164    parser->setCurrentSource(source.get());
     165
     166    bool ok = parser->parsePathDataFromSource(parsingMode);
     167    parser->setCurrentConsumer(0);
     168    parser->setCurrentSource(0);
     169    builder->setCurrentSVGPathSegList(0);
     170    return ok;
     171}
     172
     173PassOwnPtr<SVGPathByteStream> SVGPathParserFactory::createSVGPathByteStreamFromString(const String& d, PathParsingMode parsingMode, bool& ok)
     174{
     175    if (d.isEmpty())
     176        return false;
     177
     178    SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder();
     179    OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create();
     180    builder->setCurrentByteStream(stream.get());
     181
     182    SVGPathParser* parser = globalSVGPathParser();
     183    parser->setCurrentConsumer(builder);
     184
     185    OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d);
     186    parser->setCurrentSource(source.get());
     187
     188    ok = parser->parsePathDataFromSource(parsingMode);
     189    parser->setCurrentConsumer(0);
     190    parser->setCurrentSource(0);
     191    builder->setCurrentByteStream(0);
     192    return stream.release();
     193}
     194
    119195}
    120196
  • trunk/WebCore/svg/SVGPathParserFactory.h

    r64898 r64909  
    2626#include "SVGPathConsumer.h"
    2727#include "SVGPathSegList.h"
     28#include "SVGPathByteStream.h"
     29#include <OwnPtr.h>
    2830
    2931namespace WebCore {
     
    3436
    3537    bool buildPathFromString(const String&, Path&);
     38    bool buildPathFromByteStream(SVGPathByteStream*, Path& result);
    3639
    3740    bool buildSVGPathSegListFromString(const String&, SVGPathSegList*, PathParsingMode);
     41    bool buildSVGPathSegListFromByteStream(SVGPathByteStream*, SVGPathSegList*, PathParsingMode);
     42
     43    PassOwnPtr<SVGPathByteStream> createSVGPathByteStreamFromString(const String&, PathParsingMode, bool& ok);
    3844
    3945private:
Note: See TracChangeset for help on using the changeset viewer.