blob: 4fd47abc3724ee02c60b517182d6b3ac45d75a84 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
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
21class SkAnimateMaker;
22class SkApply;
23class SkEvents;
24struct SkMemberInfo;
25struct SkScriptValue;
26class SkOpArray; // compiled scripting experiment
27union SkOperand2; // compiled scripting experiment
28
29class SkDisplayable {
30public:
31#ifdef SK_DEBUG
32 SkDisplayable();
33#endif
34 virtual ~SkDisplayable();
tfarina@chromium.org1d3c4112012-12-03 14:38:08 +000035 virtual bool addChild(SkAnimateMaker& , SkDisplayable* child);
reed@android.com8a1c16f2008-12-17 15:59:43 +000036 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();
rmistry@google.comd6176b02012-08-23 18:14:13 +000053 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,
reed@android.com8a1c16f2008-12-17 15:59:43 +000058 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[]);
rmistry@google.comd6176b02012-08-23 18:14:13 +000063 const SkFunctionParamType* getParameters(const SkMemberInfo* info,
reed@android.com8a1c16f2008-12-17 15:59:43 +000064 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;
rmistry@google.comd6176b02012-08-23 18:14:13 +000070 bool isAnimate() const {
71 SkDisplayTypes type = getType();
reed@android.com8a1c16f2008-12-17 15:59:43 +000072 return type == SkType_Animate || type == SkType_Set; }
73 bool isApply() const { return getType() == SkType_Apply; }
74 bool isColor() const { return getType() == SkType_Color; }
75 virtual bool isDrawable() const;
rmistry@google.comd6176b02012-08-23 18:14:13 +000076 bool isGroup() const { return getType() == SkType_Group ||
reed@android.com8a1c16f2008-12-17 15:59:43 +000077 getType() == SkType_Save || getType() == SkType_DrawTo ||
78 getType() == SkType_SaveLayer; }
79 bool isMatrix() const { return getType() == SkType_Matrix; }
80 virtual bool isPaint() const { return getType() == SkType_Paint; }
81 virtual bool isPath() const { return false; }
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
reed@google.com8d0b5772011-06-24 13:07:31 +000091 bool isDataInput() const { return getType() == SkType_DataInput; };
reed@android.com8a1c16f2008-12-17 15:59:43 +000092 bool isEvent() const { return getType() == SkType_Event; }
93 virtual bool isMatrixPart() const { return false; }
94 bool isPatch() const { return getType() == SkType_3D_Patch; }
95 virtual bool isPaintPart() const { return false; }
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
103 void validate() {}
104#endif
105#ifdef SK_DUMP_ENABLED
106private:
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