1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/svg/SkSVGClipPath.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 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 "SkSVGClipPath.h" 1.14 +#include "SkSVGParser.h" 1.15 +#include "SkSVGUse.h" 1.16 + 1.17 +DEFINE_SVG_NO_INFO(ClipPath) 1.18 + 1.19 +bool SkSVGClipPath::isDef() { 1.20 + return true; 1.21 +} 1.22 + 1.23 +bool SkSVGClipPath::isNotDef() { 1.24 + return false; 1.25 +} 1.26 + 1.27 +void SkSVGClipPath::translate(SkSVGParser& parser, bool defState) { 1.28 + parser._startElement("clip"); 1.29 + INHERITED::translate(parser, defState); 1.30 + SkASSERT(fChildren.count() == 1); 1.31 + SkSVGElement* child = *fChildren.begin(); 1.32 + SkASSERT(child->getType() == SkSVGType_Use); 1.33 + SkSVGUse* use = (SkSVGUse*) child; 1.34 + SkSVGElement* ref = NULL; 1.35 + const char* refStr = &use->f_xlink_href.c_str()[1]; 1.36 + SkASSERT(parser.getIDs().find(refStr, &ref)); 1.37 + SkASSERT(ref); 1.38 + if (ref->getType() == SkSVGType_Rect) 1.39 + parser._addAttribute("rectangle", refStr); 1.40 + else 1.41 + parser._addAttribute("path", refStr); 1.42 + parser._endElement(); 1.43 +}