1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkSVGPath.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkSVGParser.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst SkSVGAttribute SkSVGPath::gAttributes[] = {
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SVG_ATTRIBUTE(d)
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comDEFINE_SVG_INFO(Path)
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkSVGPath::translate(SkSVGParser& parser, bool defState) {
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    parser._startElement("path");
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    INHERITED::translate(parser, defState);
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool hasMultiplePaths = false;
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const char* firstZ = strchr(f_d.c_str(), 'z');
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (firstZ != NULL) {
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        firstZ++; // skip over 'z'
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        while (*firstZ == ' ')
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            firstZ++;
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        hasMultiplePaths = *firstZ != '\0';
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (hasMultiplePaths) {
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkString& fillRule = parser.getPaintLast(SkSVGPaint::kFillRule);
32d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        if (fillRule.size() > 0)
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            parser._addAttribute("fillType", fillRule.equals("evenodd") ? "evenOdd" : "winding");
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SVG_ADD_ATTRIBUTE(d);
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    parser._endElement();
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
38