michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkDisplayable_DEFINED michael@0: #define SkDisplayable_DEFINED michael@0: michael@0: #include "SkOperand.h" michael@0: #ifdef SK_DEBUG michael@0: #include "SkString.h" michael@0: #endif michael@0: #include "SkIntArray.h" michael@0: #include "SkRect.h" michael@0: #include "SkTDArray.h" michael@0: michael@0: class SkAnimateMaker; michael@0: class SkApply; michael@0: class SkEvents; michael@0: struct SkMemberInfo; michael@0: struct SkScriptValue; michael@0: class SkOpArray; // compiled scripting experiment michael@0: union SkOperand2; // compiled scripting experiment michael@0: michael@0: class SkDisplayable { michael@0: public: michael@0: #ifdef SK_DEBUG michael@0: SkDisplayable(); michael@0: #endif michael@0: virtual ~SkDisplayable(); michael@0: virtual bool addChild(SkAnimateMaker& , SkDisplayable* child); michael@0: virtual bool canContainDependents() const; michael@0: virtual bool childrenNeedDisposing() const; michael@0: virtual void clearBounder(); michael@0: virtual bool contains(SkDisplayable* ); michael@0: virtual SkDisplayable* contains(const SkString& ); michael@0: virtual SkDisplayable* deepCopy(SkAnimateMaker* ); michael@0: virtual void dirty(); michael@0: #ifdef SK_DUMP_ENABLED michael@0: virtual void dump(SkAnimateMaker* ); michael@0: void dumpAttrs(SkAnimateMaker* ); michael@0: void dumpBase(SkAnimateMaker* ); michael@0: void dumpChildren(SkAnimateMaker* maker, bool closedAngle = false ); michael@0: void dumpEnd(SkAnimateMaker* ); michael@0: virtual void dumpEvents(); michael@0: #endif michael@0: virtual bool enable( SkAnimateMaker& ); michael@0: virtual void enableBounder(); michael@0: virtual void executeFunction(SkDisplayable* , int functionIndex, michael@0: SkTDArray& , SkDisplayTypes , SkScriptValue* ); michael@0: void executeFunction(SkDisplayable* , const SkMemberInfo* , michael@0: SkTypedArray* , SkScriptValue* ); michael@0: virtual void executeFunction2(SkDisplayable* , int functionIndex, michael@0: SkOpArray* params , SkDisplayTypes , SkOperand2* ); // compiled scripting experiment michael@0: virtual void getBounds(SkRect* ); michael@0: virtual const SkFunctionParamType* getFunctionsParameters(); michael@0: virtual const SkMemberInfo* getMember(int index); michael@0: virtual const SkMemberInfo* getMember(const char name[]); michael@0: const SkFunctionParamType* getParameters(const SkMemberInfo* info, michael@0: int* paramCount); michael@0: virtual SkDisplayable* getParent() const; michael@0: virtual bool getProperty(int index, SkScriptValue* value) const; michael@0: virtual bool getProperty2(int index, SkOperand2* value) const; // compiled scripting experiment michael@0: virtual SkDisplayTypes getType() const; michael@0: virtual bool hasEnable() const; michael@0: bool isAnimate() const { michael@0: SkDisplayTypes type = getType(); michael@0: return type == SkType_Animate || type == SkType_Set; } michael@0: bool isApply() const { return getType() == SkType_Apply; } michael@0: bool isColor() const { return getType() == SkType_Color; } michael@0: virtual bool isDrawable() const; michael@0: bool isGroup() const { return getType() == SkType_Group || michael@0: getType() == SkType_Save || getType() == SkType_DrawTo || michael@0: getType() == SkType_SaveLayer; } michael@0: bool isMatrix() const { return getType() == SkType_Matrix; } michael@0: virtual bool isPaint() const { return getType() == SkType_Paint; } michael@0: virtual bool isPath() const { return false; } michael@0: bool isPost() const { return getType() == SkType_Post; } michael@0: virtual void onEndElement(SkAnimateMaker& ); michael@0: virtual const SkMemberInfo* preferredChild(SkDisplayTypes type); michael@0: virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* ); michael@0: virtual void setChildHasID(); michael@0: virtual bool setParent(SkDisplayable* ); michael@0: virtual bool setProperty(int index, SkScriptValue& ); michael@0: void setReference(const SkMemberInfo* info, SkDisplayable* ref); michael@0: #ifdef SK_DEBUG michael@0: bool isDataInput() const { return getType() == SkType_DataInput; }; michael@0: bool isEvent() const { return getType() == SkType_Event; } michael@0: virtual bool isMatrixPart() const { return false; } michael@0: bool isPatch() const { return getType() == SkType_3D_Patch; } michael@0: virtual bool isPaintPart() const { return false; } michael@0: virtual bool isPathPart() const { return false; } michael@0: virtual void validate(); michael@0: SkString _id; michael@0: const char* id; michael@0: // static int fAllocationCount; michael@0: static SkTDDisplayableArray fAllocations; michael@0: #else michael@0: void validate() {} michael@0: #endif michael@0: #ifdef SK_DUMP_ENABLED michael@0: private: michael@0: void dumpValues(const SkMemberInfo* info, SkDisplayTypes type, SkOperand op, SkOperand blankOp, michael@0: SkOperand op2, SkOperand blankOp2); michael@0: #endif michael@0: }; michael@0: michael@0: #endif // SkDisplayable_DEFINED