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 SkAnimateMaker_DEFINED michael@0: #define SkAnimateMaker_DEFINED michael@0: michael@0: // #define SK_DEBUG_ANIMATION_TIMING michael@0: michael@0: #include "SkAnimator.h" michael@0: #include "SkBitmap.h" michael@0: #include "SkIntArray.h" michael@0: #include "SkDisplayEvents.h" michael@0: #include "SkDisplayList.h" michael@0: #include "SkDisplayScreenplay.h" michael@0: #include "SkDisplayXMLParser.h" michael@0: #include "SkScript.h" michael@0: #include "SkString.h" michael@0: #include "SkTDict.h" michael@0: michael@0: // not sure where this little helper macro should go michael@0: michael@0: michael@0: class SkActive; michael@0: class SkAnimate; michael@0: class SkCanvas; michael@0: class SkDisplayable; michael@0: class SkDrawable; michael@0: class SkDump; michael@0: class SkEvent; michael@0: class SkEventSink; michael@0: class SkExtras; michael@0: class SkGroup; michael@0: class SkPaint; michael@0: class SkStream; michael@0: michael@0: class SkAnimateMaker { michael@0: public: michael@0: SkAnimateMaker(SkAnimator* animator, SkCanvas* canvas, SkPaint* paint); michael@0: ~SkAnimateMaker(); michael@0: void appendActive(SkActive* ); michael@0: void childrenAdd(SkDisplayable* child) { *fChildren.append() = child; } michael@0: void clearExtraPropertyCallBack(SkDisplayTypes type); michael@0: bool computeID(SkDisplayable* displayable, SkDisplayable* parent, SkString* newID); michael@0: SkDisplayable* createInstance(const char name[], size_t len); michael@0: bool decodeStream(SkStream* stream); michael@0: bool decodeURI(const char uri[]); michael@0: void delayEnable(SkApply* apply, SkMSec time); michael@0: void doDelayedEvent(); michael@0: bool doEvent(const SkEvent& event); michael@0: #ifdef SK_DUMP_ENABLED michael@0: void dump(const char* match); michael@0: #endif michael@0: int dynamicProperty(SkString& nameStr, SkDisplayable** ); michael@0: bool find(const char* str, SkDisplayable** displayablePtr) const { michael@0: return fIDs.find(str, displayablePtr); michael@0: } michael@0: bool find(const char* str, size_t len, SkDisplayable** displayablePtr) const { michael@0: return fIDs.find(str, len, displayablePtr); michael@0: } michael@0: bool findKey(SkDisplayable* displayable, const char** string) const { michael@0: return fIDs.findKey(displayable, string); michael@0: } michael@0: // bool find(SkString& string, SkDisplayable** displayablePtr) { michael@0: // return fIDs.find(string.c_str(), displayablePtr); michael@0: // } michael@0: SkAnimator* getAnimator() { return fAnimator; } michael@0: SkMSec getAppTime() const; // call caller to get current time michael@0: #ifdef SK_DEBUG michael@0: SkAnimator* getRoot(); michael@0: #endif michael@0: SkXMLParserError::ErrorCode getErrorCode() const { return fError.getErrorCode(); } michael@0: SkMSec getInTime() { return fDisplayList.getTime(); } michael@0: int getNativeCode() const { return fError.getNativeCode(); } michael@0: bool hasError() { return fError.hasError(); } michael@0: void helperAdd(SkDisplayable* trackMe); michael@0: void helperRemove(SkDisplayable* alreadyTracked); michael@0: void idsSet(const char* attrValue, size_t len, SkDisplayable* displayable) { michael@0: fIDs.set(attrValue, len, displayable); } michael@0: // void loadMovies(); michael@0: void notifyInval(); michael@0: void notifyInvalTime(SkMSec time); michael@0: void postOnEnd(SkAnimateBase* animate, SkMSec end); michael@0: void removeActive(SkActive* ); michael@0: void reset(); michael@0: bool resolveID(SkDisplayable* displayable, SkDisplayable* original); michael@0: void setEnableTime(SkMSec appTime, SkMSec expectedTime); michael@0: void setErrorCode(SkXMLParserError::ErrorCode err) { if (fError.hasError() == false) fError.INHERITED::setCode(err); } michael@0: void setErrorCode(SkDisplayXMLParserError::ErrorCode err) { if (fError.hasError() == false) fError.setCode(err); } michael@0: void setErrorNoun(const SkString& str) { if (fError.hasError() == false) fError.setNoun(str); } michael@0: void setErrorString(); michael@0: void setExtraPropertyCallBack(SkDisplayTypes type, SkScriptEngine::_propertyCallBack , void* userStorage); michael@0: void setID(SkDisplayable* displayable, const SkString& newID); michael@0: void setInnerError(SkAnimateMaker* maker, const SkString& str) { fError.setInnerError(maker, str); } michael@0: void setScriptError(const SkScriptEngine& ); michael@0: #ifdef SK_DEBUG michael@0: void validate() { fDisplayList.validate(); } michael@0: #else michael@0: void validate() {} michael@0: #endif michael@0: SkDisplayEvent* fActiveEvent; michael@0: SkMSec fAdjustedStart; michael@0: SkCanvas* fCanvas; michael@0: SkMSec fEnableTime; michael@0: int fEndDepth; // passed parameter to onEndElement michael@0: SkEvents fEvents; michael@0: SkDisplayList fDisplayList; michael@0: SkEventSinkID fHostEventSinkID; michael@0: SkMSec fMinimumInterval; michael@0: SkPaint* fPaint; michael@0: SkAnimateMaker* fParentMaker; michael@0: SkString fPrefix; michael@0: SkDisplayScreenplay fScreenplay; michael@0: const SkAnimator::Timeline* fTimeline; michael@0: SkBool8 fInInclude; michael@0: SkBool8 fInMovie; michael@0: SkBool8 fFirstScriptError; michael@0: #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING michael@0: SkMSec fDebugTimeBase; michael@0: #endif michael@0: #ifdef SK_DUMP_ENABLED michael@0: SkString fDumpAnimated; michael@0: SkBool8 fDumpEvents; michael@0: SkBool8 fDumpGConditions; michael@0: SkBool8 fDumpPosts; michael@0: #endif michael@0: private: michael@0: void deleteMembers(); michael@0: static bool GetStep(const char* token, size_t len, void* stepPtr, SkScriptValue* ); michael@0: SkAnimateMaker& operator=(SkAnimateMaker& ); michael@0: SkTDDisplayableArray fChildren; michael@0: SkTDDisplayableArray fDelayed; // SkApply that contain delayed enable events michael@0: SkDisplayXMLParserError fError; michael@0: SkString fErrorString; michael@0: SkTDArray fExtras; michael@0: SkString fFileName; michael@0: SkTDDisplayableArray fHelpers; // helper displayables michael@0: SkBool8 fLoaded; michael@0: SkTDDisplayableArray fMovies; michael@0: SkTDict fIDs; michael@0: SkAnimator* fAnimator; michael@0: friend class SkAdd; michael@0: friend class SkAnimateBase; michael@0: friend class SkDisplayXMLParser; michael@0: friend class SkAnimator; michael@0: friend class SkAnimatorScript; michael@0: friend class SkApply; michael@0: friend class SkDisplayMovie; michael@0: friend class SkDisplayType; michael@0: friend class SkEvents; michael@0: friend class SkGroup; michael@0: friend struct SkMemberInfo; michael@0: }; michael@0: michael@0: #endif // SkAnimateMaker_DEFINED