blob: bd71429da736911e878210a8f08866dd94be4370 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/* libs/graphics/svg/SkSVGClipPath.cpp
2**
3** Copyright 2006, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#include "SkSVGClipPath.h"
19#include "SkSVGParser.h"
20#include "SkSVGUse.h"
21
22DEFINE_SVG_NO_INFO(ClipPath)
23
24bool SkSVGClipPath::isDef() {
25 return true;
26}
27
28bool SkSVGClipPath::isNotDef() {
29 return false;
30}
31
32void SkSVGClipPath::translate(SkSVGParser& parser, bool defState) {
33 parser._startElement("clip");
34 INHERITED::translate(parser, defState);
35 SkASSERT(fChildren.count() == 1);
36 SkSVGElement* child = *fChildren.begin();
37 SkASSERT(child->getType() == SkSVGType_Use);
38 SkSVGUse* use = (SkSVGUse*) child;
39 SkSVGElement* ref;
40 const char* refStr = &use->f_xlink_href.c_str()[1];
41 SkASSERT(parser.getIDs().find(refStr, &ref));
42 SkASSERT(ref);
43 if (ref->getType() == SkSVGType_Rect)
44 parser._addAttribute("rectangle", refStr);
45 else
46 parser._addAttribute("path", refStr);
47 parser._endElement();
48}