epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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(); |
tfarina@chromium.org | 1d3c411 | 2012-12-03 14:38:08 +0000 | [diff] [blame] | 35 | virtual bool addChild(SkAnimateMaker& , SkDisplayable* child); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 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, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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[]); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 63 | const SkFunctionParamType* getParameters(const SkMemberInfo* info, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 70 | bool isAnimate() const { |
| 71 | SkDisplayTypes type = getType(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 72 | 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.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 76 | bool isGroup() const { return getType() == SkType_Group || |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 77 | 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.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 91 | bool isDataInput() const { return getType() == SkType_DataInput; }; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 92 | 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 |
| 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 |