• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libs/graphics/animator/SkDisplayable.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 SkDisplayable_DEFINED
19 #define SkDisplayable_DEFINED
20 
21 #include "SkOperand.h"
22 #ifdef SK_DEBUG
23 #include "SkString.h"
24 #endif
25 #include "SkIntArray.h"
26 #include "SkRect.h"
27 #include "SkTDArray.h"
28 
29 class SkAnimateMaker;
30 class SkApply;
31 class SkEvents;
32 struct SkMemberInfo;
33 struct SkScriptValue;
34 class SkOpArray; // compiled scripting experiment
35 union SkOperand2; // compiled scripting experiment
36 
37 class SkDisplayable {
38 public:
39 #ifdef SK_DEBUG
40     SkDisplayable();
41 #endif
42     virtual ~SkDisplayable();
43     virtual bool add(SkAnimateMaker& , SkDisplayable* child);
44     virtual bool canContainDependents() const;
45     virtual bool childrenNeedDisposing() const;
46     virtual void clearBounder();
47     virtual bool contains(SkDisplayable* );
48     virtual SkDisplayable* contains(const SkString& );
49     virtual SkDisplayable* deepCopy(SkAnimateMaker* );
50     virtual void dirty();
51 #ifdef SK_DUMP_ENABLED
52     virtual void dump(SkAnimateMaker* );
53     void dumpAttrs(SkAnimateMaker* );
54     void dumpBase(SkAnimateMaker* );
55     void dumpChildren(SkAnimateMaker* maker, bool closedAngle = false );
56     void dumpEnd(SkAnimateMaker* );
57     virtual void dumpEvents();
58 #endif
59     virtual bool enable( SkAnimateMaker& );
60     virtual void enableBounder();
61     virtual void executeFunction(SkDisplayable* , int functionIndex,
62         SkTDArray<SkScriptValue>& , SkDisplayTypes , SkScriptValue* );
63     void executeFunction(SkDisplayable* , const SkMemberInfo* ,
64         SkTypedArray* , SkScriptValue* );
65     virtual void executeFunction2(SkDisplayable* , int functionIndex,
66         SkOpArray* params , SkDisplayTypes , SkOperand2* ); // compiled scripting experiment
67     virtual void getBounds(SkRect* );
68     virtual const SkFunctionParamType* getFunctionsParameters();
69     virtual const SkMemberInfo* getMember(int index);
70     virtual const SkMemberInfo* getMember(const char name[]);
71     const SkFunctionParamType* getParameters(const SkMemberInfo* info,
72         int* paramCount);
73     virtual SkDisplayable* getParent() const;
74     virtual bool getProperty(int index, SkScriptValue* value) const;
75     virtual bool getProperty2(int index, SkOperand2* value) const;    // compiled scripting experiment
76     virtual SkDisplayTypes getType() const;
77     virtual bool hasEnable() const;
isAnimate()78     bool isAnimate() const {
79         SkDisplayTypes type = getType();
80         return type == SkType_Animate || type == SkType_Set; }
isApply()81     bool isApply() const { return getType() == SkType_Apply; }
isColor()82     bool isColor() const { return getType() == SkType_Color; }
83     virtual bool isDrawable() const;
isGroup()84     bool isGroup() const { return getType() == SkType_Group ||
85         getType() == SkType_Save || getType() == SkType_DrawTo ||
86         getType() == SkType_SaveLayer; }
isMatrix()87     bool isMatrix() const { return getType() == SkType_Matrix; }
isPaint()88     virtual bool isPaint() const { return getType() == SkType_Paint; }
isPath()89     virtual bool isPath() const { return false; }
isPost()90     bool isPost() const { return getType() == SkType_Post; }
91     virtual void onEndElement(SkAnimateMaker& );
92     virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
93     virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
94     virtual void setChildHasID();
95     virtual bool setParent(SkDisplayable* );
96     virtual bool setProperty(int index, SkScriptValue& );
97     void setReference(const SkMemberInfo* info, SkDisplayable* ref);
98 #ifdef SK_DEBUG
isData()99     bool isData() const { return getType() == SkType_Data; };
isEvent()100     bool isEvent() const { return getType() == SkType_Event; }
isMatrixPart()101     virtual bool isMatrixPart() const { return false; }
isPatch()102     bool isPatch() const { return getType() == SkType_3D_Patch; }
isPaintPart()103     virtual bool isPaintPart() const { return false; }
isPathPart()104     virtual bool isPathPart() const { return false; }
105     virtual void validate();
106     SkString _id;
107     const char* id;
108 //  static int fAllocationCount;
109     static SkTDDisplayableArray fAllocations;
110 #else
validate()111     void validate() {}
112 #endif
113 #ifdef SK_DUMP_ENABLED
114 private:
115     void dumpValues(const SkMemberInfo* info, SkDisplayTypes type, SkOperand op, SkOperand blankOp,
116         SkOperand op2, SkOperand blankOp2);
117 #endif
118 };
119 
120 #endif // SkDisplayable_DEFINED
121