gfx/skia/trunk/src/svg/SkSVGPath.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/svg/SkSVGPath.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2006 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#include "SkSVGPath.h"
    1.14 +#include "SkSVGParser.h"
    1.15 +
    1.16 +const SkSVGAttribute SkSVGPath::gAttributes[] = {
    1.17 +    SVG_ATTRIBUTE(d)
    1.18 +};
    1.19 +
    1.20 +DEFINE_SVG_INFO(Path)
    1.21 +
    1.22 +void SkSVGPath::translate(SkSVGParser& parser, bool defState) {
    1.23 +    parser._startElement("path");
    1.24 +    INHERITED::translate(parser, defState);
    1.25 +    bool hasMultiplePaths = false;
    1.26 +    const char* firstZ = strchr(f_d.c_str(), 'z');
    1.27 +    if (firstZ != NULL) {
    1.28 +        firstZ++; // skip over 'z'
    1.29 +        while (*firstZ == ' ')
    1.30 +            firstZ++;
    1.31 +        hasMultiplePaths = *firstZ != '\0';
    1.32 +    }
    1.33 +    if (hasMultiplePaths) {
    1.34 +        SkString& fillRule = parser.getPaintLast(SkSVGPaint::kFillRule);
    1.35 +        if (fillRule.size() > 0)
    1.36 +            parser._addAttribute("fillType", fillRule.equals("evenodd") ? "evenOdd" : "winding");
    1.37 +    }
    1.38 +    SVG_ADD_ATTRIBUTE(d);
    1.39 +    parser._endElement();
    1.40 +}

mercurial