1/* libs/graphics/animator/SkDrawPath.h
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#ifndef SkDrawPath_DEFINED
19#define SkDrawPath_DEFINED
20
21#include "SkBoundable.h"
22#include "SkIntArray.h"
23#include "SkMemberInfo.h"
24#include "SkPath.h"
25
26class SkDrawPath : public SkBoundable {
27    DECLARE_DRAW_MEMBER_INFO(Path);
28    SkDrawPath();
29    virtual ~SkDrawPath();
30    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
31    bool childHasID() { return SkToBool(fChildHasID); }
32    virtual bool childrenNeedDisposing() const;
33    virtual void dirty();
34    virtual bool draw(SkAnimateMaker& );
35    virtual SkDisplayable* getParent() const;
36#ifdef SK_DUMP_ENABLED
37    virtual void dump(SkAnimateMaker* );
38#endif
39    SkPath& getPath();
40    virtual bool getProperty(int index, SkScriptValue* value) const;
41    virtual bool setProperty(int index, SkScriptValue& value);
42    virtual void onEndElement(SkAnimateMaker& );
43    virtual void setChildHasID();
44    virtual bool setParent(SkDisplayable* parent);
45    virtual bool isPath() const { return true; }
46public:
47    SkPath fPath;
48protected:
49    void parseSVG();
50    SkString d;
51    SkTDPathPartArray fParts;
52    mutable SkScalar fLength;
53    SkDisplayable* fParent; // SkPolyToPoly or SkFromPath, for instance
54    SkBool8 fChildHasID;
55    SkBool8 fDirty;
56private:
57    typedef SkBoundable INHERITED;
58};
59
60class SkPolyline : public SkDrawPath {
61    DECLARE_MEMBER_INFO(Polyline);
62    virtual bool add(SkAnimateMaker& , SkDisplayable*) const;
63    virtual void onEndElement(SkAnimateMaker& );
64protected:
65    SkTDScalarArray points;
66private:
67    typedef SkDrawPath INHERITED;
68};
69
70class SkPolygon : public SkPolyline {
71    DECLARE_MEMBER_INFO(Polygon);
72    virtual void onEndElement(SkAnimateMaker& );
73private:
74    typedef SkPolyline INHERITED;
75};
76
77#endif // SkDrawPath_DEFINED
78