1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkDisplayable_DEFINED
11 #define SkDisplayable_DEFINED
12 
13 #include "SkOperand.h"
14 #ifdef SK_DEBUG
15 #include "SkString.h"
16 #endif
17 #include "SkIntArray.h"
18 #include "SkRect.h"
19 #include "SkTDArray.h"
20 
21 class SkAnimateMaker;
22 class SkApply;
23 class SkEvents;
24 struct SkMemberInfo;
25 struct SkScriptValue;
26 class SkOpArray; // compiled scripting experiment
27 union SkOperand2; // compiled scripting experiment
28 
29 class SkDisplayable {
30 public:
31 #ifdef SK_DEBUG
32     SkDisplayable();
33 #endif
34     virtual ~SkDisplayable();
35     virtual bool addChild(SkAnimateMaker& , SkDisplayable* child);
36     virtual bool canContainDependents() const;
37     virtual bool childrenNeedDisposing() const;
38     virtual void clearBounder();
39     virtual bool contains(SkDisplayable* );
40     virtual SkDisplayable* contains(const SkString& );
41     virtual SkDisplayable* deepCopy(SkAnimateMaker* );
42     virtual void dirty();
43 #ifdef SK_DUMP_ENABLED
44     virtual void dump(SkAnimateMaker* );
45     void dumpAttrs(SkAnimateMaker* );
46     void dumpBase(SkAnimateMaker* );
47     void dumpChildren(SkAnimateMaker* maker, bool closedAngle = false );
48     void dumpEnd(SkAnimateMaker* );
49     virtual void dumpEvents();
50 #endif
51     virtual bool enable( SkAnimateMaker& );
52     virtual void enableBounder();
53     virtual void executeFunction(SkDisplayable* , int functionIndex,
54         SkTDArray<SkScriptValue>& , SkDisplayTypes , SkScriptValue* );
55     void executeFunction(SkDisplayable* , const SkMemberInfo* ,
56         SkTypedArray* , SkScriptValue* );
57     virtual void executeFunction2(SkDisplayable* , int functionIndex,
58         SkOpArray* params , SkDisplayTypes , SkOperand2* ); // compiled scripting experiment
59     virtual void getBounds(SkRect* );
60     virtual const SkFunctionParamType* getFunctionsParameters();
61     virtual const SkMemberInfo* getMember(int index);
62     virtual const SkMemberInfo* getMember(const char name[]);
63     const SkFunctionParamType* getParameters(const SkMemberInfo* info,
64         int* paramCount);
65     virtual SkDisplayable* getParent() const;
66     virtual bool getProperty(int index, SkScriptValue* value) const;
67     virtual bool getProperty2(int index, SkOperand2* value) const;    // compiled scripting experiment
68     virtual SkDisplayTypes getType() const;
69     virtual bool hasEnable() const;
isAnimate()70     bool isAnimate() const {
71         SkDisplayTypes type = getType();
72         return type == SkType_Animate || type == SkType_Set; }
isApply()73     bool isApply() const { return getType() == SkType_Apply; }
isColor()74     bool isColor() const { return getType() == SkType_Color; }
75     virtual bool isDrawable() const;
isGroup()76     bool isGroup() const { return getType() == SkType_Group ||
77         getType() == SkType_Save || getType() == SkType_DrawTo ||
78         getType() == SkType_SaveLayer; }
isMatrix()79     bool isMatrix() const { return getType() == SkType_Matrix; }
isPaint()80     virtual bool isPaint() const { return getType() == SkType_Paint; }
isPath()81     virtual bool isPath() const { return false; }
isPost()82     bool isPost() const { return getType() == SkType_Post; }
83     virtual void onEndElement(SkAnimateMaker& );
84     virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
85     virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
86     virtual void setChildHasID();
87     virtual bool setParent(SkDisplayable* );
88     virtual bool setProperty(int index, SkScriptValue& );
89     void setReference(const SkMemberInfo* info, SkDisplayable* ref);
90 #ifdef SK_DEBUG
isDataInput()91     bool isDataInput() const { return getType() == SkType_DataInput; };
isEvent()92     bool isEvent() const { return getType() == SkType_Event; }
isMatrixPart()93     virtual bool isMatrixPart() const { return false; }
isPatch()94     bool isPatch() const { return getType() == SkType_3D_Patch; }
isPaintPart()95     virtual bool isPaintPart() const { return false; }
isPathPart()96     virtual bool isPathPart() const { return false; }
97     virtual void validate();
98     SkString _id;
99     const char* id;
100 //  static int fAllocationCount;
101     static SkTDDisplayableArray fAllocations;
102 #else
validate()103     void validate() {}
104 #endif
105 #ifdef SK_DUMP_ENABLED
106 private:
107     void dumpValues(const SkMemberInfo* info, SkDisplayTypes type, SkOperand op, SkOperand blankOp,
108         SkOperand op2, SkOperand blankOp2);
109 #endif
110 };
111 
112 #endif // SkDisplayable_DEFINED
113