From 9e73b858323949d3e9ec57119e0432a95fbe2f8b Mon Sep 17 00:00:00 2001 From: brly Date: Mar 23 2016 14:32:56 +0000 Subject: Remove TFlash::Imp class and sources/common files --- diff --git a/toonz/sources/common/flash/F3SDK.h b/toonz/sources/common/flash/F3SDK.h deleted file mode 100644 index 0ee0296..0000000 --- a/toonz/sources/common/flash/F3SDK.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: F3SDK.h - - This header-file includes all the header-files of Flash File Format SDK - low-level manager. - -****************************************************************************************/ - -#ifndef F3SDK_INCLUDED -#define F3SDK_INCLUDED - -#include "Macromedia.h" -#include "FObj.h" -#include "FAction.h" -#include "FCT.h" -#include "FDT.h" -#include "FDTBitmaps.h" -#include "FDTButtons.h" -#include "FDTFonts.h" -#include "FDTShapes.h" -#include "FDTSounds.h" -#include "FDTSprite.h" -#include "FDTText.h" -#include "FPrimitive.h" - -#endif diff --git a/toonz/sources/common/flash/FAction.cpp b/toonz/sources/common/flash/FAction.cpp deleted file mode 100644 index b153a1d..0000000 --- a/toonz/sources/common/flash/FAction.cpp +++ /dev/null @@ -1,842 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FAction.cpp - - This source file contains the definition for the low-level action-related functions, - grouped by classes, which are all derived from class FAction (except FActionCondition): - - - Class Member Function - - FActionGetURL FActionGetURL(FString*, FString*); - ~FActionGetURL(); - void WriteToSWFStream(FSWFStream*); - - FActionGetURL2 FActionGetURL2(U8); - void WriteToSWFStream(FSWFStream*); - - FActionGotoFrame FActionGotoFrame(U16); - void WriteToSWFStream(FSWFStream*); - - FActionGotoFrame2 FActionGotoFrame2(U8); - void WriteToSWFStream(FSWFStream*); - - FActionGotoLabel FActionGotoLabel(FString*); - ~FActionGotoLabel(); - void WriteToSWFStream(FSWFStream*); - - FActionIf FActionIf(S16); - void WriteToSWFStream(FSWFStream*); - - FActionJump FActionJump(S16); - void WriteToSWFStream(FSWFStream*); - - FActionPush FActionPush(FString*); - FActionPush(FLOAT); - void WriteToSWFStream(FSWFStream*); - - FActionSetTarget FActionSetTarget(FString*); - ~FActionSetTarget(); - void WriteToSWFStream(FSWFStream*); - - FActionWaitForFrame FActionWaitForFrame(U16, U16); - void WriteToSWFStream(FSWFStream*); - - FActionWaitForFrame2 FActionWaitForFrame2(U8); - void WriteToSWFStream(FSWFStream*); - - FActionCondition FActionCondition(); - ~FActionCondition(); - Clear(); - AddActionRecord(FActionRecord*); - AddKeyCode(U32); - AddCondition(U16); - void WriteToSWFStream(FSWFStream*); - void WriteToSWFStream(FSWFStream*, int); - - - Functions of these classes have not been implemented yet: - - class FActionAdd; - class FActionAnd; - class FActionAsciiToChar; - class FActionCall; - class FActionCharToAscii; - class FActionCloneSprite; - class FActionDivide; - class FActionEndDrag; - class FActionEquals; - class FActionGetProperty; - class FActionGetTime; - class FActionGetVariable; - class FActionLess; - class FActionMBAsciiToChar; - class FActionMBCharToAscii; - class FActionMBStringExtract; - class FActionMBStringLength; - class FActionMultiply; - class FActionNextFrame; - class FActionNot; - class FActionOr; - class FActionPlay; - class FActionPop; - class FActionPrevFrame; - class FActionRandomNumber; - class FActionRemoveSprite; - class FActionSetProperty; - class FActionSetTarget2; - class FActionSetVariable; - class FActionStartDrag; - class FActionStop; - class FActionStopSounds; - class FActionStringAdd; - class FActionStringEquals; - class FActionStringExtract; - class FActionStringLength; - class FActionStringLess; - class FActionSubtract; - class FActionToggleQuality; - class FActionToInteger; - class FActionTrace. - - -****************************************************************************************/ - -#include "FPrimitive.h" -#include "FAction.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionUnparsed ---------------------------------------------------------- - -FActionUnparsed::FActionUnparsed(UCHAR _code, USHORT _length, UCHAR *_data) : code(_code) -{ - if (code >= 0x80) - length = _length, data = _data; - else - length = 0, data = 0; -} - -void FActionUnparsed::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->WriteByte(code); - if (code >= 0x80) { - _SWFStream->WriteWord(length); - for (int i = 0; i < length; i++) - _SWFStream->WriteByte(data[i]); - } -} -////////////////////////////////////////////////////////////////////////////////////// - -FActionGetURL::FActionGetURL(FString *_url, FString *_window) -{ - url = _url; - window = _window; -} - -FActionGetURL::~FActionGetURL() -{ - delete url; - delete window; -} - -void FActionGetURL::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - url->WriteToSWFStream(&body, true); - - window->WriteToSWFStream(&body, true); - - _SWFStream->WriteByte(sactionGetURL); - _SWFStream->WriteWord(body.Size()); - - _SWFStream->Append(&body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionGetURL2 --------------------------------------------------------- - -FActionGetURL2::FActionGetURL2(U8 _method) -{ - method = _method; -} - -void FActionGetURL2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //sactionEquals: enumerated in "Macromedia.h" - _SWFStream->WriteByte(sactionGetURL2); - - //write the length since the high bit is set in the action tag - _SWFStream->WriteWord(1); - - //write the method - _SWFStream->WriteByte(method); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionGotoFrame ------------------------------------------------------- - -FActionGotoFrame::FActionGotoFrame(U16 _frameIndex) -{ - frameIndex = _frameIndex; -} - -void FActionGotoFrame::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //enumerated constant (see "Macromedia.h") - _SWFStream->WriteByte(sactionGotoFrame); - - _SWFStream->WriteWord(2); - - _SWFStream->WriteWord((U32)frameIndex); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionGotoFrame2 ------------------------------------------------------ - -// Constructor takes in play flag. - -FActionGotoFrame2::FActionGotoFrame2(U8 _play) -{ - - play = _play; -} - -void FActionGotoFrame2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //sactionGotoFrame2: enumerated in "Macromedia.h" - _SWFStream->WriteByte(sactionGotoFrame2); - - //write the length since the high bit is set in the action tag - _SWFStream->WriteWord(1); - - //write the play flag - _SWFStream->WriteByte(play); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionGotoLabel ------------------------------------------------------- - -FActionGotoLabel::FActionGotoLabel(FString *_label) -{ - label = _label; -} - -FActionGotoLabel::~FActionGotoLabel() -{ - - delete label; -} - -void FActionGotoLabel::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //enumerated type (see "Macromedia.h") - _SWFStream->WriteByte(sactionGotoLabel); - - label->WriteToSWFStream(_SWFStream, true); -} - -/////////////////////////////////////////////////////////////////////////////// -// -------- FActionIf ------------------------------------------------------- - -// Constructor records the branch offset. - -FActionIf::FActionIf(S16 _branchOffset) -{ - - branchOffset = _branchOffset; -} - -void FActionIf::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //enumerations in "Macromedia.h" - _SWFStream->WriteByte(sactionIf); - - //write the length since the high bit is set in the action tag - _SWFStream->WriteWord(2); - - //write the offset - _SWFStream->WriteWord((U32)branchOffset); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionJump ------------------------------------------------------- - -// Constructor records the branch offset. - -FActionJump::FActionJump(S16 _branchOffset) -{ - - branchOffset = _branchOffset; -} - -void FActionJump::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //enumerations in "Macromedia.h" - _SWFStream->WriteByte(sactionJump); - - //write the length since the high bit is set in the action tag - _SWFStream->WriteWord(2); - - //write the offset - _SWFStream->WriteWord((U32)branchOffset); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionPush ------------------------------------------------------- -// Constructor for string push. - -FActionPush::FActionPush(FString *_string) -{ - - string = _string; - number = 0; - cValue = 0; - dValue = 0; - type = 0; -} - -FActionPush::FActionPush(FLOAT _number) -{ - - number = _number; - string = 0; - cValue = 0; - dValue = 0; - type = 1; -} - -// Constructor for float push. - -FActionPush::FActionPush(U8 _type, FLOAT _number) -{ - - number = _number; - string = 0; - cValue = 0; - dValue = 0; - type = _type; -} - -FActionPush::FActionPush(double _number) -{ - number = 0; - string = 0; - cValue = 0; - dValue = _number; - type = 6; -} - -FActionPush::FActionPush(U8 _type, U8 _value) -{ - number = 0; - string = 0; - cValue = _value; - dValue = 0; - type = _type; -} - -void FActionPush::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //sactionPush: enumerated in "Macromedia.h" - _SWFStream->WriteByte(sactionPush); - - U16 size = 0; - FSWFStream temp; - // un byte c'e' sempre per memorizzare il tipo - switch (type) { - case 0: - size = 1 + string->Length() + 1; //bisogna tener conto che la deve essere null terminated - string->WriteToSWFStream(&temp, true); - break; - case 1: - case 7: - size = 5; - temp.WriteDWord((U32)number); - break; - case 4: - case 5: - case 8: - size = 2; - temp.WriteByte(cValue); - break; - case 6: { - size = 9; - U8 *bPtr = (U8 *)&dValue; -#ifndef __LP64__ - temp.WriteByte((U32)(bPtr + 4)); - temp.WriteByte((U32)(bPtr + 5)); - temp.WriteByte((U32)(bPtr + 6)); - temp.WriteByte((U32)(bPtr + 7)); - temp.WriteByte((U32)bPtr); - temp.WriteByte((U32)(bPtr + 1)); - temp.WriteByte((U32)(bPtr + 2)); - temp.WriteByte((U32)(bPtr + 3)); -#else - typedef unsigned long U64; - temp.WriteByte((U64)(bPtr + 4)); - temp.WriteByte((U64)(bPtr + 5)); - temp.WriteByte((U64)(bPtr + 6)); - temp.WriteByte((U64)(bPtr + 7)); - temp.WriteByte((U64)bPtr); - temp.WriteByte((U64)(bPtr + 1)); - temp.WriteByte((U64)(bPtr + 2)); - temp.WriteByte((U64)(bPtr + 3)); -#endif - break; - } - default: - break; - } - _SWFStream->WriteWord(size); - - //write the type - _SWFStream->WriteByte((U32)type); - - //write the object to be pushed - _SWFStream->Append(&temp); -} - -/*//originale -// Writes to the given FSWFStream. -void FActionPush::WriteToSWFStream(FSWFStream *_SWFStream){ - - //sactionPush: enumerated in "Macromedia.h" - _SWFStream->WriteByte(sactionPush); - - // un byte c'e' sempre per memorizzare il tipo - //since tag's high bit is set, must write the length - if ( type == 0 ) { - _SWFStream->WriteWord( 1 + (U32)string->Length() + 1); //bisogna tener conto che la deve essere null terminated - } else { - _SWFStream->WriteWord( 1 + 4 ); //scrive una Dword => 4 bytes - } - - //write the type - _SWFStream->WriteByte((U32)type); - - //write the object to be pushed - if ( type == 0 ) { - string->WriteToSWFStream(_SWFStream, true); - } else { - _SWFStream->WriteDWord( (U32)number ); - } -} -*/ - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionSetTarget ------------------------------------------------------- -FActionSetTarget::FActionSetTarget(FString *_targetName) -{ - targetName = _targetName; -} - -FActionSetTarget::~FActionSetTarget() -{ - delete targetName; -} - -void FActionSetTarget::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->WriteByte(sactionSetTarget); - _SWFStream->WriteWord(targetName->Length() + 1); - targetName->WriteToSWFStream(_SWFStream, true); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionWaitForFrame ---------------------------------------------------- -FActionWaitForFrame::FActionWaitForFrame(U16 index, U16 count) -{ - // frameIndex = frameIndex; - // skipCount = skipCount; - frameIndex = index; // fixed from DV - skipCount = count; -} - -void FActionWaitForFrame::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - // enumerations in "Macromedia.h" - _SWFStream->WriteByte(sactionWaitForFrame); - - _SWFStream->WriteWord(3); - _SWFStream->WriteWord((U32)frameIndex); - _SWFStream->WriteByte((U32)skipCount); -} - -/////////////////////////////////////////////////////////////////////////////////////// -// -------- FActionWaitForFrame2 ---------------------------------------------------- - -FActionWaitForFrame2::FActionWaitForFrame2(U8 _skipCount) -{ - - skipCount = _skipCount; -} - -void FActionWaitForFrame2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - // enumerations in "Macromedia.h" - _SWFStream->WriteByte(sactionWaitForFrame2); - - //write the length since high bit in tag id is set - _SWFStream->WriteWord(1); - - //write the skip count - _SWFStream->WriteByte(skipCount); -} - -// Constructor. Initially, there are no actions or conditions so the conditions flag -// equals zero, and the action record list is empty. - -FActionCondition::FActionCondition() -{ - - conditionFlags = 0; -} - -// Deletes all of the action records in the action record list. - -FActionCondition::~FActionCondition() -{ - - while (!actionRecordList.empty()) { - - delete actionRecordList.front(); - actionRecordList.pop_front(); - } -} - -void FActionCondition::Clear() -{ - while (!actionRecordList.empty()) { - - delete actionRecordList.front(); - actionRecordList.pop_front(); - } -} - -// Adds an action record to the action record list - -void FActionCondition::AddActionRecord(FActionRecord *_ActionRecord) -{ - - actionRecordList.push_back(_ActionRecord); -} - -// Adds the key code information to the action condition (Flash 4). - -void FActionCondition::AddKeyCode(U32 keyCode) -{ - - conditionFlags |= (keyCode << 9); -} - -// Adds a condition to the list of conditions for which the actions in the action record list -// will be taken. Sees what condition is passed, and sets the bit which corresponds to the -// condition in the conditionFlags field to 1. - -void FActionCondition::AddCondition(U16 _condition) -{ - - switch (_condition) - - { - - case OverDownToIdle: - conditionFlags = conditionFlags | 256; //this bitwise OR has the same effect as making the 8th bit a "1" - break; - case IdleToOverDown: - conditionFlags = conditionFlags | 128; //makes 9th bit a "1" ... etc. - break; - case OutDownToIdle: - conditionFlags = conditionFlags | 64; - break; - case OutDownToOverDown: - conditionFlags = conditionFlags | 32; - break; - case OverDownToOutDown: - conditionFlags = conditionFlags | 16; - break; - case OverDownToOverUp: - conditionFlags = conditionFlags | 8; - break; - case OverUpToOverDown: - conditionFlags = conditionFlags | 4; - break; - case OverUpToIdle: - conditionFlags = conditionFlags | 2; - break; - case IdleToOverUp: - conditionFlags = conditionFlags | 1; - } -} - -// Writes the action condition to the given FSWFStream. Since the action condition contains -// an offset field to the next action condition, the body of the action condition must first -// be written to a temporary stream so that size can be calculated for the offset. - -void FActionCondition::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream temp; - - temp.WriteWord((U32)conditionFlags); - int boh = temp.Size(); - - std::list::iterator cursor; - for (cursor = actionRecordList.begin(); cursor != actionRecordList.end(); cursor++) { - - (*cursor)->WriteToSWFStream(&temp); - boh = temp.Size(); - } - - //add 2 to the size because the offset is actually to the beginning of the - //next action condition's conditionFlags - _SWFStream->WriteWord(2 + temp.Size()); - - _SWFStream->Append(&temp); -} - -// Writes the action condition to the given stream. The lastFlag indicates that this is the -// last action condition so the offset is set to 0 by default. - -void FActionCondition::WriteToSWFStream(FSWFStream *_SWFStream, int /*lastFlag*/) -{ - - _SWFStream->WriteWord(0); //the offset - - _SWFStream->WriteWord((U32)conditionFlags); - - std::list::iterator cursor; - for (cursor = actionRecordList.begin(); cursor != actionRecordList.end(); cursor++) { - - (*cursor)->WriteToSWFStream(_SWFStream); - } - - //_SWFStream->FlushBits(); - - _SWFStream->WriteByte((U32)0); -} - -/* -FActionConditionList::FActionConditionList(){ -} - - -FActionConditionList::~FActionConditionList(){ - - while (!conditionList.empty()){ - - delete conditionList.front(); - - conditionList.pop_front(); - - } - -} - - -void FActionConditionList::AddActionCondition(FActionCondition* _ActionCondition){ - - conditionList.push_back(_ActionCondition); - -} - -U32 FActionConditionList::Size(){ - - return conditionList.size(); - - } - - - void FActionConditionList::WriteToSWFStream(FSWFStream* _SWFStream){ - - std::list::iterator cursor; - std::list::iterator cursor2; - cursor2 = (conditionList.end()); - cursor2--; - - for (cursor = conditionList.begin(); cursor != cursor2; cursor++) { - - (*cursor)->WriteToSWFStream(_SWFStream); - - } - - (*cursor)->WriteToSWFStream(_SWFStream, 1); //flag indicating it is the last action condition - -} -*/ - -//============================================================================= -// ALCUNE AZIONI FLASH 5 -//============================================================================= - -FActionConstantPool::FActionConstantPool(FString *string) -{ - constantList.push_back(string); -} - -FActionConstantPool::~FActionConstantPool() -{ - while (!constantList.empty()) { - delete constantList.front(); - constantList.pop_front(); - } -} - -void FActionConstantPool::addConstant(FString *string) -{ - constantList.push_back(string); -} - -void FActionConstantPool::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream temp; - std::list::iterator it = constantList.begin(); - while (it != constantList.end()) { - (*it)->WriteToSWFStream(&temp, true); - ++it; - } - - _SWFStream->WriteByte(sactionConstantPool); - _SWFStream->WriteWord(temp.FullSize() + 2); - _SWFStream->WriteWord(constantList.size()); - _SWFStream->Append(&temp); -} - -//============================================================================= -// CLIP ACTION / CLIP ACTION RECORD -//============================================================================= - -FClipAction::FClipAction() -{ - eventFlags = 0; -} - -FClipAction::~FClipAction() -{ - Clear(); -} - -void FClipAction::Clear() -{ - while (!clipActionRecordList.empty()) { - delete clipActionRecordList.front(); - clipActionRecordList.pop_front(); - } -} - -void FClipAction::AddClipActionRecord(FClipActionRecord *_clipActionRecord) -{ - clipActionRecordList.push_back(_clipActionRecord); -} - -void FClipAction::AddFlags(U32 _flags) -{ - //e' meglio definire i flags come enumerazione che sono gia' i valori da - // mettere in OR per settare l'abilitazione del particolare evento - eventFlags |= _flags; -} - -void FClipAction::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream temp; - - //Reserved - temp.WriteWord(0); - - //allEvent - temp.WriteDWord(eventFlags); - - //tutti i clip - std::list::iterator it = clipActionRecordList.begin(); - int i = 0; - while (it != clipActionRecordList.end()) { - (*it)->WriteToSWFStream(&temp); //, i);//prova zozza - ++it; - ++i; - } - - //end clipAction - temp.WriteDWord(0); - _SWFStream->Append(&temp); -} - -//============================================================================= - -FClipActionRecord::FClipActionRecord() -{ - eventFlags = 0; - keyCode = 0; -} - -FClipActionRecord::~FClipActionRecord() -{ - Clear(); -} - -void FClipActionRecord::Clear() -{ - while (!actionRecordList.empty()) { - delete actionRecordList.front(); - actionRecordList.pop_front(); - } -} - -void FClipActionRecord::AddActionRecord(FActionRecord *_actionRecord) -{ - actionRecordList.push_back(_actionRecord); -} - -void FClipActionRecord::AddKeyCode(U8 _keyCode) -{ - keyCode |= _keyCode; -} - -void FClipActionRecord::AddFlags(U32 _flags) -{ - //e' meglio definire i flags come enumerazione che sono gia' i valori da - // mettere in OR per settare l'abilitazione del particolare evento - eventFlags |= _flags; -} - -void FClipActionRecord::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream temp; - //metto tutte le azioni su per sapere la size - std::list::iterator it = actionRecordList.begin(); - while (it != actionRecordList.end()) { - (*it)->WriteToSWFStream(&temp); - ++it; - } - temp.WriteByte(sactionNone); - - //e' un offset deve andare a quello dopo - U32 size = temp.FullSize(); - - FSWFStream temp1; - temp1.WriteDWord(eventFlags); - - if ((eventFlags & ClipEventKeyPress) == ClipEventKeyPress) { - temp1.WriteDWord(size + 1); - temp1.WriteByte(keyCode); - } else - temp1.WriteDWord(size); - - temp1.Append(&temp); - - _SWFStream->Append(&temp1); -} diff --git a/toonz/sources/common/flash/FAction.h b/toonz/sources/common/flash/FAction.h deleted file mode 100644 index bc4c2a6..0000000 --- a/toonz/sources/common/flash/FAction.h +++ /dev/null @@ -1,1346 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FAction.h - - This header-file contains the declarations of the low-level action-related classes: - - 1) class FActionRecord; - 2) all the derived classes of class FAction: - - class FActionAdd; - class FActionAnd; - class FActionAsciiToChar; - class FActionCall; - class FActionCharToAscii; - class FActionCloneSprite; - class FActionDivide; - class FActionEndDrag; - class FActionEquals; - class FActionGetProperty; - class FActionGetTime; - class FActionGetURL; - class FActionGetURL2; - class FActionGetVariable; - class FActionGotoFrame; - class FActionGotoFrame2; - class FActionGotoLabel; - class FActionIf; - class FActionJump; - class FActionLess; - class FActionMBAsciiToChar; - class FActionMBCharToAscii; - class FActionMBStringExtract; - class FActionMBStringLength; - class FActionMultiply; - class FActionNextFrame; - class FActionNot; - class FActionOr; - class FActionPlay; - class FActionPop; - class FActionPrevFrame; - class FActionPush; - class FActionRandomNumber; - class FActionRemoveSprite; - class FActionSetProperty; - class FActionSetTarget; - class FActionSetTarget2; - class FActionSetVariable; - class FActionStartDrag; - class FActionStop; - class FActionStopSounds; - class FActionStringAdd; - class FActionStringEquals; - class FActionStringExtract; - class FActionStringLength; - class FActionStringLess; - class FActionSubtract; - class FActionToggleQuality; - class FActionToInteger; - class FActionTrace; - class FActionWaitForFrame; - class FActionWaitForFrame2; - and, - - 3) class FActionCondition. - -****************************************************************************************/ - -#ifndef _F_ACTION_H_ -#define _F_ACTION_H_ - -#include "Macromedia.h" -#include "FSWFStream.h" - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif -class FString; - -//! A general class specifying an action to be performed by the Flash player -/*! -Buttons and DoAction tags utilize FActionRecords. -When encountered in a button tag, the Flash player adds action to a list to be processed when a button state has changed. -When encountered in a DoAction tag, the Flash player adds the action to a list to be processed when a FCTShowframe tag is encountered. -FActionRecords specifiy actions such as: starting and stoping movie play, toggling display quality, performing stack arithmetic... etc. -Many actions involve the use of a last-on/first-off stack machine (Flash 4.0) that stores string values. -\sa FCTDoAction, FDTDefineButton, FDTDefineButton2 -*/ - -class DVAPI FActionRecord -{ -public: - virtual ~FActionRecord() {} - - //! A general function that will write its object out to a FSWFStream - /*! - All FActionRecords contain the WriteToSWFStream member function, a function that will writes out its Object's data out to a FSWFStream - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; -}; - -class DVAPI FActionUnparsed : public FActionRecord -{ - UCHAR code; - USHORT length; - UCHAR *data; - -public: - FActionUnparsed(UCHAR _code, USHORT _length, UCHAR *_data); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); -}; - -//! An action that adds two numbers -/*! \verbatim -1. pops value A off the stack machine -2. pops value B off the stack machine -3. A and B are converted to floating-point (if non-numeric,converts to 0) -4. A and B are added -5. Result, A + B, is pushed back onto stack -\endverbatim */ - -class FActionAdd : public FActionRecord -{ -public: - FActionAdd() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionAdd); } -}; - -//! An action that performs a logical AND of two numbers -/*! \verbatim -1. pops value A off the stack -2. pops value B off the stack -3. A nd B are converted to floating-point(if non-numeric, converts to 0) -4. If both A and B are non-zero, a 1 is pushed onto the stack; otherwise a 0 is pushed -\endverbatim */ - -class FActionAnd : public FActionRecord -{ -public: - FActionAnd() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionAnd); } -}; - -//! An action that converts ASCII to character code -/*! \verbatim -1. pops value A off the stack -2. the value is converted from a number to the corresponding ASCII character -3. the resulting character is pushed to the stack -\endverbatim */ - -class FActionAsciiToChar : public FActionRecord -{ -public: - FActionAsciiToChar() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionAsciiToChar); } -}; - -//! An action that calls a subroutine -/*! \verbatim -1. pops value A off the stack -2. this value should be either a string matching a frame label, or a number indicating a frame number -3. The value may be prefixed by a target string identifying the movie clip that contains the frame being called -4. If the frame is successfully located, the actions in the target frame are executed. After the actions in the target frame are executed, execution resumes at the instruction after the ActionCall instruction. -5. If the frame cannot be found, nothing happens -6. NOTE: This action's tag (0x9e) has the high bit set, this is a bug -\endverbatim */ -class FActionCall : public FActionRecord -{ -public: - FActionCall() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) - { - _SWFStream->WriteByte(sactionCall); - // Write the length since the high bit is set in the action tag - _SWFStream->WriteWord(0); - } -}; - -//! An action that converts character code to ASCII -/*! \verbatim -1. pops value A off the stack -2. The first character of value a is converted to a numeric ASCII character code -3. The resulting character code is pushed to the stack -\endverbatim */ -class FActionCharToAscii : public FActionRecord -{ -public: - FActionCharToAscii() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionCharToAscii); } -}; - -//! An action that clones a sprite -/*! \verbatim -1. pops value DEPTH (new sprite depth) off the stack -2. pops value TARGET (name of new sprite) off the stack -3. pops value SOURCE (souce sprite) off stack -4. duplicate the movie SOURCE, giving the new movie the name TARGET at z-order depth DEPTH -\endverbatim */ -class FActionCloneSprite : public FActionRecord -{ -public: - FActionCloneSprite() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionCloneSprite); } -}; - -//! An action that divides two numbers -/*! \verbatim -1. pops value A off the stack -2. pops value B off stack -3. A and B are converted to floating-point (if non-numeric convert to 0) -4. Result B divided by A is pushed to stack -5. If A is 0, the result is the string "#ERROR#" -\endverbatim */ -class FActionDivide : public FActionRecord -{ -public: - FActionDivide() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionDivide); } -}; - -//! An action that ends drag operation -/*! \verbatim -1. ends the drag operation in progress (if any) -\endverbatim */ -class FActionEndDrag : public FActionRecord -{ -public: - FActionEndDrag() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionEndDrag); } -}; - -//! An action that tests two numbers for equality -/*! \verbatim -1. pops value A off the stack -2. pops value B off stack -3. A and B converted to floating-point (if non-numeric, converted to 0) -4. A and B compared for equality -5. If equal, a 1 is pushed to stack -6. Otherwise, 0 is pushed -\endverbatim */ -class FActionEquals : public FActionRecord -{ -public: - FActionEquals() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionEquals); } -}; - -//! An action that gets a movie property -/*! \verbatim -1. pops value INDEX off the stack -2. pops TARGET off the stack -3. retrieve the value of the property enumerated as INDEX from the movie clip with target path TARGET and push this value onto stack -\endverbatim */ -class FActionGetProperty : public FActionRecord -{ - -public: - FActionGetProperty() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionGetProperty); } -}; - -//! An action that reports milliseconds since player started -/*! \verbatim -1. an integer representing the number of minutes since the player was started is pushed onto stack -\endverbatim */ -class FActionGetTime : public FActionRecord -{ -public: - FActionGetTime() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionGetTime); } -}; - -//! An action that opens the given URL in a given window -/*! \verbatim -An action record specifying that the player open the given URL in a given window -\endverbatim */ -class FActionGetURL : public FActionRecord -{ -public: - //! FActionGetURL constructor - /*! - \param _url a pointer to an FString representing a URL address - \param _window a pointer to an FString identifying a window to open the URL in (empty FString indicates current window) - */ - FActionGetURL(FString *_url, FString *_window); - - virtual ~FActionGetURL(); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FString *url; - FString *window; -}; - -//! An action that opens a URL in an indicated window (stack based) -/*! \verbatim -1. pops value WINDOW off stack, window specifies the target window, empty string indicates current -2. pops URL off stack, specifies which URL to retrieve -3. retrieve URL in WINDOW using given HTTP request method - - if method is "HTTP GET" or "HTTP POST", variables in movie clip are sent using standard "x-www-urlencoded" encoding -\endverbatim */ -class FActionGetURL2 : public FActionRecord -{ -public: - //! FActionGetURL2 constructor - /*! - \param _method a number indicating an HTTP request method (value 0 indicates that it is not a request method, 1 indicates HTTP GET, 2 indicates HTTP POST) - */ - FActionGetURL2(U8 _method); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 method; -}; - -//! An action that gets a variable's value -/*! \verbatim -1. pops value NAME off the stack -2. retrieves value of variable NAME -3. pushes NAME's associated value back onto stack -Variables in other execution contexts may be referenced by prefixing a variable name with a target path followed by a colon -\endverbatim */ -class FActionGetVariable : public FActionRecord -{ -public: - FActionGetVariable() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionGetVariable); } -}; - -//! An action that goes to the specified frame -/*! \verbatim -An action record specifying that the player goto the frame specified by the given frame index -\endverbatim */ -class DVAPI FActionGotoFrame : public FActionRecord -{ -public: - //! FActionGotoFrame constructor - /*! - \param frameIndex a number specifying the frame index of a frame to go to - */ - FActionGotoFrame(U16 frameIndex); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 frameIndex; -}; - -//! An action that goes to a identified frame (stack based) -/*! \verbatim -1. pops value FRAME off the stack -2. if frame is a number, the next movie frame displayed will be FRAME'th frame in the current movie -3. if frame is a string, the next movie frame displayed will be the frame designated by label "FRAME" (if no such label exists, action is ignored) -4. FRAME may be prefixed by a target path -5. if given "play" flag is set, the movie begins playing the goto frame, otherwise movie play is stopped on goto frame -\endverbatim */ -class FActionGotoFrame2 : public FActionRecord -{ -public: - //! FActionGotoFrame2 constructor - /*! - \param _play a true or false value indicating whether or not goto frame should be played - */ - - FActionGotoFrame2(U8 _play); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 play; -}; - -//! An action that goes to the frame indicated by the given label -/*! \verbatim -An action record specifying that the player goto the frame with the given label -\endverbatim */ -class FActionGotoLabel : public FActionRecord -{ -public: - //! FActionLabel constructor - /*! - \param _label a FString pointer indicating the label of the frame to go to - */ - FActionGotoLabel(FString *_label); - - virtual ~FActionGotoLabel(); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FString *label; -}; - -//! An action that test a condition and branches -/*! \verbatim -1. pops value CONDITION off the stack -2. if CONDITION is non-zero, branch to a given number of offset bytes following FActionIf record (a 0 value points to action directly following FActionIf; offset is a signed integer quantity enabling forward and backward branching) -\endverbatim */ -class DVAPI FActionIf : public FActionRecord -{ -public: - //!FActionIf constructor - /*! - \param _branchOffset a value representing a number of bytes (pos or neg) following the current tag to brach off to - */ - FActionIf(S16 _branchOffset); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - S16 branchOffset; -}; - -//! An action that performs an unconditional branch -/*! \verbatim -An action record specifying that the player branch to a given number of bytes following the FActionJump record(a 0 value points to the action record immediately following) -Can branch either forward or backward -\endverbatim */ -class FActionJump : public FActionRecord -{ -public: - //! FActionJump constructor - /*! - \param _branchOffset a value representing a number of bytes (pos or neg) following the current tagto branch off to - */ - FActionJump(S16 _branchOffset); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - S16 branchOffset; -}; - -//! An action that tests if a number is less than another number -/*! \verbatim -1. pops value A off the stack -2. pops value B off the stack -3. A and B converted to floating-point (non-numeric converted to 0) -4. if B < A, a 1 is pushed onto stack, otherwise a 0 is pushed -\endverbatim */ -class FActionLess : public FActionRecord -{ -public: - FActionLess() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionLess); } -}; - -//! An action that converts ASCII to character code (multi-byte aware) -/*! \verbatim -1. pops value VALUE off the stack -2. the value is converted from a number to the corresponding character. If 16bit value, double byte character constructed -3. resulting character pushed back onto stack -\endverbatim */ -class FActionMBAsciiToChar : public FActionRecord -{ -public: - FActionMBAsciiToChar() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionMBAsciiToChar); } -}; - -//! An action that converts character code to ASCII (multi-byte aware) -/*! \verbatim -1. pops value VALUE off the stack -2. the first character of VALUE is converted to a numeric character code. If the first character of VALUE is a double-byte character, a 16bit code value is constructed -3. resulting code is pushed to stack -\endverbatim */ -class FActionMBCharToAscii : public FActionRecord -{ -public: - FActionMBCharToAscii() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionMBCharToAscii); } -}; - -//! An action that extracts a substring from a string (multi-byte aware) -/*! \verbatim -1. pops number COUNT off the stack -2. pops number INDEX off stack -3. pops string STRING off stack -4. push to stack, the string of length LENGTH starting at the INDEX'th character of STRING -5. if INDEX or COUNT are non-numeric, push empty string to stack -\endverbatim */ -class FActionMBStringExtract : public FActionRecord -{ -public: - FActionMBStringExtract() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionMBStringExtract); } -}; - -//! An action that computes the length of a string (multi-byte aware) -/*! \verbatim -1. pops value STRING off stack -2. push length of STRING onto stack -\endverbatim */ -class FActionMBStringLength : public FActionRecord -{ -public: - FActionMBStringLength() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionMBStringLength); } -}; - -//! An action that multiplies two numbers -/*! \verbatim -1. pops value A off stack -2. pops value B off stack -3. A and B are converted to floating-point (non-numeric converted to 0) -4. result of A multiply B is pushed to stack -\endverbatim */ -class FActionMultiply : public FActionRecord -{ -public: - FActionMultiply() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionMultiply); } -}; - -//! An action that goes to next frame -/*! \verbatim -An action specifying that the Flash player goto the next frame -\endverbatim */ -class FActionNextFrame : public FActionRecord -{ -public: - FActionNextFrame() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionNextFrame); } -}; - -//! An action that performs the logical NOT of a number -/*! \verbatim -An action specifying that the Flash player: -1. pops value A off stack -2. A is converted to floating-point (non-numeric is converted to zero) -3. if A is zero, 1 pushed to stack -4. otherwise 0 pushed to stack -\endverbatim */ -class FActionNot : public FActionRecord -{ -public: - FActionNot() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionNot); } -}; - -//! An action that performs the logical OR of two numbers -/*! \verbatim -1. pops value A off stack -2. pops value B off stack -3. A and B converted to floating-point (non-numeric converted to zero) -4. if either A or B are non-zero, 1 is pushed to stack, otherwise 0 pushed to stack -\endverbatim */ -class FActionOr : public FActionRecord -{ -public: - FActionOr() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionOr); } -}; - -//! An action that starts playing the movie at the current frame -/*! \verbatim -An action specifying that the Flash player to start playing the movie at the current frame -\endverbatim */ -class FActionPlay : public FActionRecord -{ -public: - FActionPlay() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionPlay); } -}; - -//! An action that pops a value off the stack -/*! \verbatim -1. pops value A off stack and discards the value -\endverbatim */ -class FActionPop : public FActionRecord -{ -public: - FActionPop() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionPop); } -}; - -//! An action that goes to the previous frame -/*! \verbatim -\endverbatim */ -class FActionPrevFrame : public FActionRecord -{ -public: - FActionPrevFrame() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionPrevFrame); } -}; - -//! An action that pushes a given value onto the stack -/*! \verbatim -Pushes either a string or floating-point number onto the stack -\endverbatim */ -class DVAPI FActionPush : public FActionRecord -{ -public: - //! FActionPush constructor for pushing strings - /*! - \param _string a pointer to the FString that will be pushed onto stack - */ - FActionPush(FString *_string); - - //! FActionPush constructor for pushing numbers - /*! - \param _number a pointer to the FLOAT that will be pushed onto stack - */ - FActionPush(FLOAT _number); - - FActionPush(U8 _type, FLOAT _number); - FActionPush(double _number); - FActionPush(U8 _type, U8 _value); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FString *string; - FLOAT number; - U8 cValue; - double dValue; - U8 type; -}; - -//! An action that constructs a random number -/*! \verbatim -1. pop MAXIMUM off stack -2. constructs a random integer in the range 0... (MAXIMUM -1) -3. pushes this random value to stack -\endverbatim */ -class FActionRandomNumber : public FActionRecord -{ -public: - FActionRandomNumber() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionRandomNumber); } -}; - -//! An action that removes a cloned sprite -/*! \verbatim -1. pops value TARGET off stack -2. Removes the cloned clip identifiesd by target TARGET -\endverbatim */ -class FActionRemoveSprite : public FActionRecord -{ -public: - FActionRemoveSprite() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionRemoveSprite); } -}; - -//! An action that sets a movie property -/*! \verbatim -1. pops value VALUE off stack -2. pops value INDEX off stack -3. pops value TARGET off stack -4. sets property enumerated as INDEX in the movie clip TARGET to the value VALUE -\endverbatim */ -class FActionSetProperty : public FActionRecord -{ -public: - FActionSetProperty() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionSetProperty); } -}; - -//! An action that sets the context of action -/*! \verbatim -Sets context of action to target named by given string -\endverbatim */ -class FActionSetTarget : public FActionRecord -{ -public: - //! FActionSetTarget constructor - /*! - \param _targetName a pointer to the FString naming the target to set action context to - */ - FActionSetTarget(FString *_targetName); - - virtual ~FActionSetTarget(); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FString *targetName; -}; - -//! An action that sets the context of action (stack based) -/*! \verbatim -1. pops value TARGET off stack -2. sets current context of action to object identified by TARGET -\endverbatim */ -class FActionSetTarget2 : public FActionRecord -{ -public: - FActionSetTarget2() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionSetTarget2); } -}; - -//! An action that sets a variable -/*! \verbatim -1. pops value VALUE off stack -2. pops string NAME off stack -3. sets NAME to VALUE in the current execution context -\endverbatim */ -class FActionSetVariable : public FActionRecord -{ -public: - FActionSetVariable() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionSetVariable); } -}; - -//! An action that starts dragging a movie clip -/*! \verbatim -1. pops value TARGET off stack -2. pops LOCKCENTER off stack -3. pops CONSTRAIN -4. if CONSTRAIN is non-zero: - - pops y2 - - pops x2 - - pops y1 - - pops x1 -5. starts dragging of movie clip identified by TARGET -6. if LOCKCENTER is non-zero, the center of clip is locked to the mouse position, otherwise clip moves relative to starting mouse position -7. if CONSTRAIN, draged clip is constrained coordinates x1, y1, x2, y2 -\endverbatim */ -class FActionStartDrag : public FActionRecord -{ -public: - FActionStartDrag() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStartDrag); } -}; - -//! An action that stops movie play at the current frame -/*! \verbatim -\endverbatim */ -class FActionStop : public FActionRecord -{ -public: - FActionStop() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStop); } -}; - -//! An action that stops playing all sounds in movie -/*! \verbatim -\endverbatim */ -class FActionStopSounds : public FActionRecord -{ -public: - FActionStopSounds() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStopSounds); } -}; - -//! An action that concatenates two strings -/*! \verbatim -1. pops string A off stack -2. pops string B off stack -3. the concatenation of BA is pushed to stack -\endverbatim */ -class FActionStringAdd : public FActionRecord -{ -public: - FActionStringAdd() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStringAdd); } -}; - -//! An action that tests two strings for equality -/*! \verbatim -1. pops string A off stack -2. pops string B off stack -3. A and B are compared (case-sensitive) -4. if strings are equal, a 1 is pushed to stack, otherwise 0 pushed -\endverbatim */ -class FActionStringEquals : public FActionRecord -{ -public: - FActionStringEquals() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStringEquals); } -}; - -//! An action that extracts a substring from a string -/*! \verbatim -1. pops number COUNT off stack -2. pops number INDEX off stack -3. pops string STRING off stack -4. the substring of length COUNT starting at the INDEX'th index of string STRING is pushed to stack -5. if COUNT or INDEX non-numeric, push empty string -\endverbatim */ -class FActionStringExtract : public FActionRecord -{ -public: - FActionStringExtract() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStringExtract); } -}; - -//! An action that computes the length of a string -/*! \verbatim -1. pops string STRING off stack -2. the length of string STRING is pushed to stack -\endverbatim */ -class FActionStringLength : public FActionRecord -{ -public: - FActionStringLength() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStringLength); } -}; - -//! An action that test if a string is less than another string -/*! \verbatim -1. pops string A off stack -2. pops string B off stack -3. if B < A using a byte to byte comparison, a 1 is pushed to the stack, otherwise 0 is pushed to stack -\endverbatim */ -class FActionStringLess : public FActionRecord -{ -public: - FActionStringLess() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionStringLess); } -}; - -//! An action that subtracts a number from another number -/*! \verbatim -1. pops value A off stack -2. pops value B off stack -3. converts values A and B to floating-point (non-numeric converts to zero) -4. the result, B-A, is pushed to stack -\endverbatim */ -class FActionSubtract : public FActionRecord -{ -public: - FActionSubtract() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionSubtract); } -}; - -//! An action that toggles screen quality between high and low -/*! \verbatim -\endverbatim */ -class FActionToggleQuality : public FActionRecord -{ -public: - FActionToggleQuality() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionToggleQuality); } -}; - -//! An action that converts a value to an integer -/*! \verbatim -1. pops value A off stack -2. A is converted to a floating-point number -3. A is truncated to an integer value -4. truncated A is pushed to stack -\endverbatim */ -class FActionToInteger : public FActionRecord -{ -public: - FActionToInteger() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionToInteger); } -}; - -//! An action that sends debugging output string -/*! \verbatim -1. pops value VALUE off stack -2. in the "Test Movie" mode of the Flash editor, appends VALUE to the output window if the debugging level is set to "None" -3. ignored by Flash Player -\endverbatim */ -class FActionTrace : public FActionRecord -{ -public: - FActionTrace(); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionTrace); } -}; - -//! An action that waits for a specified frame, otherwise skips a specified number of actions -/*! \verbatim -\endverbatim */ -class FActionWaitForFrame : public FActionRecord -{ -public: - //! FActionWaitForFrame constructor - /*! - \param _frameIndex a number indexing the frame to wait for - \param skipCount a number indicating the number of frames to skip - */ - FActionWaitForFrame(U16 _frameIndex, U16 skipCount); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 frameIndex; - U16 skipCount; -}; - -//! An action that waits for a frame to be loaded -/*! \verbatim -1. pops value FRAME off stack -2. frame is evaluated in the same manner as in FActionGotoFrame2 -3. if the frame identified by FRAME has been loaded, skip a specified number of actions following the current one -\endverbatim */ -class FActionWaitForFrame2 : public FActionRecord -{ -public: - //! FActionWaitForFrame2 constructor - /*! - \param _skipCount a number of actions to skip - */ - FActionWaitForFrame2(U8 _skipCount); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 skipCount; -}; - -//! A class specifying a set of conditions and a set of subsequent actions to perform -/*! \verbatim -Buttons contain a set of FActionConditions. -An FActionCondition conatins a set of conditions and a set of actions to perform when the set of conditions is met - \sa FDTDefineButton, FDTDefineButton2 -*/ -class DVAPI FActionCondition -{ -public: - FActionCondition(); - - ~FActionCondition(); - - void Clear(); - - //! A member function that adds another action to the ActionCondition - /*! - Appends an FActionRecord to the list of FActionRecords. - These actions will be performed when the set of conditions is met - \param _ActionRecord any FActionRecord pointer - */ - void AddActionRecord(FActionRecord *_ActionRecord); - - //! A member function that adds a key-stroke condition to the set of conditions in an ActionCondition - /*! - \param keyCode one of the enumerated key-codes found in "Macromedia.h" - */ - void AddKeyCode(U32 keyCode); - - //! A member function that adds a button condition to the set of conditions in an ActionCondition - /*! - \param _condition one of the enumerated action-conditions found in "Macromedia.h" - */ - void AddCondition(U16 _condition); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - \sa WriteToSWFStream(FSWFStream* _SWFStream, int lastFlag), FSWFStream - */ - void WriteToSWFStream(FSWFStream *_SWFStream); - - //! Writes the object out to a FSWFStream and writes the terminating record to the FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - \param lastFlag a flag that, if true, indicates that this ActionCondition is the last record to be writen - \sa WriteToSWFStream(FSWFStream* _SWFStream), FSWFStream - */ - void WriteToSWFStream(FSWFStream *_SWFStream, int lastFlag); - -private: - std::list actionRecordList; - U16 conditionFlags; -}; - -/* -class FActionConditionList -{ -public: - FActionConditionList(); - ~FActionConditionList(); - - void AddActionCondition(FActionCondition* _ActionCondition); - U32 Size(); - void WriteToSWFStream(FSWFStream* _SWFStream); - -private: - std::list conditionList; -}; -*/ -//============================================================================= -// ALCUNE AZIONI FLASH 5 -//============================================================================= - -class FActionConstantPool : public FActionRecord -{ -public: - FActionConstantPool(FString *string); - ~FActionConstantPool(); - - void addConstant(FString *string); - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - std::list constantList; - FActionConstantPool(); -}; - -class FActionLess2 : public FActionRecord -{ -public: - FActionLess2() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionLess2); } -}; - -class FActionEquals2 : public FActionRecord -{ -public: - FActionEquals2() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionEquals2); } -}; - -class FActionCallMethod : public FActionRecord -{ -public: - FActionCallMethod() {} - - //! Writes the object out to a FSWFStream - /*! - \param _SWFStream any FSWFStream pointer, though usually the FSWFStream given as an argument to the appendTag function of the FSWFStream representing the .swf file being created - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) { _SWFStream->WriteByte(sactionCallMethod); } -}; - -//============================================================================= -// CLIP ACTION / CLIP ACTION RECORD -//============================================================================= - -class FClipActionRecord; - -class DVAPI FClipAction -{ -public: - FClipAction(); - ~FClipAction(); - - void Clear(); - void AddClipActionRecord(FClipActionRecord *_clipActionRecord); - void AddFlags(U32 _flags); - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - std::list clipActionRecordList; - U32 eventFlags; -}; - -//============================================================================= - -class DVAPI FClipActionRecord -{ -public: - FClipActionRecord(); - ~FClipActionRecord(); - - void Clear(); - void AddActionRecord(FActionRecord *_actionRecord); - void AddKeyCode(U8 _keyCode); - void AddFlags(U32 _flags); - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - std::list actionRecordList; - U32 eventFlags; - U8 keyCode; -}; -#endif diff --git a/toonz/sources/common/flash/FCT.cpp b/toonz/sources/common/flash/FCT.cpp deleted file mode 100644 index db1546c..0000000 --- a/toonz/sources/common/flash/FCT.cpp +++ /dev/null @@ -1,502 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FCT.cpp - - This source file contains the definition for the low-level Control-Tag related functions, - grouped by classes, which are all derived from class FCT: - - - Class Member Function - - FCTDoAction FCTDoAction(void); - ~FCTDoAction(); - void AddAction(FActionRecord*); - void WriteToSWFStream(FSWFStream*); - - FCTFrameLabel FCTFrameLabel(FString*); - ~FCTFrameLabel(); - void WriteToSWFStream(FSWFStream*); - - FCTPlaceObject FCTPlaceObject(U16, U16, FMatrix*, FCXForm*); - ~FCTPlaceObject(); - void WriteToSWFStream(FSWFStream*); - - FCTPlaceObject2 FCTPlaceObject2(U16, U16, U16, U16, U16, U16, FMatrix*, - FCXForm*, U16, FString*, U16); - ~FCTPlaceObject2(); - void WriteToSWFStream(FSWFStream*); - - FCTProtect FCTProtect(); - void WriteToSWFStream(FSWFStream*); - - FCTRemoveObject FCTRemoveObject(U16, U16); - void WriteToSWFStream(FSWFStream*); - - FCTRemoveObject2 FCTRemoveObject2(U16); - void WriteToSWFStream(FSWFStream*); - - FCTSetBackgroundColor FCTSetBackgroundColor(FColor*); - ~FCTSetBackgroundColor(); - void WriteToSWFStream(FSWFStream*); - - FCTShowFrame FCTShowFrame(); - U32 IsShowFrame(); - void WriteToSWFStream(FSWFStream*); - - FCTStartSound FCTStartSound(U16, FSoundInfo*); - ~FCTStartSound(); - void WriteToSWFStream(FSWFStream*); - - -****************************************************************************************/ - -#include "FCT.h" -#include "FDTShapes.h" -#include "FDTSounds.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FCTDoAction ------------------------------------------------------------ - -FCTDoAction::FCTDoAction(void) -{ -} - -FCTDoAction::~FCTDoAction() -{ - - while (!actionRecordList.empty()) { - - delete actionRecordList.front(); - - actionRecordList.pop_front(); - } -} - -void FCTDoAction::AddAction(FActionRecord *_actionRecord) -{ - - actionRecordList.push_back(_actionRecord); -} - -void FCTDoAction::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - std::list::iterator cursor; - for (cursor = actionRecordList.begin(); cursor != actionRecordList.end(); cursor++) { - - (*cursor)->WriteToSWFStream(&body); - } - - body.WriteByte(0); - - _SWFStream->AppendTag(stagDoAction, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FCTFrameLabel ---------------------------------------------------------- - -FCTFrameLabel::FCTFrameLabel(FString *_frameName) -{ - frameName = _frameName; -} - -FCTFrameLabel::~FCTFrameLabel() -{ - delete frameName; -} - -void FCTFrameLabel::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - frameName->WriteToSWFStream(&body, true); - - _SWFStream->AppendTag(stagFrameLabel, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FCTPlaceObject ---------------------------------------------------------- - -FCTPlaceObject::FCTPlaceObject(U16 _characterID, - U16 _depth, - FMatrix *_matrix, - FCXForm *_colorTransform) -{ - characterID = _characterID; - depth = _depth; - matrix = _matrix; - colorTransform = _colorTransform; - - FLASHASSERT(_colorTransform); -} - -FCTPlaceObject::~FCTPlaceObject() -{ - delete matrix; - delete colorTransform; -} -void FCTPlaceObject::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - ; - - body.WriteWord((U32)characterID); - - body.WriteWord((U32)depth); - - matrix->WriteToSWFStream(&body); - - if (colorTransform) { - colorTransform->WriteToSWFStream(&body); - } - - _SWFStream->AppendTag(stagPlaceObject, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FCTPlaceObject2 -------------------------------------------------------- - -FCTPlaceObject2::FCTPlaceObject2(U16 _hasClipDepth, - U16 _hasRatio, - U16 _hasChar, - U16 _hasMove, - U16 _depth, - U16 _characterID, - FMatrix *_matrix, - FCXFormWAlpha *_colorTransform, - U16 _ratio, - FString *_name, - U16 _clipDepth) -{ - SetParameters(_hasClipDepth, _hasRatio, _hasChar, _hasMove, _depth, _characterID, - _matrix, _colorTransform, _ratio, _name, _clipDepth); -} - -FCTPlaceObject2::FCTPlaceObject2(const FCTPlaceObject2 &obj) -{ - SetParameters(obj.hasClipDepth, obj.hasRatio, obj.hasCharID, obj.hasMove, - obj.depth, obj.characterID, 0, obj.colorTransform, - obj.ratio, 0, obj.clipDepth); - matrix = obj.matrix ? new FMatrix(*(obj.matrix)) : 0; - name = obj.name ? new FString(*(obj.name)) : 0; -} - -void FCTPlaceObject2::SetParameters(U16 _hasClipDepth, - U16 _hasRatio, - U16 _hasChar, - U16 _hasMove, - U16 _depth, - U16 _characterID, - FMatrix *_matrix, - FCXFormWAlpha *_colorTransform, - U16 _ratio, - FString *_name, - U16 _clipDepth) -{ - hasClipAction = 0; - hasClipDepth = _hasClipDepth; - hasRatio = _hasRatio; - hasCharID = _hasChar; - hasMove = _hasMove; - depth = _depth; - characterID = _characterID; - matrix = _matrix; - colorTransform = _colorTransform; - ratio = _ratio; - name = _name; - clipDepth = _clipDepth; - clipAction = NULL; -} - -FCTPlaceObject2::FCTPlaceObject2(U16 _hasClipAction, - U16 _hasClipDepth, - U16 _hasRatio, - U16 _hasChar, - U16 _hasMove, - U16 _depth, - U16 _characterID, - FMatrix *_matrix, - FCXFormWAlpha *_colorTransform, - U16 _ratio, - FString *_name, - U16 _clipDepth, - FClipAction *_clipAction) -{ - hasClipAction = _hasClipAction; - hasClipDepth = _hasClipDepth; - hasRatio = _hasRatio; - hasCharID = _hasChar; - hasMove = _hasMove; - depth = _depth; - characterID = _characterID; - matrix = _matrix; - colorTransform = _colorTransform; - ratio = _ratio; - name = _name; - clipDepth = _clipDepth; - clipAction = _clipAction; -} - -FCTPlaceObject2::~FCTPlaceObject2() -{ - - delete name; - delete matrix; - delete colorTransform; - delete clipAction; -} - -U32 FCTPlaceObject2::IsPlaceObject() -{ - - return 1; -} - -int FCTPlaceObject2::GetPlacedId() -{ - return hasCharID ? characterID : -1; -} - -void FCTPlaceObject2::SetId(U16 id) -{ - characterID = id; - hasMove = 0; - hasCharID = 1; -} - -void FCTPlaceObject2::ChangePlacedId(U16 id) -{ - if (hasCharID) { - characterID = id; - //hasMove=0; - } -} - -void FCTPlaceObject2::SetMatrix(FMatrix *_matrix) -{ - matrix = _matrix; -} - -void FCTPlaceObject2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteBits(hasClipAction, 1); /*DM*/ - body.WriteBits(hasClipDepth, 1); /*DM*/ - body.WriteBits((name != 0), 1); - body.WriteBits(hasRatio, 1); - body.WriteBits((colorTransform != 0), 1); - body.WriteBits((matrix != 0), 1); - body.WriteBits(hasCharID, 1); - body.WriteBits(hasMove, 1); - - body.WriteWord(depth); - - if (hasCharID) - body.WriteWord((U32)characterID); - if (matrix) - matrix->WriteToSWFStream(&body); - if (colorTransform) - colorTransform->WriteToSWFStream(&body); - if (hasRatio) - body.WriteWord((U32)ratio); - if (name) - name->WriteToSWFStream(&body, true); - if (hasClipDepth) /*DM*/ - body.WriteWord((U32)clipDepth); /*DM*/ - if (hasClipAction) - clipAction->WriteToSWFStream(&body); - - body.FlushBits(); - - _SWFStream->AppendTag(stagPlaceObject2, body.Size(), &body); -} - -///////////////////////////////////////////////////////////////////////////////// -// -------- FCTProtect -------------------------------------------------------- - -FCTProtect::FCTProtect() -{ -} - -void FCTProtect::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->AppendTag(stagProtect, 0, 0); -} - -///////////////////////////////////////////////////////////////////////////////// -// -------- FCTRemoveObject --------------------------------------------------- - -FCTRemoveObject::FCTRemoveObject(U16 _characterID, U16 _depth) -{ - characterID = _characterID; - depth = _depth; -} - -void FCTRemoveObject::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteWord((U32)characterID); - body.WriteWord((U32)depth); - - _SWFStream->AppendTag(stagRemoveObject, body.Size(), &body); -} - -///////////////////////////////////////////////////////////////////////////////// -// -------- FCTRemoveObject2 -------------------------------------------------- - -FCTRemoveObject2::FCTRemoveObject2(U16 _depth) -{ - depth = _depth; -} - -void FCTRemoveObject2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - body.WriteWord((U32)depth); - - _SWFStream->AppendTag(stagRemoveObject2, body.Size(), &body); -} - -///////////////////////////////////////////////////////////////////////////////// -// -------- FCTSetBackgroundColor -------------------------------------------------- - -FCTSetBackgroundColor::FCTSetBackgroundColor(FColor *_color) -{ - color = _color; - // here changed. - // Background color is always opaque, i.e. no alpha channel. - color->AlphaChannel(false); -} - -FCTSetBackgroundColor::~FCTSetBackgroundColor() -{ - delete (color); -} - -void FCTSetBackgroundColor::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - // here changed. - color->WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagSetBackgroundColor, body.Size(), &body); -} - -///////////////////////////////////////////////////////////////////////////////// -// -------- FCTUnparsedTag -------------------------------------------------- - -FCTUnparsedTag::FCTUnparsedTag(U16 _tagId, U32 _lenght, U8 *_data) -{ - lenght = _lenght; - if (lenght > 0) { - data = new U8[lenght]; - memcpy(data, _data, lenght); - } else - data = 0; - - tagId = _tagId; -} - -FCTUnparsedTag::~FCTUnparsedTag() -{ - delete data; -} - -void FCTUnparsedTag::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - // here changed. - if (lenght > 0) - body.WriteLargeData(data, lenght); - - _SWFStream->AppendTag(tagId, body.Size(), &body); -} - -USHORT FCTUnparsedTag::GetID() -{ - if (tagId == stagDefineButton2 || - tagId == stagDefineButton || - tagId == stagDefineText || - tagId == stagDefineText2 || - tagId == stagDefineEditText || - tagId == stagDefineMorphShape || - tagId == stagDefineBitsLossless2 || - tagId == stagDefineBitsLossless || - tagId == stagDefineBitsJPEG3) - return (USHORT)(data[0] | (data[1] << 8)); - return 0; -} - -void FCTUnparsedTag::SetID(USHORT id) -{ - if (tagId == stagDefineButton2 || - tagId == stagDefineButton || - tagId == stagDefineText || - tagId == stagDefineText2 || - tagId == stagDefineEditText || - tagId == stagDefineMorphShape || - tagId == stagDefineBitsLossless2 || - tagId == stagDefineBitsLossless || - tagId == stagDefineBitsJPEG3) { - data[0] = (id & 0xff); - data[1] = (id >> 8); - } -} - -///////////////////////////////////////////////////////////////////////////// -// -------- FCTShowFrame -------------------------------------------------- - -FCTShowFrame::FCTShowFrame() -{ -} - -U32 FCTShowFrame::IsShowFrame() -{ - - return 1; -} - -void FCTShowFrame::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - _SWFStream->AppendTag(stagShowFrame, 0, 0); -} - -///////////////////////////////////////////////////////////////////////////// -// -------- FCTStartSound -------------------------------------------------- - -FCTStartSound::FCTStartSound(U16 _soundID, FSoundInfo *_soundInfo) -{ - - soundID = _soundID; - soundInfo = _soundInfo; -} - -FCTStartSound::~FCTStartSound() -{ - - delete soundInfo; -} - -void FCTStartSound::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)soundID); - soundInfo->WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagStartSound, body.Size(), &body); -} diff --git a/toonz/sources/common/flash/FCT.h b/toonz/sources/common/flash/FCT.h deleted file mode 100644 index f503ec6..0000000 --- a/toonz/sources/common/flash/FCT.h +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FCT.h - - This header-file contains the declarations of the low-level Control-Tag related classes: - - 1) class FCT; - 2) all the derived classes of class FCT: - - class FCTDoAction; - class FCTFrameLabel; - class FCTPlaceObject; - class FCTPlaceObject2; - class FCTProtect; - class FCTRemoveObject; - class FCTRemoveObject2; - class FCTSetBackgroundColor; - class FCTShowFrame; - class FCTStartSound; - - -****************************************************************************************/ - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TNZCORE_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif -#ifndef _F_C_T_H_ -#define _F_C_T_H_ - -#include "Macromedia.h" -#include "FObj.h" -#include "FAction.h" -#include "FPrimitive.h" - -class FCXForm; -class FCXFormWAlpha; - -class FSoundInfo; - -// A "control tag" type of flash object - -class DVAPI FCT : public FObj -{ -public: - virtual ~FCT() {} - virtual void WriteToSWFStream(FSWFStream * /*_SWFStream*/) {} -}; - -// flash object that directs the flash player to complete a given set of actions at frame completion - -class DVAPI FCTDoAction : public FCT -{ -public: - FCTDoAction(); - virtual ~FCTDoAction(); - - void AddAction(FActionRecord *_actionRecord); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - std::list actionRecordList; -}; - -// Associates a label with the frame. This label can then be used -// in the Go to Label Action. - -class DVAPI FCTFrameLabel : public FCT -{ - -public: - FCTFrameLabel(FString *_frameName); - virtual ~FCTFrameLabel(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FString *frameName; -}; - -// a flash object that directs the player to add an object to the display list (flash 1.0) - -class DVAPI FCTPlaceObject : public FCT -{ -public: - // if no color transform then _colorTransform argument must be null - FCTPlaceObject(U16 _characterID, - U16 _depth, - FMatrix *_matrix, // always present - FCXForm *_colorTransform); // NULL if there is not a color transform - virtual ~FCTPlaceObject(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - U16 depth; - FMatrix *matrix; - FCXForm *colorTransform; -}; - -class DVAPI FCTPlaceObject2 : public FCT -{ -public: - // if a certain flag is not true, you must provide a NULL value for its associated argument(s) - FCTPlaceObject2(U16 _hasClipDepth, /*DM*/ - U16 _hasRatio, - U16 _hasCharID, - U16 _hasMove, - U16 _depth, - U16 _characterID, - FMatrix *_matrix, // NULL if the object does not have a matrix - FCXFormWAlpha *_colorTransform, // NULL if there is no color transform - U16 _ratio, - FString *_name, // NULL if there is no name - U16 _clipDepth); /*DM*/ - - //now is possible to give a clip action - // if a certain flag is not true, you must provide a NULL value for its associated argument(s) - FCTPlaceObject2(U16 _hasClipAction, - U16 _hasClipDepth, /*DM*/ - U16 _hasRatio, - U16 _hasCharID, - U16 _hasMove, - U16 _depth, - U16 _characterID, - FMatrix *_matrix, // NULL if the object does not have a matrix - FCXFormWAlpha *_colorTransform, // NULL if there is no color transform - U16 _ratio, - FString *_name, // NULL if there is no name - U16 _clipDepth, - FClipAction *_clipAction); /*DM*/ - - FCTPlaceObject2(const FCTPlaceObject2 &_obj); - - void SetParameters(U16 _hasClipDepth, /*DM*/ - U16 _hasRatio, - U16 _hasCharID, - U16 _hasMove, - U16 _depth, - U16 _characterID, - FMatrix *_matrix, // NULL if the object does not have a matrix - FCXFormWAlpha *_colorTransform, // NULL if there is no color transform - U16 _ratio, - FString *_name, // NULL if there is no name - U16 _clipDepth); /*DM*/ - - // Used to fix the high level manager depth sorting problem. - int GetDepth() { return depth; } - void SetDepth(int d) { depth = d; } - - virtual ~FCTPlaceObject2(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - U32 IsPlaceObject(); - int GetPlacedId(); - std::string GetName() { return name ? name->GetString() : string(); } - void SetId(U16 id); - void ChangePlacedId(U16 id); - - void SetMatrix(FMatrix *matrix); - void ApplyMatrix(const FMatrix &_matrix) - { - if (matrix) - (*matrix) = (*matrix) * _matrix; - else - matrix = new FMatrix(_matrix); - } - -private: - //flags - U16 hasClipAction; - U16 hasClipDepth; /*DM*/ - U16 hasRatio; - U16 hasCharID; - U16 hasMove; - - U16 depth; - U16 characterID; - FMatrix *matrix; - FCXFormWAlpha *colorTransform; - U16 ratio; - FString *name; - U16 clipDepth; /*DM*/ - FClipAction *clipAction; -}; - -// a flash control tag object which marks a SWF movie as uneditable - -class DVAPI FCTProtect : public FCT -{ -public: - FCTProtect(); - - virtual void WriteToSWFStream(FSWFStream *_SWFStream); -}; - -// a Flash control tag object which indicates to the flash player to remove an object from the display list (flash 1.0) - -class DVAPI FCTRemoveObject : public FCT -{ - -public: - FCTRemoveObject(U16 _characterID, U16 _depth); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - - // Used to fix the high level manager depth sorting problem. - int GetDepth() { return depth; } - void SetDepth(int d) { depth = d; } - -private: - U16 characterID; - U16 depth; -}; - -// a Flash control tag object which indicates to the flash player to remove an object from the display list (flash 1.0) - -class DVAPI FCTRemoveObject2 : public FCT -{ - -public: - FCTRemoveObject2(U16 _depth); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 depth; -}; - -// A flash object which sets a movie's background color - -class DVAPI FCTSetBackgroundColor : public FCT -{ -public: - FCTSetBackgroundColor(FColor *_color); - virtual ~FCTSetBackgroundColor(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FColor *color; -}; - -class DVAPI FCTUnparsedTag : public FCT -{ -public: - FCTUnparsedTag(U16 _tagId, U32 _lenght, U8 *_data); - virtual ~FCTUnparsedTag(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - USHORT GetID(); - void SetID(USHORT id); - -private: - U8 *data; - U32 lenght; - U16 tagId; -}; - -//a control tag that indicates end of the current frame - -class DVAPI FCTShowFrame : public FCT -{ - -public: - FCTShowFrame(); - U32 IsShowFrame(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); -}; - -// A flash object that instructs flash player to start a sound - -class DVAPI FCTStartSound : public FCT -{ -public: - FCTStartSound(U16 _soundID, FSoundInfo *_soundInfo); - virtual ~FCTStartSound(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 soundID; - FSoundInfo *soundInfo; -}; - -#ifdef WIN32 // added from DV -#pragma warning(pop) -#endif - -#endif diff --git a/toonz/sources/common/flash/FDT.cpp b/toonz/sources/common/flash/FDT.cpp deleted file mode 100644 index 6a59a01..0000000 --- a/toonz/sources/common/flash/FDT.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDT.cpp - - This source file is empty, since class FDT is an low-level abstract class for all - Definition-Tags, and all the derived classes of class FDT are defined in other - FDTxxx.cpp files. - -****************************************************************************************/ - -#include "FDT.h" - -// return 1; -// -// } diff --git a/toonz/sources/common/flash/FDT.h b/toonz/sources/common/flash/FDT.h deleted file mode 100644 index 37e459a..0000000 --- a/toonz/sources/common/flash/FDT.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDT.h - - This header-file contains the declaration of low-level class FDT. It is derived from - low-level class FObj, and also an abstract class from which all other low-level - FDTxxxx classes are derived. - -****************************************************************************************/ - -#ifndef F_D_T_H_ -#define F_D_T_H_ - -#include "FObj.h" - -// A "define type" flash object -// Flash objects are separated into define and control types -// distinction neccecary because in a flash frame, all define objects must come before control objects - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -class DVAPI FDT : public FObj -{ -public: - virtual ~FDT() {} - virtual void WriteToSWFStream(FSWFStream * /*_SWFStream*/) {} - // Defines, used by the font system. Perhaps not the best place for them, but better than - // the global situation. lee@middlesoft - enum { - ShiftJIS = 1, - Unicode = 2, - ANSI = 3 - }; - - virtual U16 ID(void) - { - FLASHASSERT(0); - return 0; - } - virtual void SetId(U16 id) { FLASHASSERT(0); } -}; - -#ifdef WIN32 // added from DV -#pragma warning(pop) -#endif -#endif diff --git a/toonz/sources/common/flash/FDTBitmaps.cpp b/toonz/sources/common/flash/FDTBitmaps.cpp deleted file mode 100644 index ded1425..0000000 --- a/toonz/sources/common/flash/FDTBitmaps.cpp +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTBitmaps.cpp - - This source file contains the definition for all low-level bitmap-related functions, - grouped by classes, which are all derived from class FDT, and related to bitmaps: - - - Class Member Function - - FDTDefineBits FDTDefineBits(U32, U8*); - U16 ID(void); - void WriteToSWFStream(FSWFStream*); - - FDTDefineBitsJPEG2 FDTDefineBitsJPEG2(U8*, U32); - U16 FDTDefineBitsJPEG2::ID(void); - void WriteToSWFStream(FSWFStream*); - - FDTDefineBitsJPEG3 FDTDefineBitsJPEG3(U8*, U32, U8*, U32); - U16 FDTDefineBitsJPEG3::ID(void); - void WriteToSWFStream(FSWFStream*); - - FDTDefineBitsLosslessBase FDTDefineBitsLosslessBase(U8, U8, U16, int, - void*, void*, bool); - void WriteToSWFStream(FSWFStream*); - - FDTDefineBitsLossless FDTDefineBitsLossless(U8, U16, U16, int, FRGB*, void*); - - FDTDefineBitsLossless2 FDTDefineBitsLossless(U8, U16, U16, int, FRGBA*, void*); - - FDTJPEGTables FDTJPEGTables(U32, U8*); - void WriteToSWFStream(FSWFStream*); - - - -****************************************************************************************/ - -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - -#include "FSWFStream.h" -#include "FObj.h" -#include "FDTBitmaps.h" -#include "zlib.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineBits ---------------------------------------------------------- - -FDTDefineBits::FDTDefineBits(U32 _size, U8 *_image) -{ - size = _size; - image = _image; - characterID = FObjCollection::Increment(); -} - -U16 FDTDefineBits::ID(void) -{ - return characterID; -} - -void FDTDefineBits::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteWord((U32)characterID); - body.WriteLargeData(image, size); - - _SWFStream->AppendTag(stagDefineBits, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineBitsJPEG2 ----------------------------------------------------- - -FDTDefineBitsJPEG2::FDTDefineBitsJPEG2(U8 *_JPEGStream, U32 _JPEGSize) -{ - - JPEGStream = new U8[_JPEGSize]; - memcpy(JPEGStream, _JPEGStream, _JPEGSize); - JPEGSize = _JPEGSize; - characterID = FObjCollection::Increment(); -} - -U16 FDTDefineBitsJPEG2::ID(void) -{ - - return characterID; -} - -FDTDefineBitsJPEG2::~FDTDefineBitsJPEG2() -{ -} - -void FDTDefineBitsJPEG2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)characterID); - - // 2 bytes indicating end of encoding stream - // no encoding data is written here because it is an empty stream - body.WriteByte(0xff); - body.WriteByte(0xd9); - - //2 bytes indicating beginning of JPEG stream - body.WriteByte(0xff); - body.WriteByte(0xd8); - - //the entire JPEG stream - body.WriteLargeData(JPEGStream, JPEGSize); - - //2 bytes indicating end of JPEG stream - body.WriteByte(0xff); - body.WriteByte(0xd9); - - _SWFStream->AppendTag(stagDefineBitsJPEG2, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineBitsJPEG3 ----------------------------------------------------- - -FDTDefineBitsJPEG3::FDTDefineBitsJPEG3(U8 *_JPEGStream, U32 _JPEGSize, - U8 *_alphaStream, U32 _alphaSize) -{ - JPEGStream = _JPEGStream; - JPEGSize = _JPEGSize; - alphaStream = _alphaStream; - alphaSize = _alphaSize; - characterID = FObjCollection::Increment(); -} - -U16 FDTDefineBitsJPEG3::ID(void) -{ - return characterID; -} - -void FDTDefineBitsJPEG3::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)characterID); - - //offset includes the 2 end of stream tags and the 1 beginning stream tag - U32 offset = JPEGSize + 6; - body.WriteDWord(offset); - - // 2 bytes indicating end of encoding stream - // no encoding data is written here - // an empty stream is written - body.WriteByte(0xff); - body.WriteByte(0xd9); - - //2 bytes indicating begining of JPEG stream - body.WriteByte(0xff); - body.WriteByte(0xd8); - - //the entire JPEG stream - body.WriteLargeData(JPEGStream, JPEGSize); - - //2 bytes indicating end of JPEG steam - body.WriteByte(0xff); - body.WriteByte(0xd9); - - // alpha data - body.WriteLargeData(alphaStream, alphaSize); - - _SWFStream->AppendTag(stagDefineBitsJPEG3, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineBitsLosslessBase ---------------------------------------------- - -FDTDefineBitsLosslessBase::FDTDefineBitsLosslessBase(U8 _format, - U16 _width, - U16 _height, - int _colorTableCount, - const void *_colorTableData, - const void *_imageData, - bool _alpha) -{ - format = _format; - width = _width; - height = _height; - colorTableCount = _colorTableCount; - alpha = _alpha; - characterID = FObjCollection::Increment(); - - // copy the memory to another block to be compressed - int rgbBytes = (alpha) ? 4 : 3; - int tableBytes = colorTableCount * rgbBytes; - - int bits = (1 << format); // how many bits does this format have? - - int imageBytes = (width * height * bits + 7) / 8; - TUINT32 totalBytes = imageBytes + tableBytes; - - // copy the image and the table to a new buffer - unsigned char *raw = new unsigned char[totalBytes]; - if (tableBytes) { - memcpy(raw, _colorTableData, tableBytes); - } - memcpy(&raw[tableBytes], _imageData, imageBytes); - - // a compressed buffer - the allocated size is based on a zlib formula - compressedSize = totalBytes + totalBytes / 100 + 12; - compressed = new unsigned char[compressedSize]; - - // now compress the raw data - note this will change compressedSize - int ret = compress2(compressed, (uLongf *)&compressedSize, raw, totalBytes, Z_BEST_COMPRESSION); - - FLASHASSERT(ret == Z_OK); - - delete[] raw; -} - -FDTDefineBitsLosslessBase::~FDTDefineBitsLosslessBase() -{ - delete[] compressed; -} - -void FDTDefineBitsLosslessBase::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteWord((U32)characterID); - body.WriteByte((U32)format); - body.WriteWord((U32)width); - body.WriteWord((U32)height); - - if (format <= bm8Bit) { - body.WriteByte((U32)(colorTableCount - 1)); - } - - body.WriteLargeData(compressed, compressedSize); - - if (alpha) - _SWFStream->AppendTag(stagDefineBitsLossless2, body.Size(), &body); - else - _SWFStream->AppendTag(stagDefineBitsLossless, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineBitsLossless -------------------------------------------------- - -FDTDefineBitsLossless::FDTDefineBitsLossless(U8 _format, - U16 _width, - U16 _height, - int _colorTableCount, - const FRGB *_colorTableData, - const void *_imageData) - : FDTDefineBitsLosslessBase(_format, _width, _height, _colorTableCount, _colorTableData, _imageData, false) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineBitsLossless2 ------------------------------------------------- - -FDTDefineBitsLossless2::FDTDefineBitsLossless2(U8 _format, - U16 _width, - U16 _height, - int _colorTableCount, - const FRGBA *_colorTableData, - const void *_imageData) - : FDTDefineBitsLosslessBase(_format, _width, _height, _colorTableCount, _colorTableData, _imageData, true) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTJPEGTables ---------------------------------------------------------- - -// Constructor. Currently takes in a U32 indicating the size of the data in bytes, and -// a pointer to the beginning of the stream of data. -FDTJPEGTables::FDTJPEGTables(U32 encodingDataSize, U8 *encodingData) -{ - this->encodingData = encodingData; - this->encodingDataSize = encodingDataSize; -} - -// Writes to the given _SWFStream. - -void FDTJPEGTables::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - body.WriteLargeData(encodingData, encodingDataSize); - - _SWFStream->AppendTag(stagJPEGTables, body.Size(), &body); -} diff --git a/toonz/sources/common/flash/FDTBitmaps.h b/toonz/sources/common/flash/FDTBitmaps.h deleted file mode 100644 index f6afb61..0000000 --- a/toonz/sources/common/flash/FDTBitmaps.h +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTBitmaps.h - - This header-file contains the declarations of all low-level bitmap-related classes, - which are all derived from class FDT: - - class FDTDefineBits; - class FDTDefineBitsJPEG2; - class FDTDefineBitsJPEG3; - class FDTDefineBitsLosslessBase; - class FDTDefineBitsLossless : public FDTDefineBitsLosslessBase; - class FDTDefineBitsLossless2 : public FDTDefineBitsLosslessBase; - class FDTJPEGTables; - -****************************************************************************************/ - -#ifndef _F_DEFINE_BITMAPS_H_ -#define _F_DEFINE_BITMAPS_H_ - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "FDT.h" - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -struct FRGB; -struct FRGBA; - -// A flash object which defines a jpeg bitmap image (flash 1.0) - -class DVAPI FDTDefineBits : public FDT -{ - -public: - // constructed with image size and a pointer to the actual jpeg stream - FDTDefineBits(U32 _size, U8 *_image); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - U32 size; - U8 *image; -}; - -// A flash object which defines a jpeg bitmap image (flash 2.0) -// Differs from FDTDefineBits in that the encoding data and image data are contained in the object separately, but this DefineBitsJPEG2 doesn't really do this (as does not flash)... -// An empty stream is writen where encoding data should normally be encountered and all the JPEG and encoding data is written within the JPEG stream - -class DVAPI FDTDefineBitsJPEG2 : public FDT -{ - -public: - FDTDefineBitsJPEG2(U8 *_JPEGStream, U32 _JPEGSize); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - ~FDTDefineBitsJPEG2(); - -private: - U16 characterID; - U32 JPEGSize; - U8 *JPEGStream; -}; - -// A flash object which defines a jpeg bitmap image (flash 3.0) -// Differs from FDTDefineBitsJPEG2 in that Alpha transparency data is contained in this object - -class DVAPI FDTDefineBitsJPEG3 : public FDT -{ - -public: - FDTDefineBitsJPEG3(U8 *_JPEGStream, U32 _JPEGSize, - U8 *_alphaStream, U32 _alphaSize); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - U32 alphaSize; - U32 JPEGSize; - U8 *JPEGStream; - U8 *alphaStream; -}; - -// Base class for FDTDefineBitsLossless (below) and FDTDefineBitsLossless2. -// Please see those two classes for descripion of parameters. -// Note this class can be constructed - it will write the correct tag when -// WriteToSWFStream is called. Or one of the child classes can be used. - -class DVAPI FDTDefineBitsLosslessBase : public FDT -{ - -public: - enum { - bm1Bit, // 2 color - bm2Bit, // 4 color - bm4Bit, // 16 color - bm8Bit, // 256 color - bm16Bit, // high - bm32Bit // true - }; - - virtual U16 ID() { return characterID; } - - FDTDefineBitsLosslessBase(U8 _format, - U16 _width, - U16 _height, - int _colorTableCount, - const void *_colorTableData, - const void *_imageData, - bool alpha); - virtual ~FDTDefineBitsLosslessBase(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - U8 format; - U16 width; - U16 height; - int colorTableCount; - bool alpha; - TUINT32 compressedSize; // a count of how many bytes are in the compressed buffer - unsigned char *compressed; // pointer to the compressed data -}; - -// Defines a loss-less bitmap object, like a GIF, BMP, or PCT. -// This version does not accept alpha channel data - FDTDefineBitsLossless2 does. -// Accepts raw bitmap data and compresses it. - -class DVAPI FDTDefineBitsLossless : public FDTDefineBitsLosslessBase -{ - -public: - FDTDefineBitsLossless(U8 _format, // format, from FDTDefineBitsLosslessBase. - U16 _width, // size of the image - U16 _height, - int _colorTableCount, // how many entries in the color table - consistent - // with format. May be 0. - const FRGB *_colorTableData, // Null if no color cable. RGB data - const void *_imageData // Pointer to the image. (byte aligned.) - ); -}; - -// Defines a loss-less bitmap object, like a GIF, BMP, or PCT. -// This version requires alpha channel data. Note the color table is RGBA. -// Accepts raw bitmap data and compresses it. - -class DVAPI FDTDefineBitsLossless2 : public FDTDefineBitsLosslessBase -{ - -public: - FDTDefineBitsLossless2(U8 _format, // format, from FDTDefineBitsLosslessBase. - U16 _width, // size of the image - U16 _height, - int _colorTableCount, // how many entries in the color table - consistent - // with format. May be 0. - const FRGBA *_colorTableData, // Null if no color cable. RGB data - const void *_imageData // Pointer to the image. (byte aligned.) - ); -}; - -//the JPEGTable structure (contains the encoding scheme for all JPEGs defined using DefineBits - -class DVAPI FDTJPEGTables : public FDT -{ - -public: - FDTJPEGTables(U32 encodingDataSize, U8 *encodingData); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 encodingDataSize; - U8 *encodingData; -}; -#endif diff --git a/toonz/sources/common/flash/FDTButtons.cpp b/toonz/sources/common/flash/FDTButtons.cpp deleted file mode 100644 index df6b692..0000000 --- a/toonz/sources/common/flash/FDTButtons.cpp +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTButtons.cpp - - This source file contains the definition for all low-level button-related functions, - grouped by classes: - - Class Member Function - - FButtonRecord1 FButtonRecord1(U8, U8, U8, U8, U16, FMatrix*); - FButtonRecord1 ~FButtonRecord1(); - void WriteToSWFStream(FSWFStream*); - - FButtonRecord2 FButtonRecord2(U8, U8, U8, U8, U16, U16, FMatrix*, FACXForm*); - ~FButtonRecord2(); - void WriteToSWFStream(FSWFStream*); - - FButtonRecordList FButtonRecordList(); - ~FButtonRecordList(); - void AddRecord(FAButtonRecord*); - int Size(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineButton FDTDefineButton(void); - ~FDTDefineButton(); - U16 ID(void); - void AddButtonRecord(FButtonRecord1*); - void AddActionRecord(FActionRecord*); - void WriteToSWFStream(FSWFStream*); - - FDTDefineButton2 FDTDefineButton2(U8); - ~FDTDefineButton2(void); - U16 ID(void); - void AddButtonRecord(FButtonRecord2*); - void AddActionCondition(FActionCondition*); - void WriteToSWFStream(FSWFStream*); - - FDTDefineButtonCXForm FDTDefineButtonCXForm(U16, FCXForm*); - ~FDTDefineButtonCXForm(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineButtonSound FDTDefineButtonSound(U16, U16, FSoundInfo*, U16, FSoundInfo*, - U16, FSoundInfo*, U16, FSoundInfo*); - ~FDTDefineButtonSound(); - void WriteToSWFStream(FSWFStream*); - -****************************************************************************************/ -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - -#include "FPrimitive.h" -#include "FDTButtons.h" -#include "FAction.h" -#include "FDTShapes.h" -#include "FDTSounds.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FButtonRecord1 --------------------------------------------------------- - -FButtonRecord1::FButtonRecord1(U8 _hit, U8 _down, U8 _over, U8 _up, U16 _layer, FMatrix *_matrix) -{ - hit = _hit; - down = _down; - over = _over; - up = _up; - layer = _layer; - matrix = _matrix; - characterID = FObjCollection::Increment(); -} - -FButtonRecord1::~FButtonRecord1() -{ - delete matrix; -} - -void FButtonRecord1::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->WriteBits(0, 4); - _SWFStream->WriteBits(hit, 1); - _SWFStream->WriteBits(down, 1); - _SWFStream->WriteBits(over, 1); - _SWFStream->WriteBits(up, 1); - _SWFStream->WriteWord(characterID); - _SWFStream->WriteWord(layer); - matrix->WriteToSWFStream(_SWFStream); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FButtonRecord2 --------------------------------------------------------- - -FButtonRecord2::FButtonRecord2(U8 _hit, U8 _down, U8 _over, U8 _up, U16 _characterID, U16 _layer, FMatrix *_matrix, FACXForm *_colorTransform) -{ - hit = _hit; - down = _down; - over = _over; - up = _up; - characterID = _characterID; - layer = _layer; - matrix = _matrix; - colorTransform = _colorTransform; -} - -FButtonRecord2::~FButtonRecord2() -{ - delete matrix; - delete colorTransform; -} - -void FButtonRecord2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->FlushBits(); - _SWFStream->WriteBits(0, 4); - _SWFStream->WriteBits(hit, 1); - _SWFStream->WriteBits(down, 1); - _SWFStream->WriteBits(over, 1); - _SWFStream->WriteBits(up, 1); - _SWFStream->WriteWord(characterID); - _SWFStream->WriteWord(layer); - - matrix->WriteToSWFStream(_SWFStream); - _SWFStream->FlushBits(); - colorTransform->WriteToSWFStream(_SWFStream); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FButtonRecordList ------------------------------------------------------ - -FButtonRecordList::FButtonRecordList() {} - -FButtonRecordList::~FButtonRecordList() -{ - while (!listOfButtonRecords.empty()) { - - delete listOfButtonRecords.front(); - - listOfButtonRecords.pop_front(); - } -} - -void FButtonRecordList::AddRecord(FAButtonRecord *_buttonRecord) -{ - - listOfButtonRecords.push_back(_buttonRecord); -} - -int FButtonRecordList::Size() -{ - - return listOfButtonRecords.size(); -} - -void FButtonRecordList::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - std::list::iterator cursor; - - for (cursor = listOfButtonRecords.begin(); cursor != listOfButtonRecords.end(); cursor++) { - - (*cursor)->WriteToSWFStream(_SWFStream); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineButton -------------------------------------------------------- - -FDTDefineButton::FDTDefineButton(void) -{ - - characterID = FObjCollection::Increment(); -} - -FDTDefineButton::~FDTDefineButton() -{ - - // delete all entries in action record list - while (!listOfActionRecords.empty()) { - - delete listOfActionRecords.front(); - listOfActionRecords.pop_front(); - } - - //delete all entries in button record list - while (!listOfButtonRecords.empty()) { - - delete listOfButtonRecords.front(); - - listOfButtonRecords.pop_front(); - } -} - -U16 FDTDefineButton::ID(void) -{ - - return characterID; -} - -void FDTDefineButton::AddButtonRecord(FButtonRecord1 *_buttonRecord) -{ - - listOfButtonRecords.push_back(_buttonRecord); -} - -void FDTDefineButton::AddActionRecord(FActionRecord *_actionRecord) -{ - - listOfActionRecords.push_back(_actionRecord); -} - -void FDTDefineButton::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - body.WriteWord((U32)characterID); - - //write the button record list to the body - std::list::iterator cursor; - - for (cursor = listOfButtonRecords.begin(); cursor != listOfButtonRecords.end(); cursor++) { - - (*cursor)->WriteToSWFStream(&body); - } - - //write the end of button record flag - body.WriteByte(0); - - //write the action record list to the body - std::list::iterator cursor2; - for (cursor2 = listOfActionRecords.begin(); cursor2 != listOfActionRecords.end(); cursor2++) { - - (*cursor2)->WriteToSWFStream(&body); - } - - //write the action end flag - body.WriteByte(0); - - _SWFStream->AppendTag(stagDefineButton2, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineButton2 ------------------------------------------------------- - -FDTDefineButton2::FDTDefineButton2(U8 _menuFlag) -{ - - characterID = FObjCollection::Increment(); - menuFlag = _menuFlag; -} - -FDTDefineButton2::~FDTDefineButton2(void) -{ - - //delete all entries in conditionsList - while (!conditionList.empty()) { - - delete conditionList.front(); - - conditionList.pop_front(); - } - - //delete all entries in listOfButtonRecords - while (!listOfButtonRecords.empty()) { - - delete listOfButtonRecords.front(); - - listOfButtonRecords.pop_front(); - } -} - -U16 FDTDefineButton2::ID(void) -{ - - return characterID; -} - -void FDTDefineButton2::AddButtonRecord(FButtonRecord2 *_buttonRecord) -{ - - listOfButtonRecords.push_back(_buttonRecord); -} - -void FDTDefineButton2::AddActionCondition(FActionCondition *_actionCondition) -{ - - conditionList.push_back(_actionCondition); -} - -void FDTDefineButton2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)characterID); - - body.WriteByte((U32)menuFlag); - - FSWFStream buttonRecordStream; - - //write the list of button records to button record stream - std::list::iterator cursor; - - for (cursor = listOfButtonRecords.begin(); cursor != listOfButtonRecords.end(); cursor++) { - - (*cursor)->WriteToSWFStream(&buttonRecordStream); - } - - buttonRecordStream.WriteByte((U32)0); - U32 offset = 0; - if (!conditionList.empty()) - offset = buttonRecordStream.Size() + 2; //have to count the action offset also - body.WriteWord(offset); - body.Append(&buttonRecordStream); - - //write the list of action records - if (!conditionList.empty()) { - std::list::iterator cursor1; - std::list::iterator cursor2; - cursor2 = (conditionList.end()); - cursor2--; - - for (cursor1 = conditionList.begin(); cursor1 != cursor2; cursor1++) { - - (*cursor1)->WriteToSWFStream(&body); - } - - (*cursor1)->WriteToSWFStream(&body, 1); //flag indicating it is the last action condition - } - - _SWFStream->AppendTag(stagDefineButton2, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineButtonCXForm -------------------------------------------------- - -FDTDefineButtonCXForm::FDTDefineButtonCXForm(U16 _characterID, FCXForm *_colorTransform) -{ - characterID = _characterID; - colorTransform = _colorTransform; -} - -FDTDefineButtonCXForm::~FDTDefineButtonCXForm() -{ - - delete colorTransform; -} - -void FDTDefineButtonCXForm::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)characterID); - colorTransform->WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagDefineButtonCxform, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineButtonSound --------------------------------------------------- - -FDTDefineButtonSound::FDTDefineButtonSound(U16 _buttonID, U16 _soundID0, FSoundInfo *_soundInfo0, - U16 _soundID1, FSoundInfo *_soundInfo1, - U16 _soundID2, FSoundInfo *_soundInfo2, - U16 _soundID3, FSoundInfo *_soundInfo3) -{ - buttonID = _buttonID; - soundID0 = _soundID0; - soundInfo0 = _soundInfo0; - soundID1 = _soundID1; - soundInfo1 = _soundInfo1; - soundID2 = _soundID2; - soundInfo2 = _soundInfo2; - soundID3 = _soundID3; - soundInfo3 = _soundInfo3; -} - -FDTDefineButtonSound::~FDTDefineButtonSound() -{ - - delete soundInfo0; - delete soundInfo1; - delete soundInfo2; - delete soundInfo3; -} - -void FDTDefineButtonSound::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)buttonID); - - body.WriteWord((U32)soundID0); - soundInfo0->WriteToSWFStream(&body); - - body.WriteWord((U32)soundID1); - soundInfo1->WriteToSWFStream(&body); - - body.WriteWord((U32)soundID2); - soundInfo2->WriteToSWFStream(&body); - - body.WriteWord((U32)soundID3); - soundInfo3->WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagDefineButtonSound, body.Size(), &body); -} diff --git a/toonz/sources/common/flash/FDTButtons.h b/toonz/sources/common/flash/FDTButtons.h deleted file mode 100644 index d2d2c3e..0000000 --- a/toonz/sources/common/flash/FDTButtons.h +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTButtons.h - - This header-file contains the declarations of all low-level button-related classes. - Their parent classes are in the parentheses: - - class FAButtonRecord; - class FButtonRecord1; (public FAButtonRecord) - class FButtonRecord2; (public FAButtonRecord) - class FButtonRecordList; - class FDTDefineButton; (public FDT) - class FDTDefineButton2; (public FDT) - class FDTDefineButtonCXForm; (public FDT) - class FDTDefineButtonSound. (public FDT) - -****************************************************************************************/ - -#ifndef _F_DTBUTTONS_H_ -#define _F_DTBUTTONS_H_ - -#include "FDT.h" - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -class FMatrix; -class FACXForm; -class FActionRecord; -class FActionCondition; -class FCXForm; -class FSoundInfo; - -// Specifies appearance aspects for a button definition - -class DVAPI FAButtonRecord -{ - -public: - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; - - virtual ~FAButtonRecord() {} -}; - -// Specifies appearance aspects for a button definition (flash 1.0) - -class DVAPI FButtonRecord1 : public FAButtonRecord -{ - -public: - FButtonRecord1(U8 _hit, U8 _down, U8 _over, U8 _up, U16 _layer, FMatrix *_matrix); - virtual ~FButtonRecord1(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 hit; - U8 down; - U8 over; - U8 up; - U16 layer; - FMatrix *matrix; - U16 characterID; -}; - -// Specifies appearance aspects for a button definition (flash 3.0) - -class DVAPI FButtonRecord2 : public FAButtonRecord -{ - -public: - FButtonRecord2(U8 _hit, U8 _down, U8 _over, U8 _up, U16 _characterID, U16 _layer, FMatrix *_matrix, FACXForm *_colorTransform); - virtual ~FButtonRecord2(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 hit; - U8 down; - U8 over; - U8 up; - U16 layer; - FMatrix *matrix; - FACXForm *colorTransform; - U16 characterID; -}; - -// a list of button records - -class DVAPI FButtonRecordList -{ - -public: - FButtonRecordList(); - virtual ~FButtonRecordList(); - void AddRecord(FAButtonRecord *_buttonRecord); - int Size(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - std::list listOfButtonRecords; -}; - -// a flash object that defines a button in a SWF movie (flash 1.0) - -class DVAPI FDTDefineButton : public FDT -{ - -public: - FDTDefineButton(void); - virtual ~FDTDefineButton(); - U16 ID(void); - void AddButtonRecord(FButtonRecord1 *_buttonRecord); - void AddActionRecord(FActionRecord *_actionRecord); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - std::list listOfActionRecords; - std::list listOfButtonRecords; -}; - -// a flash object that defines a button in a SWF movie (flash 3.0) - -class DVAPI FDTDefineButton2 : public FDT -{ - -public: - FDTDefineButton2(U8 _menuFlag); - virtual ~FDTDefineButton2(void); - U16 ID(void); - void AddButtonRecord(FButtonRecord2 *_buttonRecord); - void AddActionCondition(FActionCondition *_actionCondition); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - virtual void SetID(U16 id) { characterID = id; } - -private: - U16 characterID; - U8 menuFlag; - std::list conditionList; - std::list listOfButtonRecords; -}; - -//A flash object that defines a color transformation on a button - -class DVAPI FDTDefineButtonCXForm : public FDT -{ - -public: - FDTDefineButtonCXForm(U16 _characterID, FCXForm *_colorTransform); - virtual ~FDTDefineButtonCXForm(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - FCXForm *colorTransform; -}; - -class DVAPI FDTDefineButtonSound : public FDT -{ - -public: - FDTDefineButtonSound(U16 _buttonID, U16 _soundID0, FSoundInfo *_soundInfo0, - U16 _soundID1, FSoundInfo *_soundInfo1, - U16 _soundID2, FSoundInfo *_soundInfo2, - U16 _soundID3, FSoundInfo *_soundInfo3); - virtual ~FDTDefineButtonSound(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 buttonID; - U16 soundID0; - U16 soundID1; - U16 soundID2; - U16 soundID3; - FSoundInfo *soundInfo0; - FSoundInfo *soundInfo1; - FSoundInfo *soundInfo2; - FSoundInfo *soundInfo3; -}; - -#endif diff --git a/toonz/sources/common/flash/FDTFonts.cpp b/toonz/sources/common/flash/FDTFonts.cpp deleted file mode 100644 index c03af60..0000000 --- a/toonz/sources/common/flash/FDTFonts.cpp +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTFonts.cpp - - This source file contains the definition for all low-level font-related functions, - grouped by classes: - - Class Member Function - - FDTDefineFont FDTDefineFont(); - ~FDTDefineFont(); - U16 ID(); - void AddShapeGlyph(FShape*); - void WriteToSWFStream(FSWFStream*); - - FDTDefineFont2 FDTDefineFont2(char*, U16, U16, U16); - FDTDefineFont2(char*, U16, U16, U16, S16, S16, S16); - ~FDTDefineFont2(); - void AddShapeGlyph(FShape*, U16, S16, FRect*); - void AddKerningRec(FKerningRec*); - U16 nIndexBits(); - U16 ID(void); - void WriteToSWFStream(FSWFStream*); - - FDTDefineFontInfo FDTDefineFontInfo(const char*, U16, U16, U16, U16); - void FDTDefineFontInfo::AddCode(U16); - U16 FDTDefineFontInfo::ID(); - void WriteToSWFStream(FSWFStream*); - -// FGlyphEntry FGlyphEntry(U16, S16); -// S16 AdvanceValue(); -// void IncludeNBitInfo(U16, U16); -// void WriteToSWFStream(FSWFStream*); - - FKerningRec FKerningRec (U16, U16, short); - void CodesWide (U16); - void WriteToSWFStream(FSWFStream*); - - - Note: All member functions of FGlyphEntry have been commented out. Need to fix. - -****************************************************************************************/ -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - -#include "FDTFonts.h" -#include "FDTShapes.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FButtonRecord1 --------------------------------------------------------- - -FDTDefineFont::FDTDefineFont() -{ - - characterID = FObjCollection::Increment(); - - nFillBits = 1; - nLineBits = 0; -} - -FDTDefineFont::~FDTDefineFont() -{ - - while (!shapeGlyphs.empty()) { - - delete shapeGlyphs.front(); - shapeGlyphs.pop_front(); - } -} - -U16 FDTDefineFont::ID() -{ - - return (U8)characterID; -} - -void FDTDefineFont::AddShapeGlyph(FShape *_shape) -{ - - _shape->SetFillBits(nFillBits); - _shape->SetLineBits(nLineBits); - shapeGlyphs.push_back(_shape); -} - -void FDTDefineFont::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - U32 offsetsBufferSize = shapeGlyphs.size() * 2; - - FSWFStream body; - FSWFStream shapeBuffer; - std::list offsetsList; - - // get values for offsets and place them in a list - // write list of shapeGlyphs to shape buffer - offsetsList.push_back(offsetsBufferSize); - - std::list::iterator cursor; - std::list::iterator nextToLast = shapeGlyphs.end(); - nextToLast--; - for (cursor = shapeGlyphs.begin(); cursor != nextToLast; cursor++) { - - (*cursor)->WriteToSWFStream(&shapeBuffer); - offsetsList.push_back(offsetsBufferSize + shapeBuffer.Size()); - } - - (*cursor)->WriteToSWFStream(&shapeBuffer); - - body.WriteWord((U32)characterID); - - // write offsetsList to body - while (!offsetsList.empty()) { - - body.WriteWord((U32)offsetsList.front()); - offsetsList.pop_front(); - } - - //write shape buffer to body - body.Append(&shapeBuffer); - - //put tag on body and write to stream - _SWFStream->AppendTag(stagDefineFont, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineFont2 --------------------------------------------------------- - -FDTDefineFont2::FDTDefineFont2(const char *_fontName, U16 _encodeType, U16 _italicFlag, U16 _boldFlag) -{ - fontID = FObjCollection::Increment(); - hasLayoutFlag = 1; - encodeType = _encodeType; - italicFlag = _italicFlag; - boldFlag = _boldFlag; - fontName = new FString((U8 *)_fontName); - nFillBits = 1; - nLineBits = 0; - ascenderHeight = 0; - descenderHeight = 0; - leadingHeight = 0; -} - -FDTDefineFont2::FDTDefineFont2(const char *_fontName, U16 _encodeType, U16 _italicFlag, - U16 _boldFlag, S16 _ascenderHeight, - S16 _descenderHeight, S16 _leadingHeight) -{ - - fontID = FObjCollection::Increment(); - hasLayoutFlag = 1; - encodeType = _encodeType; - italicFlag = _italicFlag; - boldFlag = _boldFlag; - fontName = new FString((U8 *)_fontName); - - ascenderHeight = _ascenderHeight; - descenderHeight = _descenderHeight; - leadingHeight = _leadingHeight; - - nFillBits = 1; - nLineBits = 0; -} - -FDTDefineFont2::~FDTDefineFont2() -{ - - delete fontName; - - while (!glyphs.empty()) { - delete glyphs.front().shape; - delete glyphs.front().bounds; - glyphs.pop_front(); - } - - while (!kerningTable.empty()) { - - delete kerningTable.front(); - kerningTable.pop_front(); - } -} - -void FDTDefineFont2::AddShapeGlyph(FShape *_shape, U16 _shapeCode, S16 _shapeAdvance, - FRect *_shapeBounds) -{ - // FIXME, don't know what nFillBits and nLineBits are - _shape->SetFillBits(nFillBits); - _shape->SetLineBits(nLineBits); - Glyph g; - g.advance = _shapeAdvance; - g.bounds = _shapeBounds; - g.code = _shapeCode; - g.shape = _shape; - glyphs.push_back(g); -} - -void FDTDefineFont2::AddKerningRec(FKerningRec *_kerningRecord) -{ - - if (hasLayoutFlag) - kerningTable.push_back(_kerningRecord); -} - -U16 FDTDefineFont2::nIndexBits() -{ - - return (U16)FSWFStream::MinBits(glyphs.size() - 1, false); -} - -U16 FDTDefineFont2::ID(void) -{ - - return fontID; -} - -void FDTDefineFont2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - // U32 offsetsSize = (glyphs.size() * 2); - // U32 offsetsSizeWide = glyphs.size() * 4; - // U16 wideOffsetsFlag = 0; - // U16 wideCodesFlag = 0; - // std::list offsetsList; - - // FIXME: add wide offset later - S16 *offsetTable; - if (glyphs.size() > 0) - offsetTable = new S16[glyphs.size()]; - else - offsetTable = 0; - - int i; - - FSWFStream body; - FSWFStream shapeBuffer; - - std::list::iterator glyphCursor; - for (glyphCursor = glyphs.begin(), i = 0; glyphCursor != glyphs.end(); glyphCursor++, i++) { - offsetTable[i] = (S8)shapeBuffer.Size(); - glyphCursor->shape->WriteToSWFStream(&shapeBuffer); - } - - body.WriteWord((U32)fontID); - //write flags to body - body.WriteBits((U32)hasLayoutFlag, 1); - - switch (encodeType) { - - case ShiftJIS: - body.WriteBits((U32)1, 1); - body.WriteBits((U32)0, 1); - body.WriteBits((U32)0, 1); - break; - case Unicode: - body.WriteBits((U32)0, 1); - body.WriteBits((U32)1, 1); - body.WriteBits((U32)0, 1); - break; - case ANSI: - body.WriteBits((U32)0, 1); - body.WriteBits((U32)0, 1); - body.WriteBits((U32)1, 1); - break; - } - body.WriteBits((U32)0, 1); // 0 for narrowOffsetFlag - body.WriteBits((U32)0, 1); // 0 for narrowOffsetCode - body.WriteBits((U32)italicFlag, 1); - body.WriteBits((U32)boldFlag, 1); - body.WriteByte(0); // FontFlagsReserved UB[8] - - body.WriteByte((U32)fontName->Length()); - fontName->WriteToSWFStream(&body, false); // write the name - - body.WriteWord((U32)glyphs.size()); - - // write offsetsList to body - if (glyphs.size() > 0) - body.WriteLargeData((U8 *)offsetTable, 2 * glyphs.size()); - - //write shape glyph buffer to body - body.Append(&shapeBuffer); - - for (glyphCursor = glyphs.begin(), i = 0; glyphCursor != glyphs.end(); glyphCursor++, i++) { - body.WriteWord(glyphCursor->code); - } - - // write layout information to body - if (hasLayoutFlag) { - body.WriteWord((U32)ascenderHeight); - body.WriteWord((U32)descenderHeight); - body.WriteWord((U32)leadingHeight); - - for (glyphCursor = glyphs.begin(), i = 0; glyphCursor != glyphs.end(); glyphCursor++, i++) { - body.WriteWord(glyphCursor->advance); - } - - for (glyphCursor = glyphs.begin(), i = 0; glyphCursor != glyphs.end(); glyphCursor++, i++) { - glyphCursor->bounds->WriteToSWFStream(&body); - } - - body.WriteWord((U32)kerningTable.size()); - - std::list::iterator kernCursor; - - for (kernCursor = kerningTable.begin(); kernCursor != kerningTable.end(); kernCursor++) { - - (*kernCursor)->CodesWide(0); // 0 is narraw offset flag - (*kernCursor)->WriteToSWFStream(&body); - } - } - - // create entire tag with record header - _SWFStream->AppendTag(stagDefineFont2, body.Size(), &body); - delete[] offsetTable; -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FButtonRecord1 --------------------------------------------------------- - -FDTDefineFontInfo::FDTDefineFontInfo(const char *_fontName, U16 _fontID, - U16 _encodeType, U16 _italicFlag, - U16 _boldFlag) -{ - - characterID = FObjCollection::Increment(); - encodeType = _encodeType; - italicFlag = _italicFlag; - boldFlag = _boldFlag; - - fontID = _fontID; - - fontName = new FString((U8 *)_fontName); -} - -FDTDefineFontInfo::~FDTDefineFontInfo() -{ - delete fontName; -} - -void FDTDefineFontInfo::AddCode(U16 _someCode) -{ - - codeTable.push_back(_someCode); -} - -U16 FDTDefineFontInfo::ID() -{ - return (U8)characterID; -} - -void FDTDefineFontInfo::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - U16 wideCodesFlag = 0; - FSWFStream body; - - //determine whether 8 or 16 bit code fields are needed - std::list::iterator cursor; - for (cursor = codeTable.begin(); (cursor != codeTable.end()) && (wideCodesFlag == 0) // fixed from DV - ; - cursor++) { - if ((*cursor) > 65530) - wideCodesFlag = 1; - } - - body.WriteWord((U32)fontID); - - body.WriteByte((U32)fontName->Length()); - - fontName->WriteToSWFStream(&body, false); - - // body.WriteBits((U32) reservedFlags, 2); - body.WriteBits((U32)0, 2); - - switch (encodeType) { - - case ShiftJIS: - body.WriteBits((U32)0, 1); - body.WriteBits((U32)1, 1); - body.WriteBits((U32)0, 1); - break; - case Unicode: - body.WriteBits((U32)1, 1); - body.WriteBits((U32)0, 1); - body.WriteBits((U32)0, 1); - break; - case ANSI: - body.WriteBits((U32)0, 1); - body.WriteBits((U32)0, 1); - body.WriteBits((U32)1, 1); - break; - } - - body.WriteBits((U32)italicFlag, 1); - body.WriteBits((U32)boldFlag, 1); - - body.WriteBits((U32)wideCodesFlag, 1); - - //write code table to body - while (!codeTable.empty()) { - if (wideCodesFlag) { - body.WriteWord((U32)codeTable.front()); - codeTable.pop_front(); - } else { - body.WriteByte((U32)codeTable.front()); - codeTable.pop_front(); - } - } - - // create entire tag with record header - _SWFStream->AppendTag(stagDefineFontInfo, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FGlyphEntry ------------------------------------------------------------ - -// FGlyphEntry::FGlyphEntry(U16 index, S16 advance) -// { -// -// glyphIndex = index; -// glyphAdvance = advance; -// -// } -// -// -// S16 FGlyphEntry::AdvanceValue() -// { -// -// return glyphAdvance; -// -// } - -// Used to specify the nBit info for the entries. This is determined and passed to -// the glyph entry just before write time. - -// void FGlyphEntry::IncludeNBitInfo(U16 _nIndexBits, U16 _nAdvanceBits) -// { -// -// nIndexBits = _nIndexBits; -// nAdvanceBits = _nAdvanceBits; -// } -// -// void FGlyphEntry::WriteToSWFStream(FSWFStream *_SWFStream) -// { -// -// _SWFStream->WriteBits((U32) glyphIndex, nIndexBits); -// _SWFStream->WriteBits((U32) glyphAdvance, nAdvanceBits); -// -// } - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FKerningRec ------------------------------------------------------------ - -FKerningRec::FKerningRec(U16 cd1, U16 cd2, short krnAdj) -{ - - wideCodesFlag = 0; // default not wide - code1 = cd1; - code2 = cd2; - kerningAdjust = krnAdj; -} - -void FKerningRec::CodesWide(U16 _flag) -{ - - if (_flag) - wideCodesFlag = 1; - else - wideCodesFlag = 0; -} - -void FKerningRec::WriteToSWFStream(FSWFStream *b) -{ - if (wideCodesFlag) { - b->WriteWord((U32)code1); - b->WriteWord((U32)code2); - } else { - b->WriteByte((U32)code1); - b->WriteByte((U32)code2); - } - - b->WriteWord((U32)kerningAdjust); -} diff --git a/toonz/sources/common/flash/FDTFonts.h b/toonz/sources/common/flash/FDTFonts.h deleted file mode 100644 index 5b64924..0000000 --- a/toonz/sources/common/flash/FDTFonts.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTFonts.h - - This header-file contains the declarations of all low-level font-related classes. - Their parent classes are in the parentheses: - - class FKerningRec; - class FDTDefineFont; (public FDT) - class FDTDefineFont2; (public FDT) - class FDTDefineFontInfo; (public FDT) -// class FGlyphEntry; - - Note: Class FGlyphEntry has been commented out. Need to fix. - -****************************************************************************************/ - -#ifndef _FDT_FONTS_H_ -#define _FDT_FONTS_H_ - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" -#include "FDT.h" -#include "FPrimitive.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -class FShape; - -// A kerning record - -class FKerningRec -{ - -public: - FKerningRec(U16 _code1, U16 _code2, S16 _kerningAdjust); - void CodesWide(U16 _flag); - virtual void WriteToSWFStream(FSWFStream *b); - - virtual ~FKerningRec() {} - -private: - U16 wideCodesFlag; - U16 code1; - U16 code2; - S16 kerningAdjust; -}; - -// A flash object that defines a font's appearance - -class DVAPI FDTDefineFont : public FDT -{ - -public: - FDTDefineFont(void); - virtual ~FDTDefineFont(); - - U16 ID(void); - void AddShapeGlyph(FShape *_shape); - int NumberOfGlyphs() { return shapeGlyphs.size(); } - - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 characterID; - std::list shapeGlyphs; - U32 nFillBits; - U32 nLineBits; -}; - -// A flash object that defines a font's appearance (flash 3.0) - -class DVAPI FDTDefineFont2 : public FDT -{ -public: - FDTDefineFont2(const char *_fontName, - U16 _encodeType, // ShiftJIS, Unicode, ANSI - U16 _italicFlag, - U16 _boldFlag); - - FDTDefineFont2(const char *_fontName, - U16 _encodeType, - U16 _italicFlag, - U16 _boldFlag, - S16 _ascenderHeight, - S16 _descenderHeight, - S16 _leadingHeight); - virtual ~FDTDefineFont2(); - - void AddShapeGlyph(FShape *_shape, U16 _shapeCode, S16 _shapeAdvance = 0, - FRect *_shapeBounds = 0); - void AddKerningRec(FKerningRec *_kerningRecord); - U16 nIndexBits(); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 fontID; - int hasLayoutFlag; - U16 encodeType; - int italicFlag; - int boldFlag; - - FString *fontName; - struct Glyph { - FShape *shape; - U16 code; - S16 advance; - FRect *bounds; - }; - S16 ascenderHeight; - S16 descenderHeight; - S16 leadingHeight; - - std::list glyphs; - - std::list kerningTable; - U32 nFillBits; - U32 nLineBits; -}; - -// A flash object that defines the mapping from a flash font object to a TrueType or ATM font so that a player can optionally use them - -class DVAPI FDTDefineFontInfo : public FDT -{ - -public: - FDTDefineFontInfo(const char *_fontName, - U16 _fontID, - U16 _encodeType, - U16 _italicFlag, - U16 _boldFlag); - virtual ~FDTDefineFontInfo(); - void AddCode(U16 _someCode); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 characterID; - FString *fontName; - U16 encodeType; - U16 italicFlag; - U16 boldFlag; - std::list codeTable; - U16 fontID; -}; - -// Found in DefineText. Used to describe the glyph index and X advance value to use for a -// particular character in the currently selected font for the text record. - -// class FGlyphEntry { -// -// public: -// -// FGlyphEntry (U16 index, S16 advance); -// S16 AdvanceValue(); -// void IncludeNBitInfo(U16 _nIndexBits, U16 _nAdvanceBits); -// void WriteToSWFStream(FSWFStream *_SWFStream); -// -// -// private: -// -// U16 glyphIndex; -// S16 glyphAdvance; -// U16 nIndexBits; -// U16 nAdvanceBits; -// -// }; - -#endif diff --git a/toonz/sources/common/flash/FDTShapes.cpp b/toonz/sources/common/flash/FDTShapes.cpp deleted file mode 100644 index 381f692..0000000 --- a/toonz/sources/common/flash/FDTShapes.cpp +++ /dev/null @@ -1,1771 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTShapes.cpp - - This source file contains the definition for all low-level shape-related functions, - grouped by classes: - - Class Member Function - - FCXForm FCXForm(U32, U32, S32, S32, S32, S32, S32, S32); - U32 FCXForm::MinBits(); - void WriteToSWFStream(FSWFStream*); - - FCXFormWAlpha FCXFormWAlpha(U32, U32, S32, S32, S32, S32, S32, S32, S32, S32); - U32 MinBits(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineMorphShape FDTDefineMorphShape (FRect*, FRect*); - ~FDTDefineMorphShape(); - U32 AddFillStyle(FMorphFillStyle*); - U32 AddLineStyle(U32, FColor*, - U32, FColor*); - void FinishStyleArrays(); - void AddShapeRec_1(FShapeRec*); - void AddEdgeRec_2(FShapeRec*); - U16 ID(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineShape FDTDefineShape(FRect*); - ~FDTDefineShape(); - void AddShapeRec(FShapeRec*); - U32 AddFillStyle(FFillStyle*); - U32 AddSolidFillStyle(FColor*); - U32 AddLineStyle(U32, FColor*); - void FinishStyleArrays(); - U16 ID(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineShape2 FDTDefineShape2(FRect*); - ~FDTDefineShape2(); - void AddShapeRec(FShapeRec*); - U32 AddFillStyle(FFillStyle*); - U32 AddSolidFillStyle(FColor*); - U32 AddLineStyle(U32, FColor*); - void FinishStyleArrays(); - U16 ID(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineShape3 FDTDefineShape3(FRect*); - ~FDTDefineShape3(); - void AddShapeRec(FShapeRec*); - U32 AddFillStyle(FFillStyle*); - U32 AddSolidFillStyle(FColor*); - U32 AddLineStyle(U32, FColor*); - void FinishStyleArrays(); - U16 ID(); - void WriteToSWFStream(FSWFStream*); - - FFillStyleArray U32 Size(); - U32 Add(FAFillStyle*); - void WriteToSWFStream(FSWFStream*); - - FFillStyleBitmap FFillStyleBitmap(int, U16, FMatrix*); - ~FFillStyleBitmap(); - void WriteToSWFStream(FSWFStream*); - - FFillStyleGradient FFillStyleGradient(int, FMatrix*, FGradient*); - ~FFillStyleGradient(); - void WriteToSWFStream(FSWFStream*); - - FFillStyleSolid FFillStyleSolid(FColor*); - ~FFillStyleSolid(); - void WriteToSWFStream(FSWFStream*); - - FGradient FGradient(void); - ~FGradient(void); - void Add(FAGradRecord*); - void WriteToSWFStream(FSWFStream*); - - FGradRecord FGradRecord(U32, FColor*); - ~FGradRecord(); - void WriteToSWFStream(FSWFStream*); - - FLineStyle FLineStyle(U32, FColor*); - ~FLineStyle(); - void WriteToSWFStream(FSWFStream*); - - FLineStyleArray FLineStyleArray(); - ~FLineStyleArray(); - U32 Size(); - U32 Add(FALineStyle *); - void WriteToSWFStream(FSWFStream *); - - FMorphFillStyleBitmap FMorphFillStyleBitmap(int, U16, FMatrix*, FMatrix*); - ~FMorphFillStyleBitmap(); - void WriteToSWFStream(FSWFStream *); - - FMorphFillStyleGradient FMorphFillStyleGradient(int, FMatrix*, FMatrix*, FGradient*); - ~FMorphFillStyleGradient(); - void WriteToSWFStream(FSWFStream *); - - FMorphFillStyleSolid FMorphFillStyleSolid( FColor*, FColor*); - ~FMorphFillStyleSolid() - void WriteToSWFStream(FSWFStream *); - - FMorphGradRecord FMorphGradRecord(U32, FColor*, U32, FColor*); - ~FMorphGradRecord(); - void WriteToSWFStream(FSWFStream*); - - FMorphLineStyle FMorphLineStyle(U32, U32, FColor*, FColor*); - ~FMorphLineStyle(); - void WriteToSWFStream(FSWFStream *); - - FShape FShape(); - ~FShape(); - SetFillBits(U32); - SetLineBits(U32); - AddShapeRec(FShapeRec *); - void WriteToSWFStream(FSWFStream *); - - FShapeRecChange FShapeRecChange(U32, U32, U32, U32, U32, - S32, S32, U32, U32, U32, - FFillStyleArray*, FLineStyleArray*); - ~FShapeRecChange(); - void IncludeNFillBitInfo(U32); - void IncludeNLineBitInfo(U32); - U32 MinBits(); - void WriteToSWFStream(FSWFStream*); - - FShapeRecEdgeStraight FShapeRecEdgeStraight(S32, S32); - U32 MinBits(void); - void IncludeNFillBitInfo(U32); - void IncludeNLineBitInfo(U32); - void WriteToSWFStream(FSWFStream*); - - FShapeRecEdgeCurved FShapeRecEdgeCurved(S32, S32, S32, S32); - U32 MinBits(void); - void IncludeNFillBitInfo(U32 ); - void IncludeNLineBitInfo(U32 ); - void WriteToSWFStream(FSWFStream*); - - FShapeRecEnd FShapeRecEnd(); - void IncludeNFillBitInfo(U32 ); - void IncludeNLineBitInfo(U32 ); - void WriteToSWFStream(FSWFStream*); - - FShapeWStyle FShapeWStyle(FFillStyleArray*, FLineStyleArray*); - ~FShapeWStyle() ; - void AddShapeRec(FShapeRec*); - U32 NumFillBits(); - U32 NumLineBits(); - void WriteToSWFStream(FSWFStream*); - -****************************************************************************************/ - -#include "tpixel.h" -#include "FDTShapes.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FCXForm ---------------------------------------------------------------- - -FCXForm::FCXForm(U32 _hasAdd, U32 _hasMult, S32 _redMultTerm, S32 _greenMultTerm, S32 _blueMultTerm, S32 _redAddTerm, S32 _greenAddTerm, S32 _blueAddTerm) -{ - hasAdd = _hasAdd; - hasMult = _hasMult; - redMultTerm = _redMultTerm; - greenMultTerm = _greenMultTerm; - blueMultTerm = _blueMultTerm; - redAddTerm = _redAddTerm; - greenAddTerm = _greenAddTerm; - blueAddTerm = _blueAddTerm; - nBits = MinBits(); -} - -// -U32 FCXForm::MinBits() -{ - - // two step process to find maximum value of 6 numbers because "FSWFStream::MaxNum" takes only 4 arguments - U32 maxValue = FSWFStream::MaxNum(redMultTerm, greenMultTerm, blueMultTerm, redAddTerm); - maxValue = FSWFStream::MaxNum(greenAddTerm, blueAddTerm, (S32)maxValue, 0); - - return FSWFStream::MinBits(maxValue, 1) + 1; -} - -// -void FCXForm::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - _SWFStream->WriteBits(hasMult, 1); - _SWFStream->WriteBits(hasAdd, 1); - _SWFStream->WriteBits(nBits, 4); - - if (hasMult) { - _SWFStream->WriteBits((S32)redMultTerm, nBits); - _SWFStream->WriteBits((S32)greenMultTerm, nBits); - _SWFStream->WriteBits((S32)blueMultTerm, nBits); - } - if (hasAdd) { - _SWFStream->WriteBits((S32)redAddTerm, nBits); - _SWFStream->WriteBits((S32)greenAddTerm, nBits); - _SWFStream->WriteBits((S32)blueAddTerm, nBits); - } - - _SWFStream->FlushBits(); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FCXFormWAlpha ---------------------------------------------------------- - -FCXFormWAlpha::FCXFormWAlpha(U32 _hasAdd, U32 _hasMult, S32 _redMultTerm, S32 _greenMultTerm, S32 _blueMultTerm, S32 _alphaMultTerm, - S32 _redAddTerm, S32 _greenAddTerm, S32 _blueAddTerm, S32 _alphaAddTerm) - : FCXForm(_hasAdd, _hasMult, _redMultTerm, _greenMultTerm, _blueMultTerm, - _redAddTerm, _greenAddTerm, _blueAddTerm) -{ - alphaMultTerm = _alphaMultTerm; - - alphaAddTerm = _alphaAddTerm; - - nBits = MinBits(); -} - -U32 FCXFormWAlpha::MinBits() -{ - - // FFileWrite's MaxNum method takes only 4 arguments, so finding maximum value of 8 arguments takes three steps: - U32 maxMult = FSWFStream::MaxNum(redMultTerm, greenMultTerm, blueMultTerm, alphaMultTerm); - U32 maxAdd = FSWFStream::MaxNum(redAddTerm, greenAddTerm, blueAddTerm, alphaAddTerm); - U32 maxValue = FSWFStream::MaxNum((S32)maxMult, (S32)maxAdd, 0, 0); - - return FSWFStream::MinBits(maxValue, 1) + 1; -} - -void FCXFormWAlpha::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //fill? I think so - _SWFStream->FlushBits(); - - _SWFStream->WriteBits(hasMult, 1); - _SWFStream->WriteBits(hasAdd, 1); - _SWFStream->WriteBits(nBits, 4); - - if (hasMult) { - _SWFStream->WriteBits((S32)redMultTerm, nBits); - _SWFStream->WriteBits((S32)greenMultTerm, nBits); - _SWFStream->WriteBits((S32)blueMultTerm, nBits); - _SWFStream->WriteBits((S32)alphaMultTerm, nBits); - } - if (hasAdd) { - _SWFStream->WriteBits((S32)redAddTerm, nBits); - _SWFStream->WriteBits((S32)greenAddTerm, nBits); - _SWFStream->WriteBits((S32)blueAddTerm, nBits); - _SWFStream->WriteBits((S32)alphaAddTerm, nBits); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineMorphShape ---------------------------------------------------- - -FDTDefineMorphShape::FDTDefineMorphShape(FRect *_rect1, FRect *_rect2) -{ - - characterID = FObjCollection::Increment(); - shapeBounds_1 = _rect1; - shapeBounds_2 = _rect2; - morphFillStyleArray = new FFillStyleArray(); - morphLineStyleArray = new FLineStyleArray(); - styleArraysFinished = false; -} - -FDTDefineMorphShape::~FDTDefineMorphShape() -{ - - delete shapeBounds_1; - delete shapeBounds_2; - delete morphFillStyleArray; - delete morphLineStyleArray; -} - -U32 FDTDefineMorphShape::AddFillStyle(FMorphFillStyle *fillStyle) -{ - - assert(!styleArraysFinished); - return morphFillStyleArray->Add(fillStyle); -} - -U32 FDTDefineMorphShape::AddLineStyle(U32 startLineWidth, FColor *startLineColor, - U32 finalLineWidth, FColor *finalLineColor) -{ - assert(!styleArraysFinished); - - // here changed. - // morph shape always has RGBA color. - startLineColor->AlphaChannel(true); - finalLineColor->AlphaChannel(true); - - // Create a morph line style (one which contains both "morph from" and "morph to" line style information - FMorphLineStyle *startToFinalLine = new FMorphLineStyle(startLineWidth, finalLineWidth, - startLineColor, finalLineColor); - return morphLineStyleArray->Add(startToFinalLine); -} - -void FDTDefineMorphShape::FinishStyleArrays(void) -{ - - styleArraysFinished = true; - nFillBits = FSWFStream::MinBits(morphFillStyleArray->Size(), 0); - nLineBits = FSWFStream::MinBits(morphLineStyleArray->Size(), 0); - - shape1.SetFillBits(nFillBits); - shape1.SetLineBits(nLineBits); - - // asumption: shape2 will never contain fill or line syle info and this means no need - // for fill or line style bits -} - -void FDTDefineMorphShape::AddShapeRec_1(FShapeRec *_shapeRec) -{ - - assert(styleArraysFinished); - shape1.AddShapeRec(_shapeRec); -} - -void FDTDefineMorphShape::AddEdgeRec_2(FShapeRec *_shapeRec) -{ - - assert(styleArraysFinished); - _shapeRec->IncludeNFillBitInfo(0); // Always Zero - _shapeRec->IncludeNLineBitInfo(0); - shape2.AddShapeRec(_shapeRec); -} - -U16 FDTDefineMorphShape::ID(void) -{ - - return characterID; -} - -void FDTDefineMorphShape::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteWord((U32)characterID); - - shapeBounds_1->WriteToSWFStream(&body); - - shapeBounds_2->WriteToSWFStream(&body); - - FSWFStream temp; - - morphFillStyleArray->WriteToSWFStream(&temp); - morphLineStyleArray->WriteToSWFStream(&temp); - - shape1.WriteToSWFStream(&temp); - - body.WriteDWord(temp.Size()); - - body.Append(&temp); - - shape2.WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagDefineMorphShape, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineShape --------------------------------------------------------- - -FDTDefineShape::FDTDefineShape(FRect *_rect) -{ - - characterID = FObjCollection::Increment(); - shapeBounds = _rect; - fillStyleArray = new FFillStyleArray(); - lineStyleArray = new FLineStyleArray(); - shapeWithStyle = NULL; - styleArraysFinished = false; -} - -FDTDefineShape::~FDTDefineShape() -{ - - delete fillStyleArray; - delete lineStyleArray; - delete shapeBounds; - delete shapeWithStyle; -} - -void FDTDefineShape::AddShapeRec(FShapeRec *_shapeRec) -{ - - //you must be done creating the fill style and line style arrays - //before you can begin adding shape records - assert(styleArraysFinished); - - //Change rec doesn't know how many bits for saving the FillStyle0 - //and FillStyle1. It gets this from the ShapeWithStyle which contains - //it. What happens when the change Rec also contains Fill and Line - //Syles??? The other types of ShapeRecs just use the "current style" - //and don't need this info so their methods don't actually do anything. - //Why not just go to the container when writing? - _shapeRec->IncludeNFillBitInfo(shapeWithStyle->NumFillBits()); - _shapeRec->IncludeNLineBitInfo(shapeWithStyle->NumLineBits()); - //now have the shapeWithStyle add the ShapeRec - shapeWithStyle->AddShapeRec(_shapeRec); -} - -//This shapes internal fillStyleArray adds a fillStyle to itself. -U32 FDTDefineShape::AddFillStyle(FFillStyle *fillStyle) -{ - - assert(!styleArraysFinished); //once complete, cannot change - return fillStyleArray->Add(fillStyle); -} -// here changed. -U32 FDTDefineShape::AddSolidFillStyle(FColor *fillColor) -{ - fillColor->AlphaChannel(false); - FFillStyle *fillStyle = new FFillStyleSolid(fillColor); - - assert(!styleArraysFinished); //once complete, cannot change - return fillStyleArray->Add(fillStyle); -} - -U32 FDTDefineShape::AddLineStyle(U32 lineWidth, FColor *lineColor) -{ - - assert(!styleArraysFinished); //once complete, cannot change - - // here changed. - lineColor->AlphaChannel(false); - FLineStyle *lineStyle = new FLineStyle(lineWidth, lineColor); - - //add line style to rectangle, remembering to store the position of the line style - //just as in the fill style - return lineStyleArray->Add(lineStyle); -} - -/*! Creates the shape with style. Can only do this once the fill style - and line style arrays are complete because the shapeWithStyle constructor - takes in complete fill and line style arrays. -*/ -void FDTDefineShape::FinishStyleArrays(void) -{ - - styleArraysFinished = true; - shapeWithStyle = new FShapeWStyle(fillStyleArray, lineStyleArray); - fillStyleArray = NULL; /*AMM*/ - lineStyleArray = NULL; -} - -U16 FDTDefineShape::ID(void) -{ - - return characterID; -} - -//Called by the FObjCollection when writing to the stream -//In turn, it calls the WriteToSWFStream methods of its embedded objects. - -void FDTDefineShape::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream tempBuffer; - - tempBuffer.WriteWord((U32)characterID); - shapeBounds->WriteToSWFStream(&tempBuffer); - shapeWithStyle->WriteToSWFStream(&tempBuffer); - - _SWFStream->AppendTag(stagDefineShape, tempBuffer.Size(), &tempBuffer); -} - -bool FDTDefineShape::IsDefineShape() -{ - return true; -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineShape2 -------------------------------------------------------- -FDTDefineShape2::FDTDefineShape2(FRect *_rect) -{ - - characterID = FObjCollection::Increment(); - shapeBounds = _rect; - fillStyleArray = new FFillStyleArray(); - lineStyleArray = new FLineStyleArray(); - shapeWithStyle = NULL; - styleArraysFinished = false; -} - -FDTDefineShape2::~FDTDefineShape2() -{ - - delete fillStyleArray; - delete lineStyleArray; - delete shapeBounds; - delete shapeWithStyle; -} - -void FDTDefineShape2::AddShapeRec(FShapeRec *_shapeRec) -{ - - //you must be done creating the fill style and line style arrays - //before you can begin adding shape records - assert(styleArraysFinished); - - _shapeRec->IncludeNFillBitInfo(shapeWithStyle->NumFillBits()); - _shapeRec->IncludeNLineBitInfo(shapeWithStyle->NumLineBits()); - shapeWithStyle->AddShapeRec(_shapeRec); -} - -U32 FDTDefineShape2::AddFillStyle(FFillStyle *fillStyle) -{ - - assert(!styleArraysFinished); //once complete, cannot change - return fillStyleArray->Add(fillStyle); -} -// here changed. -U32 FDTDefineShape2::AddSolidFillStyle(FColor *fillColor) -{ - fillColor->AlphaChannel(false); - FFillStyle *fillStyle = new FFillStyleSolid(fillColor); - - assert(!styleArraysFinished); //once complete, cannot change - return fillStyleArray->Add(fillStyle); -} - -U32 FDTDefineShape2::AddLineStyle(U32 lineWidth, FColor *lineColor) -{ - - assert(!styleArraysFinished); //once complete, cannot change - - // here changed. - lineColor->AlphaChannel(false); - FLineStyle *lineStyle = new FLineStyle(lineWidth, lineColor); - - //add line style to rectangle, remembering to store the position of the line style - //just as in the fill style - return lineStyleArray->Add(lineStyle); -} - -// Creates the shape with style. Can only do this once the fill style -// and line style arrays are complete because the shapeWithStyle constructor -// takes in complete fill and line style arrays. - -void FDTDefineShape2::FinishStyleArrays(void) -{ - - styleArraysFinished = true; - shapeWithStyle = new FShapeWStyle(fillStyleArray, lineStyleArray); - fillStyleArray = NULL; /*AMM*/ - lineStyleArray = NULL; -} - -U16 FDTDefineShape2::ID(void) -{ - - return characterID; -} - -bool FDTDefineShape2::IsDefineShape() -{ - assert(false); - return true; -} - -void FDTDefineShape2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteWord((U32)characterID); - shapeBounds->WriteToSWFStream(&body); - shapeWithStyle->WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagDefineShape2, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineShape3 -------------------------------------------------------- - -FDTDefineShape3::FDTDefineShape3(FRect *_rect) -{ - characterID = FObjCollection::Increment(); - shapeBounds = _rect; - fillStyleArray = new FFillStyleArray(); - lineStyleArray = new FLineStyleArray(); - shapeWithStyle = NULL; - styleArraysFinished = false; -} - -////////////////////////////////////////////////////////////////////////////////////// - -FDTDefineShape3::FDTDefineShape3() -{ - - characterID = FObjCollection::Increment(); - shapeBounds = 0; - fillStyleArray = new FFillStyleArray(); - lineStyleArray = new FLineStyleArray(); - shapeWithStyle = NULL; - styleArraysFinished = false; -} - -FDTDefineShape3::~FDTDefineShape3() -{ - - delete fillStyleArray; - delete lineStyleArray; - delete shapeBounds; - delete shapeWithStyle; -} - -void FDTDefineShape3::setBounds(FRect *_rect) -{ - if (shapeBounds) - delete shapeBounds; - shapeBounds = _rect; -} - -////////////////////////////////////////////////////////////////////////////////////// - -bool FDTDefineShape3::IsDefineShape() -{ - return true; -} - -////////////////////////////////////////////////////////////////////////////////////// - -inline FColor tpixel2fcolor(const TPixel &color) -{ - return FColor(color.r, color.g, color.b, color.m); -} - -////////////////////////////////////////////////////////////////////////////////////// - -inline TPixel fcolor2tpixel(FColor &color) -{ - return TPixel(color.Red(), color.Green(), color.Blue(), color.Alpha()); -} - -////////////////////////////////////////////////////////////////////////////////////// - -void FDTDefineShape3::changeColor(const std::map &table) -{ - unsigned int i; - if (fillStyleArray) - for (i = 0; i < fillStyleArray->Size(); i++) { - FAFillStyle *style = fillStyleArray->get(i); - if (style->IsSolidStyle()) { - TPixel oldColor = fcolor2tpixel(*(((FFillStyleSolid *)style)->getColor())); - std::map::const_iterator it = table.find(oldColor); - if (it != table.end()) - ((FFillStyleSolid *)style)->setColor(new FColor(tpixel2fcolor(it->second))); - } - } - - shapeWithStyle->changeColor(table); -} - -////////////////////////////////////////////////////////////////////////////////////// - -void FDTDefineShape3::changeColor(const FColor &oldColor, const FColor &newColor) -{ - unsigned int i; - if (fillStyleArray) - for (i = 0; i < fillStyleArray->Size(); i++) { - FAFillStyle *style = fillStyleArray->get(i); - if (style->IsSolidStyle() && (*((FFillStyleSolid *)style)->getColor()) == oldColor) - ((FFillStyleSolid *)style)->setColor(new FColor(newColor)); - } - - shapeWithStyle->changeColor(oldColor, newColor); -} - -////////////////////////////////////////////////////////////////////////////////////// - -void FDTDefineShape3::AddShapeRec(FShapeRec *_shapeRec) -{ - - //you must be done creating the fill style and line style arrays - //before you can begin adding shape records - assert(styleArraysFinished); - - _shapeRec->IncludeNFillBitInfo(shapeWithStyle->NumFillBits()); - _shapeRec->IncludeNLineBitInfo(shapeWithStyle->NumLineBits()); - shapeWithStyle->AddShapeRec(_shapeRec); -} - -U32 FDTDefineShape3::AddFillStyle(FFillStyle *fillStyle) -{ - - assert(!styleArraysFinished); //once complete, cannot change - return fillStyleArray->Add(fillStyle); -} - -// here changed. -U32 FDTDefineShape3::AddSolidFillStyle(FColor *fillColor) -{ - fillColor->AlphaChannel(true); - FFillStyle *fillStyle = new FFillStyleSolid(fillColor); - - assert(!styleArraysFinished); //once complete, cannot change - return fillStyleArray->Add(fillStyle); -} - -U32 FDTDefineShape3::AddLineStyle(U32 lineWidth, FColor *lineColor) -{ - - assert(!styleArraysFinished); //once complete, cannot change - - // here changed. - lineColor->AlphaChannel(true); - FLineStyle *lineStyle = new FLineStyle(lineWidth, lineColor); - - //add line style to rectangle, remembering to store the position of the line style - //just as in the fill style - return lineStyleArray->Add(lineStyle); -} - -// Creates the shape with style. Can only do this once the fill style -// and line style arrays are complete because the shapeWithStyle constructor -// takes in complete fill and line style arrays. - -void FDTDefineShape3::FinishStyleArrays(void) -{ - - styleArraysFinished = true; - shapeWithStyle = new FShapeWStyle(fillStyleArray, lineStyleArray); - fillStyleArray = NULL; - lineStyleArray = NULL; -} - -U16 FDTDefineShape3::ID(void) -{ - - return characterID; -} - -void FDTDefineShape3::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteWord((U32)characterID); - shapeBounds->WriteToSWFStream(&body); - shapeWithStyle->WriteToSWFStream(&body); - - _SWFStream->AppendTag(stagDefineShape3, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FFillStyleArray -------------------------------------------------------- - -FFillStyleArray::~FFillStyleArray() -{ - while (!fillStyleArray.empty()) { - delete fillStyleArray.back(); - fillStyleArray.pop_back(); - } -} - -// Returns the size of the fill style list. -U32 FFillStyleArray::Size(void) -{ - return (U32)fillStyleArray.size(); -} - -// The given fill style is added to the end of the fill style array. The position of -// the added fill style is returned so that the fill style can later be referenced. - -U32 FFillStyleArray::Add(FAFillStyle *fillStyle) -{ - FLASHASSERT(fillStyle); - - fillStyleArray.push_back(fillStyle); - return ((U32)fillStyleArray.size()); -} - -////////////////////////////////////////////////////////////////////////////////////// - -FAFillStyle *FFillStyleArray::get(unsigned int index) -{ - return fillStyleArray[index]; -} - -// Writes to the stream by travelling through all of the nodes in the array and writing -// their fill styles. First has to write the count of fill style arrays. See's if count -// is small enough to fit in to an 8 bit field, and either writes the count into an 8 bit -// field, or writes all 1's into an 8 bit field and writes the real count into a 16 bit -// field. - -void FFillStyleArray::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the size - U32 size = fillStyleArray.size(); - - if (size >= 0xff) { - - _SWFStream->WriteByte(0xff); - _SWFStream->WriteWord(size); - - } else { - - _SWFStream->WriteByte(size); - } - - //write the fill styles - std::vector::iterator cursor; - - for (cursor = fillStyleArray.begin(); cursor != fillStyleArray.end(); cursor++) { - (*cursor)->WriteToSWFStream(_SWFStream); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FFillStyleBitmap ------------------------------------------------------- - -// The tiledFlag indicates if the Bitmap fill style is tiled (tiledFlag==1) or -// clipped (tiledFlag==0). -FFillStyleBitmap::FFillStyleBitmap(int tiled, U16 ID, FMatrix *matrix) -{ - - tiledFlag = tiled; - bitmapID = ID; - bitmapMatrix = matrix; -} - -// Deletes the matrix. - -FFillStyleBitmap::~FFillStyleBitmap(void) -{ - - delete bitmapMatrix; - bitmapMatrix = NULL; -} - -// Writes the bitmap fill style to the given FSWFStream. - -void FFillStyleBitmap::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the type - if (tiledFlag) - _SWFStream->WriteByte(fillTiledBits); - else - _SWFStream->WriteByte(fillClippedBits); - - //write the bitmap id - _SWFStream->WriteWord(bitmapID); - - //write the matrix - bitmapMatrix->WriteToSWFStream(_SWFStream); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FFillStyleGradient ----------------------------------------------------- - -// The linearFlag indicates if the gradient fill style is linear (linearFlag==1) or -// radial (linearFlag==0). -FFillStyleGradient::FFillStyleGradient(int linear, FMatrix *matrix, FGradient *gradient) -{ - linearFlag = linear; - gradFillMatrix = matrix; - gradFill = gradient; -} - -// Deletes the matrix and gradient. - -FFillStyleGradient::~FFillStyleGradient(void) -{ - delete gradFillMatrix; - delete gradFill; -} - -// Writes the Gradient fill style to the given FSWFStream. - -void FFillStyleGradient::WriteToSWFStream(FSWFStream *_SWFStream) -{ - //write the type - if (linearFlag) - _SWFStream->WriteByte(fillLinearGradient); - else - _SWFStream->WriteByte(fillRadialGradient); - - //write the matrix - gradFillMatrix->WriteToSWFStream(_SWFStream); - - //write the gradient - gradFill->WriteToSWFStream(_SWFStream); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FFillStyleSolid -------------------------------------------------------- - -// Stores the color of the solid fill style. -FFillStyleSolid::FFillStyleSolid(FColor *_color) : color(_color) {} - -FFillStyleSolid::~FFillStyleSolid() -{ - delete color; -} - -// Writes the solid fill style to the given FSWFStream. - -void FFillStyleSolid::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the type - _SWFStream->WriteByte(fillSolid); //cast to U32? - - //write the color - color->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FGradient -------------------------------------------------------------- - -// Constructor. The grad record list is automatically constructed. -FGradient::FGradient(void) {} - -// Removes and deletes all the grad records from the grad record list. - -FGradient::~FGradient(void) -{ - - while (!gradRecords.empty()) { - - delete gradRecords.front(); - - gradRecords.pop_front(); - } -} - -// Adds the given grad record to the end of the grad record list. - -void FGradient::Add(FAGradRecord *gradRec) -{ - - gradRecords.push_back(gradRec); -} - -// Writes the grad records to the given _SWFStream. - -void FGradient::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the size - - _SWFStream->WriteByte((U32)gradRecords.size()); - - //write the grad records - - std::list::iterator cursor; - - for (cursor = gradRecords.begin(); cursor != gradRecords.end(); cursor++) { - - (*cursor)->WriteToSWFStream(_SWFStream); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FGradientRecord -------------------------------------------------------- - -// FGradRecord class constructor. -FGradRecord::FGradRecord(U32 _ratio, FColor *_color) -{ - color = _color; - ratio = _ratio; -} - -FGradRecord::~FGradRecord() -{ - delete color; -} - -// Writes the grad record to the given buffer. - -void FGradRecord::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - _SWFStream->WriteByte((U32)ratio); - - color->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FLineStyle ------------------------------------------------------------- - -// LineStyle class constructor. -FLineStyle::FLineStyle(U32 _width, FColor *_color) -{ - color = _color; - width = _width; //in TWIPS -} - -FLineStyle::~FLineStyle() -{ - delete color; -} - -// Writes the object to the given _SWFStream. - -void FLineStyle::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - _SWFStream->WriteWord(width); - color->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FLineStyleArray -------------------------------------------------------- - -// The line style array is automatically constructed -FLineStyleArray::FLineStyleArray(void) {} - -// Removes and deletes every element in the list. - -FLineStyleArray::~FLineStyleArray(void) -{ - - while (!lineStyleArray.empty()) { - - delete lineStyleArray.front(); - lineStyleArray.pop_front(); - } -} - -// Returns the size of the line style list. - -U32 FLineStyleArray::Size(void) -{ - - return (U32)lineStyleArray.size(); -} - -// The given line style is added to the end of the line style array. The position of -// the added line style is returned so that the line style can later be referenced. - -U32 FLineStyleArray::Add(FALineStyle *lineStyle) -{ - - lineStyleArray.push_back(lineStyle); - return ((U32)lineStyleArray.size()); -} - -// Writes to the stream by travelling through all of the nodes in the array and writing -// their line styles. First has to write the count of line style arrays. See's if count -// is small enough to fit in to an 8 bit field, and either writes the count into an 8 bit -// field, or writes all 1's into an 8 bit field and writes the real count into a 16 bit -// field. - -void FLineStyleArray::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the size - U32 size = lineStyleArray.size(); - - if (size >= 0xff) { - - _SWFStream->WriteByte(0xff); - _SWFStream->WriteWord(size); - - } else { - - _SWFStream->WriteByte(size); - } - - //write the line styles - std::list::iterator cursor; - - for (cursor = lineStyleArray.begin(); cursor != lineStyleArray.end(); cursor++) { - - (*cursor)->WriteToSWFStream(_SWFStream); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FMorphFillStyleBitmap -------------------------------------------------- - -// The tiledFlag indicates if the Bitmap fill style is tiled (tiledFlag==1) or -// clipped (tiledFlag==0). -FMorphFillStyleBitmap::FMorphFillStyleBitmap(int tiled, U16 ID, - FMatrix *matrix1, FMatrix *matrix2) -{ - - tiledFlag = tiled; - bitmapID = ID; - bitmapMatrix1 = matrix1; - bitmapMatrix2 = matrix2; -} - -// Deletes the matrices. - -FMorphFillStyleBitmap::~FMorphFillStyleBitmap(void) -{ - - delete bitmapMatrix1; - bitmapMatrix1 = NULL; - - delete bitmapMatrix2; - bitmapMatrix2 = NULL; -} - -// Writes the bitmap fill style to the given FSWFStream. - -void FMorphFillStyleBitmap::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the type - if (tiledFlag) - _SWFStream->WriteByte(fillTiledBits); - else - _SWFStream->WriteByte(fillClippedBits); - - //write the bitmap id - _SWFStream->WriteWord(bitmapID); - - //write the matrices - bitmapMatrix1->WriteToSWFStream(_SWFStream); - bitmapMatrix2->WriteToSWFStream(_SWFStream); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FMorphFillStyleGradient ------------------------------------------------ - -// The linearFlag indicates if the gradient fill style is linear (linearFlag==1) or -// radial (linearFlag==0). -FMorphFillStyleGradient::FMorphFillStyleGradient(int linear, FMatrix *matrix1, FMatrix *matrix2, - FGradient *gradient) -{ - - linearFlag = linear; - gradFillMatrix1 = matrix1; - gradFillMatrix2 = matrix2; - gradFill = gradient; -} - -// Deletes the matrices and gradient. - -FMorphFillStyleGradient::~FMorphFillStyleGradient(void) -{ - - delete gradFillMatrix1; - gradFillMatrix1 = NULL; - delete gradFillMatrix2; - gradFillMatrix2 = NULL; - delete gradFill; - gradFill = NULL; -} - -// Writes the Gradient fill style to the given FSWFStream. - -void FMorphFillStyleGradient::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the type - if (linearFlag) - _SWFStream->WriteByte(fillLinearGradient); - else - _SWFStream->WriteByte(fillRadialGradient); - - //write the matrices - gradFillMatrix1->WriteToSWFStream(_SWFStream); - gradFillMatrix2->WriteToSWFStream(_SWFStream); - - //write the gradient - gradFill->WriteToSWFStream(_SWFStream); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FMorphFillStyleSolid --------------------------------------------------- - -// Stores the colors of the solid fill style. -FMorphFillStyleSolid::FMorphFillStyleSolid(FColor *_color1, FColor *_color2) -{ - color1 = _color1; - color2 = _color2; -} - -FMorphFillStyleSolid::~FMorphFillStyleSolid() -{ - delete color1; - delete color2; -} - -// Writes the solid fill style to the given FSWFStream. - -void FMorphFillStyleSolid::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //write the type - _SWFStream->WriteByte(fillSolid); //cast to U32? - - //write the colors - color1->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. - color2->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FMorphGradRecord ------------------------------------------------------- - -// Constructor. -FMorphGradRecord::FMorphGradRecord(U32 _ratio1, FColor *_color1, U32 _ratio2, FColor *_color2) -{ - - ratio1 = _ratio1; - ratio2 = _ratio2; - - color1 = _color1; - color2 = _color2; -} - -FMorphGradRecord::~FMorphGradRecord() -{ - delete color1; - delete color2; -} - -// Writes to the given _SWFStream. - -void FMorphGradRecord::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - _SWFStream->WriteByte((U32)ratio1); - color1->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. - - _SWFStream->WriteByte((U32)ratio2); - color2->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FMorphLineStyle -------------------------------------------------------- - -//The line style used by morph shapes -FMorphLineStyle::FMorphLineStyle(U32 _width1, U32 _width2, FColor *_color1, - FColor *_color2) : color1(_color1), color2(_color2) -{ - width1 = _width1; - width2 = _width2; - - color1 = _color1; - color2 = _color2; -} - -FMorphLineStyle::~FMorphLineStyle() -{ - delete color1; - delete color2; -} - -// Writes to the given _SWFStream. - -void FMorphLineStyle::WriteToSWFStream(FSWFStream *_SWFStream) -{ - //write the widths - _SWFStream->WriteWord(width1); - _SWFStream->WriteWord(width2); - - //write the colors - color1->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. - color2->WriteToSWFStream(_SWFStream); //, FColor::WRITE_SMALLEST ); changed here. -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FShape ----------------------------------------------------------------- - -// Shape class constructor. The shape record list is automatically constructed -FShape::FShape(void) -{ - - nFillBits = 0; - nLineBits = 0; -} - -// Removes and deletes every element in the list. - -FShape::~FShape(void) -{ - - while (!shapeRecs.empty()) { - - delete shapeRecs.back(); - shapeRecs.pop_back(); - } -} - -// Sets the nFillBits field. - -void FShape::SetFillBits(U32 _nFillBits) -{ - - nFillBits = _nFillBits; -} - -// Sets the nLineBits field. - -void FShape::SetLineBits(U32 _nLineBits) -{ - - nLineBits = _nLineBits; -} - -// Adds a shape record to the end of the shape record list. - -void FShape::AddShapeRec(FShapeRec *shapeRec) -{ - - shapeRecs.push_back(shapeRec); -} - -// Writes the object to the given buffer. - -void FShape::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - _SWFStream->WriteBits(nFillBits, 4); - _SWFStream->WriteBits(nLineBits, 4); - - std::vector::iterator cursor; - - for (cursor = shapeRecs.begin(); cursor != shapeRecs.end(); cursor++) { - //the shape rec might be referring to a fillor line style arry - //external (ShapesWStyle) and will need the # of fillBits. - (*cursor)->IncludeNFillBitInfo(nFillBits); //enter fillbits - (*cursor)->IncludeNLineBitInfo(nLineBits); //enter linebits - (*cursor)->WriteToSWFStream(_SWFStream); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FShapeRecChange -------------------------------------------------------- - -// FShapeRecChange class constructor. It is passed the nFillBits and nLineBits values. -FShapeRecChange::FShapeRecChange(U32 _stateNewStyles, - U32 _stateLineStyle, - U32 _stateFillStyle1, - U32 _stateFillStyle0, - U32 _stateMoveTo, - S32 _moveDeltaX, - S32 _moveDeltaY, - U32 _fill0Style, - U32 _fill1Style, - U32 _lineStyle, - FFillStyleArray *_fillStyles, - FLineStyleArray *_lineStyles) -{ - stateNewStyles = _stateNewStyles; - stateLineStyle = _stateLineStyle; - stateFillStyle1 = _stateFillStyle1; - stateFillStyle0 = _stateFillStyle0; - stateMoveTo = _stateMoveTo; - - moveDeltaX = _moveDeltaX; - moveDeltaY = _moveDeltaY; - fill0Style = _fill0Style; - fill1Style = _fill1Style; - lineStyle = _lineStyle; - fillStyles = _fillStyles; - lineStyles = _lineStyles; - nMoveBits = MinBits(); -} - -FFillStyleArray *FShapeRecChange::GetFillStyles() -{ - return fillStyles; -} - -// Deletes fillStyles and lineStyles if they exist. - -FShapeRecChange::~FShapeRecChange(void) -{ - - if (fillStyles) { //if fillStyles isn't NULL - - delete fillStyles; - fillStyles = NULL; - } - - if (lineStyles) { //if lineStyles isn't NULL - - delete lineStyles; - lineStyles = NULL; - } -} - -//!Change Rec needs to know how many bits to write for the Fill and Line Styles -/*!Change Rec doesn't actually store the nLineBits or nFillBits, but needs to know - them when it writes the active style fields so that it knows how many bits - to write - \param _nFillBits the size in bits of the index into the FillStyleArray -*/ -void FShapeRecChange::IncludeNFillBitInfo(U32 _nFillBits) -{ - - nFillBits = _nFillBits; -} - -//!Change Rec needs to know how many bits to write for the Fill and Line Styles -/*!Change Rec doesn't actually store the nLineBits or nFillBits, but needs to know - them when it writes the active style fields so that it knows how many bits - to write - \param _nLineBits the size in bits of the index into the LineStyleArray -*/ -void FShapeRecChange::IncludeNLineBitInfo(U32 _nLineBits) -{ - - nLineBits = _nLineBits; -} - -// Calculates nMoveBits by returning the number of bits needed to store the larger of -// moveDeltaX and moveDeltaY. - -U32 FShapeRecChange::MinBits(void) -{ - - U32 max = FSWFStream::MaxNum(moveDeltaX, moveDeltaY, 0, 0); - return FSWFStream::MinBits(max, 1); -} - -// Writes the shape record to the given _SWFStream. - -void FShapeRecChange::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //non-edge record flag - _SWFStream->WriteBits(NOT_EDGE_REC, 1); - - _SWFStream->WriteBits(stateNewStyles, 1); - _SWFStream->WriteBits(stateLineStyle, 1); - _SWFStream->WriteBits(stateFillStyle1, 1); - _SWFStream->WriteBits(stateFillStyle0, 1); - _SWFStream->WriteBits(stateMoveTo, 1); - - if (stateMoveTo) { - - _SWFStream->WriteBits(nMoveBits, 5); - _SWFStream->WriteBits(moveDeltaX, nMoveBits); - _SWFStream->WriteBits(moveDeltaY, nMoveBits); - } - - if (stateFillStyle0) { - - _SWFStream->WriteBits(fill0Style, nFillBits); - } - - if (stateFillStyle1) { - - _SWFStream->WriteBits(fill1Style, nFillBits); - } - - if (stateLineStyle) { - - _SWFStream->WriteBits(lineStyle, nLineBits); - } - - if (stateNewStyles) { - - fillStyles->WriteToSWFStream(_SWFStream); - lineStyles->WriteToSWFStream(_SWFStream); - - nFillBits = FSWFStream::MinBits(fillStyles->Size(), 0); - nLineBits = FSWFStream::MinBits(lineStyles->Size(), 0); - - _SWFStream->WriteBits(nFillBits, 4); //li mortacci loro!!! "dimenticavano" di mettere questi... - _SWFStream->WriteBits(nLineBits, 4); - } - - //NO FILLING IN BETWEEN SHAPE RECORDS -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FShapeRecEdgeStraight -------------------------------------------------- - -FShapeRecEdgeStraight::FShapeRecEdgeStraight(S32 dx, S32 dy) -{ - generalLineFlag = 0; - generalDeltaX = 0; - generalDeltaY = 0; - verticalLineFlag = 0; - horizontalDeltaX = 0; - verticalDeltaY = 0; - - edgeFlag = 1; - - // is this a general line? - if (dx != 0 && dy != 0) { - generalLineFlag = true; - generalDeltaX = dx; - generalDeltaY = dy; - } else if (dx == 0) // not general, is it vertical? - { - verticalLineFlag = true; - verticalDeltaY = dy; - } else { - verticalLineFlag = false; - horizontalDeltaX = dx; - } - nBits = MinBits(); - assert(nBits < 16 + 2); //vincenzo: se no non entra nei quattro bits riservati per scrivere questo valore... -} - -U32 FShapeRecEdgeStraight::MinBits(void) -{ - - U32 maxDelta = FSWFStream::MaxNum(generalDeltaX, generalDeltaY, - horizontalDeltaX, verticalDeltaY); - - return FSWFStream::MinBits(maxDelta, 1); -} - -void FShapeRecEdgeStraight::IncludeNFillBitInfo(U32 /*_nFillBits*/) -{ -} - -void FShapeRecEdgeStraight::IncludeNLineBitInfo(U32 /*_nLineBits*/) -{ -} - -void FShapeRecEdgeStraight::WriteToSWFStream(FSWFStream *_SWFStream) -{ - //edge record flag - _SWFStream->WriteBits(EDGE_REC, 1); - - _SWFStream->WriteBits(STRAIGHT_EDGE, 1); //This is a Straight edge record - _SWFStream->WriteBits(nBits - 2, 4); - _SWFStream->WriteBits(generalLineFlag, 1); - - if (generalLineFlag) { - - _SWFStream->WriteBits((U32)generalDeltaX, nBits); - _SWFStream->WriteBits((U32)generalDeltaY, nBits); - - } else { - - _SWFStream->WriteBits(verticalLineFlag, 1); //verticalFlag is supposed to be signed but don't think it matters - - if (!verticalLineFlag) - _SWFStream->WriteBits((U32)horizontalDeltaX, nBits); - - else - _SWFStream->WriteBits((U32)verticalDeltaY, nBits); - } - - //NO FILLING IN BETWEEN SHAPE RECORDS -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FShapeRecEdgeCurved --------------------------------------------------- - -// FShapeRecEdge class constructor. -FShapeRecEdgeCurved::FShapeRecEdgeCurved(S32 controlDX, S32 controlDY, S32 anchorDX, S32 anchorDY) -{ - edgeFlag = 0; - - controlDeltaX = controlDX; - controlDeltaY = controlDY; - anchorDeltaX = anchorDX; - anchorDeltaY = anchorDY; - - nBits = MinBits(); -} -// Finds the min bits necessary to represent the 4 fields, by seeing how many bits are -// necessary to represent the largest field of the four. - -U32 FShapeRecEdgeCurved::MinBits(void) -{ - - U32 maxDelta = FSWFStream::MaxNum(controlDeltaX, controlDeltaY, anchorDeltaX, anchorDeltaY); - - return FSWFStream::MinBits(maxDelta, 1); -} - -void FShapeRecEdgeCurved::IncludeNFillBitInfo(U32 /*_nFillBits*/) -{ -} - -void FShapeRecEdgeCurved::IncludeNLineBitInfo(U32 /*_nLineBits*/) -{ -} - -// Writes the shape record to the given _SWFStream. - -void FShapeRecEdgeCurved::WriteToSWFStream(FSWFStream *_SWFStream) -{ - //edge record flag - _SWFStream->WriteBits(EDGE_REC, 1); - - _SWFStream->WriteBits(CURVED_EDGE, 1); //This is a curved edge record - - _SWFStream->WriteBits(nBits - 2, 4); - - _SWFStream->WriteBits((U32)controlDeltaX, nBits); - _SWFStream->WriteBits((U32)controlDeltaY, nBits); - _SWFStream->WriteBits((U32)anchorDeltaX, nBits); - _SWFStream->WriteBits((U32)anchorDeltaY, nBits); - - //NO FILLING IN BETWEEN SHAPE RECORDS -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FShapeRecEnd ---------------------------------------------------------- - -// ShapeRecEnd class constructor. Doesn't take in anything because the -// object serves as an end tag and has no details. -FShapeRecEnd::FShapeRecEnd(void) {} - -void FShapeRecEnd::IncludeNFillBitInfo(U32 /*_nFillBits*/) -{ - // does nothing - //virtual method needed for shape rec change -} - -void FShapeRecEnd::IncludeNLineBitInfo(U32 /*_nLineBits*/) -{ - //same deal -} - -// Writes the object to the given buffer. - -void FShapeRecEnd::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - //stream of 0's signifies the end - _SWFStream->WriteBits(0, 6); - - //need to fill to end shape rec array structure. - _SWFStream->FlushBits(); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FShapeWStyle ---------------------------------------------------------- - -// FShapeWStyle class constructor. The shape record list is automatically constructed. -FShapeWStyle::FShapeWStyle(FFillStyleArray *_fillStyles, FLineStyleArray *_lineStyles) -{ - - fillStyles = _fillStyles; - lineStyles = _lineStyles; - - nFillBits = FSWFStream::MinBits(fillStyles->Size(), 0); - nLineBits = FSWFStream::MinBits(lineStyles->Size(), 0); -} - -// Deleted the fill style array, line style array, and shape records. - -FShapeWStyle::~FShapeWStyle(void) -{ - - delete fillStyles; - fillStyles = NULL; - - delete lineStyles; - lineStyles = NULL; - - while (!shapeRecs.empty()) { - - delete shapeRecs.back(); - shapeRecs.pop_back(); - } -} - -// Adds a shape record to the end of the shape record list. - -void FShapeWStyle::AddShapeRec(FShapeRec *shapeRec) -{ - - shapeRecs.push_back(shapeRec); -} - -U32 FShapeWStyle::NumFillBits() -{ - - return nFillBits; -} - -U32 FShapeWStyle::NumLineBits() -{ - - return nLineBits; -} - -////////////////////////////////////////////////////////////////////// - -void FShapeWStyle::changeColor(const std::map &table) -{ - unsigned int i, j; - if (fillStyles) - for (i = 0; i < fillStyles->Size(); i++) { - FAFillStyle *style = fillStyles->get(i); - //FColor* color = ((FFillStyleSolid*)style)->getColor(); - if (style->IsSolidStyle()) { - TPixel oldColor = fcolor2tpixel(*(((FFillStyleSolid *)style)->getColor())); - std::map::const_iterator it = table.find(oldColor); - if (it != table.end()) - ((FFillStyleSolid *)style)->setColor(new FColor(tpixel2fcolor(it->second))); - } - } - - for (i = 0; i < shapeRecs.size(); i++) { - FShapeRec *rec = shapeRecs[i]; - if (rec->isFShapeRecChange() && ((FShapeRecChange *)rec)->GetFillStyles()) - for (j = 0; j < ((FShapeRecChange *)rec)->GetFillStyles()->Size(); j++) { - FAFillStyle *style = ((FShapeRecChange *)rec)->GetFillStyles()->get(j); - //FColor* color = ((FFillStyleSolid*)style)->getColor(); - if (style->IsSolidStyle()) { - TPixel oldColor = fcolor2tpixel(*(((FFillStyleSolid *)style)->getColor())); - std::map::const_iterator it = table.find(oldColor); - if (it != table.end()) - ((FFillStyleSolid *)style)->setColor(new FColor(tpixel2fcolor(it->second))); - } - } - } -} - -///////////////////////////////////////////////////////////////////// - -void FShapeWStyle::changeColor(const FColor &oldColor, const FColor &newColor) -{ - unsigned int i, j; - if (fillStyles) - for (i = 0; i < fillStyles->Size(); i++) { - FAFillStyle *style = fillStyles->get(i); - FColor *color = ((FFillStyleSolid *)style)->getColor(); - if (style->IsSolidStyle() && *color == oldColor) - ((FFillStyleSolid *)style)->setColor(new FColor(newColor)); - color = ((FFillStyleSolid *)style)->getColor(); - } - - for (i = 0; i < shapeRecs.size(); i++) { - FShapeRec *rec = shapeRecs[i]; - if (rec->isFShapeRecChange() && ((FShapeRecChange *)rec)->GetFillStyles()) - for (j = 0; j < ((FShapeRecChange *)rec)->GetFillStyles()->Size(); j++) { - FAFillStyle *style = ((FShapeRecChange *)rec)->GetFillStyles()->get(j); - FColor *color = ((FFillStyleSolid *)style)->getColor(); - if (style->IsSolidStyle() && *color == oldColor) - ((FFillStyleSolid *)style)->setColor(new FColor(newColor)); - color = ((FFillStyleSolid *)style)->getColor(); - } - } -} - -///////////////////////////////////////////////////////////////////// - -// Writes the shape with style to the given _SWFStream. - -void FShapeWStyle::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - fillStyles->WriteToSWFStream(_SWFStream); - lineStyles->WriteToSWFStream(_SWFStream); - - _SWFStream->WriteBits(nFillBits, 4); - _SWFStream->WriteBits(nLineBits, 4); - - //write the shape records - std::vector::iterator cursor; - - for (cursor = shapeRecs.begin(); cursor != shapeRecs.end(); cursor++) { - (*cursor)->IncludeNFillBitInfo(nFillBits); //vincenzo - (*cursor)->IncludeNLineBitInfo(nLineBits); //vincenzo - - (*cursor)->WriteToSWFStream(_SWFStream); - if ((*cursor)->isFShapeRecChange()) //vincenzo - ((FShapeRecChange *)(*cursor))->getFillLineBits(nFillBits, nLineBits); //vincenzo - } - _SWFStream->FlushBits(); -} diff --git a/toonz/sources/common/flash/FDTShapes.h b/toonz/sources/common/flash/FDTShapes.h deleted file mode 100644 index 488c62d..0000000 --- a/toonz/sources/common/flash/FDTShapes.h +++ /dev/null @@ -1,1278 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTShapes.h - - This header-file contains the declarations of all low-level shape-related classes. - Their parent classes are in the parentheses: - - class FShape; - class FACXForm; - class FALineStyle; - class FAGradRecord; - class FCXForm; (public FACXForm) - class FCXFormWAlpha; (public FACXForm) - class FDTDefineMorphShape; (public FDT) - class FDTDefineShape; (public FDT) - class FDTDefineShape2; (public FDT) - class FDTDefineShape3; (public FDT) - class FAFillStyle; - class FFillStyle; (public FAFillStyle) - class FFillStyleArray; - class FFillStyleBitmap; (public FFillStyle) - class FFillStyleGradient; (public FFillStyle) - class FFillStyleSolid; (public FFillStyle) - class FGradient; - class FGradRecord; (public FAGradRecord) - class FLineStyle; (public FALineStyle) - class FLineStyleArray; - class FMorphFillStyle; (public FAFillStyle) - class FMorphFillStyleBitmap; (public FMorphFillStyle) - class FMorphFillStyleGradient; (public FMorphFillStyle) - class FMorphFillStyleSolid; (public FMorphFillStyle) - class FMorphGradRecord; (public FAGradRecord) - class FMorphLineStyle; (public FALineStyle) - class FShapeRec; - class FShapeRecChange; (public FShapeRec) - class FShapeRecEdgeStraight; (public FShapeRec) - class FShapeRecEdgeCurved; (public FShapeRec) - class FShapeRecEnd; (public FShapeRec) - class FShapeWStyle; - -****************************************************************************************/ - -#ifndef _FDT_SHAPES_H_ -#define _FDT_SHAPES_H_ - -#include "Macromedia.h" -#include "FDT.h" -#include "FSWFStream.h" -#include "FPrimitive.h" -#include "tpixel.h" - -class FMorphFillStyle; -class FMorphLineStyle; -class FShapeRec; -class FFillStyle; -class FLineStyle; -class FFillStyleArray; -class FLineStyleArray; -class FShapeWStyle; -class FGradient; - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -//! Holds an array of ShapeRec's -/*! The ShapeRecs are written to a SWFStream in - the order they are added to the array. Normally used to store Font - Glyphs in a Definefont tag. An array of ShapeRec'sThis should probably - be called FShapeArray or such. FShapeWStyle is an expanded version. - \sa FShapeRec, FShapeRecChange, -*/ -class DVAPI FShape -{ -public: - FShape(); - virtual ~FShape(); - - //! Sets the number of bits necessary to index a Fill Style array into the SWF field nFillBits. - /*! The SWF SHAPE tag needs the number of bits necessary to index a - fillstyle array However, what Fill Style Array is it referring to ??? - Put 0 for now. - \param _nFillBits - */ - void SetFillBits(U32 _nFillBits); - //! Sets the number of bits necessary to index a Line Style array into theSWF field nFillBits. - /*! The SWF SHAPE tag also needs the number of bits necessary to index a - linestyle array. Again, what Line Style Array is it referring to ??? - Put 0 for now. - \param _nLineBits - */ - void SetLineBits(U32 _nLineBits); - - //! Add a ShapeRec (of type curve, line, or ChangeRec) to this Shape - /*! Add a ShapeRec which could be a ChangeRec, or an EdgeRec (curve or line) - to this Shape. The first is always a ChangeRec to set drawing position. - - \param shapeRec - */ - void AddShapeRec(FShapeRec *shapeRec); - - //! Stream the ShapeRecs out to the temporary buffer - /*! For each ShapeRec, tell it the # of fill bits, line bits, - and tell it to write itself to the temp stream. - - \param _SWFStream: the temporary output stream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); //not Complete, see comments - -private: - U32 nFillBits; - U32 nLineBits; - std::vector shapeRecs; -}; - -//! Abstract Base class of FCXForm and FCXFormWAlpha -/*! Specifies a color transform for certain objects - - \sa FCXForm, FCXFormWAlpha - */ -class DVAPI FACXForm -{ -public: - //! Virtual method. Write the color transform out to stream. - /*! Implemented by FCXForm, FCXFormWAlpha - - \param _SWFStream - */ - virtual ~FACXForm() {} - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; -}; - -//! Abstract Base class of FLineStyle, FMorphLineStyle -/*! All line styles fall into this category (morph or regular) - - \sa FLineStyle, FMorphLineStyle - */ -class DVAPI FALineStyle -{ -public: - virtual ~FALineStyle() {} - //! Virtual Method for writing LineStyles out to a stream - /*! Virtual Method for writing LineStyles out to a stream - - \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; -}; - -// - -//! Virtual Base Class of FGradRecord,FMorphGradRecord -/*! All grad records fall into this category - - \sa FGradRecord,FMorphGradRecord - */ -class DVAPI FAGradRecord -{ -public: - virtual ~FAGradRecord() {} - - //! Virtual Method for writing a Gradient out to a stream - - /*! - \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; -}; - -// - -//! Color Transform -/*! Specifies a color transformation for some object without transparency information - - \sa - */ -class DVAPI FCXForm : public FACXForm -{ -public: - //! Set the values of the transform - no alpha channel - /*! Do we need the _has parameters? - Is 0 a valid value for each of these mult or add params? - - \param U32 _hasAdd: Has color addition values if equal to 1 - \param U32 _hasMult: Has color multipy values if equal to 1 - \param S32 _redMultTerm: Red multiply value - \param S32 _greenMultTerm: Green multiply value - \param S32 _blueMultiTerm: Blue multiply value - \param S32 _redAddTerm: Red addition value - \param S32 _greenAddTerm: Green addition value - \param S32 _blueAddTerm: Blue addition value - - */ - FCXForm( - U32 _hasAdd, U32 _hasMult, S32 _redMultTerm, S32 _greenMultTerm, - S32 _blueMultiTerm, S32 _redAddTerm, S32 _greenAddTerm, S32 _blueAddTerm); - - //! Write a SWF Color Transform without Alpha to Stream - /*! Writes the _has bits, and depending on their values, the multiply and add - color values. Computes the SWF nBits field from color values passed. - - \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -protected: - //flags - U32 hasAdd; - U32 hasMult; - - // bits in each term field - U32 nBits; - - S32 redMultTerm; - S32 greenMultTerm; - S32 blueMultTerm; - S32 redAddTerm; - S32 greenAddTerm; - S32 blueAddTerm; - - // finds minimum number of bits needed to represent the largest term - U32 MinBits(void); -}; - -// Specifies a color transformation for some object with transparency information - -//! Set the values of the transform - same as FCXForm with alpha channel -/*! Do we need the _has parameters? - Is 0 a valid value for each of these mult or add params? - - \param U32 _hasAdd: Has color addition values if equal to 1 - \param U32 _hasMult: Has color multipy values if equal to 1 - \param S32 _redMultTerm: Red multiply value - \param S32 _greenMultTerm: Green multiply value - \param S32 _blueMultiTerm: Blue multiply value - \param S32 _alphaMultTerm: Alpha transparency multiply value - \param S32 _redAddTerm: Red addition value - \param S32 _greenAddTerm: Green addition value - \param S32 _blueAddTerm: Blue addition value - \param S32 _alphaAddTerm: Alpha transparency addition value - - */ -class DVAPI FCXFormWAlpha : public FCXForm -{ - -public: - FCXFormWAlpha(U32 _hasAdd, U32 _hasMult, S32 _redMultTerm, S32 _greenMultTerm, S32 _blueMultTerm, S32 _alphaMultTerm, - S32 _redAddTerm, S32 _greenAddTerm, S32 _blueAddTerm, S32 _alphaAddTerm); - //! Write a SWF Color Transform with Alpha to Stream - /*! Writes the _has bits, and depending on their values, the multiply and add - color values. Computes the SWF nBits field from color values passed. - - \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - //flags - // U32 hasAdd; - // U32 hasMult; - - //bits in each term field - U32 nBits; - - // S32 redMultTerm; - // S32 greenMultTerm; - // S32 blueMultTerm; - S32 alphaMultTerm; - - // S32 redAddTerm; - // S32 greenAddTerm; - // S32 blueAddTerm; - S32 alphaAddTerm; - - //returns minimum number of bits needed to represent largest term value - U32 MinBits(void); -}; - -// - -//! a flash object which defines a morphing shape. It contains appearance information about an original shape and a shape being morphed into -/*! Note: this is the SWF info and should be rewritten. I would have expected that a - morph would take two character IDs instead of defining everything here. ??? - Defines the metamorphosis of one shape (Shape1) into another (Shape2). - The ShapeBounds1 specifies the boundaries of the original shape, - while ShapeBounds2 specifies the boundaries of the shape into which - Shape1 changes. The data specified in MorphFillStyles and MorphLineStyles - are for both shapes. For example, the fill style for Shape1 is specified, - then the corresponding fill style for Shape2 is specified. Edges1 - specifies the edges for Shape1 as well as the morph style data for - both shapes. Edges2 specifies the edges for Shape2, and contains no - style data. The number of edges specified in Edges1 must equal the - number of edges in Edges2. - - Should point to example code here. - */ - -class DVAPI FDTDefineMorphShape : public FDT -{ - -public: - //! Constructor just takes the before and after bounds RECTs - /*! - \param _rect1, _rect2 rects of before and after shapes - */ - FDTDefineMorphShape(FRect *_rect1, FRect *_rect2); - virtual ~FDTDefineMorphShape(); - //! Add Fill style to array and record its index - /*! You should have used FMorphFillStyles (solid, gradient, bitmap) - to create a morph fill style - \param fillStyle - */ - U32 AddFillStyle(FMorphFillStyle *fillStyle); - - // here changed. - //! Add line style to array and record its index. - /*! You need a pair of line styles (lineWidth + lineColor), - which contains both "morph from" and "morph to" line style information. - \param startLineWidth Line thickness of starting shape in twips. - \param startLineColor Line color of starting shape. (should be RGBA type). - \param finalLineWidth Line thickness of ending shape in twips. - \param finalLineColor Line color of ending shape. (should be RGBA type). - \return the position in the array. - */ - U32 AddLineStyle(U32 startLineWidth, FColor *startLineColor, - U32 finalLineWidth, FColor *finalLineColor); - - //! Cleans up the internal representation of the fill and line style arrays. - void FinishStyleArrays(void); - - //! Add a Shape Record to the first morph object definition - /*! The AddShapeRec_1 method takes style information for both shapes and edge - information for the "morph from" shape - \param _shapeRec the change, straight, curve record, or end record - */ - void AddShapeRec_1(FShapeRec *_shapeRec); - //! Add a Shape Record to the second morph object - /*! The AddEdgeRec_2 method takes edge information for just the "morph to" - \param _shapeRec the change, straight, curve record, or end record - */ - void AddEdgeRec_2(FShapeRec *_shapeRec); - - //! Record morphing objects's ID for later reference - U16 ID(void); - - //! Called by the FObj to write to the output stream - /*! \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - FRect *shapeBounds_1; // 1 subscript denotes original shape - FRect *shapeBounds_2; // and 2 subscript denotes shape being morphed to - FShape shape1; - FShape shape2; - U32 offset; - FFillStyleArray *morphFillStyleArray; - FLineStyleArray *morphLineStyleArray; - U32 nFillBits; - U32 nLineBits; - U8 styleArraysFinished; -}; - -//! Create a DefineShape tag -/*! Creates a Flash 1.0 Define Shape tag. You should use DefineShape3. - All the DefineShape tags only differ in the fill/line style arrays - and fill/line style records - - \sa FFillStyle, FLineStyle, FShapeRec, FShapeWStyle, - see also FExampleRectangle.cpp - */ -class DVAPI FDTDefineShape : public FDT -{ - -public: - //! Create the basic empty shell of a DefineShape tag - /*! Only the bounds rect is passed. Fills, Lines, and - Shapes must be added. - - \param _rect the bounds rectangle - */ - FDTDefineShape(FRect *_rect); - virtual ~FDTDefineShape(); - - //! Add a Shape record to the internal ShapeRec array - /*! Use FShapeRecChange, FShapeRecEdgeStraight, FShapeRecEdgeStraight - to create edges to add to this shape - \param _shapeRec - */ - void AddShapeRec(FShapeRec *_shapeRec); - - //! Cleans up the internal representation of the fill and line style arrays. - void FinishStyleArrays(void); - //! Add fill style to shape, - /*! Remember to store the position of the fill style. Use this when - creating the shape change record later, to indicate which style - to use for the fill. - \param fillStyle - \return the position in the array. when creating the shape change record later. - */ - U32 AddFillStyle(FFillStyle *fillStyle); - - // changed here. - //! Add solid fill style to shape, - /*! Remember to store the position of the fill style. Use this when - creating the shape change record later, to indicate which style - to use for the fill. - \param fillColor - \return the position in the array. when creating the shape change record later. - */ - U32 AddSolidFillStyle(FColor *fillColor); - - // here changed. - //! Add line style to array and record its index. - /*! Remember to store the position of the fill style. Use this - when creating the shape change record later, to indicate which style - to use for the next edges. - \param lineWidth Line thickness in twips. - \param lineColor Line color. (should be RGB type). - \return the position in the array. - */ - U32 AddLineStyle(U32 lineWidth, FColor *lineColor); - - //! Record objects's ID for when you do a PlaceObject - U16 ID(void); - //! Called by the FObj to write to the output stream - /*! \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - virtual void SetId(U16 id) { characterID = id; } - bool IsDefineShape(); - -private: - U16 characterID; - FRect *shapeBounds; - FShapeWStyle *shapeWithStyle; - FFillStyleArray *fillStyleArray; - FLineStyleArray *lineStyleArray; - //U32 nFillBits; - //U32 nLineBits; - U8 styleArraysFinished; -}; - -//! Create a DefineShape2 tag -/*! Creates a Flash 2.0 Define Shape tag. You should use DefineShape3. - All the DefineShape tags only differ in the fill/line style arrays - and fill/line style records - - \sa FFillStyle, FLineStyle, FShapeRec, FShapeWStyle, - see also FExampleRectangle.cpp - */ -class DVAPI FDTDefineShape2 : public FDT -{ - -public: - //! Create the basic empty shell of a DefineShape tag - /*! Only the bounds rect is passed. Fills, Lines, and - Shapes must be added. - - \param _rect the bounds rectangle - */ - FDTDefineShape2(FRect *_rect); - virtual ~FDTDefineShape2(); - //! Add a Shape record to the internal ShapeRec array - /*! Use FShapeRecChange, FShapeRecEdgeStraight, FShapeRecEdgeStraight - to create edges to add to this shape - \param _shapeRec - */ - void AddShapeRec(FShapeRec *_shapeRec); - - //! Cleans up the internal representation of the fill and line style arrays. - void FinishStyleArrays(void); - - //! Add fill style to shape, - /*! Remember to store the position of the fill style. Use this when - creating the shape change record later, to indicate which style - to use for the fill. Remember, DefineShape2s don't support Alpha. - \param fillStyle - \return the position in the array. When creating the shape change record later. - */ - U32 AddFillStyle(FFillStyle *fillStyle); - - // here changed. - //! Add solid fill style to shape, - /*! Remember to store the position of the fill style. Use this when - creating the shape change record later, to indicate which style - to use for the fill. Remember, DefineShape2s don't support Alpha. - \param fillColor - \return the position in the array. When creating the shape change record later. - */ - U32 AddSolidFillStyle(FColor *fillColor); - - // here changed. - //! Add line style to rectangle, - /*! Remember to store the position of the fill style. Use this - when creating the shape change record later, to indicate which style - to use for the next edges. - \param lineWidth Line thickness in twips. - \param lineColor Line color. (should be RGB type). - \return the position in the array. - */ - U32 AddLineStyle(U32 lineWidth, FColor *lineColor); - - //! Record objects's ID for when you do a PlaceObject - U16 ID(void); - //! Called by the FObj to write to the output stream - /*! \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - virtual void SetId(U16 id) { characterID = id; } - bool IsDefineShape(); - -private: - U16 characterID; - FRect *shapeBounds; - FShapeWStyle *shapeWithStyle; - FFillStyleArray *fillStyleArray; - FLineStyleArray *lineStyleArray; - U32 nFillBits; - U32 nLineBits; - U8 styleArraysFinished; -}; - -//! Create a DefineShape3 tag -/*! Creates a Flash 3.0 Define Shape tag. - All the DefineShape tags only differ in the fill/line style arrays - and fill/line style records (accepts alpha color values). - - \sa FFillStyle, FLineStyle, FShapeRec, FShapeWStyle, - see also FExampleRectangle.cpp - */ - -class DVAPI FDTDefineShape3 : public FDT -{ - -public: - //! Create the basic empty shell of a DefineShape tag - /*! Only the bounds rect is passed. Fills, Lines, and - Shapes must be added. - - \param _rect the bounds rectangle - */ - FDTDefineShape3(); - FDTDefineShape3(FRect *_rect); - void setBounds(FRect *_rect); - virtual ~FDTDefineShape3(); - //! Add a Shape record to the internal ShapeRec array - /*! Use FShapeRecChange, FShapeRecEdgeStraight, FShapeRecEdgeStraight - to create edges to add to this shape - \param _shapeRec - */ - void AddShapeRec(FShapeRec *_shapeRec); - //! Cleans up the internal representation of the fill and line style arrays. - void FinishStyleArrays(void); - - //! Add fill style to shape, - /*! Remember to store the position of the fill style. Use this when - creating the shape change record later, to indicate which style - to use for the fill. - \param fillStyle - \return the position in the array. When creating the shape change record later. - */ - U32 AddFillStyle(FFillStyle *fillStyle); - - //! Add solid fill style to shape, - /*! Remember to store the position of the fill style. Use this when - creating the shape change record later, to indicate which style - to use for the fill. - \param fillColor - \return the position in the array. When creating the shape change record later. - */ - U32 AddSolidFillStyle(FColor *fillColor); - - //! Add line style to array and record its index. - /*! Remember to store the position of the fill style. Use this - when creating the shape change record later, to indicate which style - to use for the next edges. - \param lineWidth Line thickness in twips. - \param lineColor Line color. (should be RGBA type). - \return the position in the array. - */ - U32 AddLineStyle(U32 lineWidth, FColor *lineColor); - - //! Record objects's ID for when you do a PlaceObject - U16 ID(void); - //! Called by the FObj to write to the output stream - /*! \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - virtual void SetId(U16 id) { characterID = id; } - bool IsDefineShape(); - void changeColor(const FColor &oldColor, const FColor &newColor); - void changeColor(const std::map &table); - - FRect GetBBox() const { return *shapeBounds; } -private: - U16 characterID; - FRect *shapeBounds; - FShapeWStyle *shapeWithStyle; - FFillStyleArray *fillStyleArray; - FLineStyleArray *lineStyleArray; - U32 nFillBits; - U32 nLineBits; - U8 styleArraysFinished; -}; - -//! Abstract Base Class. All edge records fall into this category -/*! The fill classes from the solid, gradient, bitmap are children. - - \sa FFillStyleGradient, FFillStyleBitmap, FFillStyleSolid - */ -class DVAPI FAFillStyle -{ -public: - virtual bool IsSolidStyle() { return false; }; - - virtual ~FAFillStyle() {} - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; -}; - -//The fill style used by regular non-morph shapes - -//! Why does this exist? -/*! It is used as a parameter to other functions but I don't know why. - - \sa FFillStyleGradient, FFillStyleBitmap, FFillStyleSolid - */ -class DVAPI FFillStyle : public FAFillStyle -{ -public: - virtual ~FFillStyle() {} -}; - -//!An array of fill styles. -/*! - - \sa FFillStyleGradient, FFillStyleBitmap, FFillStyleSolid, FAFillStyle -*/ -class DVAPI FFillStyleArray -{ - -public: - FFillStyleArray(void) {} - virtual ~FFillStyleArray(void); - //! The given fill style is added to the end of the fill style array. - /*! The position of the added fill style is returned so that the fill style can later be referenced. - - \param fillStyle the style to add - */ - - U32 Add(FAFillStyle *fillStyle); - //! Returns the size of the fill style list. - U32 Size(); - FAFillStyle *get(unsigned int index); - - //! Writes the array to the stream - /*! Travels through all of the nodes in the array and writing - their fill styles. First has to write the count of fill style arrays. See's if count - is small enough to fit in to an 8 bit field, and either writes the count into an 8 bit - field, or writes all 1's into an 8 bit field and writes the real count into a 16 bit - field. - - \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - //the list which contains all of the fill styles - std::vector fillStyleArray; -}; - -//! The Bitmap fill style used by regular non-morph shapes -/*! Can be tiled or clipped, depending on the flag. - - \sa FFillStyleArray, FFillStyleGradient, FFillStyleBitmap, FFillStyleSolid, FAFillStyle - */ -// -// - -class DVAPI FFillStyleBitmap : public FFillStyle -{ - -public: - /*! - - \param tiled indicates if the Bitmap fill style is tiled (tiledFlag==1) or - clipped (tiledFlag==0). - \param matrix translation matrix for offsetting, rotating, scaleing etc. the bitmap - */ - FFillStyleBitmap(int tiled, U16 ID, FMatrix *matrix); - virtual ~FFillStyleBitmap(void); - //! Writes the bitmap fill style to the given FSWFStream. - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - int tiledFlag; - U16 bitmapID; - FMatrix *bitmapMatrix; -}; - -//! The Gradient fill style used by regular non-morph shapes -/*! Can be linear or radial, depending on the flag. - - \sa FFillStyleArray, FGradient - */ -class DVAPI FFillStyleGradient : public FFillStyle -{ - -public: - //! Create a Gradient fill style - /*! - \param linear indicates if the gradient fill style is linear (linearFlag==1) or - radial (linearFlag==0). - \param matrix matrix translation matrix for placing the gradient in the fill area - Not sure what each of the matrix fields do??? - \param gradient a pre-build gradient object. See FGradient - */ - FFillStyleGradient(int linear, FMatrix *matrix, FGradient *gradient); - virtual ~FFillStyleGradient(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - int linearFlag; - FMatrix *gradFillMatrix; - FGradient *gradFill; -}; - -//The solid fill style used by regular non-morph shapes - -//! Creates a Solid Fill object -/*! Basically just contains a color - - \sa FFillStyleArray, FFillStyleGradient, FFillStyleBitmap - */ -class DVAPI FFillStyleSolid : public FFillStyle -{ -public: - //! Create a style object - /*! Whether or not FColor contains alpha information is not - important until the color is written out. - - \param Fcolor which can contain alpha or not - */ - FFillStyleSolid(FColor *_color); - - virtual ~FFillStyleSolid(); - - //! Write the color to the file stream - /*! When this object is serialized, it automatically handles the case of - including the alpha information if its there. - \param *_SWFStream the output stream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - bool IsSolidStyle() { return true; }; - void setColor(FColor *_color) - { - delete color; - color = _color; - } - FColor *getColor() { return color; } - -private: - FColor *color; -}; - -//! Gradient information is stored in an array of Gradient Records -/*! This is that array. This style of gradient records is used with - non-morphing objects. - - \sa FGradRecord - */ -class DVAPI FGradient -{ - -public: - FGradient(void); - ~FGradient(void); - //! Add a Gradient Record to the internal list - /*! Up to 8 gradient records may be added to this list - The ratio field within each GradientRec determines what percentage - of a gradient is a particular color. - \param FAGradRecord* pointer to a gradient record - */ - void Add(FAGradRecord *g); - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - //the list which contains all of the grad records - std::list gradRecords; -}; - -// used by non-morph shapes - -//! A non morph gradient record. -/*! Note that ostensibly the ratio parameter is the percentage complete aTLong - the gradient that this color should be but it's really not known what this - field is. - \sa FGradient, FFillStyleGradient - */ -class DVAPI FGradRecord : public FAGradRecord -{ -public: - //!Create the Gradient record with the mysterious ration parm. - /*! - - \param U_ratio know one knows for sure - \param FColor one of the colors to shift through - */ - FGradRecord(U32 _ratio, FColor *color); - - virtual ~FGradRecord(); - - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 ratio; - FColor *color; -}; - -// - -//! The line style used by regular non-morph shapes -/*! LineStyles are held in arrays of LineStyles which are held - in DefineShape Tags. - - \sa FExampleRectangle.cpp, FLineStyleArray - */ -class DVAPI FLineStyle : public FALineStyle -{ - -public: - //!Line Style is just a thickness and color - /*! - - \param width U32 - \param _color FColor - */ - FLineStyle(U32 _width, FColor *_color); - virtual ~FLineStyle(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 width; - FColor *color; -}; - -// -//! An array of line styles. -/*! LineStyles are held in arrays of LineStyles which are held - in DefineShape Tags. - - \sa FLineStyle, FExampleRectangle.cpp -*/ -class DVAPI FLineStyleArray -{ - -public: - //!Create an empty initialized array - FLineStyleArray(void); - ~FLineStyleArray(void); - //!Add the line style to the array. - /*! Automatically handles the case of packing the corresponding SWF object - properly when you go over 255 styles. Not that we can see why you'd do - this. - - \param lineStyle the style object to add to the internal array - */ - U32 Add(FALineStyle *lineStyle); - //! The number of items in the list - /*! This is needed when a containing DefineShape needs to know how how - many styles there are and therefore how many bits are needed for an index. - The given line style is added to the end of the line style array. The position of - the added line style is returned so that the line style can later be referenced. - */ - U32 Size(void); - //! Write the array to the output stream. - /*! Writes to the stream by travelling through all of the nodes in - the array and writing their line styles. First has to write the count - of line style arrays. Sees if count is small enough to fit in to an - 8 bit field, and either writes the count into an 8 bit field, or writes - all 1's into an 8 bit field and writes the real count into a 16 bit field. - - \param *_SWFStream - */ - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - //the list which contains all of the line styles - std::list lineStyleArray; -}; - -//! The Base class of fill style objects used by morph shapes -/*! - - \sa FMorphFillStyleGradient, FMorphFillStyleBitmap, FMorphFillStyleSolid - */ -class DVAPI FMorphFillStyle : public FAFillStyle -{ -public: - virtual ~FMorphFillStyle() {} - virtual void WriteToSWFStream(FSWFStream * /* _SWFStream */) {} -}; - -// -// - -//!The Bitmap fill style used by morph shapes -/*! Note that all Morph fill styles are documented in SWF as a single overloaded - data structure. It's simplier to have three separate routiens. - - This can be tiled or clipped, depending on the flag. - - \sa FMorphFillStyleGradient, FMorphFillStyleBitmap, FMorphFillStyleSolid, FMatrix - */ -class DVAPI FMorphFillStyleBitmap : public FMorphFillStyle -{ - -public: - // The tiledFlag indicates if the Bitmap fill style is tiled (tiledFlag==1) or - // clipped (tiledFlag==0). - - //! Bitmap fill style for a morph - /*! - - \param tiled The tiledFlag indicates if the Bitmap fill style is tiled (tiledFlag==1) or - clipped (tiledFlag==0) - \param ID Character ID of bitmap - \param matrix1 rotation/translation Matrix for first state - \param matrix2 for the second state - */ - FMorphFillStyleBitmap(int tiled, U16 ID, FMatrix *matrix1, FMatrix *matrix2); - virtual ~FMorphFillStyleBitmap(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - int tiledFlag; - U16 bitmapID; - FMatrix *bitmapMatrix1; - FMatrix *bitmapMatrix2; -}; - -//!The Gradient fill style used by morph shapes -/*! Note that all Morph fill styles are documented in SWF as a single overloaded - data structure. It's simplier to have three separate routines. - - Can be linear or radial, depending on the flag, depending on the flag. - - \sa FMorphFillStyleGradient, FMorphFillStyleBitmap, FMorphFillStyleSolid, FGradient, FMatrix, FFillStyleArray - */ -class DVAPI FMorphFillStyleGradient : public FMorphFillStyle -{ - -public: - //!Construct a Gradient Fill Style - /*! Ultimatly to go in a MorphFillStyles Array and then get - added to a DefineMorphShape - - \param linear The linearFlag indicates if the gradient fill - style is linear (linearFlag==1) or radial (linearFlag==0) - \param matrix1 - \param matrix2 translation matrix for the gradient before and after. - \param gradient an FGradient fill - */ - FMorphFillStyleGradient(int linear, FMatrix *matrix1, FMatrix *matrix2, FGradient *gradient); - virtual ~FMorphFillStyleGradient(void); - //!Writes the Gradient fill style to the given FSWFStream. - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - int linearFlag; - FMatrix *gradFillMatrix1; - FMatrix *gradFillMatrix2; - FGradient *gradFill; -}; - -//!The solid fill style used by morph shapes -/*! Each Fill style has two colors for the two objects being morphed. The FillStyles are -in a FFillStyle array. In this case the fill styles object 1 and 2 are interleaved. The -FillStyleArray is then stored in a DefineMorphShape. - - \sa FMorphFillStyleGradient, FMorphFillStyleBitmap, FMorphFillStyleSolid, FGradient, FMatrix,FFillStyleArray - */ -class DVAPI FMorphFillStyleSolid : public FMorphFillStyle -{ - -public: - /*! - \param _color1 Solid fill color with transparency information for first shape - \param _color2 Same for second - */ - FMorphFillStyleSolid(FColor *_color1, FColor *_color2); - virtual ~FMorphFillStyleSolid(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FColor *color1; - FColor *color2; -}; - -//!The grad record used by morph shapes -/*! The Morph Gradient store an array of these records. Each is like a double -of the regular Gradient fill record. Each Morph Gradient Record has two colors -and two ratio numbers for the two objects being morphed. Theses Gradient Records -possibly 8 of them, are stored in an FAGradient array, the base of all gradient records. -Normally the Colors in a gradient array store the colors aTLong the gradient. These -store pairs of colors, one for each of the two objects aTLong with the mysterious ratio number. - The FMorphFillStyleGradient is then stored in a DefineMorphShape. - - \sa FMorphFillStyleGradient, FMorphFillStyleBitmap, FMorphFillStyleSolid, FAGradient, FMatrix,FFillStyleArray - */ -class DVAPI FMorphGradRecord : public FAGradRecord -{ - -public: - //!Create a Morph Gradient record - /*! - \param _ratio1 for the first object - \param _color1 - \param _ratio2 for the second object - \param _color2 - */ - FMorphGradRecord(U32 _ratio1, FColor *_color1, U32 _ratio2, FColor *_color2); - virtual ~FMorphGradRecord(); - - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 ratio1; - U32 ratio2; - - FColor *color1; - FColor *color2; -}; - -//! Morph line styles to go in the DefineMorph Object -/*! MorphLineStyle is an FALineStyle. These get put into - FLineStyleArrays which in turn are put in the Define Morph Object. - These are just line regular line styles, except that they - carry a pair of line styles, one for the morph from object - and the corresponding one in the Morphe to object. - - \sa FLineStyleArray - */ -class FMorphLineStyle : public FALineStyle -{ - -public: - //!create the pair of styles, width/color - /*! - - \param width1 - \param width2 - \param _color1 - \param _color2 - - */ - FMorphLineStyle(U32 _width1, U32 _width2, FColor *_color1, FColor *_color2); - virtual ~FMorphLineStyle(); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FColor *color1; - FColor *color2; - U32 width1; - U32 width2; -}; - -//! Virtual Base class for the change, straight, and curved Shape records -/*! - - \sa FShapeRecChange, FShapeRecEdgeStraight, FShapeRecEdgeCurved - */ -class DVAPI FShapeRec -{ - -public: - virtual ~FShapeRec() {} - virtual bool isFShapeRecChange() { return false; } - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; - virtual void IncludeNFillBitInfo(U32 _nFillBits) = 0; - virtual void IncludeNLineBitInfo(U32 _nLineBits) = 0; - virtual bool IsRecChange() { return false; } -}; - -// shape record that defines changes in line style, fill style, position, or a new set of styles - -class DVAPI FShapeRecChange : public FShapeRec -{ - -public: - FShapeRecChange(U32 _stateNewStyles, - U32 _stateLineStyle, - U32 _stateFillStyle1, - U32 _stateFillStyle0, - U32 _stateMoveTo, - S32 _moveDeltaX, - S32 _moveDeltaY, - U32 _fill0Style, - U32 _fill1Style, - U32 _lineStyle, - FFillStyleArray *_fillStyles, - FLineStyleArray *_lineStyles); - - virtual ~FShapeRecChange(void); - - virtual bool isFShapeRecChange() { return true; } - void getFillLineBits(U32 &_nFillBits, U32 &_nLineBits) - { - _nFillBits = nFillBits; - _nLineBits = nLineBits; - } - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - virtual void IncludeNFillBitInfo(U32 _nFillBits); - virtual void IncludeNLineBitInfo(U32 _nLineBits); - bool IsRecChange() { return true; } - FFillStyleArray *GetFillStyles(); - -private: - U32 stateNewStyles; - U32 stateLineStyle; - U32 stateFillStyle0; - U32 stateFillStyle1; - U32 stateMoveTo; - U32 nMoveBits; - U32 nFillBits; // these two values are stored in the Shape field - U32 nLineBits; // they are passed to each ShapeRec - S32 moveDeltaX; - S32 moveDeltaY; - U32 fill0Style; - U32 fill1Style; - U32 lineStyle; - FFillStyleArray *fillStyles; - FLineStyleArray *lineStyles; - U32 MinBits(void); -}; - -//! Create a straight edge -/*! The XY values are passed as delta values from the previous XY points. - Creating and adding several straight edges in a row will create a set - of connected edges. - - This may change to absolution positions in the future. ??? - - See also FExampleRectangle.cpp - - */ -class DVAPI FShapeRecEdgeStraight : public FShapeRec -{ -public: - //! Create a straight edge from the previous point - /*! This is the equivalent of a "LineTo" command - - \param generalDX - \param generalDY - */ - FShapeRecEdgeStraight(S32 dx, S32 dy); - virtual ~FShapeRecEdgeStraight(){}; - - //!Write out as Vertical, Horizontal or general line SWF Record automatically - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - //!dummy in this object. This call only makes sense for a Change Rec, here for historical - virtual void IncludeNFillBitInfo(U32 _nFillBits); - //!dummy in this object. This call only makes sense for a Change Rec, here for historical - virtual void IncludeNLineBitInfo(U32 _nLineBits); - -private: - U32 edgeFlag; - U32 nBits; - U32 generalLineFlag; - S32 generalDeltaX; - S32 generalDeltaY; - U32 verticalLineFlag; - S32 horizontalDeltaX; - S32 verticalDeltaY; - U32 MinBits(void); -}; - -//! Create a bezier edge -/*! The control points are passed as delta values from the previous control points. - This may change to absolution positions in the future. ??? - - See also [example file], [bezier info file] - - */ -class DVAPI FShapeRecEdgeCurved : public FShapeRec -{ -public: - //! Create a bezier - /*! All values expressed in twips ??? - \param controlDX delta from the last X control value - \param controlDY delta from the last Y control value - \param anchorDX delta from the last X anchor value - \param anchorDY delta from the last Y anchor value - */ - FShapeRecEdgeCurved(S32 controlDX, S32 controlDY, S32 anchorDX, S32 anchorDY); - virtual ~FShapeRecEdgeCurved(void) {} - //! Called by containing Shape when file is serialized - /*! Writes the anchor, control, pts, as well as the minBits and edgeFlag - \param _SWFStream - */ - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - //!dummy in this object. This call only makes sense for a Change Rec, here for historical - virtual void IncludeNFillBitInfo(U32 _nFillBits); - //!dummy in this object. This call only makes sense for a Change Rec, here for historical - virtual void IncludeNLineBitInfo(U32 _nLineBits); - -private: - U32 edgeFlag; - U32 nBits; - S32 controlDeltaX; - S32 controlDeltaY; - S32 anchorDeltaX; - S32 anchorDeltaY; - U32 MinBits(void); -}; - -//The shape record which signifies the end of a shape record array. - -class DVAPI FShapeRecEnd : public FShapeRec -{ - -public: - FShapeRecEnd(void); - //!Write an EndRecord. Signifies the last ShapeRecord in the ShapeRecArray - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - //!dummy in this object. This call only makes sense for a Change Rec, here for historical - virtual void IncludeNFillBitInfo(U32 _nFillBits); - //!dummy in this object. This call only makes sense for a Change Rec, here for historical - virtual void IncludeNLineBitInfo(U32 _nLineBits); -}; - -class DVAPI FShapeWStyle -{ - -public: - FShapeWStyle(FFillStyleArray *_fillStyles, FLineStyleArray *_lineStyles); - ~FShapeWStyle(void); - void AddShapeRec(FShapeRec *shapeRec); - void WriteToSWFStream(FSWFStream *_SWFStream); - U32 NumFillBits(); - U32 NumLineBits(); - FFillStyleArray *GetFillStyles() { return fillStyles; } - void changeColor(const FColor &oldColor, const FColor &newColor); - void changeColor(const std::map &table); - -private: - FFillStyleArray *fillStyles; - FLineStyleArray *lineStyles; - U32 nFillBits; - U32 nLineBits; - std::vector shapeRecs; //see comments, will need to be changed -}; - -#ifdef WIN32 // added from DV -#pragma warning(pop) -#endif -#endif diff --git a/toonz/sources/common/flash/FDTSounds.cpp b/toonz/sources/common/flash/FDTSounds.cpp deleted file mode 100644 index 67617ab..0000000 --- a/toonz/sources/common/flash/FDTSounds.cpp +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTSounds.cpp - - This source file contains the definition for all low-level sound-related functions, - grouped by classes: - - Class Member Function - - FDTDefineSound FDTDefineSound() - void WriteToSWFStream(FSWFStream*); - - FDTDefineSoundADPCM FDTDefineSoundADPCM(U8, U8, U8, U32, U8*, U32, int); - - FDTDefineSoundWAV FDTDefineSoundWAV(FILE*, int); - bool loadWavFile(FILE*, SSound*, U8**, int*); - FDTSoundStreamBlock FDTSoundStreamBlock(U32, U8*); - void WriteToSWFStream(FSWFStream*); - - FDTSoundStreamHead FDTSoundStreamHead(U8, U8, U16); - void WriteToSWFStream(FSWFStream*); - - FDTSoundStreamHead2 FDTSoundStreamHead2(U8, U8, U8, U8, U16); - void WriteToSWFStream(FSWFStream*); - - FSndEnv FSndEnv(U32, U16, U16); - void WriteToSWFStream(FSWFStream*); - - FSoundInfo FSoundInfo(U8, U8, U8, U8, U8, U32, U32, U16, U8, FSndEnv*); - ~FSoundInfo(); - void WriteToSWFStream(FSWFStream*); - -****************************************************************************************/ - -#include "FDTSounds.h" -#include "FSound.h" -#include "FSWFStream.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineSound -------------------------------------------------------- - -FDTDefineSound::FDTDefineSound() -{ - soundID = FObjCollection::Increment(); - memset(&soundData, 0, sizeof(soundData)); -} - -void FDTDefineSound::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream tempBuffer; - - tempBuffer.WriteWord((U32)soundID); - tempBuffer.WriteBits((U32)soundData.format, 4); - tempBuffer.WriteBits((U32)soundData.rate, 2); - tempBuffer.WriteBits((U32)soundData.size, 1); - tempBuffer.WriteBits((U32)soundData.type, 1); - tempBuffer.WriteDWord(soundData.sampleCount); - tempBuffer.WriteLargeData(soundData.sound, soundData.soundSize); - - _SWFStream->AppendTag(stagDefineSound, tempBuffer.Size(), &tempBuffer); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineSoundADPCM --------------------------------------------------- - -FDTDefineSoundADPCM::FDTDefineSoundADPCM(U8 rate, - U8 size, - U8 type, - U32 sampleCount, - const U8 *wavData, - U32 wavDataSize, - int compression) -{ - // clear the vector to write to - pcmData.clear(); - - soundData.format = 1; //a 1 indicates ADPCM - soundData.rate = rate; - soundData.size = size; - soundData.type = type; - soundData.sampleCount = sampleCount; - - // Construct a FSound object - FSound sound; - sound.format = Format(); - - sound.nSamples = (S16)soundData.sampleCount; - sound.samples = const_cast(wavData); // it won't change it - so we cast (lee) - sound.dataLen = (S16)wavDataSize; - sound.delay = 0; - - FSoundComp compress(&sound, compression); - - compress.Compress(const_cast(wavData), sound.nSamples, &pcmData); // it won't change it - so we cast (lee) - compress.Flush(&pcmData); - - // store the compressed data to the sound structure - soundData.sound = &pcmData[0]; - soundData.soundSize = pcmData.size(); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineSoundWAV ----------------------------------------------------- - -FDTDefineSoundWAV::FDTDefineSoundWAV(FILE *fp, int comp) -{ - U8 *wavData; // memory where the WAV file is stored - int wavDataSize; // the number of bytes in the WAV file - - // clear the vector to write to - pcmData.clear(); - - // fp = fopen( waveFile, "rb" ); - if (!fp) { - return; - } - - if (loadWavFile(fp, &soundData, &wavData, &wavDataSize) == false) { - // there was an error - return; - } - - // Construct a FSound object - FSound sound; - sound.format = Format(); - - sound.nSamples = (S16)soundData.sampleCount; - sound.samples = wavData; - sound.dataLen = wavDataSize; - sound.delay = 0; - - FSoundComp compress(&sound, comp); - - compress.Compress(wavData, sound.nSamples, &pcmData); - compress.Flush(&pcmData); - - // fclose( fp ); - - // store the compressed data to the sound structure - soundData.sound = &pcmData[0]; - soundData.soundSize = pcmData.size(); - - // delete the wav data - delete[] wavData; -} - -//------------------------------------------------------------------------------ -bool FDTDefineSoundWAV::loadWavFile(FILE *fp, SSound *soundData, U8 **wavData, int *wavDataSize) -{ - TUINT32 nextseek; - TUINT32 filesize; - TUINT32 fileTag; - TUINT32 typeTag; - TUINT32 chunkSize; - TUINT32 chunkId; - TUINT32 formatTag = 0; - - assert(fp); - memset(soundData, 0, sizeof(SSound)); - - soundData->format = 1; // ADPCM compressed - - fileTag = read32(fp); - if (fileTag != 0x46464952) { - FLASHOUTPUT("Not a RIFF format file\n"); - return false; - } - - filesize = read32(fp); - filesize += ftell(fp); - - typeTag = read32(fp); - if (typeTag != 0x45564157) { - FLASHOUTPUT("Not a WAVE file\n"); - return false; - } - - nextseek = ftell(fp); - while (nextseek < filesize) { - fseek(fp, (TINT32)nextseek, 0); - chunkId = read32(fp); - chunkSize = read32(fp); - nextseek = chunkSize + ftell(fp); - -#ifndef __LP64__ - FLASHOUTPUT("\n----- Chunk ID %d, Size %d -----\n", chunkId, chunkSize); -#else - FLASHOUTPUT("\n----- Chunk ID %d, Size %d -----\n", chunkId, chunkSize); -#endif - - switch (chunkId) { - case 0x20746D66: //Format Chunk - { - FLASHOUTPUT("Format Chunk\n"); - FLASHOUTPUT("Common Fields:\n"); - - formatTag = read16(fp); -#ifndef __LP64__ - FLASHOUTPUT(" Format Tag %04lXh: ", (long unsigned int)formatTag); -#else - FLASHOUTPUT(" Format Tag %04Xh: ", formatTag); -#endif - switch (formatTag) { - default: - case 0x0000: - FLASHOUTPUT("WAVE_FORMAT_UNKNOWN"); - break; - case 0x0001: - FLASHOUTPUT("WAVE_FORMAT_PCM\n"); - break; - case 0x0002: - FLASHOUTPUT("WAVE_FORMAT_ADPCM\n"); - break; - case 0x0005: - FLASHOUTPUT("WAVE_FORMAT_IBM_CVSD\n"); - break; - case 0x0006: - FLASHOUTPUT("WAVE_FORMAT_ALAW\n"); - break; - case 0x0007: - FLASHOUTPUT("WAVE_FORMAT_MULAW\n"); - break; - case 0x0010: - FLASHOUTPUT("WAVE_FORMAT_OKI_ADPCM"); - break; - case 0x0011: - FLASHOUTPUT("WAVE_FORMAT_DVI_ADPCM or WAVE_FORMAT_IMA_ADPCM\n"); - break; - case 0x0015: - FLASHOUTPUT("WAVE_FORMAT_DIGISTD\n"); - break; - case 0x0016: - FLASHOUTPUT("WAVE_FORMAT_DIGIFIX\n"); - break; - case 0x0020: - FLASHOUTPUT("WAVE_FORMAT_YAMAHA_ADPCM\n"); - break; - case 0x0021: - FLASHOUTPUT("WAVE_FORMAT_SONARC\n"); - break; - case 0x0022: - FLASHOUTPUT("WAVE_FORMAT_DSPGROUP_TRUESPEECH\n"); - break; - case 0x0023: - FLASHOUTPUT("WAVE_FORMAT_ECHOSC1\n"); - break; - case 0x0024: - FLASHOUTPUT("WAVE_FORMAT_AUDIOFILE_AF18\n"); - break; - case 0x0101: - FLASHOUTPUT("IBM_FORMAT_MULAW\n"); - break; - case 0x0102: - FLASHOUTPUT("IBM_FORMAT_ALAW\n"); - break; - case 0x0103: - FLASHOUTPUT("IBM_FORMAT_ADPCM\n"); - break; - case 0x0200: - FLASHOUTPUT("WAVE_FORMAT_CREATIVE_ADPCM\n"); - break; - } - int channels = (int)read16(fp); - soundData->type = channels - 1; - FLASHOUTPUT(" %u Channels\n", channels); - - int samplesPerSec = (int)read32(fp); - FLASHOUTPUT(" %u Samples Per Second\n", samplesPerSec); - switch (samplesPerSec / 5000) { - case 1: // 5k - soundData->rate = Snd5k; - break; - case 2: // 11k - soundData->rate = Snd11k; - break; - case 4: // 22k - soundData->rate = Snd22k; - break; - case 8: // 44k - soundData->rate = Snd44k; - break; - default: - FLASHOUTPUT("Sample rate %d unsupported\n", samplesPerSec); - return false; - } - - int bytesPerSec = (int)read32(fp); - FLASHOUTPUT(" %u Average Bytes Per Second\n", bytesPerSec); - - int blockAlign = read16(fp); - FLASHOUTPUT(" Block Align %u\n", blockAlign); - - FLASHOUTPUT("Format Specific Fields:\n"); - int bits = read16(fp); - FLASHOUTPUT(" %u Bits Per Sample\n", bits); - - //store the size of the chunks of data (8v16 bit) - if (bits == 8) - soundData->size = 0; - else if (bits == 16) - soundData->size = 1; - else - FLASHASSERT(0); - - if (formatTag != 0x0001) { - int extra = read16(fp); - FLASHOUTPUT(" %d Bytes of extra information\n", extra); - FLASHOUTPUT(" NOT YET SUPPORTED\n"); - return false; - } - } break; - - case 0x61746164: //Data Chunk - { - FLASHOUTPUT("Data Chunk\n"); - if (!formatTag) { - FLASHOUTPUT("Warning Format Chunk not defined before Data Chunk\n"); - return false; - } - *wavDataSize = (int)chunkSize; - soundData->sampleCount = chunkSize / (soundData->size + 1); - *wavData = new U8[chunkSize]; - int read = fread(*wavData, 1, *wavDataSize, fp); - - if (read != (*wavDataSize)) { - FLASHOUTPUT("Warning Read %d of %d bytes\n", read, (*wavDataSize)); - return false; - } - return true; - } - - default: - FLASHOUTPUT("Unknown Chunk\n"); - return false; - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTSoundStreamBlock --------------------------------------------------- - -FDTSoundStreamBlock::FDTSoundStreamBlock(U32 _size, U8 *_data) -{ - size = _size; - data = _data; -} - -void FDTSoundStreamBlock::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - body.WriteLargeData(data, size); - - _SWFStream->AppendTag(stagSoundStreamBlock, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTSoundStreamHead ---------------------------------------------------- - -FDTSoundStreamHead::FDTSoundStreamHead(U8 _mixFormat, U8 _soundType, U16 _count) -{ - mixFormat = _mixFormat; - soundType = _soundType; - count = _count; -} - -void FDTSoundStreamHead::WriteToSWFStream(FSWFStream *_SWFStream) -{ - FSWFStream body; - - body.WriteByte((U32)mixFormat); - body.WriteBits(1, 4); - body.WriteBits(0, 2); - body.WriteBits(1, 1); - body.WriteBits((U32)soundType, 1); - body.WriteWord((U32)count); - _SWFStream->AppendTag(stagSoundStreamHead, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTSoundStreamHead2 --------------------------------------------------- - -FDTSoundStreamHead2::FDTSoundStreamHead2(U8 _mixFormat, U8 _compression, U8 _size, U8 _soundType, U16 _count) -{ - mixFormat = _mixFormat; - compression = _compression; - rate = 0; - size = _size; - soundType = _soundType; - count = _count; -} - -FDTSoundStreamHead2::FDTSoundStreamHead2(U8 _mixFormat, U8 _compression, U8 _rate, U8 _size, U8 _soundType, U16 _count) -{ - mixFormat = _mixFormat; - compression = _compression; - rate = _rate; - size = _size; - soundType = _soundType; - count = _count; -} - -void FDTSoundStreamHead2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteByte((U32)mixFormat); - body.WriteBits((U32)compression, 4); - body.WriteBits((U32)rate, 2); - body.WriteBits((U32)size, 1); - body.WriteBits((U32)soundType, 1); - body.WriteWord((U32)count); - - _SWFStream->AppendTag(stagSoundStreamHead2, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FSndEnv --------------------------------------------------------------- -FSndEnv::FSndEnv(U32 mark44, U16 level0, U16 level1) -{ - mark44 = mark44; - level0 = level0; - level1 = level1; -} - -void FSndEnv::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->WriteDWord(mark44); - _SWFStream->WriteWord((U32)level0); - _SWFStream->WriteWord((U32)level1); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FSoundInfo ------------------------------------------------------------ -FSoundInfo::FSoundInfo(U8 _syncFlags, U8 _hasEnvelope, U8 _hasLoops, U8 _hasOutPoint, - U8 _hasInPoint, U32 _inPoint, U32 _outPoint, U16 _loopCount, - U8 _nPoints, FSndEnv *_soundEnvelope) -{ - - syncFlags = _syncFlags; - hasEnvelope = _hasEnvelope; - hasLoops = _hasLoops; - hasOutPoint = _hasOutPoint; - hasInPoint = _hasInPoint; - inPoint = _inPoint; - outPoint = _outPoint; - loopCount = _loopCount; - nPoints = _nPoints; - soundEnvelope = _soundEnvelope; -} - -FSoundInfo::~FSoundInfo() -{ - - delete soundEnvelope; -} - -void FSoundInfo::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->WriteBits((U32)syncFlags, 4); - _SWFStream->WriteBits((U32)hasEnvelope, 1); - _SWFStream->WriteBits((U32)hasLoops, 1); - _SWFStream->WriteBits((U32)hasOutPoint, 1); - _SWFStream->WriteBits((U32)hasInPoint, 1); - if (hasInPoint) - _SWFStream->WriteDWord(inPoint); - if (hasOutPoint) - _SWFStream->WriteDWord(outPoint); - if (hasLoops) - _SWFStream->WriteWord(loopCount); - if (hasEnvelope) { - _SWFStream->WriteByte(nPoints); - soundEnvelope->WriteToSWFStream(_SWFStream); - } -} diff --git a/toonz/sources/common/flash/FDTSounds.h b/toonz/sources/common/flash/FDTSounds.h deleted file mode 100644 index 655f334..0000000 --- a/toonz/sources/common/flash/FDTSounds.h +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTSounds.h - - This header-file contains the declarations of all low-level sound-related classes. - Their parent classes are in the parentheses: - - class FDTDefineSound; (public FDT) - class FDTDefineSoundADPCM; (public FDTDefineSound) - class FDTDefineSoundWAV; (public FDTDefineSound) - class FDTSoundStreamBlock; (public FDT) - class FDTSoundStreamHead; (public FDT) - class FDTSoundStreamHead2; (public FDT) - class FSndEnv; - class FSoundInfo; - -****************************************************************************************/ - -#ifndef _F_DEFINE_SOUNDS_H_ -#define _F_DEFINE_SOUNDS_H_ - -#include "Macromedia.h" -#include "FDT.h" - -#include - -// A flash object that defines a sound - -class FDTDefineSound : public FDT -{ -public: - // Compression Type - enum { - NO_COMPRESSION, - PCM - }; - - // Compression Level - enum { - Comp2 = 2, - Comp3, - Comp4, - Comp5 - }; - - // Sound Rate - enum { - Snd5k, - Snd11k, - Snd22k, - Snd44k - }; - - // Sound Size - enum { - Snd8Bit, - Snd16Bit - }; - - // Sound Type - enum { - Snd16Mono, - Snd16Stereo - }; - - FDTDefineSound(); - virtual ~FDTDefineSound() {} - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - - U16 ID() { return soundID; } - int NumSamples() { return (U8)soundData.sampleCount; } - int Format() { return 4 * (soundData.rate) + (soundData.size) * 2 + (soundData.type); } - int SoundType() { return soundData.type; } - -protected: - U16 soundID; - SSound soundData; - std::vector pcmData; -}; - -// A flash object that defines a sound - -class FDTDefineSoundADPCM : public FDTDefineSound -{ -public: - FDTDefineSoundADPCM(U8 rate, U8 size, U8 type, U32 sampleCount, - const U8 *data, U32 dataSize, int compression); -}; - -// A flash object that defines a sound -class FDTDefineSoundWAV : public FDTDefineSound -{ - -public: - FDTDefineSoundWAV(FILE *wavFile, int compression); - -private: - bool loadWavFile(FILE *fp, - SSound *soundData, - U8 **wavData, - int *wavDataSize); - U32 read32(FILE *fp) - { - U32 val; - fread(&val, 1, 4, fp); - return val; - } - U16 read16(FILE *fp) - { - U16 val; - fread(&val, 1, 2, fp); - return val; - } -}; - -// A Flash object that defines sound data that is interleaved with frame data -//enables sound streaming - -class FDTSoundStreamBlock : public FDT -{ - -public: - FDTSoundStreamBlock(U32 _size, U8 *_data); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 size; - U8 *data; -}; - -// A flash object that defines the start of sound data that will be interleaved within flash frames -// This is how sound streaming of networks is possible. -// Doesn't support compressed sound (flash 2.0) - -class FDTSoundStreamHead : public FDT -{ - -public: - FDTSoundStreamHead(U8 _mixFormat, // mixer format (?) set to 6 - U8 _soundType, // 0 mono, 1 stereo - U16 _count // number of sound samples - ); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 mixFormat; - U8 soundType; - U16 count; -}; - -class FDTSoundStreamHead2 : public FDT -{ - -public: - FDTSoundStreamHead2(U8 _mixFormat, U8 _compression, U8 _size, U8 _soundType, U16 _count); - FDTSoundStreamHead2(U8 _mixFormat, U8 _compression, U8 _rate, U8 _size, U8 _soundType, U16 _count); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U8 mixFormat; - U8 compression; - U8 rate; - U8 size; - U8 soundType; - U16 count; -}; - -class FSndEnv -{ - -public: - FSndEnv(U32 mark44, U16 level0, U16 level1); - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 mark44; - U16 level0; - U16 level1; -}; - -// specifies how a sound character is player - -class FSoundInfo -{ - -public: - FSoundInfo(U8 _syncFlags, U8 _hasEnvelope, U8 _hasLoops, U8 _hasOutPoint, - U8 _hasInPoint, U32 _inPoint, U32 _outPoint, U16 _loopCount, - U8 _nPoints, FSndEnv *_soundEnvelope); - ~FSoundInfo(); - void WriteToSWFStream(FSWFStream *_SWFStream); - - enum { - SyncNoMultiple = 0x01, - SyncStor = 0x02 - }; - -private: - U8 syncFlags; - U8 hasEnvelope; - U8 hasLoops; - U8 hasOutPoint; - U8 hasInPoint; - U32 inPoint; - U32 outPoint; - U16 loopCount; - U8 nPoints; - FSndEnv *soundEnvelope; -}; - -#endif diff --git a/toonz/sources/common/flash/FDTSprite.cpp b/toonz/sources/common/flash/FDTSprite.cpp deleted file mode 100644 index 88db2b8..0000000 --- a/toonz/sources/common/flash/FDTSprite.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTSprite.cpp - - This source file contains the definition for all low-level sprite-related functions, - grouped by classes: - - Class Member Function - - FDTSprite FDTSprite(); - ~FDTSprite(); - void AddFObj(FObj* ); - void WriteToSWFStream(FSWFStream* ); - - -****************************************************************************************/ -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif -#include "FSWFStream.h" -#include "FDTSprite.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTSprite ------------------------------------------------------------- - -FDTSprite::FDTSprite() -{ - characterID = FObjCollection::Increment(); - numOfFrames = 0; -} - -FDTSprite::~FDTSprite() -{ - while (!objectList.empty()) { - - delete objectList.front(); - objectList.pop_front(); - } -} - -void FDTSprite::AddFObj(FObj *_object) -{ - if (_object->IsShowFrame()) - numOfFrames++; - - objectList.push_back(_object); -} - -void FDTSprite::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream body; - - body.WriteWord((U32)characterID); - - body.WriteWord(numOfFrames); - - std::list::iterator cursor; - for (cursor = objectList.begin(); cursor != objectList.end(); cursor++) { - - (*cursor)->WriteToSWFStream(&body); - } - - // Put an end tag on the end of the temporary buffer: - body.AppendTag(stagEnd, 0, 0); - - // put the buffer into the main stream - _SWFStream->AppendTag(stagDefineSprite, body.Size(), &body); -} diff --git a/toonz/sources/common/flash/FDTSprite.h b/toonz/sources/common/flash/FDTSprite.h deleted file mode 100644 index 6b7b5b4..0000000 --- a/toonz/sources/common/flash/FDTSprite.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTSprite.h - - This header-file contains the declarations of low-level sprite-related class. - Its parent class is in the parentheses: - - class FDTSprite; (public FDT) - -****************************************************************************************/ - -#ifndef _SPRITE_H_ -#define _SPRITE_H_ - -#include -#include "Macromedia.h" -#include "FDT.h" - -//! Defines a low-level sprite object. -/*! A sprite is a flash object that acts as a "movie within a movie". - \sa FDT -*/ -class FDTSprite : public FDT -{ -public: - //! Construct a low-level sprite object. - /*! */ - FDTSprite(); - - //! Destruct a low-level sprite object. - /*! */ - virtual ~FDTSprite(); - - // Method for internal use. - void AddFObj(FObj *_object); - - // Method for internal use. - U16 ID() { return characterID; } - - // Method for internal use. - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U16 characterID; - std::list objectList; - U32 numOfFrames; -}; - -#endif diff --git a/toonz/sources/common/flash/FDTText.cpp b/toonz/sources/common/flash/FDTText.cpp deleted file mode 100644 index c404b46..0000000 --- a/toonz/sources/common/flash/FDTText.cpp +++ /dev/null @@ -1,448 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTText.cpp - - This source file contains the definition for all low-level text-related functions, - grouped by classes: - - Class Member Function - - FDTDefineEditText FDTDefineEditText(FRect*, U8, U8, U8, U8, U8, U8, U8, U8, - U8, U8, U8, U8, U16, U16, FColor*, U16, U8, U16, U16, - U16, U16, FString*, FString*); - ~FDTDefineEditText(); - void WriteToSWFStream(FSWFStream*); - - FDTDefineText FDTDefineText(FRect*, FMatrix*, int); - ~FDTDefineText(); - void AddTextRecord(FTextRecord*); - U16 ID(); - void WriteToSWFStream( FSWFStream*); - - FDTDefineText2 FDTDefineText2(FRect*, FMatrix*, int); - ~FDTDefineText2(); - void AddTextRecord(FTextRecord*); - U16 ID(); - void WriteToSWFStream(FSWFStream*); - - FTextChangeRecord FTextChangeRecord(U16, U16, U16, U16, U16, U16, FColor*, - S16, S16); - ~FTextChangeRecord() - -// FTextChangeRecord void IncludeNBitInfo(U16, U16); - void WriteToSWFStream(FSWFStream* , int, int); - - FTextGlyphRecord FTextGlyphRecord(); - ~FTextGlyphRecord(); - void AddGlyphEntry(U16, U16); - U32 MinAdvanceBits(); - U32 MinCodeBits(); - void WriteToSWFStream(FSWFStream*, int, int); - - -****************************************************************************************/ - -#include "FDTText.h" -#include "FDTFonts.h" - -// Constructor. - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineEditText ----------------------------------------------------- - -FDTDefineEditText::FDTDefineEditText(FRect *_bounds, U8 _hasFont, U8 _hasMaxLength, U8 _hasTextColor, - U8 _readOnly, U8 _password, U8 _multiline, U8 _wordWrap, U8 _hasText, - U8 _useOutlines, U8 _border, U8 _noSelect, U8 _hasLayout, U16 _fontID, - U16 _fontHeight, FColor *_textColor, U16 _maxLength, U8 _alignment, - U16 _leftMargin, U16 _rightMargin, U16 _indent, U16 _leading, - FString *_variableName, FString *_initialText) : textColor(_textColor) -{ - - bounds = _bounds; - hasFont = _hasFont; - hasMaxLength = _hasMaxLength; - hasTextColor = _hasTextColor; - readOnly = _readOnly; - password = _password; - multiline = _multiline; - wordWrap = _wordWrap; - hasText = _hasText; - useOutlines = _useOutlines; - border = _border; - noSelect = _noSelect; - hasLayout = _hasLayout; - fontID = _fontID; - fontHeight = _fontHeight; - textColor = _textColor; - maxLength = _maxLength; - alignment = _alignment; - leftMargin = _leftMargin; - rightMargin = _rightMargin; - indent = _indent; - leading = _leading; - variableName = _variableName; - initialText = _initialText; - - characterID = FObjCollection::Increment(); -} - -// deletes the FRECT and 2 FString's if they exist. - -FDTDefineEditText::~FDTDefineEditText(void) -{ - - delete bounds; - delete variableName; - delete initialText; - delete textColor; -} - -// Writes to the given FSWFStream. - -void FDTDefineEditText::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - FSWFStream tempBuffer; - - tempBuffer.WriteWord((U32)characterID); - //character ID - - //write the bounds, it's an object that knows how to write itself - bounds->WriteToSWFStream(&tempBuffer); - - //write all flags - - tempBuffer.WriteBits(hasText, 1); - tempBuffer.WriteBits(wordWrap, 1); - tempBuffer.WriteBits(multiline, 1); - tempBuffer.WriteBits(password, 1); - tempBuffer.WriteBits(readOnly, 1); - tempBuffer.WriteBits(hasTextColor, 1); - tempBuffer.WriteBits(hasMaxLength, 1); - tempBuffer.WriteBits(hasFont, 1); - - tempBuffer.WriteBits(0, 2); //unknown flags - tempBuffer.WriteBits(hasLayout, 1); - tempBuffer.WriteBits(noSelect, 1); - tempBuffer.WriteBits(border, 1); - tempBuffer.WriteBits(0, 2); //unknown flags - tempBuffer.WriteBits(useOutlines, 1); - - //tempBuffer.WriteBits(hasFont, 1); - //tempBuffer.WriteBits(hasMaxLength, 1); - //tempBuffer.WriteBits(hasTextColor, 1); - //tempBuffer.WriteBits(readOnly, 1); - //tempBuffer.WriteBits(password, 1); - //tempBuffer.WriteBits(multiline, 1); - //tempBuffer.WriteBits(wordWrap, 1); - //tempBuffer.WriteBits(hasText, 1); - //tempBuffer.WriteBits(useOutlines, 1); - //tempBuffer.WriteBits(border, 1); - //tempBuffer.WriteBits(noSelect, 1); - //tempBuffer.WriteBits(hasLayout, 1); - //tempBuffer.WriteBits(0, 4); //check on this, 3 in docs but 4 gives 16 bits - - if (hasFont) { - tempBuffer.WriteWord((U32)fontID); - tempBuffer.WriteWord((U32)fontHeight); - } - - if (hasTextColor) { // here changed. - textColor->AlphaChannel(true); - textColor->WriteToSWFStream(&tempBuffer); - } - - if (hasMaxLength) { - tempBuffer.WriteWord((U32)maxLength); - } - - if (hasLayout) { - tempBuffer.WriteByte(alignment); - tempBuffer.WriteWord(leftMargin); - tempBuffer.WriteWord(rightMargin); - tempBuffer.WriteWord(indent); - tempBuffer.WriteWord(leading); - } - - variableName->WriteToSWFStream(&tempBuffer, true); - - if (hasText) { - initialText->WriteToSWFStream(&tempBuffer, true); - } - - _SWFStream->AppendTag(stagDefineEditText, tempBuffer.Size(), &tempBuffer); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineText --------------------------------------------------------- - -FDTDefineText::FDTDefineText(FRect *_textBounds, FMatrix *_textMatrix, int glyhpsInFont) -{ - - characterID = FObjCollection::Increment(); - textBounds = _textBounds; - textMatrix = _textMatrix; - nIndexBits = (U8)FSWFStream::MinBits(glyhpsInFont, 0); -} - -FDTDefineText::~FDTDefineText() -{ - - delete textBounds; - - delete textMatrix; - - while (!textRecords.empty()) { - - delete textRecords.front(); - - textRecords.pop_front(); - } -} - -void FDTDefineText::AddTextRecord(FTextRecord *_textRec) -{ - - textRecords.push_back(_textRec); -} - -U16 FDTDefineText::ID(void) -{ - - return (U16)characterID; -} - -void FDTDefineText::WriteToSWFStream(FSWFStream *_SWFStream) -{ - U16 nAdvanceBits = 0; - U16 nCodeBits = 0; - FSWFStream body; - - body.WriteWord((U32)characterID); - - textBounds->WriteToSWFStream(&body); - textMatrix->WriteToSWFStream(&body); - - // Get the bits needed to write the advance and character codes - std::list::iterator cursor1; - for (cursor1 = textRecords.begin(); cursor1 != textRecords.end(); cursor1++) { - nAdvanceBits = (U16)std::max((*cursor1)->MinAdvanceBits(), (U32)nAdvanceBits); - nCodeBits = (U16)std::max((*cursor1)->MinCodeBits(), (U32)nCodeBits); - } - body.WriteByte((U32)nCodeBits); - body.WriteByte((U32)nAdvanceBits); - - std::list::iterator cursor; - for (cursor = textRecords.begin(); cursor != textRecords.end(); cursor++) { - (*cursor)->WriteToSWFStream(&body, nCodeBits, nAdvanceBits); - } - - body.FlushBits(); - body.WriteByte((U32)0); - - _SWFStream->AppendTag(stagDefineText, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FDTDefineText2 -------------------------------------------------------- - -FDTDefineText2::FDTDefineText2(FRect *_textBounds, FMatrix *_textMatrix, int glyhpsInFont) -{ - characterID = FObjCollection::Increment(); - textBounds = _textBounds; - textMatrix = _textMatrix; - nIndexBits = (int)FSWFStream::MinBits(glyhpsInFont, 0); -} - -FDTDefineText2::~FDTDefineText2() -{ - - delete textBounds; - - delete textMatrix; - - while (!textRecords.empty()) { - - delete textRecords.front(); - - textRecords.pop_front(); - } -} - -void FDTDefineText2::AddTextRecord(FTextRecord *_textRec) -{ - - textRecords.push_back(_textRec); -} - -U16 FDTDefineText2::ID(void) -{ - - return (U16)characterID; -} - -void FDTDefineText2::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - U16 nAdvanceBits = 0; - U16 nCodeBits = 0; - FSWFStream body; - - body.WriteWord((U32)characterID); - - textBounds->WriteToSWFStream(&body); - - textMatrix->WriteToSWFStream(&body); - - // Get the bits needed to write the advance and character codes - std::list::iterator cursor1; - for (cursor1 = textRecords.begin(); cursor1 != textRecords.end(); cursor1++) { - nAdvanceBits = (U16)std::max((*cursor1)->MinAdvanceBits(), (U32)nAdvanceBits); - nCodeBits = (U16)std::max((*cursor1)->MinCodeBits(), (U32)nCodeBits); - } - - body.WriteByte((U32)nCodeBits); - body.WriteByte((U32)nAdvanceBits); - - std::list::iterator cursor; - for (cursor = textRecords.begin(); cursor != textRecords.end(); cursor++) { - (*cursor)->WriteToSWFStream(&body, nCodeBits, nAdvanceBits); - } - - body.FlushBits(); - - body.WriteByte((U32)0); - - _SWFStream->AppendTag(stagDefineText2, body.Size(), &body); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FTextChangeRecord ----------------------------------------------------- - -FTextChangeRecord::FTextChangeRecord(U16 _hasFontFlag, U16 _hasColorFlag, - U16 _hasXOffsetFlag, U16 _hasYOffsetFlag, - U16 _fontID, U16 _fontHeight, FColor *_fontColor, - S16 _xOffset, S16 _yOffset) -{ - hasFontFlag = _hasFontFlag; - hasColorFlag = _hasColorFlag; - hasXOffsetFlag = _hasXOffsetFlag; - hasYOffsetFlag = _hasYOffsetFlag; - fontID = _fontID; - fontColor = _fontColor; - xOffset = _xOffset; - yOffset = _yOffset; - fontHeight = _fontHeight; -} - -FTextChangeRecord::~FTextChangeRecord() -{ - delete fontColor; -} - -// void FTextChangeRecord::IncludeNBitInfo(U16 _nIndexBits, U16 _nAdvanceBits){ -// Does absolutely nothing -// TextGlyphRecord needs this method -// Had to be virtual so it could be called on any TextRecord -// } - -void FTextChangeRecord::WriteToSWFStream(FSWFStream *_SWFStream, int /*codeBits*/, int /*advanceBits */) -{ - - _SWFStream->WriteBits((U32)1, 1); - - // _SWFStream->WriteBits((U32) reserved, 3); - _SWFStream->WriteBits((U32)0, 3); - - _SWFStream->WriteBits((U32)hasFontFlag, 1); - _SWFStream->WriteBits((U32)hasColorFlag, 1); - _SWFStream->WriteBits((U32)hasYOffsetFlag, 1); - _SWFStream->WriteBits((U32)hasXOffsetFlag, 1); - - if (hasFontFlag) - _SWFStream->WriteWord((U32)fontID); - - if (hasColorFlag) { // here changed. - fontColor->AlphaChannel(true); - fontColor->WriteToSWFStream(_SWFStream); - } - - if (hasXOffsetFlag) - _SWFStream->WriteWord((U32)xOffset); - - if (hasYOffsetFlag) - _SWFStream->WriteWord((U32)yOffset); - - if (hasFontFlag) - _SWFStream->WriteWord((U32)fontHeight); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FTextGlyphRecord ------------------------------------------------------ - -FTextGlyphRecord::FTextGlyphRecord() -{ -} - -FTextGlyphRecord::~FTextGlyphRecord() -{ - while (!glyphEntries.empty()) { - glyphEntries.pop_front(); - } -} - -void FTextGlyphRecord::AddGlyphEntry(U16 code, U16 advance) -{ - GlyphEntry glyph = {code, advance}; - - glyphEntries.push_back(glyph); -} - -U32 FTextGlyphRecord::MinAdvanceBits() -{ - std::list::iterator it; - - int maxBit = 0; - for (it = glyphEntries.begin(); it != glyphEntries.end(); ++it) { - maxBit = (int)std::max(FSWFStream::MinBits(it->advance, 1), (U32)maxBit); - } - return maxBit; -} - -U32 FTextGlyphRecord::MinCodeBits() -{ - // return FSWFStream::MinBits( glyphEntries.size(), 0 ); - std::list::iterator it; - - int maxBit = 0; - for (it = glyphEntries.begin(); it != glyphEntries.end(); ++it) { - int code = it->code; - maxBit = (int)std::max(FSWFStream::MinBits(code, 1), (U32)maxBit); - } - return maxBit; -} - -void FTextGlyphRecord::WriteToSWFStream(FSWFStream *_SWFStream, int codeBits, int advanceBits) -{ - FLASHASSERT((int)MinAdvanceBits() <= advanceBits); - FLASHASSERT((int)MinCodeBits() <= codeBits); - - // Bug: The number of glyphs used to limit the the max code size, but this changes with - // DefineFont2, where we could use glyph 38 as our sole glyph. So the re-write begins.... - int numberOfGlyphs = glyphEntries.size(); - - _SWFStream->WriteBits((U32)0, 1); - _SWFStream->WriteBits((U32)numberOfGlyphs, 7); - - std::list::iterator cursor; - - for (cursor = glyphEntries.begin(); cursor != glyphEntries.end(); cursor++) { - _SWFStream->WriteBits((U32)cursor->code, codeBits); - _SWFStream->WriteBits((U32)cursor->advance, advanceBits); - } -} diff --git a/toonz/sources/common/flash/FDTText.h b/toonz/sources/common/flash/FDTText.h deleted file mode 100644 index b9a7263..0000000 --- a/toonz/sources/common/flash/FDTText.h +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FDTText.h - - This header-file contains the declarations of low-level text-related classes. - All parent classes are in the parentheses: - - class FTextRecord; - class FDTDefineEditText; (public FDT) - class FDTDefineText; (public FDT) - class FDTDefineText2; (public FDT) - class FTextChangeRecord; (public FTextRecord) - class FTextGlyphRecord; (public FTextRecord) - -****************************************************************************************/ - -#ifndef _F_DEFINE_TEXT_H_ -#define _F_DEFINE_TEXT_H_ - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "tcommon.h" -#include "Macromedia.h" -#include "FDT.h" -#include "FSWFStream.h" -#include "FPrimitive.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -class FGlyphEntry; - -class DVAPI FTextRecord -{ -public: - virtual U32 MinAdvanceBits() = 0; // the computed minimum # of bits to record the advance values - virtual U32 MinCodeBits() = 0; // the computed minimum # of bits to record the character code values - virtual ~FTextRecord() {} - - // Because of multiple text records, the DefineText will specify the code and advance bits - // when it writes. - virtual void WriteToSWFStream(FSWFStream *_SWFStream, int codeBits, int advanceBits) = 0; -}; - -// A flash object that defines a font's appearance - -class DVAPI FDTDefineEditText : public FDT -{ - -public: - FDTDefineEditText(FRect *_bounds, U8 _hasFont, U8 _hasMaxLength, U8 _hasTextColor, - U8 _readOnly, U8 _password, U8 _multiline, U8 _wordWrap, U8 _hasText, - U8 _useOutlines, U8 _border, U8 _noSelect, U8 _hasLayout, U16 _fontID, - U16 _fontHeight, FColor *_textColor, U16 _maxLength, U8 _alignment, - U16 _leftMargin, U16 _rightMargin, U16 _indent, U16 _leading, - FString *_variableName, FString *_initialText); - virtual ~FDTDefineEditText(void); - U16 ID(void) { return characterID; } - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - FRect *bounds; - U8 hasFont; - U8 hasMaxLength; - U8 hasTextColor; - U8 readOnly; - U8 password; - U8 multiline; - U8 wordWrap; - U8 hasText; - U8 useOutlines; - U8 border; - U8 noSelect; - U8 hasLayout; - U16 fontID; - U16 fontHeight; - FColor *textColor; - U16 maxLength; - U8 alignment; - U16 leftMargin; - U16 rightMargin; - U16 indent; - U16 leading; - FString *variableName; - FString *initialText; - U16 characterID; -}; - -// A flash object that defines the font and formating of text characters in the record (flash 1.0) -// takes only RGB color values - -class DVAPI FDTDefineText : public FDT -{ - -public: - FDTDefineText(FRect *_textBounds, - FMatrix *_textMatrix, - int glyhpsInFont); // glyhpsInFont: how many characters are in the font? - virtual ~FDTDefineText(); - void AddTextRecord(FTextRecord *_textRec); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 characterID; - FRect *textBounds; - FMatrix *textMatrix; - std::list textRecords; - U16 nIndexBits; -}; - -// A flash object that defines the font and formating of text characters in the record (flash 1.0) -// takes RGBA color values - -class DVAPI FDTDefineText2 : public FDT -{ - -public: - FDTDefineText2(FRect *_textBounds, FMatrix *_textMatrix, - int glyhpsInFont); - virtual ~FDTDefineText2(); - void AddTextRecord(FTextRecord *_textRec); - U16 ID(void); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 characterID; - FRect *textBounds; - FMatrix *textMatrix; - std::list textRecords; - U16 nIndexBits; -}; - -// specifies text format changes in a flash DefineText object - -class DVAPI FTextChangeRecord : public FTextRecord -{ - -public: - FTextChangeRecord(U16 _hasFontFlag, U16 _hasColorFlag, - U16 _hasXOffsetFlag, U16 _hasYOffsetFlag, - U16 _fontID, U16 _fontHeight, FColor *_fontColor, - S16 _xOffset, S16 _yOffset); - virtual ~FTextChangeRecord(); - - virtual U32 MinAdvanceBits() { return 0; } - virtual U32 MinCodeBits() { return 0; } - - virtual void WriteToSWFStream(FSWFStream *_SWFStream, int advanceBits, int codeBits); - -private: - U16 reserved; - U16 hasFontFlag; - U16 hasColorFlag; - U16 hasYOffsetFlag; - U16 hasXOffsetFlag; - U16 fontID; - FColor *fontColor; - S16 xOffset; - S16 yOffset; - U16 fontHeight; -}; - -class DVAPI FTextGlyphRecord : public FTextRecord -{ - -public: - FTextGlyphRecord(); - virtual ~FTextGlyphRecord(); - - void AddGlyphEntry(U16 code, U16 advance); - virtual void WriteToSWFStream(FSWFStream *_SWFStream, int advanceBits, int codeBits); - - virtual U32 MinAdvanceBits(); // number of bits needed to write the advance data - virtual U32 MinCodeBits(); // number of bits needed to write the character code data - -private: - struct GlyphEntry { - U16 code; - U16 advance; - }; - std::list glyphEntries; -}; - -#endif diff --git a/toonz/sources/common/flash/FFixed.h b/toonz/sources/common/flash/FFixed.h deleted file mode 100644 index b95489b..0000000 --- a/toonz/sources/common/flash/FFixed.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef FIXED_INCLUDED -#define FIXED_INCLUDED - -#define fixed_1 0x00010000L - -// fixed 2.0 -#define fixed2 0x00020000L -// fixed 0.5 -#define fixedHalf 0x00008000L -#define infinity 0x7FFFFFFFL -#define negInfinity 0x80000000L -#define fixedStdErr 0x0000003FL -// fixed sqrt(2) -#define fixedSqrt2 0x00016A0AL - -#define FixedRound(a) ((S16)((SFIXED)(a) + 0x8000L >> 16)) -#define FixedTrunc(a) ((S16)((SFIXED)(a) >> 16)) - -#define FixedCeiling(a) ((S16)(((SFIXED)(a) + 0x8000L) >> 16)) -#define FixedFloor(a) ((S16)((SFIXED)(a) >> 16)) - -#define FixedToInt(a) ((S16)((SFIXED)(a) + 0x8000L >> 16)) -#define IntToFixed(a) ((SFIXED)(a) << 16) -// Fixed integer constant -#define FC(a) IntToFixed(a) - -#define FixedToFloat(a) ((float)(a) / fixed_1) -#define FloatToFixed(a) ((SFIXED)((float)(a)*fixed_1)) - -#define FixedToDouble(a) ((double)(a) / fixed_1) -#define DoubleToFixed(a) ((SFIXED)((double)(a)*fixed_1)) - -#define FixedAverage(a, b) (((a) + (b)) >> 1) - -#define FixedAbs(x) ((x) < 0 ? -(x) : (x)) -#define FixedMin(a, b) ((a) < (b) ? (a) : (b)) -#define FixedMax(a, b) ((a) > (b) ? (a) : (b)) -#define FixedEqual(a, b, err) (FixedAbs((a) - (b)) <= err) - -SFIXED FixedNearestMultiple(SFIXED x, SFIXED factor); - -// Note that all angles are handled in Fixed point degrees to simplify rounding issues -// they are kept in the range of 0 to 360 degrees - -// Generic Floating point routines for quick porting not fast enough for shipping code -SFIXED FixedMul(SFIXED, SFIXED); -SFIXED FixedDiv(SFIXED, SFIXED); -SFIXED FixedSin(SFIXED); -SFIXED FixedCos(SFIXED); -SFIXED FixedTan(SFIXED); -SFIXED FixedAtan2(SFIXED dy, SFIXED dx); - -int _FPMul(int a, int b, int shift); -int _FPDiv(int a, int b, int rshift); - -#endif diff --git a/toonz/sources/common/flash/FObj.cpp b/toonz/sources/common/flash/FObj.cpp deleted file mode 100644 index a099a5e..0000000 --- a/toonz/sources/common/flash/FObj.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FObj.cpp - - This source file contains the definition for all low-level FObj-related functions, - grouped by classes: - - Class Member Function - - FObj U32 IsShowFrame(); - - FObjCollection FObjCollection(); - ~FObjCollection(); - void AddFObj(FObj*); - void WriteToSWFStream(FSWFStream*); - void CreateMovie(char*, SCOORD, SCOORD, U32); - void WriteFileHeader(U32, SCOORD, SCOORD, U32, FILE*); - void WriteEndTag(FSWFStream*); - U16 Increment(); - - FFragment FFragment(void*, int); - void WriteToSWFStream(FSWFStream*); - -****************************************************************************************/ - -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - -#include "FPrimitive.h" -#include "FObj.h" -#include "FSWFStream.h" - -//#include "tfilepath_io.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FObj ------------------------------------------------------------------ - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FObjCollection -------------------------------------------------------- - -// When constructor is called, the empty FObjList is automatically created. -FObjCollection::FObjCollection(void) -{ - - numOfFrames = 0; -} - -// Removes and deletes every element in the list. - -FObjCollection::~FObjCollection(void) -{ - - while (!FObjList.empty()) { - - delete FObjList.front(); - FObjList.pop_front(); - } -} - -// The given FObj is added to the end of FObjList - -void FObjCollection::AddFObj(FObj *fobj) -{ - - if (fobj->IsShowFrame()) //increment numFrames then store the tag - numOfFrames++; - - FObjList.push_back(fobj); -} - -void FObjCollection::EraseFObj(int tagindex) -{ - - std::list::iterator it = FObjList.begin(); - std::advance(it, tagindex); - FObjList.erase(it); -} - -void FObjCollection::InsertFObj(int beforeTag, FObj *fobj) -{ - - if (fobj->IsShowFrame()) //increment numFrames then store the tag - numOfFrames++; - - std::list::iterator it = FObjList.begin(); - std::advance(it, beforeTag); - FObjList.insert(it, fobj); -} - -int FObjCollection::GetFObjCount() const -{ - return FObjList.size(); -} - -FObj *FObjCollection::GetFObj(int i) const -{ - if (i >= (int)FObjList.size()) - return 0; - std::list::const_iterator it = FObjList.begin(); - std::advance(it, i); - - return *it; -} - -// Uses a cursor to loop through the entire list and write all of the -// list's FObjs to the given SWFStream - -void FObjCollection::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - std::list::iterator cursor; - - for (cursor = FObjList.begin(); cursor != FObjList.end(); cursor++) { - - (*cursor)->WriteToSWFStream(_SWFStream); - } -} - -void FObjCollection::CreateMovie(FILE *fp, FRect cameraBox, U32 _frameRate, U8 _version) -{ - //FILE* fp = fopen( fileName, "wb" ); - if (fp) { - FSWFStream stream; - - CreateMovie(&stream, cameraBox, _frameRate, _version); - stream.WriteToFile(fp); - } -} - -void FObjCollection::CreateCompressedMovie(FILE *fp, FRect cameraBox, U32 _frameRate) -{ - //FILE* fp = fopen( fileName, "wb" ); - if (fp) { - FSWFStream stream; - - CreateMovie(&stream, cameraBox, _frameRate); - stream.WriteToFileVersion6(fp); - } -} - -// creates a Flash Movie -void FObjCollection::CreateMovie(FSWFStream *swfStream, FRect cameraBox, U32 _frameRate, U8 _version) -{ - // Carve out space for the header -- always 21 bytes - for (int i = 0; i < HEADER_SIZE; i++) - swfStream->WriteByte(0); - - // This FObjCollection is dumped into swfFileBody - WriteToSWFStream(swfStream); - - //swfFileBody Terminated with a FCTEnd tag - WriteEndTag(swfStream); - - // write file header into file - WriteFileHeader(swfStream->Memory(), swfStream->Size(), cameraBox, _frameRate, _version); - - characterID = 0; -} - -// creates a Flash Movie -void FObjCollection::CreateSprite(FSWFStream *swfStream, FRect cameraBox, U32 /*_frameRate*/) -{ - // Sprites do not have headers. - - // This FObjCollection is dumped into swfFileBody - WriteToSWFStream(swfStream); - - //swfFileBody Terminated with a FCTEnd tag - WriteEndTag(swfStream); - - characterID = 0; -} - -// This works differently than the other calls, because it hacks the header information back -// into the beginning of an existing SWF stream. -void FObjCollection::WriteFileHeader(U8 *target, - U32 _fileLengthNoHeader, - FRect cameraBox, - U32 _frameRate, - U8 _version) -{ - FSWFStream header; - - header.WriteByte('F'); - header.WriteByte('W'); - header.WriteByte('S'); - header.WriteByte(_version); - - header.WriteDWord(_fileLengthNoHeader); - - // Write the movie dimensions "by hand" so they will have the correct bit size to fill the 21 bytes header - int nBits = 16; - header.WriteBits(nBits, 5); - - header.WriteBits((U32)cameraBox.Xmin(), nBits); - header.WriteBits((U32)cameraBox.Xmax(), nBits); - header.WriteBits((U32)cameraBox.Ymin(), nBits); - header.WriteBits((U32)cameraBox.Ymax(), nBits); - - header.FlushBits(); - - // The frame rate is 8.8 - we currently support 8.0 - header.WriteByte(0); - header.WriteByte(_frameRate); - - header.WriteWord(numOfFrames); - - // Copy this buffer to the target - memcpy(target, header.Memory(), HEADER_SIZE); -} - -void FObjCollection::WriteEndTag(FSWFStream *_SWFStream) -{ - - _SWFStream->AppendTag(stagEnd, 0, 0); -} - -// stores the number of flash objects created -U16 FObjCollection::characterID = 0; - -// increments the number of flash objects created -U16 FObjCollection::Increment(void) -{ - assert(characterID != 0xffff); - return ++characterID; -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FFragment ------------------------------------------------------------- - -FFragment::FFragment(const void *_data, int _size) -{ - data = _data; - size = _size; -} - -void FFragment::WriteToSWFStream(FSWFStream *_SWFStream) -{ - _SWFStream->WriteLargeData((U8 *)data, size); -} diff --git a/toonz/sources/common/flash/FObj.h b/toonz/sources/common/flash/FObj.h deleted file mode 100644 index 0baa804..0000000 --- a/toonz/sources/common/flash/FObj.h +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. -// Last Modified On 18/06/2002 by DV for Fixes. -/**************************************************************************************** - - File Summary: FObj.h - - This header-file contains the declarations of low-level FObj-related classes. - All parent classes are in the parentheses: - - class FObj; - class FFragment; (public FObj) - class FObjCollection; - -****************************************************************************************/ - -#ifndef _FOBJ_H_ -#define _FOBJ_H_ - -#include "tcommon.h" -#include -#include - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "Macromedia.h" -#include "FPrimitive.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -//All Flash tagged data block objects fall into this category - -class DVAPI FObj -{ -public: - virtual ~FObj() {} // Doesn't do anything, just makes all the other destructors virtual - - virtual void WriteToSWFStream(FSWFStream *_SWFStream) = 0; - virtual U32 IsShowFrame() { return false; } - virtual U32 IsPlaceObject() { return false; } - virtual bool IsDefineShape() { return false; } - virtual bool IsSprite() { return false; } - - virtual void SetId(U16 id) { FLASHASSERT(0); } - virtual void SetMatrix(FMatrix *matrix) { FLASHASSERT(0); } -}; - -/*! A class for writing an arbitrary block of data (a SWF fragment, perhaps) to - * the SWFStream. The data is assumed to be large, so it is not changed. - */ -class FFragment : public FObj -{ -public: - FFragment(const void *data, int size); - virtual void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - const void *data; - int size; -}; - -// Holds a collection of FObj's so that they can be dumped in a SWF format -//Writes tags in the same order as they appear in the collection - -//using namespace std; - -class DVAPI FObjCollection -{ - -public: - FObjCollection(void); - ~FObjCollection(void); - void AddFObj(FObj *fobj); - void InsertFObj(int beforeTag, FObj *fobj); - void EraseFObj(int tagindex); - - void WriteToSWFStream(FSWFStream *_SWFStream); - //void CreateCompressedMovie( const TFilePath &_fileName, FRect cameraBox, U32 _frameRate = 12 ); - //void CreateMovie( const TFilePath &_fileName, FRect cameraBox, U32 _frameRate = 12, U8 _version = 6); - void CreateCompressedMovie(FILE *fp, FRect cameraBox, U32 _frameRate = 12); - void CreateMovie(FILE *fp, FRect cameraBox, U32 _frameRate = 12, U8 _version = 6); - void CreateMovie(FSWFStream *stream, FRect cameraBox, U32 _frameRate = 12, U8 _version = 6); - void CreateSprite(FSWFStream *stream, FRect cameraBox, U32 _frameRate = 12); - static U16 Increment(void); - int GetFObjCount() const; - FObj *GetFObj(int i) const; - -private: - enum { - HEADER_SIZE = 21 - }; - - U32 numOfFrames; - std::list FObjList; - void WriteFileHeader(U8 *target, U32 _fileLengthNoHeader, FRect cameraBox, - U32 _frameRate, U8 _version); - void WriteEndTag(FSWFStream *_SWFStream); - static U16 characterID; -}; - -#ifdef WIN32 // added from DV -#pragma warning(pop) -#endif - -#endif diff --git a/toonz/sources/common/flash/FPrimitive.cpp b/toonz/sources/common/flash/FPrimitive.cpp deleted file mode 100644 index f6505af..0000000 --- a/toonz/sources/common/flash/FPrimitive.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FPrimitive.cpp - - This source file contains the definition for all low-level primitive-related functions, - grouped by classes: - - Class Member Function - - FColor FColor(U32, U32, U32); - FColor(U32, U32, U32, U32); - FColor(FRGB); - FColor(FRGBA); - void WriteToSWFStream(FSWFStream*, int); - - FMatrix FMatrix(U32, SFIXED, SFIXED, - U32, SFIXED, SFIXED, - SCOORD , SCOORD); - Matrix(); - U32 MinBits(S32, S32); - void WriteToSWFStream(FSWFStream*); - - FRect FRect(SCOORD, SCOORD, SCOORD, SCOORD); - TUINT32 MinBits(); - void WriteToSWFStream(FSWFStream *); - - FString FString(const U8*); - void WriteToSWFStream(FSWFStream*, bool); - -****************************************************************************************/ - -#include "FPrimitive.h" -#include "FSWFStream.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FColor ---------------------------------------------------------------- - -FColor::FColor(U32 _red, U32 _green, U32 _blue) - : red(_red), - green(_green), - blue(_blue), - alpha(0xff), - alphaT(false) -{ -} - -FColor::FColor(U32 _red, U32 _green, U32 _blue, U32 _alpha) - : red(_red), - green(_green), - blue(_blue), - alpha(_alpha), - alphaT(true) -{ -} - -FColor::FColor(FRGB rgb) - : red(rgb.red), - green(rgb.green), - blue(rgb.blue), - alpha(0xff), - alphaT(false) -{ -} - -FColor::FColor(FRGBA rgba) - : red(rgba.red), - green(rgba.green), - blue(rgba.blue), - alpha(rgba.alpha), - alphaT(true) -{ -} - -void FColor::WriteToSWFStream(FSWFStream *_SWFStream) -{ - //no filling, everything should already be byte aligned - _SWFStream->WriteByte(red); - _SWFStream->WriteByte(green); - _SWFStream->WriteByte(blue); - if (alphaT) { - _SWFStream->WriteByte(alpha); - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FMatrix --------------------------------------------------------------- - -// The Matrix class constructor -FMatrix::FMatrix(U32 _hasScale, SFIXED _scaleX, SFIXED _scaleY, U32 _hasRotate, SFIXED - _rotateSkew0, - SFIXED _rotateSkew1, SCOORD _translateX, SCOORD _translateY) -{ - - hasScale = _hasScale; - - scaleX = _scaleX; - scaleY = _scaleY; - - hasRotate = _hasRotate; - rotateSkew0 = _rotateSkew0; - rotateSkew1 = _rotateSkew1; - - translateX = _translateX; - translateY = _translateY; - - nScaleBits = MinBits(scaleX, scaleY); - nRotateBits = MinBits(rotateSkew0, rotateSkew1); - nTranslateBits = MinBits(translateX, translateY); - - identity = false; -} - -// Creates an identity matrix. - -FMatrix::FMatrix(void) -{ - - identity = true; - hasScale = false; - scaleX = 1; - scaleY = 1; - - hasRotate = false; - rotateSkew0 = 0; - rotateSkew1 = 0; -} - -// Calculates the minimum number of bits necessary to represent the given 2 signed numbers. -// This is used to calculate the 3 nbit fields in the Matrix class. Takes two signed -// numbers, sees which has the greatest magnitude, and calls FileWrite::MinBits with the -// unsigned magnitude of the larger number and the sign flag equal to 1 to account for the -// fact that the numbers are signed. - -U32 FMatrix::MinBits(S32 x, S32 y) -{ - - int xAbs = abs(x); - int yAbs = abs(y); - - if (xAbs > yAbs) - return FSWFStream::MinBits((U32)xAbs, 1); - - else - return FSWFStream::MinBits((U32)yAbs, 1); -} - -FMatrix FMatrix::operator*(const FMatrix &b) const -{ - SFIXED _scaleX = scaleX * b.scaleX + rotateSkew0 * b.rotateSkew1; - SFIXED _scaleY = scaleY * b.scaleY + rotateSkew0 * b.rotateSkew1; - SFIXED _rot0 = scaleX * b.rotateSkew0 + rotateSkew0 * b.scaleY; - SFIXED _rot1 = rotateSkew1 * b.scaleX + scaleY * b.rotateSkew1; - - return FMatrix( - _scaleX != 1 || scaleY != 1, _scaleX, _scaleY, - _rot0 != 0 || _rot1 != 0, _rot0, _rot1, - scaleX * b.translateX + rotateSkew0 * b.translateY + translateX, - rotateSkew1 * b.translateX + scaleY * b.translateY + translateY); -} - -// Writes the Matrix to the given _SWFStream. - -void FMatrix::WriteToSWFStream(FSWFStream *_SWFStream) -{ - - if (identity) { - - _SWFStream->WriteByte(0); - - } - - else { - _SWFStream->FlushBits(); - - _SWFStream->WriteBits(hasScale, 1); - - if (hasScale) { - - _SWFStream->WriteBits(nScaleBits, 5); - _SWFStream->WriteBits((U32)scaleX, nScaleBits); - _SWFStream->WriteBits((U32)scaleY, nScaleBits); - } - - _SWFStream->WriteBits(hasRotate, 1); - - if (hasRotate) { - - _SWFStream->WriteBits(nRotateBits, 5); - _SWFStream->WriteBits((U32)rotateSkew0, nRotateBits); - _SWFStream->WriteBits((U32)rotateSkew1, nRotateBits); - } - if (translateX == 0 && translateY == 0) - _SWFStream->WriteBits(0, 5); - else { - _SWFStream->WriteBits(nTranslateBits, 5); - - _SWFStream->WriteBits((U32)translateX, nTranslateBits); - _SWFStream->WriteBits((U32)translateY, nTranslateBits); - } - } -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FRect ------------------------------------------------------------------ - -// Rectangle class constructor. -FRect::FRect(SCOORD _xmin, SCOORD _ymin, SCOORD _xmax, SCOORD _ymax) -{ - - xmin = _xmin; - xmax = _xmax; - ymin = _ymin; - ymax = _ymax; -} - -// FRect's MinBits function. Calls MinBits with number being the absolute value of the -// rectangle coordinate with the greatest magnitude, and sign being 1 since a rectangle -// coord is signed. - -TUINT32 FRect::MinBits(void) -{ - TUINT32 maxCoord = FSWFStream::MaxNum(xmin, xmax, ymin, ymax); - - return FSWFStream::MinBits(maxCoord, 1); -} - -// Writes the rectangle to the given buffer. - -void FRect::WriteToSWFStream(FSWFStream *_SWFStream) -{ - int nBits = (int)MinBits(); - _SWFStream->WriteBits(nBits, 5); - - _SWFStream->WriteBits((U32)xmin, nBits); - _SWFStream->WriteBits((U32)xmax, nBits); - _SWFStream->WriteBits((U32)ymin, nBits); - _SWFStream->WriteBits((U32)ymax, nBits); - - _SWFStream->FlushBits(); -} - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FString --------------------------------------------------------------- - -FString::FString(const U8 *_string) -{ - text = (const char *)_string; -} - -FString::FString(const char *_string) -{ - text = _string; -} - -void FString::WriteToSWFStream(FSWFStream *_SWFStream, bool null_end) -{ - U16 i = 0; - for (i = 0; i < text.length(); i++) { - _SWFStream->WriteByte((U32)text[i]); - } - if (null_end) - _SWFStream->WriteByte(0); -} diff --git a/toonz/sources/common/flash/FPrimitive.h b/toonz/sources/common/flash/FPrimitive.h deleted file mode 100644 index 4cd2b69..0000000 --- a/toonz/sources/common/flash/FPrimitive.h +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/18/1999. -// Mostly about FRGB, FRGBA, and FColor. -// Additionally, there is some brain-dump on how color should be implemented in low and -// high level manager. - -/**************************************************************************************** - - File Summary: FPrmitive.h - - This header-file contains the declarations of low-level prmitive-related structs and - classes. - - struct FRGB; - struct FRGBA; - - class FColor; - class FMatrix; - class FRect; - class FString; - -****************************************************************************************/ - -#ifndef FPRIMITIVE_INCLUDED -#define FPRIMITIVE_INCLUDED -#include "tcommon.h" -#include "Macromedia.h" -#include -class FSWFStream; - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -// color structures - -struct FRGB { - U8 red; - U8 green; - U8 blue; -}; - -struct FRGBA { - // FRGBA( U8 r, U8 g, U8 b, U8 a ) { red = r; green = g; blue = b; alpha = a; } - // FRGBA() { red = 0; green = 0; blue = 0; alpha = 255; } - // void Set( U8 r, U8 g, U8 b, U8 a ) { red = r; green = g; blue = b; alpha = a; } - // - U8 red; - U8 green; - U8 blue; - U8 alpha; -}; - -//! This object specifies a color object. -/*! FColor is used (copied) as a structure. Do not add dynamic memory or virtual functions. - - There are two types of FColor, i.e. one with alpha channel on and the other with alpha channel.off. - When you construct an instance of FColor, if you provide three parameters, the alpha channel is off; - if you provide four, the alpha channel is on. - - Each color-related SWF tag requires the correct color type, either RGB or RGBA. For example, - DefineShape, DefineShape2, SetBackgroundColor need RGB (alpha off); - DefineShape3, DefineMorphShape, DefineEditText need RGBA (alpha on). - - The low-level manager can correct some errors of wrong color type, but not all. So don't rely on it. - If the wrong one got over low-level manager, the flash play might crash on that. - - We recommend you use RGBA whenever reasonable. The reason? Using RGBA is very consistent - and worth the sacrifice of some file space (in SWF, it's one more byte for each occurance of color info, and some - additional for color transformation.) - - Actually, we only provide RGBA interface for colors in high-level manager because this solution is much more elegant - in terms of consistency and compatibility. -*/ -class DVAPI FColor -{ -public: - //! Default FColor is white (0xff, 0xff, 0xff), construct a FColor with Alpha channel off. - FColor(U32 _red = 0xff, U32 _green = 0xff, U32 _blue = 0xff); - - //! Construct a FColor with Alpha channel on. - FColor(U32 _red, U32 _green, U32 _blue, U32 _alpha); - - //! Construct a FColor with Alpha channel off. - FColor(FRGB rgb); - - //! Construct a FColor with Alpha channel on. - FColor(FRGBA rgba); - - //! Returns red component. - int Red() { return (int)red; } - - //! Returns green component. - int Green() { return (int)green; } - - //! Returns blue component. - int Blue() { return (int)blue; } - - //! Returns alpha value. - int Alpha() { return (int)alpha; } - - bool HasAlpha() { return alphaT; } - - //! Alpha switch: turn on/off alpha channel. - void AlphaChannel(bool on) { alphaT = on; } - - bool operator==(const FColor &color) { return (red == color.red && - green == color.green && - blue == color.blue && - alpha == color.alpha); } - - /* - enum { - WRITE_SMALLEST, - WRITE_3BYTE, - WRITE_4BYTE - }; -*/ - // Method for internal use. - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - U32 red; // should be U8 - U32 green; // should be U8 - U32 blue; // should be U8 - U32 alpha; // should be U8 - bool alphaT; //alpha type flag -}; - -class DVAPI FMatrix -{ - -public: - FMatrix(void); - - FMatrix(U32 _hasScale, - SFIXED _scaleX, - SFIXED _scaleY, - U32 _hasRotate, - SFIXED _rotateSkew0, - SFIXED _rotateSkew1, - SCOORD _translateX, - SCOORD _translateY); - - void WriteToSWFStream(FSWFStream *_SWFStream); - - FMatrix operator*(const FMatrix &b) const; - -public: - U32 hasScale; - U32 nScaleBits; - - SFIXED scaleX; - SFIXED scaleY; - - U32 hasRotate; - U32 nRotateBits; - SFIXED rotateSkew0; - SFIXED rotateSkew1; - - U32 nTranslateBits; - SCOORD translateX; - SCOORD translateY; - - U32 MinBits(S32 x, S32 y); - U16 identity; -}; - -//rectangle class - -class DVAPI FRect -{ -public: - FRect() { xmin = ymin = xmax = ymax = 0; } - FRect(SCOORD xmin, SCOORD ymin, SCOORD xmax, SCOORD ymax); - - SCOORD Xmin() { return xmin; } - SCOORD Ymin() { return ymin; } - SCOORD Xmax() { return xmax; } - SCOORD Ymax() { return ymax; } - SCOORD Width() { return xmax - xmin + 1; } - SCOORD Height() { return ymax - ymin + 1; } - - void SetXmin(SCOORD val) { xmin = val; } - void SetYmin(SCOORD val) { ymin = val; } - void SetXmax(SCOORD val) { xmax = val; } - void SetYmax(SCOORD val) { ymax = val; } - - void WriteToSWFStream(FSWFStream *_SWFStream); - -private: - SCOORD xmin; - SCOORD xmax; - SCOORD ymin; - SCOORD ymax; - - U32 MinBits(void); -}; - -// a flash string - -class DVAPI FString -{ - -public: - FString(const U8 *_string); - FString(const char *_string); - std::string GetString() { return text; } - - void WriteToSWFStream(FSWFStream *_SWFStream, bool writeNull); - U16 Length() { return text.length(); } - -private: - std::string text; -}; - -#ifdef WIN32 // added from DV -#pragma warning(pop) -#endif -#endif diff --git a/toonz/sources/common/flash/FSWFStream.cpp b/toonz/sources/common/flash/FSWFStream.cpp deleted file mode 100644 index b8a15e6..0000000 --- a/toonz/sources/common/flash/FSWFStream.cpp +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FSWFStream.cpp - - This source file contains the definition for all low-level SWF-stream functions: - - Class Member Function - - FSWFStream FSWFStream(); - void WriteBits(U32, U32); - void WriteLargeData(U8*, U32); - void FlushBits(); - void WriteDWord(U32); - void WriteWord(U32); - void WriteByte(U32); - U32 Size(); - void Append(FSWFStream *); - void WriteToFile( FILE*); - void AppendTag(U16, U32, FSWFStream*); - U32 MinBits(U32, U16); - U32 MaxNum(S32, S32, S32, S32); - -****************************************************************************************/ -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - -#ifndef _DEBUG -#undef _STLP_DEBUG -#else -#define _STLP_DEBUG 1 -#endif - -#include "zlib.h" -#include "FObj.h" -#include "FSWFStream.h" - -////////////////////////////////////////////////////////////////////////////////////// -// -------- FSWFStream ------------------------------------------------------------ - -// FSWFStream is the object used to store a string of bytes, an SWF file "in memory" -// before being written to the disk. It handles bit packing and endian issues. - -// SWF uses bit packing a lot to reduce the size of the data going over the Net. -// The issue here of course is how to pack and unpack the bits correctly. - -FSWFStream::FSWFStream() -{ - streamPos = 0; //the position in the FSWFStream(how many bytes you have put in) - bytePos = 8; //the number of bits left to fill in the current byte - currentByte = 0; //the value of the current byte being created - -#ifndef DEBUG - stream.reserve(1024); // start out at 1k to make faster - - // if it is a debug build, don't reserve, as we wish to stress the system -#endif - stream.push_back(0); -} - -// Adds 'size' bits from 'data' to the stream FSWFStream. Data is in the form of -// a U32. Size indicates how many of the 32 bits are significant and should -// be output. It checks how many bits are available in the current output byte -// and works by repeatedly stuffing it with the next bits from 'data' -// and then adding currentByte to the stream until all "size" bits have been output. - -void FSWFStream::WriteBits(U32 data, U32 size) //adds individual bits -{ - FLASHASSERT(((int)data <= (0x01 << size) - 1) || (-(S32)(data) <= (0x01 << size) - 1)); - while (size != 0) { - if (size > bytePos) { - //if more bits left to write than shift out what will fit - currentByte |= data << (32 - size) >> (32 - bytePos); - - // shift all the way left, then right to right - // justify the data to be or'ed in - stream[streamPos] = currentByte; - streamPos++; - stream.push_back(0); - size -= bytePos; - currentByte = 0; - bytePos = 8; - } else if (size <= bytePos) { - currentByte |= data << (32 - size) >> (32 - bytePos); - bytePos -= size; - size = 0; - - if (!bytePos) { //if current byte is filled - stream[streamPos] = currentByte; - streamPos++; - stream.push_back(0); - currentByte = 0; - bytePos = 8; - } - } - } -} - -// For adding large data that is pointed to by a pointer. The data is only -// integrated into the stream when it is actually written to disk. -// E. G. a large JPEG. This is to avoid storing it twice. -// Stores the current streamPos, data pointer and size in the OutDataList. - -void FSWFStream::WriteLargeData(const U8 *data, U32 size) -{ - LargeData large; - - large.position = streamPos; - large.data = data; - large.size = size; - - outDataList.push_back(large); -} - -// Kick out the current partially filled byte to the stream. -// If there is a byte currently being built for addition to the stream, then the end of that -// byte is filled with zeroes and the byte is added to the stream. - -void FSWFStream::FlushBits() -{ - - if (bytePos != 8) { - - stream[streamPos] = currentByte; - streamPos++; - stream.push_back(0); - currentByte = 0; - bytePos = 8; - } -} - -// - -// Writes a 32 bit stream of data to given FSWFStream in the proper form (reversed byte order), -// so B1B2B3B4 is written as B4B3B2B1. The function does this by sending a byte at a time -// of the data to the FSWFStream in the appropriate order. - -void FSWFStream::WriteDWord(U32 data) -{ - //declare variable used to output the bytes - U32 v; - - FlushBits(); //vincenzo: l'ho messo io!! col cazzo che era "no bit swapping"! stronzi! - - //output the rightmost byte - v = data << 24 >> 24; - WriteBits(v, 8); - - //output the center right byte - v = data << 16 >> 24; - WriteBits(v, 8); - - //output the center left byte - v = data << 8 >> 24; - WriteBits(v, 8); - - //output the leftmost byte - v = data >> 24; - WriteBits(v, 8); -} - -// Writes a 16 bit stream of data to the FSWFStream in the proper form, so B1B2 is written as -// B2B1. - -void FSWFStream::WriteWord(U32 data) -{ - - //declare the variable used to output the bytes - U32 v; - FlushBits(); //vincenzo: l'ho messo io!! col cazzo che era "no bit swapping"! stronzi! - - //output the rightmost byte - v = data << 24 >> 24; - WriteBits(v, 8); - - //output the leftmost byte - v = data << 16 >> 24; - WriteBits(v, 8); -} - -// Writes an 8 bit stream of data to the FSWFStream. There is no bit swapping!! A byte is -// written as a byte. - -void FSWFStream::WriteByte(U32 data) -{ - - //declare the variable used to output the byte - U32 v = 0; - FlushBits(); //vincenzo: l'ho messo io!! col cazzo che era "no bit swapping"! stronzi! - - //output the byte - v = data << 24 >> 24; - - WriteBits(v, 8); -} - -// Returns the size of the FSWFStream. For purposes of denoting size in tags and headers. - -U32 FSWFStream::Size(void) -{ - int size = (int)streamPos; - std::list::iterator it; - - for (it = outDataList.begin(); it != outDataList.end(); it++) { - LargeData &data = (*it); - size += data.size; - } - return size; -} - -//------------------------------------------------------------------ -U32 FSWFStream::FullSize(void) -{ - U32 currentStreamPos = 0; //the current position in the FSWFStream for writing - - std::list::iterator it = outDataList.begin(), it_e = outDataList.end(); - U32 size = 0; - - for (; it != it_e; it++) { - - FLASHASSERT((*it).position >= currentStreamPos); - - if ((*it).position - currentStreamPos > 0) - size += (*it).position - currentStreamPos; - - currentStreamPos = (*it).position; - - //currentStreamPos should now equal currentDataPosition - FLASHASSERT((*it).size > 0); - - size += (*it).size; - } - - if (streamPos > currentStreamPos) - size += streamPos - currentStreamPos; - return size; -} - -//------------------------------------------------------------------- -// Appends the stream FSWFStream to this. Doesn't actually write the bitmaps, -// jpegs ... Instead it just writes their file name with a note that the actual file -// should go there. - -void FSWFStream::Append(FSWFStream *add) -{ - int addStreamPos = 0; // this functions position in the "add" stream, - // remembering that add->streamPos is the END - // of the "add" stream. - - // remove all the large data from the other stream - while (add->outDataList.size()) { - LargeData data = add->outDataList.front(); - add->outDataList.pop_front(); - - for (; addStreamPos < (int)data.position; addStreamPos++) { - WriteBits(add->stream[addStreamPos], 8); - } - //addStreamPos should now equal data.position - WriteLargeData(data.data, data.size); - } - - // Write the remainder of the stream data, after the last outData. - for (; addStreamPos < (int)add->streamPos; addStreamPos++) { - WriteBits(add->stream[addStreamPos], 8); - } -} - -// Writes the stream FSWFStream to the given file. -//--------------------------------------------------------------------- - -void FSWFStream::WriteToFileVersion6(FILE *swfFile) -{ - U32 size = FullSize(); - U8 *buf = new U8[size]; - WriteToMemory(buf); - - assert(buf[0] == 'F'); - assert(buf[1] == 'W'); - assert(buf[2] == 'S'); - //assert(buf[3]==4); - assert(((U32)(buf[4] + (buf[5] << 8) + (buf[6] << 16) + (buf[7] << 24))) == size); - - buf[3] = 6; //version 6 - - U32 sizeOut = (U32)(2 * ((size * 1.1) + 12)); - U8 *bufOut = new U8[sizeOut]; - - compress(bufOut, (uLongf *)&sizeOut, buf + 8, size - 8); - - if (size > sizeOut + 8) //meglio non comprimere altrimenti!!! - { - buf[0] = 'C'; - fwrite(buf, 1, 8, swfFile); - fwrite(bufOut, 1, sizeOut, swfFile); - } else - fwrite(buf, 1, size, swfFile); - - delete[] bufOut; - delete[] buf; -} - -//------------------------------------------------------------------------------------- - -void FSWFStream::WriteToFile(FILE *swfFile) -{ - U32 currentStreamPos = 0; //the current position in the FSWFStream for writing - const U8 *currentData; - U32 currentDataSize; - U32 currentDataPosition; - U32 outDataListSize = outDataList.size(); - - int wrote = 0; - - if (outDataListSize) { - - for (U32 i = 0; i < outDataListSize; i++) { - currentDataPosition = outDataList.front().position; - currentData = outDataList.front().data; - currentDataSize = outDataList.front().size; - outDataList.pop_front(); - - FLASHASSERT(currentDataPosition >= currentStreamPos); - - if (currentDataPosition - currentStreamPos > 0) { - fwrite(&stream[currentStreamPos], 1, (currentDataPosition - currentStreamPos), swfFile); - } - wrote += currentDataPosition - currentStreamPos; - currentStreamPos = currentDataPosition; - - //currentStreamPos should now equal currentDataPosition - FLASHASSERT(currentDataSize > 0); - - fwrite(currentData, 1, currentDataSize, swfFile); - wrote += currentDataSize; - } - } - - if (streamPos > currentStreamPos) { - fwrite(&stream[currentStreamPos], 1, streamPos - currentStreamPos, swfFile); - } - wrote += streamPos - currentStreamPos; -} - -void FSWFStream::WriteToMemory(U8 *memory) -{ - U32 currentStreamPos = 0; //the current position in the FSWFStream for writing - const U8 *currentData; - U32 currentDataSize; - U32 currentDataPosition; - U32 outDataListSize = outDataList.size(); - - int wrote = 0; - - if (outDataListSize) { - - for (U32 i = 0; i < outDataListSize; i++) { - currentDataPosition = outDataList.front().position; - currentData = outDataList.front().data; - currentDataSize = outDataList.front().size; - outDataList.pop_front(); - - FLASHASSERT(currentDataPosition >= currentStreamPos); - - if (currentDataPosition - currentStreamPos > 0) { - memcpy(memory, &stream[currentStreamPos], (currentDataPosition - currentStreamPos)); - memory += currentDataPosition - currentStreamPos; - } - wrote += currentDataPosition - currentStreamPos; - currentStreamPos = currentDataPosition; - - //currentStreamPos should now equal currentDataPosition - FLASHASSERT(currentDataSize > 0); - - memcpy(memory, currentData, currentDataSize); - memory += currentDataSize; - wrote += currentDataSize; - } - } - - if (streamPos > currentStreamPos) { - // fwrite( &stream[currentStreamPos], 1, streamPos - currentStreamPos, swfFile ); - memcpy(memory, &stream[currentStreamPos], streamPos - currentStreamPos); - memory += streamPos - currentStreamPos; - } - wrote += streamPos - currentStreamPos; -} - -void FSWFStream::AppendTag(U16 tagID, U32 length, FSWFStream *buffer) -{ - U32 longLength = 0; - bool longHead = false; - - if (length > 62 || (tagID == 32 && length == 29) || (tagID == 2 && length == 28) || (tagID == 26 && length == 19)) //If long type tag: - { - longHead = true; - longLength = length; //The actual length is here. - length = 0x3f; //This field's length becomes 63 to indicate a TLong tag. - } else { //Else short type tag: - longHead = false; //It is not a TLong header, so the length is valid. - } - - U16 firstPartOfTag = (U16)((tagID << 6) | length); // Build up the first 2 bytes of the tag: - // 10bits for tag ID - // 6bits for tag length - - WriteWord((U32)firstPartOfTag); - - if (longHead) { - WriteDWord(longLength); - } - - if (buffer) // If there is not a buffer, don't write any more. - { - Append(buffer); // Copy the buffer passed in to this object. - } -} - -// Calculates the minimum number of bits necessary to represent the given number. The -// number should be given in its unsigned form with the flag sign equal to 1 if it is -// signed. Repeatedly compares number to another unsigned int called x. -// x is initialized to 1. The value of x is shifted left i times until x is greater -// than number. Now i is equal to the number of bits the UNSIGNED value of number needs. -// The signed value will need one more bit for the sign so i+1 is returned if the number -// is signed, and i is returned if the number is unsigned. - -U32 FSWFStream::MinBits(U32 number, U16 sign) -{ - //If the number == 0, then 0 bits are necessary for unsigned, and 1 for signed. - //Sign should either have a value of 0 or 1. - if (number == 0) { - return sign; - } - - //declare and initialize the variable for comparison - U32 x = 1; - U32 i; - - //keep increasing the value of x and i until s is greater than the given number - for (i = 1; i < 33; i++) { - x <<= 1; - if (x > number) { - break; - } - } - - FLASHASSERT(sign + i <= 32); - - //return the calculated value and account for the number being signed or not - return i + sign; -} - -// Compares the absolute values of 4 signed integers and returns the unsigned magnitude of -// the number with the greatest absolute value. - -U32 FSWFStream::MaxNum(S32 a, S32 b, S32 c, S32 d) -{ - - //take the absolute values of the given numbers - int aAbs = abs(a); - int bAbs = abs(b); - int cAbs = abs(c); - int dAbs = abs(d); - - //compare the numbers and return the unsigned value of the one with the greatest magnitude - if (aAbs > bAbs) { - if (aAbs > cAbs) { - if (aAbs > dAbs) { - return (U32)aAbs; - } else { - return (U32)dAbs; - } - } else if (cAbs > dAbs) { - return (U32)cAbs; - } else { - return (U32)dAbs; - } - } else { - if (bAbs > cAbs) { - if (bAbs > dAbs) { - return (U32)bAbs; - } else { - return (U32)dAbs; - } - } else if (cAbs > dAbs) { - return (U32)cAbs; - } else { - return (U32)dAbs; - } - } -} diff --git a/toonz/sources/common/flash/FSWFStream.h b/toonz/sources/common/flash/FSWFStream.h deleted file mode 100644 index eef08b1..0000000 --- a/toonz/sources/common/flash/FSWFStream.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. - -/**************************************************************************************** - - File Summary: FSWFStream.h - - This header-file contains the declarations of low-level SWF-stream class, i.e. - - class FSWFStream; - -****************************************************************************************/ - -#ifndef SWFSTREAM_INCLUDED -#define SWFSTREAM_INCLUDED - -#ifdef WIN32 // added from DV -#pragma warning(push) -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#endif - -#include "Macromedia.h" - -// #include -// #include -#include -#include - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TFLASH_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -// class used to store data before it is written to a .swf file - -class DVAPI FSWFStream -{ -public: - FSWFStream(); - - U32 Size(); - U32 FullSize(); - - U8 *Memory() { return &stream[0]; } // Useful to get the origin of the stream memory. - // Used by CreateMovie to write the header information. - - void WriteBits(U32 data, U32 size); // Writes # of bits size, that has value data - void WriteLargeData(const U8 *data, U32 size); // Stores the pointer to a large block of data - // to be written. Ownership of the data is NOT passed - // to this stream. - - // NOTE: These functions all take in U32's even though in some situations a smaller data - // type can suffice. This is for the sake of simplicity. - void WriteDWord(U32 data); - void WriteWord(U32 data); - void WriteByte(U32 data); - - void FlushBits(); // Kick out the current partially filled byte to the stream. - - void AppendTag(U16 _tagID, U32 _length, FSWFStream *_tagBody); // Copies the stream, adding tag id - // and length information. - void Append(FSWFStream *_SWFStream); // Copies another stream to the end - // of this without any changes. The stream - // will be empty but still needs to be deleted - // by the caller. - - // Utility functions - void WriteToFile(FILE *out); // writes this data to file - void WriteToFileVersion6(FILE *out); // writes this data to file, compressing with zlib(flash 6) - void WriteToMemory(U8 *memory); // copy this data to a memory buffer (use Size() to make sure it is large enough) - - //functions used to calculate optimal size for fields - static U32 MinBits(U32 number, U16 sign); - static U32 MaxNum(S32 a, S32 b, S32 c, S32 d); - -private: - struct LargeData { - U32 position; - const U8 *data; - U32 size; - }; - - std::vector stream; - - U32 streamPos; - U32 bytePos; - U8 currentByte; - - std::list outDataList; // stores pointer data - the overhead is not as bad as it seems -}; - -#endif diff --git a/toonz/sources/common/flash/FSound.cpp b/toonz/sources/common/flash/FSound.cpp deleted file mode 100644 index 01e184a..0000000 --- a/toonz/sources/common/flash/FSound.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "Macromedia.h" -#include "FSound.h" - -// -// The Low Level sound object -// - -const S32 FSound::kRateTable[4] = {sndRate5K, sndRate11K, sndRate22K, sndRate44K}; -const int FSound::kRateShiftTable[4] = {3, 2, 1, 0}; - -void FSound::Init() -{ - format = 0; - nSamples = 0; - samples = 0; - dataLen = 0; - delay = 0; -} - -void FSound::Set(WaveFormat *wfmt) -{ - wfmt->wFormatTag = 1; //WAVE_FORMAT_PCM; - wfmt->nSamplesPerSec = Rate(); - wfmt->nChannels = NChannels(); - wfmt->wBitsPerSample = BitsPerSample(); - wfmt->nBlockAlign = (wfmt->wBitsPerSample * wfmt->nChannels) / 8; - wfmt->nAvgBytesPerSec = wfmt->nBlockAlign * wfmt->nSamplesPerSec; - - //wfmt->cbSize = 0; -} - -// -// ADPCM tables -// - -static const int indexTable2[2] = { - -1, 2, -}; - -// Is this ok? -static const int indexTable3[4] = { - -1, -1, 2, 4, -}; - -static const int indexTable4[8] = { - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -static const int indexTable5[16] = { - -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16, -}; - -static const int *indexTables[] = { - indexTable2, - indexTable3, - indexTable4, - indexTable5}; - -static const int stepsizeTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767}; - -// -// The Compressor -// - -FSoundComp::FSoundComp(FSound *snd, S32 nb) -{ - // assert(snd->CompressFormat() == sndCompressADPCM); - isStereo = snd->Stereo(); - is8Bit = snd->Is8Bit(); - - nBits = nb; - nSamples = 0; - - len = 0; - - bitBuf = 0; - bitPos = 0; -} - -void FSoundComp::WriteBits(std::vector *stream) -{ - if (stream) { - // Actually write the bits... - while (bitPos >= 8) { - // May need to rewrite this line - // recorder->PutByte((U8)(bitBuf >> (bitPos-8))); - stream->push_back((U8)(bitBuf >> (bitPos - 8))); - - bitPos -= 8; - len++; - } - } else { - // Just counting... - len += bitPos / 8; - bitPos &= 0x7; - } -} - -void FSoundComp::Flush(std::vector *stream) -{ - WriteBits(stream); - if (bitPos > 0) { - PutBits(0, 8 - bitPos, stream); - WriteBits(stream); - } -} - -void FSoundComp::Compress16(S16 *src, S32 n, std::vector *stream) -{ - if (nSamples == 0) { - // Emit the compression settings - PutBits(nBits - 2, 2, stream); - } - - int sn = isStereo ? 2 : 1; - const int *indexTable = indexTables[nBits - 2]; - while (n-- > 0) { - nSamples++; - if ((nSamples & 0xfff) == 1) { - // We emit a header every 4096 samples so we can seek quickly - for (int i = 0; i < sn; i++) { - // Pick an initial index value - S32 d = abs(src[sn] - src[0]); - int k = 0; - while (k < 63 && stepsizeTable[k] < d) - k++; - - PutBits(valpred[i] = *src++, 16, stream); - PutBits(index[i] = k, 6, stream); - } - - } else { - // Generate a delta value - for (int i = 0; i < sn; i++) { - /* Step 1 - compute difference with previous value */ - S32 diff = *src++ - valpred[i]; /* Difference between val and valprev */ - int sign; - if (diff < 0) { - sign = 1 << (nBits - 1); - diff = -diff; - } else { - sign = 0; - } - - /* Step 2 - Divide and clamp */ - /* Note: - ** This code *approximately* computes: - ** delta = diff*4/step; - ** vpdiff = (delta+0.5)*step/4; - ** but in shift step bits are dropped. The net result of this is - ** that even if you have fast mul/div hardware you cannot put it to - ** good use since the fixup would be too expensive. - */ - int step = stepsizeTable[index[i]]; /* Stepsize */ - S32 delta = 0; /* Current adpcm output value */ - S32 vpdiff = 0; /* Current change to valpred */ - - int k = 1 << (nBits - 2); - do { - if (diff >= step) { - delta |= k; - diff -= step; - vpdiff += step; - } - step >>= 1; - k >>= 1; - } while (k); - vpdiff += step; // add the 0.5 - - /* Step 3 - Update previous value */ - if (sign) - valpred[i] -= vpdiff; - else - valpred[i] += vpdiff; - - /* Step 4 - Clamp previous value to 16 bits */ - if (valpred[i] != (S16)valpred[i]) - valpred[i] = valpred[i] < 0 ? -32768 : 32767; - assert(valpred[i] <= 32767 && valpred[i] >= -32768); - - /* Step 5 - Assemble value, update index and step values */ - index[i] += indexTable[delta]; - if (index[i] < 0) - index[i] = 0; - else if (index[i] > 88) - index[i] = 88; - - delta |= sign; - - /* Step 6 - Output value */ - PutBits(delta, nBits, stream); - } - } - } -} - -inline void Filter8to16(U8 *src, S16 *dst, S32 n) -// Can work in place -{ - src += n; - dst += n; - while (n--) - *(--dst) = ((S16) * (--src) - 128) << 8; -} - -void FSoundComp::Compress(void *src, S32 n, std::vector *stream) -{ - if (is8Bit) { - S16 buf[4096]; - U8 *s = (U8 *)src; - while (n > 0) { - // Expand to 16 bit and compress - S32 nb = std::min((S32)4096, n); - Filter8to16(s, buf, nb); - Compress16(buf, nb, stream); - n -= nb; - s += nb; - } - - } else { - Compress16((S16 *)src, n, stream); - } -} diff --git a/toonz/sources/common/flash/FSound.h b/toonz/sources/common/flash/FSound.h deleted file mode 100644 index 127ef26..0000000 --- a/toonz/sources/common/flash/FSound.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef SNDMIX_INCLUDED -#define SNDMIX_INCLUDED - -// #include -// #include -#include -#include -#include - -#include "Macromedia.h" -#include "FFixed.h" - -struct WaveFormat { - U16 wFormatTag; /* format type */ - U16 nChannels; /* number of channels (i.e. mono, stereo...) */ - U32 nSamplesPerSec; /* sample rate */ - U32 nAvgBytesPerSec; /* for buffer estimation */ - U16 nBlockAlign; /* block size of data */ - U16 wBitsPerSample; /* number of bits per sample of mono data */ - U16 cbSize; /* the count in bytes of the size of */ -}; - -// Our supported sample rates -// Note that sndRate5K is really 5512.5khz -// Use defines instead of an enum since these must be 32 bits on all platforms -#define sndRate5K 5512L -#define sndRate11K 11025L -#define sndRate22K 22050L -#define sndRate44K 44100L - -const int sndMono = 0x0; -const int sndStereo = 0x1; - -const int snd8Bit = 0x0; -const int snd16Bit = 0x2; - -const int snd5K = 0 << 2; -const int snd11K = 1 << 2; -const int snd22K = 2 << 2; -const int snd44K = 3 << 2; - -const int sndCompressNone = 0x00; // we could add 14 more compression types here... -const int sndCompressADPCM = 0x10; -const int sndCompressMP3 = 0x20; -const int sndCompressNoneI = 0x30; // save out in intel byte order -const int sndRateMask = 0x3 << 2; -const int sndCompressMask = 0xF0; - -enum { // Sound format types - snd5K8Mono = 0, - snd5K8Stereo, - snd5K16Mono, - snd5K16Stereo, - snd11K8Mono, - snd11K8Stereo, - snd11K16Mono, - snd11K16Stereo, - snd22K8Mono, - snd22K8Stereo, - snd22K16Mono, - snd22K16Stereo, - snd44K8Mono, - snd44K8Stereo, - snd44K16Mono, - snd44K16Stereo -}; - -// This object defines a sound sample -class FSound -{ -public: - int format; - S32 nSamples; // the number of samples - duration = nSamples/Rate() - void *samples; // this should probably be a handle on Mac - S32 dataLen; // length in bytes of samples - set only if needed - S32 delay; // MP3 compression has a delay before the real sound data - - static const S32 kRateTable[4]; - static const int kRateShiftTable[4]; - -public: - void Init(); - - S32 Rate() { return kRateTable[(format >> 2) & 0x3]; } - int RateShift() { return kRateShiftTable[(format >> 2) & 0x3]; } - bool Stereo() { return (format & sndStereo) != 0; } - int NChannels() { return (format & sndStereo) ? 2 : 1; } - bool Is8Bit() { return (format & snd16Bit) == 0; } - int BitsPerSample() { return (format & snd16Bit) ? 16 : 8; } - int BytesPerSample() { return (format & snd16Bit) ? 2 : 1; } - int CompressFormat() { return format & sndCompressMask; } - bool Compressed() { return (format & sndCompressMask) != 0; } - - // Manage the duration in 44kHz units - S32 GetDuration44() { return nSamples << RateShift(); } - void SetDuration44(S32 d) { nSamples = d >> RateShift(); } - - int BytesPerBlock() { return BytesPerSample() * NChannels(); } - S32 SizeBytes() { return nSamples * BytesPerBlock(); } - - void Set(WaveFormat *); -}; - -class FSoundComp -{ -private: - BOOL isStereo; - BOOL is8Bit; - int nBits; // number of bits in each sample - - S32 nSamples; // samples compressed so far - - S32 valpred[2]; // ADPCM state - int index[2]; - - // The Destination - S32 len; // default is to just calculate the size - - // State for writing bits - unsigned int bitBuf; - int bitPos; - -public: - FSoundComp(FSound *snd, S32 numberBits); // numberBits from 2-5 - ~FSoundComp() { assert(bitPos == 0); } - - void Compress(void *src, S32 n, std::vector *stream); - void Flush(std::vector *stream); - -private: - void Compress16(S16 *src, S32 n, std::vector *stream); - - // Write variable width bit fields - void WriteBits(std::vector *stream); // empty the buffer of whole bytes - - void PutBits(S32 v, int n, std::vector *stream) - { - assert(n <= 16); - if (bitPos + n > 32) - WriteBits(stream); - bitBuf = (bitBuf << n) | (v & ~(0xFFFFFFFFL << n)); - bitPos += n; - } -}; - -#endif diff --git a/toonz/sources/common/flash/Macromedia.h b/toonz/sources/common/flash/Macromedia.h deleted file mode 100644 index 566ef05..0000000 --- a/toonz/sources/common/flash/Macromedia.h +++ /dev/null @@ -1,514 +0,0 @@ -// Copyright © 1999 Middlesoft, Inc. All rights reserved. -// First Created By Lee Thomason. -// First Created On 09/08/1999. -// Last Modified On 11/09/1999. -// Last Modified On 18/06/2002 by DV for Fixes -/**************************************************************************************** - - File Summary: Macromedia.h - - This header file defines various structs and enums used by Flash File Format SDK - low-level manager. - -****************************************************************************************/ - -#ifndef _MACROMEDIA_H_ -#define _MACROMEDIA_H_ - -#ifdef WIN32 // added by DV -#pragma warning(disable : 4786) -#endif - -#include "tcommon.h" -#include -#include -#include - -class FSWFStream; - -#ifdef _DEBUG -#ifndef DEBUG -#define DEBUG -#endif -#endif - -// Some basic defines for debugging: -#ifdef DEBUG -#define FLASHOUTPUT printf -#define FLASHASSERT assert -#define FLASHPRINT printf -// -// #define FLASHOUTPUT ((void)0) -// #define FLASHASSERT ((void)0) -// #define FLASHPRINT ((void)0) -#else -inline void nothing(...) -{ -} -#define FLASHOUTPUT nothing //((void)0) -#define FLASHASSERT nothing //((void)0) -#define FLASHPRINT printf -#endif - -/* // removed by DV -#ifndef min - #define min( a, b ) ( ( a < b ) ? a : b ) -#endif -#ifndef max - #define max( a, b ) ( ( a > b ) ? a : b ) -#endif -*/ - -// Global Types -typedef float FLOAT; -typedef TUINT32 U32, *P_U32, **PP_U32; -typedef TINT32 S32, *P_S32, **PP_S32; -typedef unsigned short U16, *P_U16, **PP_U16; -typedef signed short S16, *P_S16, **PP_S16; -typedef unsigned char U8, *P_U8, **PP_U8; -typedef signed char S8, *P_S8, **PP_S8; -typedef TINT32 SFIXED, *P_SFIXED; -typedef TINT32 SCOORD, *P_SCOORD; -typedef int BOOL; - -const SFIXED Fixed1 = 0x00010000; -const SCOORD SCoord1 = 20; - -typedef struct SRECT { - SCOORD xmin; - SCOORD xmax; - SCOORD ymin; - SCOORD ymax; -} SRECT, *P_SRECT; - -const U8 Snd5k = 0; -const U8 Snd11k = 1; -const U8 Snd22k = 2; -const U8 Snd44k = 3; - -const U8 Snd8Bit = 0; -const U8 Snd16Bit = 1; - -const U8 SndMono = 0; -const U8 SndStereo = 1; - -typedef struct SSound { - U8 format; // 0 none, 1 PCM - U8 rate; // Snd5k...Snd44k - U8 size; // 0 8bit, 1 16bit - U8 type; // 0 mono, 1 stereo - U32 sampleCount; // the number of samples - U32 soundSize; // the number of bytes in the sample - U8 *sound; // pointer to the sound data -} SSound, *P_SSound; - -typedef struct SPOINT { - SCOORD x; - SCOORD y; -} SPOINT, *P_SPOINT; - -// Start Sound Flags -enum { - soundHasInPoint = 0x01, - soundHasOutPoint = 0x02, - soundHasLoops = 0x04, - soundHasEnvelope = 0x08 - - // the upper 4 bits are reserved for synchronization flags -}; - -enum { - fillSolid = 0x00, - fillGradient = 0x10, - fillLinearGradient = 0x10, - fillRadialGradient = 0x12, - fillMaxGradientColors = 8, - // Texture/bitmap fills - fillTiledBits = 0x40, // if this bit is set, must be a bitmap pattern - fillClippedBits = 0x41 -}; - -enum { - CURVED_EDGE = 0, - STRAIGHT_EDGE = 1 -}; - -enum { - NOT_EDGE_REC = 0, - EDGE_REC = 1 -}; - -// Flags for defining a shape character -enum { - // These flag codes are used for state changes - and as return values from ShapeParser::GetEdge() - eflagsMoveTo = 0x01, - eflagsFill0 = 0x02, - eflagsFill1 = 0x04, - eflagsLine = 0x08, - eflagsNewStyles = 0x10, - - eflagsEnd = 0x80 // a state change with no change marks the end -}; - -#ifndef NULL -#define NULL 0 -#endif - -// Tag values that represent actions or data in a Flash script. -enum { - stagEnd = 0, - stagShowFrame = 1, - stagDefineShape = 2, - stagFreeCharacter = 3, - stagPlaceObject = 4, - stagRemoveObject = 5, - stagDefineBits = 6, - stagDefineButton = 7, - stagJPEGTables = 8, - stagSetBackgroundColor = 9, - stagDefineFont = 10, - stagDefineText = 11, - stagDoAction = 12, - stagDefineFontInfo = 13, - stagDefineSound = 14, // Event sound tags. - stagStartSound = 15, - stagDefineButtonSound = 17, - stagSoundStreamHead = 18, - stagSoundStreamBlock = 19, - stagDefineBitsLossless = 20, // A bitmap using lossless zlib compression. - stagDefineBitsJPEG2 = 21, // A bitmap using an internal JPEG compression table. - stagDefineShape2 = 22, - stagDefineButtonCxform = 23, - stagProtect = 24, // This file should not be importable for editing. - - stagPathsArePostScript = 25, // assume shapes are filled as PostScript style paths - - // These are the new tags for Flash 3. - stagPlaceObject2 = 26, // The new style place w/ alpha color transform and name. - stagRemoveObject2 = 28, // A more compact remove object that omits the character tag (just depth). - - // This tag is used for RealMedia only - stagSyncFrame = 29, // Handle a synchronization of the display list - - stagFreeAll = 31, // Free all of the characters - - stagDefineShape3 = 32, // A shape V3 includes alpha values. - stagDefineText2 = 33, // A text V2 includes alpha values. - stagDefineButton2 = 34, // A button V2 includes color transform, alpha and multiple actions - stagDefineBitsJPEG3 = 35, // A JPEG bitmap with alpha info. - stagDefineBitsLossless2 = 36, // A lossless bitmap with alpha info. - stagDefineSprite = 39, // Define a sequence of tags that describe the behavior of a sprite. - stagNameCharacter = 40, // Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). - - stagSerialNumber = 41, // a tag command for the Flash Generator customer serial id and cpu information - stagDefineTextFormat = 42, // define the contents of a text block with formating information - - stagFrameLabel = 43, // A string label for the current frame. - stagSoundStreamHead2 = 45, // For lossless streaming sound, should not have needed this... - stagDefineMorphShape = 46, // A morph shape definition - - stagFrameTag = 47, // a tag command for the Flash Generator (WORD duration, STRING label) - stagDefineFont2 = 48, // a tag command for the Flash Generator Font information - stagGenCommand = 49, // a tag command for the Flash Generator intrinsic - stagDefineCommandObj = 50, // a tag command for the Flash Generator intrinsic Command - stagCharacterSet = 51, // defines the character set used to store strings - stagFontRef = 52, // defines a reference to an external font source - - // Flash 4 tags - stagDefineEditText = 37, // an edit text object (bounds, width, font, variable name) - stagDefineVideo = 38, // a reference to an external video stream - - // NOTE: If tag values exceed 255 we need to expand SCharacter::tagCode from a BYTE to a WORD - stagDefineBitsPtr = 1023 // a special tag used only in the editor -}; - -// PlaceObject2 Flags -enum { - splaceMove = 0x01, // this place moves an exisiting object - splaceCharacter = 0x02, // there is a character tag (if no tag, must be a move) - splaceMatrix = 0x04, // there is a matrix (matrix) - splaceColorTransform = 0x08, // there is a color transform (cxform with alpha) - splaceRatio = 0x10, // there is a blend ratio (word) - splaceName = 0x20, // there is an object name (string) - splaceDefineClip = 0x40, // this shape should open or close a clipping bracket (character != 0 to open, character == 0 to close) - splaceCloneExternalSprite = 0x80 // cloning a movie which was loaded externally - // one bit left for expansion -}; - -//ActionConditions -enum { - OverDownToIdle = 1, - IdleToOverDown = 2, - OutDownToIdle = 3, - OutDownToOverDown = 4, - OverDownToOutDown = 5, - OverDownToOverUp = 6, - OverUpToOverDown = 7, - OverUpToIdle = 8, - IdleToOverUp = 9 -}; - -//Clip Action -enum { - //Flash 5- - ClipEventLoad = 0x00000001, - ClipEventEnterFrame = 0x00000002, - ClipEventUnload = 0x00000004, - ClipEventMouseMove = 0x00000008, - ClipEventMouseDown = 0x00000010, - ClipEventMouseUp = 0x00000020, - ClipEventKeyDown = 0x00000040, - ClipEventKeyUp = 0x00000080, - ClipEventData = 0x00000100, - - //Flash 6+ - ClipEventInitialize = 0x00000200, - ClipEventPress = 0x00000400, - ClipEventRelease = 0x00000800, - ClipEventReleaseOutside = 0x00001000, - ClipEventRollOver = 0x00002000, - ClipEventRollOut = 0x00004000, - ClipEventDragOver = 0x00008000, - ClipEventDragOut = 0x00010000, - ClipEventKeyPress = 0x00020000, -}; - -//Key Codes -enum { - ID_KEY_LEFT = 0x01, - ID_KEY_RIGHT = 0x02, - ID_KEY_HOME = 0x03, - ID_KEY_END = 0x04, - ID_KEY_INSERT = 0x05, - ID_KEY_DELETE = 0x06, - ID_KEY_CLEAR = 0x07, - ID_KEY_BACKSPACE = 0x08, - ID_KEY_ENTER = 0x0D, - ID_KEY_UP = 0x0E, - ID_KEY_DOWN = 0x0F, - ID_KEY_PAGE_UP = 0x10, - ID_KEY_PAGE_DOWN = 0x11, - ID_KEY_TAB = 0x12 -}; - -// Action codes -enum { - // Flash 1 and 2 actions - sactionHasLength = 0x80, - sactionNone = 0x00, - sactionGotoFrame = 0x81, // frame num (WORD) - sactionGetURL = 0x83, // url (STR), window (STR) - sactionNextFrame = 0x04, - sactionPrevFrame = 0x05, - sactionPlay = 0x06, - sactionStop = 0x07, - sactionToggleQuality = 0x08, - sactionStopSounds = 0x09, - sactionWaitForFrame = 0x8A, // frame needed (WORD), actions to skip (BYTE) - - // Flash 3 Actions - sactionSetTarget = 0x8B, // name (STR) - sactionGotoLabel = 0x8C, // name (STR) - - // Flash 4 Actions - sactionAdd = 0x0A, // Stack IN: number, number, OUT: number - sactionSubtract = 0x0B, // Stack IN: number, number, OUT: number - sactionMultiply = 0x0C, // Stack IN: number, number, OUT: number - sactionDivide = 0x0D, // Stack IN: dividend, divisor, OUT: number - sactionEquals = 0x0E, // Stack IN: number, number, OUT: bool - sactionLess = 0x0F, // Stack IN: number, number, OUT: bool - sactionAnd = 0x10, // Stack IN: bool, bool, OUT: bool - sactionOr = 0x11, // Stack IN: bool, bool, OUT: bool - sactionNot = 0x12, // Stack IN: bool, OUT: bool - sactionStringEquals = 0x13, // Stack IN: string, string, OUT: bool - sactionStringLength = 0x14, // Stack IN: string, OUT: number - sactionStringAdd = 0x21, // Stack IN: string, strng, OUT: string - sactionStringExtract = 0x15, // Stack IN: string, index, count, OUT: substring - sactionPush = 0x96, // type (BYTE), value (STRING or FLOAT) - sactionPop = 0x17, // no arguments - sactionToInteger = 0x18, // Stack IN: number, OUT: integer - sactionJump = 0x99, // offset (WORD) - sactionIf = 0x9D, // offset (WORD) Stack IN: bool - sactionCall = 0x9E, // Stack IN: name - sactionGetVariable = 0x1C, // Stack IN: name, OUT: value - sactionSetVariable = 0x1D, // Stack IN: name, value - sactionGetURL2 = 0x9A, // method (BYTE) Stack IN: url, window - sactionGotoFrame2 = 0x9F, // flags (BYTE) Stack IN: frame - sactionSetTarget2 = 0x20, // Stack IN: target - sactionGetProperty = 0x22, // Stack IN: target, property, OUT: value - sactionSetProperty = 0x23, // Stack IN: target, property, value - sactionCloneSprite = 0x24, // Stack IN: source, target, depth - sactionRemoveSprite = 0x25, // Stack IN: target - sactionTrace = 0x26, // Stack IN: message - sactionStartDrag = 0x27, // Stack IN: no constraint: 0, center, target - // constraint: x1, y1, x2, y2, 1, center, target - sactionEndDrag = 0x28, // no arguments - sactionStringLess = 0x29, // Stack IN: string, string, OUT: bool - sactionWaitForFrame2 = 0x8D, // skipCount (BYTE) Stack IN: frame - sactionRandomNumber = 0x30, // Stack IN: maximum, OUT: result - sactionMBStringLength = 0x31, // Stack IN: string, OUT: length - sactionCharToAscii = 0x32, // Stack IN: character, OUT: ASCII code - sactionAsciiToChar = 0x33, // Stack IN: ASCII code, OUT: character - sactionGetTime = 0x34, // Stack OUT: milliseconds since Player start - sactionMBStringExtract = 0x35, // Stack IN: string, index, count, OUT: substring - sactionMBCharToAscii = 0x36, // Stack IN: character, OUT: ASCII code - sactionMBAsciiToChar = 0x37, // Stack IN: ASCII code, OUT: character - - // Flash 5 Actions - sactionConstantPool = 0x88, // create a set of constant - sactionLess2 = 0x48, // Stack IN: number, number, OUT: bool - sactionEquals2 = 0x49, // Stack IN: number, number, OUT: bool - sactionCallMethod = 0x52, // Stack IN: string, string, number, [number] OUT: return value or undefined - - // Reserved for Quicktime - sactionQuickTime = 0xAA // I think this is what they are using... -}; - -enum { - kStringType = 0, - kFloatType = 1 -}; - -enum { - kSpritePosX = 0, - kSpritePosY, - kSpriteScaleX, - kSpriteScaleY, - kSpriteCurFrame, // (can only get but not set) - kSpriteTotalframes, // (can only get but not set) - kSpriteAlpha, // (a value between 0 and 100 %) - kSpriteVisible, // (if zero this means we don't hit test the object) - kSpriteWidth, // (can only get, but not set) - kSpriteHeight, // (can only get, but not set), - kSpriteRotate, - kSpriteTarget, - kSpriteLastFrameLoaded, - kSpriteName, - kSpriteDropTarget, - kSpriteURL, - kSpriteHighQuality, // (global) - kSpriteFocusRect, // (global) - kSpriteSoundBufferTime // (global) -}; - -// Mouse target conditions -enum { - stargetMouseEnter = 1, - stargetMouseExit = 2, - stargetMouseDown = 3, - stargetMouseUp = 4 -}; - -// Bitmap Alpha types -enum { - sbitsAlphaFlag = 0, // just a flag that the alpha channel is valid - sbitsAlphaCTab = 1, // alpha values for a color table - sbitsAlphaMask = 2 // a complete alpha mask for a jpeg image -}; - -// Server Packet Flags -enum { - spktObject = 0x00, // packet types - spktFrame = 0x01, - spktMask = 0x03, - - spktResend = 0x04, // flags for object packets - - spktSeekPoint = 0x04, // flags for frame packets - spktKeyFrame = 0x08 - - // Upper 4 bits are reserved for a sequence number -}; - -// Template Text Flags. -enum { - stextEnd = 0x00, // end of text flag - stextStyle = 0x80, // font style: followed by 8-bit flags (bold, italic, etc...) - stextFont = 0x81, // font identifier: followed by 16-bit font identifier - stextSize = 0x82, // font size: followed by 16-bit value in twips - stextColor = 0x83, // font color: followed by 32-bit RGB value - stextPosition = 0x84, // font position: followed by 8-bit position (normal, super or subscript) - stextKerning = 0x85, // font kerning: followed by 16-bit kerning value in twips - stextReserved1 = 0x86, // reserved value - stextReserved2 = 0x87, // reserved value - stextAlignment = 0x88, // paragraph alignment: followed by 8-bit alignment value - stextIndent = 0x89, // paragraph alignment: followed by 16-bit indent value in twips - stextLMargin = 0x8a, // paragraph left margin: followed by 16-bit left margin value in twips - stextRMargin = 0x8b, // paragraph right margin: followed by 16-bit right margin value in twips - stextLeading = 0x8c, // paragraph leading: followed by 16-bit leading value in twips - stextReserved3 = 0x8d, // reserved value - stextReserved4 = 0x8e, // reserved value - stextReserved5 = 0x8f // reserved value -}; - -// Template Text Style Flags -enum { - stextStyleNone = 0x00, - stextStyleBold = 0x01, - stextStyleItalic = 0x02 - // 6 bits left for expansion -}; - -// Template Text Position Values -enum { - stextPosNormal = 0x00, - stextPosSuperScript = 0x01, - stextPosSubScript = 0x02 -}; - -// Template Text Alignment Values -enum { - stextAlignLeft = 0x00, - stextAlignRight = 0x01, - stextAlignCenter = 0x02, - stextAlignJustify = 0x03 -}; - -// Template Text Flags -enum { - sfontFlagsBold = 0x01, - sfontFlagsItalic = 0x02, - sfontFlagsWideCodes = 0x04, - sfontFlagsWideOffsets = 0x08, - sfontFlagsANSI = 0x10, - sfontFlagsUnicode = 0x20, - sfontFlagsShiftJIS = 0x40, - sfontFlagsHasLayout = 0x80 -}; - -// GetURL2 methods -enum { - kHttpDontSend = 0, - kHttpSendUseGet = 1, - kHttpSendUsePost = 2, - kHttpLoadTarget = 0x40, - kHttpLoadVariables = 0x80 -}; - -// Edit Text Flags -enum { - seditTextFlagsHasFont = 0x0001, - seditTextFlagsHasMaxLength = 0x0002, - seditTextFlagsHasTextColor = 0x0004, - seditTextFlagsReadOnly = 0x0008, - seditTextFlagsPassword = 0x0010, - seditTextFlagsMultiline = 0x0020, - seditTextFlagsWordWrap = 0x0040, - seditTextFlagsHasText = 0x0080, - seditTextFlagsUseOutlines = 0x0100, - seditTextFlagsBorder = 0x0800, - seditTextFlagsNoSelect = 0x1000, - seditTextFlagsHasLayout = 0x2000 -}; - -// Drag constrants -enum { - sdragFromPoint = 0, - sdragFromCenter = 1 -}; -enum { - sdragNoConstraint = 0, - sdragRectConstraint = 1 -}; - -#endif diff --git a/toonz/sources/common/tvrender/tflash.cpp b/toonz/sources/common/tvrender/tflash.cpp index 67f2973..d4ed7a8 100644 --- a/toonz/sources/common/tvrender/tflash.cpp +++ b/toonz/sources/common/tvrender/tflash.cpp @@ -13,8 +13,6 @@ #include "trasterimage.h" #include "tsimplecolorstyles.h" #include "tcolorfunctions.h" -#include "F3SDK.h" -#include "FFixed.h" #include "tsop.h" #include "tropcm.h" #include "tsweepboundary.h" @@ -165,243 +163,6 @@ public: TImageP m_img; }; -class FlashColorStyle -{ -public: - TPixel m_color; - double m_thickness; - U32 m_id; - FlashColorStyle(TPixel color, double thickness, U32 id) - : m_color(color), m_thickness(thickness), m_id(id) {} -}; - -class TFlash::Imp -{ -public: - //double m_totMem; - bool m_supportAlpha; - int m_tw; - UCHAR m_version; - SCOORD m_sCoord1; - bool m_loaderAdded; - TAffine m_globalScale; - //typedef triple FlashImageData; - typedef vector FrameData; - FObjCollection m_tags; - FDTSprite *m_currSprite; - int m_currDepth; - int m_frameRate; - int m_currFrameIndex; - int m_lx, m_ly; - //ouble cameradpix, cameradpiy, inchFactor; - const TPalette *m_currPalette; - int m_soundRate; - Tiio::SwfWriterProperties m_properties; - - bool m_maskEnabled; - bool m_isMask; - - bool m_keepImages; - - std::list m_polylinesArray; - //std::set m_currentEdgeArray; - - TPixel32 m_lineColor; - double m_thickness; - - PolyStyle m_polyData; - //vector m_currentBgStyle; - int m_regionDepth; - int m_strokeCount; - /*TPixel32 m_fillColor; - TAffine m_fillMatrix; - TRaster32P m_texture; - GradientType m_gradientType; - TPixel32 m_gradientColor1, m_gradientColor2;*/ - //std::ofstream m_of; - - TAffine m_affine; - vector m_matrixStack; - map m_imagesMap; - map m_imagesScaleMap; - map m_edgeMap; - map m_texturesMap; - map m_autocloseMap; - map> m_strokeMap; - - vector m_outlines; - TPixel m_currStrokeColor; - //std::set m_outlineColors; - - FrameData *m_frameData; - FrameData *m_oldFrameData; - //bool m_notClipped; - vector m_sound; - int m_soundSize; - vector m_soundBuffer; - int m_soundOffset; - TVectorImageP m_currMask; - - vector *> m_toBeDeleted; - vector m_quadsToBeDeleted; - vector m_strokesToBeDeleted; - void drawPolygon(const vector &poly, bool isOutline); - int setFill(FDTDefineShape3 *shape); - inline FMatrix *affine2Matrix(const TAffine &aff); - void drawHangedObjects(); - void setStyles(const list &polylines, - vector &lineStyleID, vector &fillStyle1ID, vector &fillStyle2ID, - FDTDefineShape3 *polygon); - - U32 findStyle(const PolyStyle &p, std::map &idMap, FDTDefineShape3 *polygon); - void addEdge(const TEdge &e, TPointD &p0, TPointD &p1); - void addNewEdge(const TEdge &e); - //void closeRegion(int numEdges); - - void drawHangedOutlines(); - - void addAutoclose(biPoint &bp, int edgeIndex); - - inline TPoint toTwips(const TPointD &p) { return TPoint((int)(m_tw * p.x), (int)(m_tw * (-p.y))); } - - ~Imp() - { - clearPointerContainer(m_toBeDeleted); - clearPointerContainer(m_quadsToBeDeleted); - clearPointerContainer(m_strokesToBeDeleted); - if (m_oldFrameData) - delete m_oldFrameData; - - while (!m_soundBuffer.empty()) { - delete[] * m_soundBuffer.rbegin(); - m_soundBuffer.pop_back(); - } - } - - //=================================================================== - - /* - l'inizializzazione di m_currDepth e' 3 poiche' si riservanola depth 1 - per la clipcamera e la depth 2 per l'eventuale bottone (non visibile) - del play non automatico -*/ - Imp(int lx, int ly, int frameCount, int frameRate, TPropertyGroup *properties, bool keepImages) - : m_version(4), m_tags(), m_currSprite(0), m_currDepth(3), m_frameRate(frameRate), m_currFrameIndex(-1), m_lx(lx), m_ly(ly), m_currPalette(0), m_maskEnabled(false), m_isMask(false), m_polylinesArray(), m_lineColor(TPixel32::Black), m_thickness(0), m_polyData(), m_regionDepth(0), m_strokeCount(0), m_affine(), m_matrixStack(), m_imagesMap(), m_imagesScaleMap(), m_edgeMap(), m_texturesMap(), m_autocloseMap(), m_strokeMap(), m_outlines(), m_currStrokeColor(0, 0, 0, 0), m_frameData(0), m_oldFrameData(0) - //, m_notClipped(true) - , - m_sound(), m_soundSize(0), m_soundBuffer(), m_currMask(), m_toBeDeleted(), m_quadsToBeDeleted(), m_strokesToBeDeleted(), m_soundOffset(0), m_loaderAdded(false), m_globalScale(), m_keepImages(keepImages), m_supportAlpha(true), m_soundRate(c_soundRate) - //, m_totMem(0) - - //, m_of("c:\\temp\\boh.txt") - - { - m_tags.AddFObj(new FCTFrameLabel(new FString("DigitalVideoRm"))); - - if (properties) - m_properties.setProperties(properties); - //m_currentBgStyle.push_back(PolyStyle()); - - m_tw = 16384 / tmax(m_lx, m_ly); - if (m_tw > 20) - m_tw = 20; - Tw = m_tw; - m_sCoord1 = m_tw; - //addCameraClip(); - if (!m_properties.m_autoplay.getValue() && !m_properties.m_preloader.getValue()) - addPause(); - } - - void drawSubregions(TFlash *tf, const TRegion *r, const TPalette *palette); - void doDrawPolygon(list &polylines, int clippedShapes = 0); - int drawSegments(const vector segmentArray, bool isGradientColor); - int drawquads(const vector quadsArray); - int drawRectangle(const TRectD &rect); - int drawPolyline(vector &poly); - int drawEllipse(const TPointD ¢er, double radiusX, double radiusY); - void drawDot(const TPointD ¢er, double radius); - - void buildRegion(TFlash *tf, const TVectorImageP &vi, int regionIndex); - void buildStroke(TFlash *tf, const TVectorImageP &vi, int strokeIndex); - - //void addCameraClip(int index); - void writeFrame(TFlash *tf, bool isLast, int frameCountLoader, bool lastScene); - U16 getTexture(const PolyStyle &p, int &lx, int &ly); - - void addSoundToFrame(bool isLast); - - void addActionStop(); - void addLoader(); - void addSkipLoader(int jumpToFrame); - void addPause(); - void beginMask(); - void endMask(); - void addUrlLink(string url); - USHORT buildImage(const TImageP vi, TFlash *tf, double &scaleFactor, bool isMask); - USHORT buildVectorImage(const TVectorImageP &img, TFlash *tf, double &scaleFactor, bool isMask); - USHORT buildRasterImage(const TImageP rimg, TFlash *tf); - bool drawOutline(TStroke *s, bool separeDifferentColors = true); - inline void addEdgeStraightToShape(FDTDefineShape3 *shape, int x, int y); - inline void addEdgeStraightToShape(FDTDefineShape3 *shape, const TPoint &p); -}; - -//=================================================================== - -void TFlash::setSoundRate(int soundrate) -{ - m_imp->m_soundRate = soundrate; -} - -//=================================================================== - -void TFlash::enableAlphaChannelForRaster(bool supportAlpha) -{ - m_imp->m_supportAlpha = supportAlpha; -} - -//=================================================================== -namespace -{ -inline void addShape(FDTDefineShape3 *polygon, bool newStyle, bool lStyle, - bool fillStyle1, bool fillStyle0, bool move, int x, int y, - int style0, int style1, int lineStyle) -{ - polygon->AddShapeRec(new FShapeRecChange(newStyle, lStyle, fillStyle1, fillStyle0, move, - x, y, style0, style1, lineStyle, 0, 0)); -} - -inline void addShape(FDTDefineShape3 *polygon, bool newStyle, bool lStyle, - bool fillStyle1, bool fillStyle0, bool move, TPoint *p, - int style0, int style1, int lineStyle) -{ - polygon->AddShapeRec(new FShapeRecChange(newStyle, lStyle, fillStyle1, fillStyle0, move, - p ? p->x : 0, p ? p->y : 0, style0, style1, lineStyle, 0, 0)); -} -} - -//=================================================================== - -inline void TFlash::Imp::addEdgeStraightToShape(FDTDefineShape3 *shape, int x, int y) -{ - if (x == 0 && y == 0) - return; - - //m_of<< "ADD STRAIGHT LINE: "< 65535 || abs(y) > 65535) //flash non sa scrivere segmenti piu' lunghi di cosi', spezzo - { - shape->AddShapeRec(new FShapeRecEdgeStraight((x + 1) / 2, (y + 1) / 2)); - shape->AddShapeRec(new FShapeRecEdgeStraight(x / 2, y / 2)); - } else - shape->AddShapeRec(new FShapeRecEdgeStraight(x, y)); -} - -inline void TFlash::Imp::addEdgeStraightToShape(FDTDefineShape3 *shape, const TPoint &p) -{ - addEdgeStraightToShape(shape, p.x, p.y); -} - -//------------------------------------------------------------------- - double computeAverageThickness(const TStroke *s) { int count = s->getControlPointCount(); @@ -419,148 +180,6 @@ double computeAverageThickness(const TStroke *s) return resThick / (s->getControlPointCount() - 4); } -//------------------------------------------------------------------- - -inline FMatrix *TFlash::Imp::affine2Matrix(const TAffine &aff) -{ - if (aff != TAffine()) { - bool hasA11OrA22, hasA12OrA21; - - hasA11OrA22 = hasA12OrA21 = (aff.a12 != 0 || aff.a21 != 0); - if (!hasA12OrA21) - hasA11OrA22 = !areAlmostEqual(aff.det(), 1.0, 1e-3); - return new FMatrix(hasA11OrA22, FloatToFixed(aff.a11), FloatToFixed(aff.a22), - hasA12OrA21, FloatToFixed(-aff.a21), FloatToFixed(-aff.a12), - (TINT32)tround(aff.a13 * m_tw), -(TINT32)tround(aff.a23 * m_tw)); - } else - return 0; -} - -//------------------------------------------------------------------- - -int TFlash::Imp::drawSegments(const vector segmentArray, bool isGradientColor) -{ - int i; - assert(m_currSprite); - - if (segmentArray.empty()) - return 0; - - TPointD firstPoint = segmentArray[0].getP0(); - - FDTDefineShape3 *polygon = new FDTDefineShape3(); - - U32 lineStyleID1, lineStyleID2, lineStyleID4; - lineStyleID1 = polygon->AddLineStyle((int)m_thickness * m_tw, new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, m_lineColor.m)); - if (isGradientColor) { - lineStyleID2 = polygon->AddLineStyle((int)m_thickness * m_tw, new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, int(0.50 * (m_lineColor.m)))); - //U32 lineStyleID3 = polygon->AddLineStyle(m_tw, new FColor(m_color.r, m_color.g, m_color.b, int(0.25*(m_color.m)))); - lineStyleID4 = polygon->AddLineStyle((int)m_thickness * m_tw, new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, int(0.125 * (m_lineColor.m)))); - } - polygon->FinishStyleArrays(); - - TRectD box; - box.x0 = firstPoint.x; - box.x1 = firstPoint.x; - box.y0 = firstPoint.y; - box.y1 = firstPoint.y; - - for (i = 0; i < (int)segmentArray.size(); i++) { - box += segmentArray[i].getBBox(); - TPoint p0 = convert(segmentArray[i].getP0()); - TPoint dp = convert(segmentArray[i].getP1()) - p0; - TPoint p((int)(m_tw * p0.x), (int)(-m_tw * p0.y)); - addShape(polygon, false, isGradientColor || (i == 0), false, false, true, &p, 0, - 0, (isGradientColor || (i == 0)) ? lineStyleID1 : 0); - - if (isGradientColor) - addEdgeStraightToShape(polygon, 5 * dp.x, -5 * dp.y); - else { - addEdgeStraightToShape(polygon, (int)(m_tw * dp.x), (int)(m_tw * -dp.y)); - continue; - } - - addShape(polygon, false, true, false, false, false, 0, 0, 0, lineStyleID2); - - addEdgeStraightToShape(polygon, 5 * dp.x, -5 * dp.y); - - addShape(polygon, false, true, false, false, false, 0, 0, 0, lineStyleID4); - - addEdgeStraightToShape(polygon, 5 * dp.x, -5 * dp.y); - } - - polygon->AddShapeRec(new FShapeRecEnd()); - polygon->setBounds(new FRect((int)(m_tw * box.x0), -(int)(m_tw * box.y0), (int)(m_tw * box.x1), -(int)(m_tw * box.y1))); - - m_tags.AddFObj(polygon); - - FCTPlaceObject2 *placePolygon = new FCTPlaceObject2(false, // ~ _hasClipDepth - false, true, false, - m_currDepth++, polygon->ID(), affine2Matrix(m_affine), 0, 0, 0, 0 /**/); - - m_currSprite->AddFObj(placePolygon); - return polygon->ID(); -} - -//------------------------------------------------------------------- - -int TFlash::Imp::drawquads(const vector quadsArray) -{ - int i; - assert(m_currSprite); - if (quadsArray.empty()) - return 0; - - TPointD firstPoint = quadsArray[0].getP0(); - - TRectD box; - box.x0 = firstPoint.x; - box.x1 = firstPoint.x; - box.y0 = firstPoint.y; - box.y1 = firstPoint.y; - - for (i = 0; i < (int)quadsArray.size(); i++) - box += quadsArray[i].getBBox(); - - FDTDefineShape3 *polygon = new FDTDefineShape3(new FRect((int)(m_tw * box.x0), -(int)(m_tw * box.y0), (int)(m_tw * box.x1), -(int)(m_tw * box.y1))); - - U32 lineStyleID; - lineStyleID = polygon->AddLineStyle(m_tw, new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, m_lineColor.m)); - - polygon->FinishStyleArrays(); - - for (i = 0; i < (int)quadsArray.size(); i++) { - TPoint p0 = toTwips(quadsArray[i].getP0()); - - addShape(polygon, false, i == 0, false, false, true, &p0, 0, 0, (i == 0) ? lineStyleID : 0); - - TPoint dp1 = convert((quadsArray[i].getP1() - quadsArray[i].getP0())); - TPoint dp2 = convert((quadsArray[i].getP2() - quadsArray[i].getP1())); - - if ((dp1 == TPoint())) { - if (dp2 == TPoint()) - continue; - addEdgeStraightToShape(polygon, (int)(m_tw * dp2.x), (int)(m_tw * -dp2.y)); - } else if ((dp2 == TPoint())) - addEdgeStraightToShape(polygon, (int)(m_tw * dp1.x), (int)(m_tw * -dp1.y)); - else - polygon->AddShapeRec(new FShapeRecEdgeCurved((int)(m_tw * dp1.x), (int)(m_tw * -dp1.y), (int)(m_tw * dp2.x), (int)(m_tw * -dp2.y))); - } - - polygon->AddShapeRec(new FShapeRecEnd()); - - m_tags.AddFObj(polygon); - - FCTPlaceObject2 *placePolygon = new FCTPlaceObject2(false, // ~ _hasClipDepth - false, true, false, - m_currDepth++, polygon->ID(), affine2Matrix(m_affine), 0, 0, 0, 0 /**/); - - m_currSprite->AddFObj(placePolygon); - return polygon->ID(); -} - -//------------------------------------------------------------------- - void putquads(const TStroke *s, double w0, double w1, vector &quads) { int chunkIndex0, chunkIndex1, i; @@ -602,252 +221,6 @@ void computeOutlineBoundary(vector &outlines, list &po //------------------------------------------------------------------- -void TFlash::Imp::drawHangedObjects() -{ - //int i=0; - - if (!m_outlines.empty()) - computeOutlineBoundary(m_outlines, m_polylinesArray, m_currStrokeColor); - - m_currStrokeColor = TPixel::Transparent; - //m_outlineColors.clear(); - - if (!m_polylinesArray.empty()) { - doDrawPolygon(m_polylinesArray, false); - - std::list::iterator it; - for (it = m_polylinesArray.begin(); it != m_polylinesArray.end(); ++it) - if (it->m_toBeDeleted) - clearPointerContainer(it->m_quads); - m_polylinesArray.clear(); - m_edgeMap.clear(); - m_autocloseMap.clear(); - m_strokeMap.clear(); - } - - clearPointerContainer(m_strokesToBeDeleted); -} - -//------------------------------------------------------------------- - -int TFlash::Imp::drawPolyline(vector &poly) -{ - TRect box(1000, 1000, -1000, -1000); - - int i; - - FDTDefineShape3 *polyLine = new FDTDefineShape3(); - U16 id = polyLine->ID(); - - U32 fillID = setFill(polyLine); - - U32 lineStyleID = 0; - - if (m_thickness > 0) - lineStyleID = polyLine->AddLineStyle((int)(m_thickness * m_tw), new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, m_lineColor.m)); - - polyLine->FinishStyleArrays(); - - TPointD currP = TPointD(m_tw * poly[0].x, -m_tw * poly[0].y); - TPoint oldIntCurrP, intCurrP = convert(currP); - - addShape(polyLine, false, lineStyleID != 0, false, fillID != 0, true, - &intCurrP, fillID, 0, lineStyleID); - - poly.push_back(poly.front()); //con le approssimazioni,le poly chiuse potrebbero non esserlo - for (i = 0; i < (int)poly.size() - 1; i++) { - currP += TPointD(m_tw * (+poly[i + 1].x - poly[i].x), m_tw * (-poly[i + 1].y + poly[i].y)); - oldIntCurrP = intCurrP; - intCurrP = convert(currP); - if (intCurrP != oldIntCurrP) - addEdgeStraightToShape(polyLine, intCurrP.x - oldIntCurrP.x, intCurrP.y - oldIntCurrP.y); - - if (intCurrP.x > box.x1) - box.x1 = intCurrP.x; - if (intCurrP.x < box.x0) - box.x0 = intCurrP.x; - if (intCurrP.y > box.y1) - box.y1 = intCurrP.y; - if (intCurrP.y < box.y0) - box.y0 = intCurrP.y; - } - poly.pop_back(); //ritolgo, per non alterare il vettore in ingresso alla funzione - - polyLine->AddShapeRec(new FShapeRecEnd()); - polyLine->setBounds(new FRect(box.x0, box.y0, box.x1, box.y1)); - m_tags.AddFObj(polyLine); - - FCTPlaceObject2 *placePoly = new FCTPlaceObject2(false, false, true, false, - m_currDepth++, id, affine2Matrix(m_affine), 0, 0, 0, 0); - - m_currSprite->AddFObj(placePoly); - return id; -} - -//------------------------------------------------------------------- - -int TFlash::Imp::drawRectangle(const TRectD &rect) -{ - TRect box = convert(TRectD(rect.x0 * m_tw, rect.y0 * m_tw, rect.x1 * m_tw, rect.y1 * m_tw)); - - FDTDefineShape3 *rectangle = new FDTDefineShape3(new FRect(box.x0, box.y0, box.x1, box.y1)); - U16 id = rectangle->ID(); - - U32 fillID = setFill(rectangle); - - U32 lineStyleID = 0; - - if (m_thickness > 0) - lineStyleID = rectangle->AddLineStyle((int)(m_thickness * m_tw), new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, m_lineColor.m)); - - rectangle->FinishStyleArrays(); - - addShape(rectangle, false, true, false, fillID != 0, true, - box.x0, -box.y0, fillID, 0, lineStyleID); - - addEdgeStraightToShape(rectangle, box.x1 - box.x0, 0); - addEdgeStraightToShape(rectangle, 0, -box.y1 + box.y0); - addEdgeStraightToShape(rectangle, -box.x1 + box.x0, 0); - addEdgeStraightToShape(rectangle, 0, box.y1 - box.y0); - rectangle->AddShapeRec(new FShapeRecEnd()); - - m_tags.AddFObj(rectangle); - - FCTPlaceObject2 *placeRectangle = new FCTPlaceObject2(false, false, true, false, - m_currDepth++, id, affine2Matrix(m_affine), 0, 0, 0, 0); - - m_currSprite->AddFObj(placeRectangle); - return id; -} - -//------------------------------------------------------------------- - -//------------------------------------------------------------------- - -U16 TFlash::Imp::getTexture(const PolyStyle &p, int &lx, int &ly) -{ - assert(p.m_type == Texture); - assert(p.m_texture->getPixelSize() == 4); - lx = p.m_texture->getLx(), ly = p.m_texture->getLy(); - - std::map::iterator it = m_texturesMap.find(p.m_texture.getPointer()); - if (it != m_texturesMap.end()) - return (*it).second; - - assert(p.m_texture->getWrap() == lx); - - std::vector *buffer = new std::vector(); - m_toBeDeleted.push_back(buffer); - Tiio::createJpg(*buffer, p.m_texture, m_properties.m_jpgQuality.getValue()); - FDTDefineBitsJPEG2 *bitmap = new FDTDefineBitsJPEG2((UCHAR *)&(*buffer)[0], buffer->size()); - - m_tags.AddFObj(bitmap); - m_texturesMap[p.m_texture.getPointer()] = bitmap->ID(); - //delete bufout; - return bitmap->ID(); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::drawDot(const TPointD ¢er, double radius) -{ - FlashPolyline quads; - quads.m_lineStyle.m_type = Centerline; - quads.m_lineStyle.m_thickness = radius * 1.5; - quads.m_lineStyle.m_color1 = (m_polyData.m_color1 == TPixel::Transparent) ? m_lineColor : m_polyData.m_color1; - - //quads.m_lineStyle.m_isRegion = false; - //quads.m_lineStyle.m_isHole = false; - - int x = (int)((m_tw * center.x) + 0.5); - x += 3; - TPointD aux = TPointD((double)x / m_tw, center.y); - - quads.m_quads.push_back((TQuadratic *)new TQuadratic(center, 0.5 * (center + aux), aux)); - m_polylinesArray.push_back(quads); -} - -//------------------------------------------------------------------- - -int TFlash::Imp::drawEllipse(const TPointD ¢er, double radiusX, double radiusY) -{ - int xmin = (int)(m_tw * (center.x - radiusX)); // x coordinate of the upper left corner of the bounding rectangle - int ymin = (int)(m_tw * (-center.y - radiusY)); // y coordinate of the upper left corner of the bounding rectangle - int xmax = (int)(m_tw * (center.x + radiusX)); // x coordinate of the bottom right corner of the bounding rectangle - int ymax = (int)(m_tw * (-center.y + radiusY)); // y coordinate of the bottom right corner of the bounding rectangle - int dx = xmax - xmin; // dx is width diameter - int dy = ymax - ymin; // dy is height diameter - - // connect a serie of curves to draw the circle - int c1dx = (int)(0.1465 * dx); - int c1dy = (int)(0.1465 * dy); - int c2dx = (int)(0.2070 * dx); - int c2dy = (int)(0.2070 * dy); - - if (c1dx == 0 || c1dy == 0 || c2dx == 0 || c2dy == 0) - return 0; - - FDTDefineShape3 *ellipse = new FDTDefineShape3(new FRect(xmin, ymin, xmax, ymax)); - - U16 ellipseID = ellipse->ID(); - U32 fillID = setFill(ellipse); - - U32 lineStyleID = 0; - if (m_thickness > 0) - lineStyleID = ellipse->AddLineStyle((int)(2 * m_thickness * m_tw), - new FColor(m_lineColor.r, m_lineColor.g, m_lineColor.b, m_lineColor.m)); - - ellipse->FinishStyleArrays(); - - addShape(ellipse, false, lineStyleID > 0, false, fillID != 0, true, - xmax, -(int)(m_tw * center.y), fillID, 0, lineStyleID); - - ellipse->AddShapeRec(new FShapeRecEdgeCurved(0, -c2dy, -c1dx, -c1dy)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(-c1dx, -c1dy, -c2dx, 0)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(-c2dx, 0, -c1dx, c1dy)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(-c1dx, c1dy, 0, c2dy)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(0, c2dy, c1dx, c1dy)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(c1dx, c1dy, c2dx, 0)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(c2dx, 0, c1dx, -c1dy)); - ellipse->AddShapeRec(new FShapeRecEdgeCurved(c1dx, -c1dy, 0, -c2dy)); - - //TPoint dp1 = convert(m_tw*(outPolyline[0]->getP0()-outPolyline.back()->getP2())); - - ellipse->AddShapeRec(new FShapeRecEnd()); - - m_tags.AddFObj(ellipse); - FCTPlaceObject2 *placePolygon = new FCTPlaceObject2(false, // ~ _hasClipDepth - false, true, false, - m_currDepth++, ellipseID, affine2Matrix(m_affine), 0, 0, 0, 0 /**/); - - m_currSprite->AddFObj(placePolygon); - return ellipseID; -} -//------------------------------------------------------------------- -int TFlash::Imp::setFill(FDTDefineShape3 *shape) -{ - if (m_polyData.m_type == Texture) { - int lx, ly; - U16 texId = getTexture(m_polyData, lx, ly); - - FMatrix *app = affine2Matrix(m_polyData.m_matrix * TScale(2048.0 / lx, 2048.0 / ly)); - return shape->AddFillStyle(new FFillStyleBitmap(true, texId, app)); - } else if (m_polyData.m_type == LinearGradient || m_polyData.m_type == RadialGradient) { - FGradient *grad = new FGradient(); - FGradRecord *gradRec1 = new FGradRecord(0, new FColor(m_polyData.m_color1.r, m_polyData.m_color1.g, m_polyData.m_color1.b, m_polyData.m_color1.m)); - FGradRecord *gradRec2 = new FGradRecord(255, new FColor(m_polyData.m_color2.r, m_polyData.m_color2.g, m_polyData.m_color2.b, m_polyData.m_color2.m)); - grad->Add(gradRec1); - grad->Add(gradRec2); - return shape->AddFillStyle(new FFillStyleGradient(m_polyData.m_type == LinearGradient, affine2Matrix(m_polyData.m_matrix * TScale(10.0)), grad)); - } else if (m_polyData.m_type == Solid) { - FColor *color1 = new FColor(m_polyData.m_color1.r, m_polyData.m_color1.g, m_polyData.m_color1.b, m_polyData.m_color1.m); - return shape->AddSolidFillStyle(color1); - } - return 0; -} - -//------------------------------------------------------------------- - bool PolyStyle::operator==(const PolyStyle &p) const { if (m_type != p.m_type) @@ -908,421 +281,48 @@ bool PolyStyle::operator<(const PolyStyle &p) const //------------------------------------------------------------------- -U32 TFlash::Imp::findStyle(const PolyStyle &p, std::map &idMap, - FDTDefineShape3 *polygon) +void computeQuadChain(const TEdge &e, + vector &quadArray, vector &toBeDeleted) { - U32 styleID = 0; - std::map::iterator it; - it = idMap.find(p); + int chunk_b, chunk_e, chunk = -1; + double t_b, t_e, w0, w1; + TThickQuadratic *q_b = 0, *q_e = 0; + TThickQuadratic dummy; + bool reversed = false; - if (it != idMap.end()) - return (*it).second; - else { - switch (p.m_type) { - case Centerline: { - FColor *color = new FColor(p.m_color1.r, p.m_color1.g, - p.m_color1.b, p.m_color1.m); - int thickness = (int)(2 * p.m_thickness * m_tw); - if (p.m_thickness > 0 && thickness == 0) - thickness = 1; + if (e.m_w0 > e.m_w1) { + reversed = true; + w0 = e.m_w1; + w1 = e.m_w0; + } else { + w0 = e.m_w0; + w1 = e.m_w1; + } - styleID = polygon->AddLineStyle(thickness, color); - } - CASE Solid: - { - if (p.m_color1.m == 0) - styleID = 0; - else { - FColor *color = new FColor(p.m_color1.r, p.m_color1.g, - p.m_color1.b, p.m_color1.m); - styleID = polygon->AddSolidFillStyle(color); - } - } - CASE Texture: - { - try { - int lx, ly; - U16 texId = getTexture(p, lx, ly); - FMatrix *app = affine2Matrix(p.m_matrix * TScale(2048.0 / lx, 2048.0 / ly)); - styleID = polygon->AddFillStyle(new FFillStyleBitmap(true, texId, app)); - } catch (TException &) { - FColor *color = new FColor(0, 0, 0, 255); - styleID = polygon->AddSolidFillStyle(color); - } - } - CASE RadialGradient: - { - FGradient *grad = new FGradient(); - //FGradRecord *gradRec1 = new FGradRecord(0, new FColor(p.m_color1.r, p.m_color1.g, p.m_color1.b, p.m_color1.m)); - //FGradRecord *gradRec2 = new FGradRecord(255, new FColor(p.m_color2.r, p.m_color2.g, p.m_color2.b, p.m_color2.m)); - int fac = (int)(127.0 - 0.56 * p.m_smooth); - assert(fac >= 0 && fac < 128); - FGradRecord *gradRec1 = new FGradRecord(fac, new FColor(p.m_color1.r, p.m_color1.g, p.m_color1.b, p.m_color1.m)); - FGradRecord *gradRec2 = new FGradRecord(255 - fac, new FColor(p.m_color2.r, p.m_color2.g, p.m_color2.b, p.m_color2.m)); - grad->Add(gradRec1); - grad->Add(gradRec2); - styleID = polygon->AddFillStyle(new FFillStyleGradient(false, affine2Matrix(p.m_matrix * TScale(15.0)), grad)); - } - CASE LinearGradient: - { - FGradient *grad = new FGradient(); - FGradRecord *gradRec1 = new FGradRecord(0, new FColor(p.m_color1.r, p.m_color1.g, p.m_color1.b, p.m_color1.m)); - FGradRecord *gradRec2 = new FGradRecord(255, new FColor(p.m_color2.r, p.m_color2.g, p.m_color2.b, p.m_color2.m)); - grad->Add(gradRec1); - grad->Add(gradRec2); - styleID = polygon->AddFillStyle(new FFillStyleGradient(true, affine2Matrix(p.m_matrix * TScale(10.0)), grad)); - } - DEFAULT: + if (w0 == 0.0) + chunk_b = 0; + else { + if (e.m_s->getChunkAndT(w0, chunk, t_b)) assert(false); - } - idMap[p] = styleID; - return styleID; + q_b = new TThickQuadratic(); + toBeDeleted.push_back(q_b); + e.m_s->getChunk(chunk)->split(t_b, dummy, *q_b); + chunk_b = chunk + 1; } -} -//------------------------------------------------------------------- - -void TFlash::Imp::setStyles(const list &polylines, - vector &lineStyleID, vector &fillStyle1ID, vector &fillStyle2ID, FDTDefineShape3 *polygon) -{ - int i; - std::list::const_iterator it, itOld; - - std::map idMap; - - for (i = 0, it = polylines.begin(); it != polylines.end(); ++i, itOld = it, ++it) { - if (it->m_lineStyle.m_type == None) - lineStyleID[i] = 0; - else if (i > 0 && it->m_lineStyle == itOld->m_lineStyle) - lineStyleID[i] = lineStyleID[i - 1]; - else - lineStyleID[i] = findStyle(it->m_lineStyle, idMap, polygon); - - if (it->m_fillStyle1.m_type == None) - fillStyle1ID[i] = 0; - else if (i > 0 && it->m_fillStyle1 == itOld->m_fillStyle1) - fillStyle1ID[i] = fillStyle1ID[i - 1]; - else - fillStyle1ID[i] = findStyle(it->m_fillStyle1, idMap, polygon); - - if (it->m_fillStyle2.m_type == None) - fillStyle2ID[i] = 0; - else if (i > 0 && it->m_fillStyle2 == itOld->m_fillStyle2) - fillStyle2ID[i] = fillStyle2ID[i - 1]; - else - fillStyle2ID[i] = findStyle(it->m_fillStyle2, idMap, polygon); - } -} - -//------------------------------------------------------------------- - -TPoint drawPoint(const TQuadratic *poly, FDTDefineShape3 *polygon, double radius, TRect &box) -{ - TPointD center = poly->getP0(); - int xmin = (int)(Tw * (center.x - radius)); // x coordinate of the upper left corner of the bounding rectangle - int ymin = (int)(Tw * (-center.y - radius)); // y coordinate of the upper left corner of the bounding rectangle - int xmax = (int)(Tw * (center.x + radius)); // x coordinate of the bottom right corner of the bounding rectangle - int ymax = (int)(Tw * (-center.y + radius)); // y coordinate of the bottom right corner of the bounding rectangle - int dx = xmax - xmin; // dx is width diameter - int dy = ymax - ymin; // dy is height diameter - - // connect a serie of curves to draw the circle - int c1dx = (int)(0.1465 * dx); - int c1dy = (int)(0.1465 * dy); - int c2dx = (int)(0.2070 * dx); - int c2dy = (int)(0.2070 * dy); - - if (c1dx == 0 || c1dy == 0 || c2dx == 0 || c2dy == 0) - return TPoint(); - - if (xmax > box.x1) - box.x1 = xmax; - if (xmin < box.x0) - box.x0 = xmin; - if (ymax > box.y1) - box.y1 = ymax; - if (ymin < box.y0) - box.y0 = ymin; - - //polygon->AddShapeRec(new FShapeRecEdgeCurved(dp1.x, -dp1.y, dp2.x, -dp2.y)); - // - - addShape(polygon, false, true, false, false, true, - xmax, (int)(Tw * -center.y), 0, 0, 0); - - polygon->AddShapeRec(new FShapeRecEdgeCurved(0, -c2dy, -c1dx, -c1dy)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(-c1dx, -c1dy, -c2dx, 0)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(-c2dx, 0, -c1dx, c1dy)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(-c1dx, c1dy, 0, c2dy)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(0, c2dy, c1dx, c1dy)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(c1dx, c1dy, c2dx, 0)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(c2dx, 0, c1dx, -c1dy)); - polygon->AddShapeRec(new FShapeRecEdgeCurved(c1dx, -c1dy, 0, -c2dy)); - - return TPoint(xmax, (int)(Tw * -center.y)); -} - -//------------------------------------------------------------------- -inline void updateBBox(TRect &box, const TPoint &p) -{ - if (p.x > box.x1) - box.x1 = p.x; - if (p.x < box.x0) - box.x0 = p.x; - if (p.y > box.y1) - box.y1 = p.y; - if (p.y < box.y0) - box.y0 = p.y; -} - -void TFlash::Imp::doDrawPolygon(list &polylines, int clippedShapes) -{ - assert(m_currSprite); - assert(!polylines.empty()); - - FDTDefineShape3 *polygon = new FDTDefineShape3(); - U16 polygonID = polygon->ID(); - - //U32 fillID = 0; - - /* -if (isOutline || isRegion) - fillID = ((clippedShapes>0)?polygon->AddSolidFillStyle( new FColor(0, 0, 0)):setFill(polygon)); -*/ - - std::map> idMap; - - vector fillStyle1ID(polylines.size()); - vector fillStyle2ID(polylines.size()); - vector lineStyleID(polylines.size()); - - int i, j; - setStyles(polylines, lineStyleID, fillStyle1ID, fillStyle2ID, polygon); - polygon->FinishStyleArrays(); - - std::list::iterator itOld, it = polylines.begin(), it_e = polylines.end(); - - for (i = 0; it != it_e; ++i, ++it) //le maschere non vengono bene con regioni con fill2 opaco e fill1 trasparente. le giro - if (fillStyle2ID[i] != 0 && fillStyle1ID[i] == 0) { - fillStyle1ID[i] = fillStyle2ID[i]; - fillStyle2ID[i] = 0; - vector &v = (*it).m_quads; - std::reverse(v.begin(), v.end()); - for (j = 0; j < (int)v.size(); j++) { - v[j] = new TQuadratic(v[j]->getP2(), v[j]->getP1(), v[j]->getP0()); - m_quadsToBeDeleted.push_back(v[j]); - } - } - - TPoint lastPoint, firstPoint = toTwips(polylines.front().m_quads[0]->getP0()); - - TPoint currP = TPoint(firstPoint.x, firstPoint.y); - TRect box; - box.x0 = firstPoint.x; - box.x1 = firstPoint.x; - box.y0 = firstPoint.y; - box.y1 = firstPoint.y; - - //const PolyStyle& p = polylines.front().m_fillStyle1; - - //assert(firstPoint.x!=0 && firstPoint.y!=0); - - U32 currLineStyle = 0, currFillStyle1 = 0, currFillStyle2 = 0; - - //if (lineStyleID[0]!=0 && (isOutline||p.m_isRegion)) - currLineStyle = lineStyleID[0]; - - //if (fillStyle1ID[0]!=0 && (isOutline||p.m_isRegion)) - currFillStyle1 = fillStyle1ID[0]; - //if (fillStyle2ID[0]!=0 && p.m_isRegion) - currFillStyle2 = fillStyle2ID[0]; - - //m_of << "DRAW POLYGON da (" << firstPoint.x<< ", "<m_skip) //m_of << " SKIPPOOOOO! " < &poly = it->m_quads; - firstPoint = toTwips(poly[0]->getP0()); - lastPoint = toTwips(poly.back()->getP2()); - /* m_of << " POLYLINE # da ( " - < 0) { - //faccio una move se il salto e' sensato...evito di mettere inutili addShapeRec nell'swf per renderlo piu' piccolo... - - bool isMove = (currP != firstPoint); - - //bool isMove = (currP.x-firstPoint.x)<-20 || (currP.x-firstPoint.x)>20||(currP.y-firstPoint.y)<-20||(currP.y-firstPoint.y)>20; - currP = firstPoint; - - updateBBox(box, currP); - - bool isLineStyle = (lineStyleID[j] != currLineStyle); - - if (isLineStyle) - currLineStyle = lineStyleID[j]; - - bool isFillStyle1 = (fillStyle1ID[j] != currFillStyle1); //se sto passando da una regione a una linea, devo mettere a zero lo stile di fill! - if (isFillStyle1) - currFillStyle1 = fillStyle1ID[j]; - - bool isFillStyle2 = (fillStyle2ID[j] != currFillStyle2); //se sto passando da una regione a una linea, devo mettere a zero lo stile di fill! - if (isFillStyle2) - currFillStyle2 = fillStyle2ID[j]; - assert(firstPoint.x != 0 || firstPoint.y != 0); - - if (isMove || isLineStyle || isFillStyle1 || isFillStyle2) - addShape(polygon, false, isLineStyle, isFillStyle2, isFillStyle1, isMove, &firstPoint, - currFillStyle1, currFillStyle2, currLineStyle); - } - - for (i = 0; i < (int)poly.size(); i++) { - if (i > 0) { - TPoint dp = toTwips(poly[i]->getP0()) - toTwips(poly[i - 1]->getP2()); - if (dp.x != 0 || dp.y != 0) { - addEdgeStraightToShape(polygon, dp); - currP.x += dp.x; - currP.y += dp.y; - } - } - - if (!it->m_isPoint) { - TPoint dp1 = toTwips(poly[i]->getP1()) - toTwips(poly[i]->getP0()); - TPoint dp2 = toTwips(poly[i]->getP2()) - toTwips(poly[i]->getP1()); - if (dp1 == dp2) - addEdgeStraightToShape(polygon, dp1 + dp2); - else if (dp1 == TPoint(0, 0)) - addEdgeStraightToShape(polygon, dp2); - else if (dp2 == TPoint(0, 0)) - addEdgeStraightToShape(polygon, dp1); - else - polygon->AddShapeRec(new FShapeRecEdgeCurved(dp1.x, dp1.y, dp2.x, dp2.y)); - - currP.x += dp1.x + dp2.x; - currP.y += dp1.y + dp2.y; - //m_of<<"CURRPOINT: ("<m_lineStyle.m_thickness, box); - currLineStyle = 0; - } - - updateBBox(box, currP); - } - - if (poly.size() != 1 && currP != lastPoint) { - addEdgeStraightToShape(polygon, lastPoint - currP); - currP.x += lastPoint.x - currP.x; - currP.y += lastPoint.y - currP.y; - //m_of<<"AGGIUNTO RACCORDO!CURRPOINT: ("<AddShapeRec(new FShapeRecEnd()); - - box = box.enlarge((int)(m_thickness * m_tw) + 1000); - - polygon->setBounds(new FRect(box.x0, box.y0, box.x1, box.y1)); - m_tags.AddFObj(polygon); - //m_of<< "aggiungo poly " <ID()<< " a depth "< 0, // ~ _hasClipDepth - false, true, false, - m_currDepth, polygonID, - affine2Matrix(m_affine), 0, 0, 0, - (clippedShapes > 0) ? m_currDepth + clippedShapes : 0 /**/); - - m_currDepth++; - m_currSprite->AddFObj(placePolygon); -} - -//------------------------------------------------------------------- -#ifdef LEVO -void TFlash::Imp::addCameraClip(int index) -{ - m_notClipped = false; - FRect *clipRectBounds = new FRect(0, 0, m_lx * m_tw, m_ly * m_tw); //coordinate values are in TWIPS - - FDTDefineShape3 *clipRectangle = new FDTDefineShape3(clipRectBounds); - - FColor black = FColor(0, 0, 0); - - U32 blackfillID = clipRectangle->AddSolidFillStyle(new FColor(black)); - clipRectangle->FinishStyleArrays(); - addShape(clipRectangle, false, true, true, false, true, 0, 0, blackfillID, 0); - - addEdgeStraightToShape(clipRectangle, 0, m_ly * m_tw); - addEdgeStraightToShape(clipRectangle, m_lx * m_tw, 0); - addEdgeStraightToShape(clipRectangle, 0, -m_ly * m_tw); - addEdgeStraightToShape(clipRectangle, -m_lx * m_tw, 0); - clipRectangle->AddShapeRec(new FShapeRecEnd()); - - // la depth e' 1 perche' riservata per la camera - m_tags.InsertFObj(index, new FCTPlaceObject2(true, false, true, false, 1, - clipRectangle->ID(), 0, 0, 0, 0, (U16)60000 /**/)); - m_tags.InsertFObj(index, clipRectangle); -} -#endif -//------------------------------------------------------------------- - -void computeQuadChain(const TEdge &e, - vector &quadArray, vector &toBeDeleted) -{ - int chunk_b, chunk_e, chunk = -1; - double t_b, t_e, w0, w1; - TThickQuadratic *q_b = 0, *q_e = 0; - TThickQuadratic dummy; - bool reversed = false; - - if (e.m_w0 > e.m_w1) { - reversed = true; - w0 = e.m_w1; - w1 = e.m_w0; - } else { - w0 = e.m_w0; - w1 = e.m_w1; - } - - if (w0 == 0.0) - chunk_b = 0; - else { - if (e.m_s->getChunkAndT(w0, chunk, t_b)) - assert(false); - q_b = new TThickQuadratic(); - toBeDeleted.push_back(q_b); - e.m_s->getChunk(chunk)->split(t_b, dummy, *q_b); - chunk_b = chunk + 1; - } - - if (w1 == 1.0) - chunk_e = e.m_s->getChunkCount() - 1; - else { - if (e.m_s->getChunkAndT(w1, chunk_e, t_e)) - assert(false); - q_e = new TThickQuadratic(); - toBeDeleted.push_back(q_e); - if (chunk_e == chunk) { - if (q_b) { - t_e = q_b->getT(e.m_s->getChunk(chunk)->getPoint(t_e)); - q_b->split(t_e, *q_e, dummy); - } else - e.m_s->getChunk(0)->split(t_e, *q_e, dummy); + if (w1 == 1.0) + chunk_e = e.m_s->getChunkCount() - 1; + else { + if (e.m_s->getChunkAndT(w1, chunk_e, t_e)) + assert(false); + q_e = new TThickQuadratic(); + toBeDeleted.push_back(q_e); + if (chunk_e == chunk) { + if (q_b) { + t_e = q_b->getT(e.m_s->getChunk(chunk)->getPoint(t_e)); + q_b->split(t_e, *q_e, dummy); + } else + e.m_s->getChunk(0)->split(t_e, *q_e, dummy); if (!reversed) quadArray.push_back(q_e); @@ -1366,1441 +366,4 @@ void computeQuadChain(const TEdge &e, //------------------------------------------------------------------- -namespace -{ -inline bool isOuterEdge(const FlashPolyline &p) -{ - bool isTrasp1 = p.m_fillStyle1.m_type == None || (p.m_fillStyle1.m_type == Solid && p.m_fillStyle1.m_color1.m == 0); - bool isTrasp2 = p.m_fillStyle2.m_type == None || (p.m_fillStyle2.m_type == Solid && p.m_fillStyle2.m_color1.m == 0); - return (isTrasp1 ^ isTrasp2); -} -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addAutoclose(biPoint &bp, int edgeIndex) -{ - std::map::iterator it = m_autocloseMap.end(); - - bp.revert(); - it = m_autocloseMap.find(bp); - bp.revert(); - if (it != m_autocloseMap.end()) - (*it).second->m_fillStyle2 = m_polyData; - else if ((it = m_autocloseMap.find(bp)) != m_autocloseMap.end()) - (*it).second->m_fillStyle1 = m_polyData; - else { - FlashPolyline quadArray1; - quadArray1.m_depth = m_regionDepth * m_strokeCount + edgeIndex + 1; - quadArray1.m_fillStyle1 = m_polyData; - quadArray1.m_quads.push_back(new TQuadratic(bp.p0, .5 * (bp.p0 + bp.p1), bp.p1)); - m_quadsToBeDeleted.push_back(quadArray1.m_quads.back()); - - m_polylinesArray.push_back(quadArray1); - m_autocloseMap[bp] = &m_polylinesArray.back(); - } - - if (m_isMask && it != m_autocloseMap.end()) - (*it).second->m_skip = !isOuterEdge(*(*it).second); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addNewEdge(const TEdge &e) -{ - m_polylinesArray.push_back(FlashPolyline()); - FlashPolyline &quadArray = m_polylinesArray.back(); - m_edgeMap[e] = &m_polylinesArray.back(); - - computeQuadChain(e, quadArray.m_quads, m_quadsToBeDeleted); - - quadArray.m_fillStyle1 = m_polyData; - quadArray.m_depth = m_regionDepth * m_strokeCount + e.m_index + 1; - - if (e.m_s->getAverageThickness() > 0) { - assert(m_currPalette); - - TStrokeProp *prop = e.m_s->getProp(); - /////questo codice stava dentro tstroke::getprop///////// - TColorStyle *style = m_currPalette->getStyle(e.m_s->getStyle()); - if (!style->isStrokeStyle() || style->isEnabled() == false) - prop = 0; - else { - if (!prop || style != prop->getColorStyle()) { - e.m_s->setProp(style->makeStrokeProp(e.m_s)); - prop = e.m_s->getProp(); - } - } - - /////////// - if (prop) { - OutlineStrokeProp *aux = dynamic_cast(prop); - - if (aux) { - const TSolidColorStyle *st = dynamic_cast(aux->getColorStyle()); - if (st) { - quadArray.m_lineStyle.m_color1 = st->getMainColor(); - quadArray.m_lineStyle.m_type = Centerline; - quadArray.m_lineStyle.m_thickness = e.m_s->getAverageThickness(); - } - } - } - //quadArray.m_lineStyle.m_color1 = e.m_s->getStyle(); - } - if (quadArray.m_fillStyle1.m_type == None) { - //assert(clippedShapes>0); - quadArray.m_fillStyle1.m_type = Solid; - quadArray.m_fillStyle1.m_color1 = TPixel::Black; - } -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addEdge(const TEdge &e, TPointD &pBegin, TPointD &pEnd) -{ - TPointD auxP = pEnd; - - TEdge aux = e; - tswap(aux.m_w0, aux.m_w1); - std::map::iterator it; - //PolyStyle style = m_polyData; - std::stack auxs; - - if ((it = m_edgeMap.find(aux)) != m_edgeMap.end()) { - (*it).second->m_fillStyle2 = m_polyData; - - pBegin = (*it).second->m_quads.back()->getP2(); - pEnd = (*it).second->m_quads.front()->getP0(); - } else if ((it = m_edgeMap.find(e)) != m_edgeMap.end()) { - (*it).second->m_fillStyle1 = m_polyData; - - pBegin = (*it).second->m_quads.front()->getP0(); - pEnd = (*it).second->m_quads.back()->getP2(); - } else { - addNewEdge(e); - pBegin = m_polylinesArray.back().m_quads[0]->getP0(); - pEnd = m_polylinesArray.back().m_quads.back()->getP2(); - } - - if (m_isMask && it != m_edgeMap.end()) //per fare le maschere, non metto gli edge che hanno entrambe le sponde non trasparenti - (*it).second->m_skip = !isOuterEdge(*(*it).second); - - if (!areTwEqual(auxP, pBegin)) { - biPoint tmp(auxP, pBegin); - addAutoclose(tmp, e.m_index); - } - - if (m_properties.m_lineQuality.getValue() == ConstantLines) { - std::map>::iterator it; - - it = m_strokeMap.find(e.m_s); - if (it != m_strokeMap.end()) { - std::set::iterator it1; - wChunk wc(tmin(e.m_w0, e.m_w1), tmax(e.m_w0, e.m_w1)); - - it1 = it->second.find(wc); - if (it1 == it->second.end()) - it->second.insert(wc); - } else { - std::set chunkSet; - chunkSet.insert(wChunk(tmin(e.m_w0, e.m_w1), tmax(e.m_w0, e.m_w1))); - m_strokeMap[e.m_s] = chunkSet; - } - } -} - -//------------------------------------------------------------------- - -void TFlash::Imp::drawSubregions(TFlash *tf, const TRegion *r, const TPalette *palette) -{ - int i; - - //m_currentBgStyle.push_back(m_polyData); - m_regionDepth++; - - for (i = 0; i < (int)r->getSubregionCount(); i++) { - TRegion *region = r->getSubregion(i); - TRegionProp *prop = region->getProp(/*palette*/); - ////prima questo codice stava dentro tregion::getprop//// - int styleId = region->getStyle(); - //if (styleId) - { - TColorStyle *style = palette->getStyle(styleId); - if (!style->isRegionStyle() || style->isEnabled() == false) - prop = 0; - else if (!prop || style != prop->getColorStyle()) { - region->setProp(style->makeRegionProp(region)); - prop = region->getProp(); - } - - //////// - if (prop) - prop->draw(*tf); - - //m_currentBgStyle.push_back(m_polyData); - drawSubregions(tf, region, palette); - //m_currentBgStyle.pop_back(); - } - } - m_regionDepth--; - - //m_currentBgStyle.pop_back(); -} -//------------------------------------------------------------------- - -bool comparevector(const FlashPolyline &p1, const FlashPolyline &p2) -{ - return p2.m_depth > p1.m_depth; -} - -//------------------------------------------------------------------- - -void TFlash::Imp::buildRegion(TFlash *tf, const TVectorImageP &vi, int regionIndex) -{ - TRegion *region = vi->getRegion(regionIndex); - TRectD rect = region->getBBox(); - double lx = rect.x1 - rect.x0; - double ly = rect.y1 - rect.y0; - if (lx < 0.5 || ly < 0.5) - return; - - TRegionProp *prop = region->getProp(); - - int styleId = region->getStyle(); - - TColorStyle *style = vi->getPalette()->getStyle(styleId); - - if (!style->isRegionStyle() || style->isEnabled() == false) - prop = 0; - else if (!prop || style != prop->getColorStyle()) { - region->setProp(style->makeRegionProp(region)); - prop = region->getProp(); - } - - tf->setThickness(0); - if (prop) - prop->draw(*tf); - - drawSubregions(tf, region, m_currPalette); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::buildStroke(TFlash *tf, const TVectorImageP &vi, int strokeIndex) -{ - TStroke *stroke = vi->getStroke(strokeIndex); - if (stroke->getBBox().isEmpty()) - return; - - TStrokeProp *prop = stroke->getProp(); - /////questo codice stava dentro tstroke::getprop///////// - TColorStyle *style = vi->getPalette()->getStyle(stroke->getStyle() /*m_imp->m_styleId*/); - if (!style->isStrokeStyle() || style->isEnabled() == false) - prop = 0; - else if (!prop || style != prop->getColorStyle()) { - stroke->setProp(style->makeStrokeProp(stroke)); - prop = stroke->getProp(); - } - - if (prop) - prop->draw(*tf); -} - -//------------------------------------------------------------------- - -USHORT TFlash::Imp::buildVectorImage(const TVectorImageP &_vi, TFlash *tf, double &scaleFactor, bool isMask) -{ - USHORT id; - int i; - const TPalette *oldPalette; - - assert(m_regionDepth == 0); - - m_strokeCount = _vi->getStrokeCount(); - - std::vector strokes; - for (i = 0; i < m_strokeCount; i++) - strokes.push_back(i); - - _vi->enableMinimizeEdges(false); - _vi->notifyChangedStrokes(strokes, vector()); - _vi->enableMinimizeEdges(true); - - TRectD box = _vi->getBBox(); - int dim = tmax(convert(box).getLx(), convert(box).getLy()); - - TVectorImageP vi; - if (dim * m_tw > 32767.0) { - scaleFactor = dim * m_tw / 32767.0; - vi = _vi->clone(); - vi->transform(TScale(1.0 / scaleFactor), true); - } else - vi = _vi; - - oldPalette = m_currPalette; - m_currPalette = vi->getPalette(); - - bool newSprite = false; - - if (m_currSprite == 0) //non e' un image pattern!!! - { - m_currSprite = new FDTSprite(); - m_currDepth = 1; - newSprite = true; - } - /*assert(m_currSprite==0); -m_currSprite = new FDTSprite(); -m_currDepth = 1;*/ - - tf->setThickness(0); - m_isMask = isMask; - if (!isMask) - for (i = 0; i < (int)vi->getStrokeCount(); i++) - vi->getStroke(i)->setAverageThickness((m_properties.m_lineQuality.getValue() == ConstantLines) ? computeAverageThickness(vi->getStroke(i)) : 0); - - UINT strokeIndex = 0; - int parentDepth = 0; - while (strokeIndex < vi->getStrokeCount()) // ogni ciclo di while fa un gruppo - { - FDTSprite *parentSprite = 0; - int currStrokeIndex = strokeIndex; - if (vi->isStrokeGrouped(currStrokeIndex) != 0) { - parentSprite = m_currSprite; - parentDepth = m_currDepth; - m_currSprite = new FDTSprite(); - m_currDepth = 0; - } - for (UINT regionIndex = 0; regionIndex < vi->getRegionCount(); regionIndex++) - if (vi->sameGroupStrokeAndRegion(currStrokeIndex, regionIndex)) - buildRegion(tf, vi, regionIndex); - - if (m_properties.m_lineQuality.getValue() != ConstantLines) - tf->drawHangedObjects(); - //else - m_polylinesArray.sort(comparevector); - - while (strokeIndex < vi->getStrokeCount() && vi->sameGroup(strokeIndex, currStrokeIndex)) { - if (!isMask) - buildStroke(tf, vi, strokeIndex); - strokeIndex++; - } - - if (isMask && vi->getRegionCount() == 0) //pezza:se non ci sono regioni, la maschera - //deve mostrare il nulla; per fare cio', metto - //un poligono posticcio(non mascherante, puro stroke - //centerline) nella sprite, altrimenti - //invece di non vedersi nulla si vede l' - //immagine mascherata completa.. - { - FlashPolyline quads; - TQuadratic qaux(TPointD(0, 0), TPointD(10, 10), TPointD(20, 20)); - quads.m_quads.push_back(&qaux); - m_polylinesArray.push_back(quads); - } - tf->drawHangedObjects(); - if (parentSprite) { - m_tags.AddFObj(m_currSprite); - parentSprite->AddFObj(new FCTPlaceObject2(false, // hasClipDepth - false, // hasRatio, - true, // hasCharId, - false, // hasMove, - parentDepth++, //depth - m_currSprite->ID(), //id - affine2Matrix(TAffine()), //matrix - 0, 0, 0, 0)); - - m_currSprite = parentSprite; - m_currDepth = parentDepth; - parentSprite = 0; - } - } - - id = m_currSprite->ID(); - - if (newSprite) { - m_currSprite->AddFObj(new FCTShowFrame()); - m_tags.AddFObj(m_currSprite); - m_currSprite = 0; - } - m_currPalette = oldPalette; - - return id; -} - -//------------------------------------------------------------------- - -USHORT TFlash::Imp::buildRasterImage(const TImageP img, TFlash *tf) -{ - if (m_currSprite) //e' un custom style - { - std::map::iterator it; - if (m_keepImages && (it = m_imagesMap.find(img.getPointer())) != m_imagesMap.end()) { - m_currSprite->AddFObj(new FCTPlaceObject2(false, // hasClipDepth - false, // hasRatio, - true, // hasCharId, - false, //i!=0, // hasMove, - m_currDepth++, it->second, affine2Matrix(m_affine), - 0, 0, 0, 0)); - - return 0; - } - } - - TToonzImageP tim = (TToonzImageP)img; - TRasterImageP rim = (TRasterImageP)img; - TRasterP ri; - - if (tim) { - TRaster32P raux(tim->getSize()); - TRop::convert(raux, tim->getRaster(), img->getPalette(), TRect(0, 0, tim->getSize().lx - 1, tim->getSize().ly - 1), false, true); - ri = raux; - } else if (!((TRaster32P)rim->getRaster())) { - TRaster32P raux(rim->getRaster()->getSize()); - TRop::convert(raux, rim->getRaster()); - ri = raux; - } else - ri = rim->getRaster(); - - //TImageWriter::save(TFilePath("C:\\temp\\flame.tif"), ri); - - int lx = ri->getLx(), ly = ri->getLy(), wrap = ri->getWrap(); - - /* -double dpix=72.,dpiy=72.; - -if (rim) - rim->getDpi(dpix,dpiy); -else - tim->getDpi(dpix,dpiy); - -if (dpix==0 && dpiy==0) -{ -dpix=cameradpix; -dpiy=cameradpiy; -} -*/ - - //const double factor = Stage::inch; - - //double unit = 100; - //int realLx = lx;//(int)(cameradpix * lx / dpix); - //int realLy = ly;//(int)(cameradpiy * ly / dpiy); - - std::vector *buffer = new std::vector(); - - //TRaster32P newRaster= TRop::copyAndSwapRBChannels(ri); - - //#ifdef TNZ_MACHINE_CHANNEL_ORDER_MRGB - - //TRaster32P newRaster= TRop::copyAndSwapRBChannels(ri); - //Tiio::createJpg(*buffer, newRaster, m_properties.m_jpgQuality.getValue()); - //#else - - Tiio::createJpg(*buffer, ri, m_properties.m_jpgQuality.getValue()); - m_toBeDeleted.push_back(buffer); - - //#endif - - int bitmapId; - if (m_supportAlpha) { - std::vector alphachannel(lx * ly); - - ri->lock(); - TPixel *auxin, *bufin = (TPixel *)ri->getRawData(); - - int i, j, count = 0; - for (i = 0; i < ly; i++) { - auxin = bufin + (ly - i - 1) * wrap; - for (j = 0; j < lx; j++, auxin++) - alphachannel[count++] = auxin->m; - } - ri->unlock(); - - U32 zippedAlphaSizeOut = (U32)(2 * ((alphachannel.size() * 1.1) + 12)); - std::vector *zippedAlphaChannel = new std::vector(zippedAlphaSizeOut); - compress(&(*zippedAlphaChannel)[0], (uLongf *)&zippedAlphaSizeOut, (const UCHAR *)&alphachannel[0], alphachannel.size()); - zippedAlphaChannel->resize(zippedAlphaSizeOut); - m_toBeDeleted.push_back(zippedAlphaChannel); - FDTDefineBitsJPEG3 *bitmap = new FDTDefineBitsJPEG3((U8 *)&(*buffer)[0], buffer->size(), &(*zippedAlphaChannel)[0], zippedAlphaSizeOut); - m_tags.AddFObj(bitmap); - bitmapId = bitmap->ID(); - } else { - FDTDefineBitsJPEG2 *bitmap = new FDTDefineBitsJPEG2((U8 *)&(*buffer)[0], buffer->size()); - m_tags.AddFObj(bitmap); - bitmapId = bitmap->ID(); - } - - // - //m_totMem += (buffer->size()/*+zippedAlphaChannel->size()*/)/1024.0; - - FRect *rectBounds = new FRect(-lx * m_sCoord1 / 2, -ly * m_sCoord1 / 2, lx * m_sCoord1 / 2, ly * m_sCoord1 / 2); - FDTDefineShape3 *rectangle = new FDTDefineShape3(rectBounds); - - FMatrix *matrix1 = new FMatrix(true, m_tw * Fixed1, m_tw * Fixed1, false, 0, 0, -(lx / 2) * m_sCoord1, -(ly / 2) * m_sCoord1); - FFillStyle *fill1 = new FFillStyleBitmap(false, bitmapId, matrix1); - - U32 fillStyle1_ID = rectangle->AddFillStyle(fill1); - - rectangle->FinishStyleArrays(); - addShape(rectangle, false, false, true, false, true, (lx / 2) * m_sCoord1, (ly / 2) * m_sCoord1, 0, - fillStyle1_ID, 0); - - addEdgeStraightToShape(rectangle, -lx * m_sCoord1, 0); - addEdgeStraightToShape(rectangle, 0, -ly * m_sCoord1); - addEdgeStraightToShape(rectangle, lx * m_sCoord1, 0); - addEdgeStraightToShape(rectangle, 0, ly * m_sCoord1); - rectangle->AddShapeRec(new FShapeRecEnd()); - - m_tags.AddFObj(rectangle); - - if (m_currSprite) { - //e' un custom style - - m_imagesMap[img.getPointer()] = rectangle->ID(); - - m_currSprite->AddFObj(new FCTPlaceObject2(false, // hasClipDepth - false, // hasRatio, - true, // hasCharId, - false, //i!=0, // hasMove, - m_currDepth++, rectangle->ID(), affine2Matrix(m_affine), - 0, 0, 0, 0)); - } - - return rectangle->ID(); - //delete bufout; -} - -//------------------------------------------------------------------- - -USHORT TFlash::Imp::buildImage(const TImageP img, TFlash *tf, double &scaleFactor, bool isMask) -{ - scaleFactor = 1.0; - - if (img->getType() == TImage::VECTOR) - return buildVectorImage((TVectorImageP)img, tf, scaleFactor, isMask); - else - return buildRasterImage(img, tf); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addSoundToFrame(bool isLast) -{ - if (!m_sound.empty()) { - TSoundTrackP sound = *m_sound.begin(); - if ((int)m_sound.size() == m_soundSize) { - bool is16Bit = (sound->getBitPerSample() == 16); - bool isStereo = (sound->getChannelCount() == 2); - UCHAR rate; - switch (sound->getSampleRate() / 5000) { - case 1: // 5k - rate = 0; - break; - case 2: // 11k - rate = 1; - break; - case 4: // 22k - rate = 2; - break; - case 8: // 44k - rate = 3; - break; - default: - rate = 0; - } - UCHAR format = 4 * (rate) + is16Bit * 2 + isStereo; - FDTSoundStreamHead2 *head = new FDTSoundStreamHead2( - format, c_soundCompression, rate, is16Bit, isStereo, (USHORT)sound->getSampleCount()); - m_tags.AddFObj(head); - } - int bytes = sound->getSampleCount() * sound->getSampleSize(); - U8 *aux = new U8[bytes]; - -#if TNZ_LITTLE_ENDIAN - memcpy(aux, sound->getRawData(), bytes); -#else //su mac, gli short vanno girati!! - int ii; - assert(c_soundBps == 16); - const U8 *buf = sound->getRawData(); - for (ii = 0; ii < (bytes & (~0x1)); ii += 2) - aux[ii] = buf[ii + 1], aux[ii + 1] = buf[ii]; -#endif - m_tags.AddFObj(new FDTSoundStreamBlock(bytes, aux)); - - m_soundBuffer.push_back(aux); - m_sound.erase(m_sound.begin()); - if (isLast) - m_sound.erase(m_sound.begin(), m_sound.end()); - } -} - -//------------------------------------------------------------------- -void TFlash::setGlobalScale(const TAffine &aff) -{ - m_imp->m_globalScale = aff; -} - -//------------------------------------------------------------------- - -void TFlash::Imp::writeFrame(TFlash *tf, bool isLast, int frameCountLoader, bool lastScene) -{ - if (!m_frameData) - return; - int oldSize = m_oldFrameData ? (int)m_oldFrameData->size() : -1; - int depth; - //bool firstTime = true; - - static bool loaderAdded = false; - bool insiderLoader = (frameCountLoader == 1); - int currTagIndex = m_tags.GetFObjCount() - 1; - //bool putCameraClip = false; - //aggiungo l'istruzione per evitare preloader se e' gia - //caricato - if (m_currFrameIndex == 1) { - if (m_properties.m_preloader.getValue() && frameCountLoader >= 1) - addSkipLoader(frameCountLoader + 1); - - if (m_properties.m_url.getValue().length() > 0) - addUrlLink(toString(m_properties.m_url.getValue())); - } - - if (m_currFrameIndex > m_soundOffset) - addSoundToFrame(isLast); - - double scaleFactor; - - std::map::iterator it; - bool lastOneIsNotMasked = true; - TImageP currMask = 0; - int currMaskDepth; - bool animatedPalette = false; - - for (depth = 0; depth < tmax((int)m_frameData->size(), oldSize); depth++) { - - FCXFormWAlpha *form = 0; - - if (depth < (int)m_frameData->size()) { - TImageP img = (*m_frameData)[depth].m_img; - - if ((*m_frameData)[depth].m_isMask) { - currMask = img; - currMaskDepth = depth; - lastOneIsNotMasked = true; - continue; - } else if ((*m_frameData)[depth].m_isMasked && lastOneIsNotMasked) { - //assert(currMask); - lastOneIsNotMasked = false; - int numMasked = 1; - while (depth + numMasked < (int)m_frameData->size() && (*m_frameData)[depth + numMasked].m_isMasked) - numMasked++; - if (m_oldFrameData && currMaskDepth < (int)m_oldFrameData->size()) - m_tags.AddFObj(new FCTRemoveObject2(currMaskDepth + 3)); - if (currMaskDepth < (int)m_frameData->size() && currMask) //&& - //(currMask->getType()!=TImage::VECTOR || ((TVectorImage*)currMask)->getRegionCount()>0)) - { - UINT id = buildImage(currMask, tf, scaleFactor, true); - assert(scaleFactor >= 1.0); - TAffine aff = TTranslation(0.5 * m_lx, -0.5 * m_ly) * m_globalScale * TScale(scaleFactor); - m_tags.AddFObj(new FCTPlaceObject2(true, // hasClipDepth - false, // hasRatio, - true, // hasCharId, - false, //i!=0, // hasMove, - currMaskDepth + 3, id, affine2Matrix(aff), - 0, 0, 0, currMaskDepth + 3 + numMasked)); - } - - } else if (!(*m_frameData)[depth].m_isMasked) - lastOneIsNotMasked = true; - TVectorImageP vimg = (TVectorImageP)img; - if (vimg) { - assert(vimg->getPalette()); - animatedPalette = vimg->getPalette()->isAnimated(); - } - } - - if (m_oldFrameData && depth < (int)m_oldFrameData->size() && depth < (int)m_frameData->size() && - (*m_frameData)[depth].m_img.getPointer() == (*m_oldFrameData)[depth].m_img.getPointer() && !animatedPalette) { - TImageP img = (*m_frameData)[depth].m_img; - const TColorFunction *ct = (*m_frameData)[depth].m_cf; - TColorFunction::Parameters p; - if (ct && ct->getParameters(p)) - form = new FCXFormWAlpha(1, 1, (TINT32)(p.m_mR * 256), (TINT32)(p.m_mG * 256), (TINT32)(p.m_mB * 256), (TINT32)(p.m_mM * 256), - (TINT32)(p.m_cR), (TINT32)(p.m_cG), (TINT32)(p.m_cB), (TINT32)(p.m_cM)); - - if ((*m_frameData)[depth].m_aff != (*m_oldFrameData)[depth].m_aff) { - std::map::iterator it1; - it1 = m_imagesScaleMap.find(img.getPointer()); - assert(it1 != m_imagesScaleMap.end()); - scaleFactor = (*it1).second; - - TAffine aff = TTranslation(0.5 * m_lx, -0.5 * m_ly) * m_globalScale * (*m_frameData)[depth].m_aff * TScale(scaleFactor); - /*if (m_notClipped && !putCameraClip) - { - TRectD box = aff*img->getBBox(); - if (box.x0<0 || -box.y1<0 || box.x1>m_lx || -box.y0>m_ly) - putCameraClip = true; - }*/ - m_tags.AddFObj(new FCTPlaceObject2(false, // hasClipDepth - false, // hasRatio, - false, // hasCharId, - true, //i!=0, // hasMove, - depth + 3, 0, affine2Matrix(aff), - form, 0, 0, 0)); - } - } else { - if (m_oldFrameData && depth < (int)m_oldFrameData->size()) - m_tags.AddFObj(new FCTRemoveObject2(depth + 3)); - if (depth < (int)m_frameData->size()) { - TImageP img = (*m_frameData)[depth].m_img; - const TColorFunction *cf = (*m_frameData)[depth].m_cf; - TColorFunction::Parameters p; - if (cf && cf->getParameters(p)) - form = new FCXFormWAlpha(1, 1, (TINT32)(p.m_mR * 256), (TINT32)(p.m_mG * 256), (TINT32)(p.m_mB * 256), (TINT32)(p.m_mM * 256), - (TINT32)(p.m_cR), (TINT32)(p.m_cG), (TINT32)(p.m_cB), (TINT32)(p.m_cM)); - it = m_keepImages ? m_imagesMap.find(img.getPointer()) : m_imagesMap.end(); - USHORT id; - if (it == m_imagesMap.end()) { - id = buildImage(img, tf, scaleFactor, false); - if (!animatedPalette) { - m_imagesMap[img.getPointer()] = id; - m_imagesScaleMap[img.getPointer()] = scaleFactor; - } - } else { - id = (*it).second; - std::map::iterator it1; - it1 = m_imagesScaleMap.find(img.getPointer()); - assert(it1 != m_imagesScaleMap.end()); - scaleFactor = (*it1).second; - } - assert(scaleFactor >= 1.0); - TAffine aff = TTranslation(0.5 * m_lx, -0.5 * m_ly) * m_globalScale * (*m_frameData)[depth].m_aff * TScale(scaleFactor); - /*if (m_notClipped && !putCameraClip) - { - TRectD box = img->getBBox(); - - box = aff*box; - - if (box.x0<0 || -box.y1<0 || box.x1>m_lx || -box.y0>m_ly) - putCameraClip = true; - }*/ - - /*Commento al seguente if: - questa cosa e' davvero FOLLE. C'era un baco per cui se facevi rewind - nel flash player mentre era in play restavano appese alcune immagini. - Dopo indagini e confronti con gli swf generati da flash mx, ho scoperto che , quando si fa place di una sprite - ad una certa depth, sostituendo un'altra sprite alla stessa depth, mx mette hasRatio=true con un valore - di ratio pari a 0x8!!!! Non capisco, ma lo faccio anch'io e funziona, don't ask me why. Vincenzo. */ - - int ratioVal = 0; - if (m_oldFrameData && (int)m_oldFrameData->size() > depth && ((*m_oldFrameData)[depth].m_img)) - ratioVal = 0x8; - - m_tags.AddFObj(new FCTPlaceObject2(false, // hasClipDepth - ratioVal > 0, // hasRatio, - true, // hasCharId, - false, //i!=0, // hasMove, - depth + 3, id, affine2Matrix(aff), - form, ratioVal, 0, 0)); - } - } - } - - //inserisce lo stop sull'ultimo frame - if (isLast && lastScene && !m_properties.m_looping.getValue()) { - addActionStop(); - //loaderAdded = false; - } - - m_tags.AddFObj(new FCTShowFrame()); - - //if (putCameraClip) - //addCameraClip(currTagIndex); - - //ho una sola scena => loader interno I frame oppure - //ci sono piu' scene => la I fa da loader - if (m_properties.m_preloader.getValue() && !m_loaderAdded && (insiderLoader || (isLast && frameCountLoader > 1))) { - for (depth = 0; depth < (int)m_frameData->size(); depth++) - m_tags.AddFObj(new FCTRemoveObject2(depth + 3)); - if (m_oldFrameData) - delete m_oldFrameData; - m_oldFrameData = m_frameData; - m_frameData = 0; - addLoader(); - m_tags.AddFObj(new FCTShowFrame()); - m_currFrameIndex++; - //inserisce lo stop al primo frame che segue il loader - if (!m_properties.m_autoplay.getValue() && loaderAdded && m_currFrameIndex == frameCountLoader + 1) - addPause(); - //m_properties.m_preloader = false; - m_loaderAdded = true; - } - //else if (!m_properties.m_autoplay.getValue()) - // addPauseAtStart(); - - if (m_frameData && isLast && m_currFrameIndex != 1) - for (depth = 0; depth < (int)m_frameData->size(); depth++) - m_tags.AddFObj(new FCTRemoveObject2(depth + 3)); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addActionStop() -{ - //construct an empty CTDoAction tag object - FCTDoAction *doAction = new FCTDoAction(); - - //add the stop action to the CTDoAction tag object - doAction->AddAction(new FActionStop()); - - //add the CTDoAction object to allTags - m_tags.AddFObj(doAction); -} - -//------------------------------------------------------------------- -void TFlash::Imp::addLoader() -{ - string target = ""; - //construct an empty CTDoAction tag object - FCTDoAction *doAction = new FCTDoAction(); - - doAction->AddAction(new FActionGotoFrame((U16)0)); - doAction->AddAction(new FActionPlay()); - - //add the CTDoAction object to allTags - m_tags.AddFObj(doAction); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addSkipLoader(int jumpToFrame) -{ - string target = ""; - //construct an empty CTDoAction tag object - FCTDoAction *doAction = new FCTDoAction(); - - //controlla se il file e' stato tutto caricato - doAction->AddAction(new FActionPush(new FString((U8 *)target.c_str()))); - doAction->AddAction(new FActionPush(7, FLOAT(12))); - doAction->AddAction(new FActionGetProperty()); - - doAction->AddAction(new FActionPush(new FString((U8 *)target.c_str()))); - doAction->AddAction(new FActionPush(7, FLOAT(5))); - doAction->AddAction(new FActionGetProperty()); - - doAction->AddAction(new FActionEquals2()); - doAction->AddAction(new FActionNot()); - doAction->AddAction(new FActionIf(5 + 1)); - doAction->AddAction(new FActionGotoFrame((U16)jumpToFrame)); - doAction->AddAction(new FActionPlay()); - - //add the CTDoAction object to allTags - m_tags.AddFObj(doAction); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addPause() -{ - addActionStop(); - - FRect *clipRectBounds = new FRect(0, 0, m_lx * m_tw, m_ly * m_tw); //coordinate values are in TWIPS - - FDTDefineShape3 *clipRectangle = new FDTDefineShape3(clipRectBounds); - - FColor black = FColor(0, 0, 0); - - U32 blackfillID = clipRectangle->AddSolidFillStyle(new FColor(black)); - clipRectangle->FinishStyleArrays(); - addShape(clipRectangle, false, true, true, false, true, 0, 0, blackfillID, 0); - - addEdgeStraightToShape(clipRectangle, 0, m_ly * m_tw); - addEdgeStraightToShape(clipRectangle, m_lx * m_tw, 0); - addEdgeStraightToShape(clipRectangle, 0, -m_ly * m_tw); - addEdgeStraightToShape(clipRectangle, -m_lx * m_tw, 0); - clipRectangle->AddShapeRec(new FShapeRecEnd()); - - m_tags.AddFObj(clipRectangle); - - FDTDefineButton2 *theButton = new FDTDefineButton2(0); //flag is 0 to indicate a push button - FMatrix *mx = new FMatrix(); - FCXFormWAlpha *cxf = new FCXFormWAlpha(false, false, 0, 0, 0, 0, 0, 0, 0, 0); - FButtonRecord2 *bRec = new FButtonRecord2(true, false, false, false, clipRectangle->ID(), 1, mx, cxf); - theButton->AddButtonRecord(bRec); - - //the button action - FActionCondition *ac = new FActionCondition(); - ac->AddCondition(OverDownToOverUp); - ac->AddActionRecord(new FActionPlay()); - theButton->AddActionCondition(ac); - - m_tags.AddFObj(theButton); - - FMatrix *matrix = new FMatrix(); - // la depth e' 2 perche' riservata per il bottone - FCTPlaceObject2 *placeButton = new FCTPlaceObject2(false, // ~ _hasClipDepth - true, true, false, - 2, theButton->ID(), matrix, 0, 0, 0, 0); - m_tags.AddFObj(placeButton); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::addUrlLink(const string _url) -{ - //addActionStop(); - - string url; - if (url.find("http") == -1) - url = "http://" + _url; - else - url = _url; - - FRect *clipRectBounds = new FRect(0, 0, m_lx * m_tw, m_ly * m_tw); //coordinate values are in TWIPS - - FDTDefineShape3 *clipRectangle = new FDTDefineShape3(clipRectBounds); - - FColor black = FColor(0, 0, 0, 0); - - U32 blackfillID = clipRectangle->AddSolidFillStyle(new FColor(black)); - clipRectangle->FinishStyleArrays(); - addShape(clipRectangle, false, true, true, false, true, 0, 0, blackfillID, 0); - - addEdgeStraightToShape(clipRectangle, 0, m_ly * m_tw); - addEdgeStraightToShape(clipRectangle, m_lx * m_tw, 0); - addEdgeStraightToShape(clipRectangle, 0, -m_ly * m_tw); - addEdgeStraightToShape(clipRectangle, -m_lx * m_tw, 0); - clipRectangle->AddShapeRec(new FShapeRecEnd()); - - m_tags.AddFObj(clipRectangle); - - FDTDefineButton2 *theButton = new FDTDefineButton2(0); //flag is 0 to indicate a push button - FMatrix *mx = new FMatrix(); - FCXFormWAlpha *cxf = new FCXFormWAlpha(false, false, 0, 0, 0, 0, 0, 0, 0, 0); - FButtonRecord2 *bRec = new FButtonRecord2(true, false, false, false, clipRectangle->ID(), 1, mx, cxf); - theButton->AddButtonRecord(bRec); - - //the button action - FActionCondition *ac = new FActionCondition(); - ac->AddCondition(OverDownToOverUp); - ac->AddActionRecord(new FActionGetURL(new FString(url.c_str()), new FString(""))); - theButton->AddActionCondition(ac); - - m_tags.AddFObj(theButton); - - FMatrix *matrix = new FMatrix(); - // la depth e' 2 perche' riservata per il bottone - FCTPlaceObject2 *placeButton = new FCTPlaceObject2(false, // ~ _hasClipDepth - true, true, false, - 2, theButton->ID(), matrix, 0, 0, 0, 0); - m_tags.AddFObj(placeButton); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::beginMask() -{ - //m_currMask = TVectorImageP(); - - m_currMask = new TVectorImage(); - m_currMask->setPalette(new TPalette()); -} - -//------------------------------------------------------------------- - -void TFlash::Imp::endMask() -{ - m_frameData->push_back(FlashImageData(TAffine(), m_currMask, 0, true, false)); - m_currMask = TVectorImageP(); -} - -//------------------------------------------------------------------- - -bool TFlash::Imp::drawOutline(TStroke *s, bool separeDifferentColors) -{ - if (m_polyData.m_color1 != m_currStrokeColor) { - //bool inserted = m_outlineColors.insert(m_polyData.m_color1).second; - if (!m_outlines.empty()) { - computeOutlineBoundary(m_outlines, m_polylinesArray, m_currStrokeColor); - } - if (!m_polylinesArray.empty() && (separeDifferentColors /* || !inserted*/)) //non posso accorpare strokes di colore diverso....flash macromedia non le importa bene! lo stronzo. - drawHangedObjects(); - m_currStrokeColor = m_polyData.m_color1; - } - m_outlines.push_back(s); - return true; -} - -//=================================================================== -TFlash::TFlash(int lx, int ly, int frameCount, int frameRate, TPropertyGroup *properties, bool keepImages) - : m_imp(new Imp(lx, ly, frameCount, frameRate, properties, keepImages)) -{ -} - -//------------------------------------------------------------------- - -TFlash::~TFlash() -{ - delete m_imp; -} - -//------------------------------------------------------------------- - -void TFlash::setBackgroundColor(const TPixel32 &bgColor) -{ - FCTSetBackgroundColor *background = - new FCTSetBackgroundColor(new FColor(bgColor.r, bgColor.g, bgColor.b)); - m_imp->m_tags.AddFObj(background); -} - -//------------------------------------------------------------------- - -void TFlash::setThickness(double thickness) -{ - m_imp->m_thickness = thickness; -} - -//------------------------------------------------------------------- - -void TFlash::setFillColor(const TPixel32 &color) -{ - m_imp->m_polyData.m_color1 = color; - m_imp->m_polyData.m_type = Solid; -} - -//------------------------------------------------------------------- - -void TFlash::setLineColor(const TPixel32 &color) -{ - m_imp->m_lineColor = color; -} - -//------------------------------------------------------------------- - -void TFlash::setTexture(const TRaster32P &texture) -{ - m_imp->m_polyData.m_type = Texture; - m_imp->m_polyData.m_texture = texture; -} - -//------------------------------------------------------------------- - -void TFlash::setGradientFill(bool isLinear, const TPixel &color1, const TPixel &color2, double smooth) -{ - m_imp->m_polyData.m_type = (isLinear) ? LinearGradient : RadialGradient; - m_imp->m_polyData.m_color1 = color1; - m_imp->m_polyData.m_color2 = color2; - m_imp->m_polyData.m_smooth = smooth; -} - -//------------------------------------------------------------------- - -void TFlash::setFillStyleMatrix(const TAffine &aff) -{ - m_imp->m_polyData.m_matrix = aff; -} - -//------------------------------------------------------------------- - -void TFlash::drawSegments(const vector segmentArray, bool isGradientColor) -{ - m_imp->drawSegments(segmentArray, isGradientColor); -} - -//------------------------------------------------------------------- - -void TFlash::drawquads(const vector quadArray) -{ - m_imp->drawquads(quadArray); -} - -//------------------------------------------------------------------- - -void TFlash::cleanCachedImages() -{ - m_imp->m_imagesMap.clear(); - m_imp->m_imagesScaleMap.clear(); - m_imp->m_texturesMap.clear(); -} - -//=================================================================== - -void TFlash::drawCenterline(const TStroke *s, bool drawAll) -{ - //vector quads; - int i; - double thickness; - - if (m_imp->m_thickness > 0) - thickness = m_imp->m_thickness; - else if (m_imp->m_properties.m_lineQuality.getValue() != ConstantLines) - thickness = computeAverageThickness(s); - else - thickness = s->getAverageThickness(); - - if (m_imp->m_lineColor.m == 0 || thickness == 0) - return; - - if (m_imp->m_properties.m_lineQuality.getValue() != ConstantLines && m_imp->m_lineColor != m_imp->m_currStrokeColor) { - drawHangedObjects(); - //m_imp->m_outlineColors.insert(m_imp->m_lineColor).second; - m_imp->m_currStrokeColor = m_imp->m_lineColor; - } - - FlashPolyline quads; - if (s->getChunkCount() == 1 && - norm2(m_imp->toTwips(s->getChunk(0)->getP2()) - m_imp->toTwips(s->getChunk(0)->getP0())) <= 4 //metto lo stile di fill: i punti si disegnano come cerchi - && thickness > 0) { - quads.m_isPoint = true; - quads.m_fillStyle1.m_type = Solid; - quads.m_fillStyle1.m_color1 = m_imp->m_lineColor; - } - - quads.m_lineStyle.m_type = Centerline; - quads.m_lineStyle.m_thickness = thickness; - quads.m_lineStyle.m_color1 = m_imp->m_lineColor; - - //quads.m_lineStyle.m_isRegion = false; - //quads.m_lineStyle.m_isHole = false; - - std::map>::iterator it = m_imp->m_strokeMap.end(); - - if (!drawAll) - it = m_imp->m_strokeMap.find(s); - - if (it == m_imp->m_strokeMap.end()) { - for (i = 0; i < s->getChunkCount(); i++) - quads.m_quads.push_back((TQuadratic *)s->getChunk(i)); - m_imp->m_polylinesArray.push_back(quads); - } else { - std::set::iterator it1; - double oldW1 = 0; - for (it1 = it->second.begin(); it1 != it->second.end(); it1++) { - if (it1->w0 > oldW1) { - putquads(s, oldW1, it1->w0, quads.m_quads); - m_imp->m_polylinesArray.push_back(quads); - quads.m_quads.clear(); - } - oldW1 = it1->w1; - } - if (oldW1 < 1.0) { - putquads(s, oldW1, 1.0, quads.m_quads); - m_imp->m_polylinesArray.push_back(quads); - quads.m_quads.clear(); - } - } -} -void TFlash::drawHangedObjects() -{ - m_imp->drawHangedObjects(); -} -//------------------------------------------------------------------- - -int TFlash::drawRectangle(const TRectD &rect) -{ - m_imp->drawHangedObjects(); - - vector v; - - v.push_back(rect.getP00()); - v.push_back(rect.getP01()); - v.push_back(rect.getP11()); - v.push_back(rect.getP10()); - - return m_imp->drawPolyline(v); -} - -//------------------------------------------------------------------- - -int TFlash::drawPolyline(vector &poly) -{ - m_imp->drawHangedObjects(); - - return m_imp->drawPolyline(poly); -} - -//------------------------------------------------------------------- - -void TFlash::drawPolygon(vector> &quads, int clippedShapes) -{ - m_imp->drawHangedObjects(); - - //std::list::iterator it = polylines.begin(), it_e = polylines.end(); - list polylines; - - for (int i = 0; i < (int)quads.size(); i++) { - polylines.push_back(FlashPolyline()); - polylines.back().m_quads = quads[i]; - polylines.back().m_fillStyle1 = m_imp->m_polyData; - } - - m_imp->doDrawPolygon(polylines, clippedShapes); -} - -//------------------------------------------------------------------- -void TFlash::drawDot(const TPointD ¢er, double radius) -{ - m_imp->drawDot(center, radius); -} - -//------------------------------------------------------------------- - -int TFlash::drawEllipse(const TPointD ¢er, double radiusX, double radiusY) -{ - m_imp->drawHangedObjects(); - - return m_imp->drawEllipse(center, radiusX, radiusY); -} - -//------------------------------------------------------------------- - -void TFlash::pushMatrix() -{ - m_imp->m_matrixStack.push_back(m_imp->m_affine); -} - -//------------------------------------------------------------------- - -void TFlash::popMatrix() -{ - assert(!m_imp->m_matrixStack.empty()); - m_imp->m_affine = m_imp->m_matrixStack.back(); - m_imp->m_matrixStack.pop_back(); -} - -//------------------------------------------------------------------- - -void TFlash::multMatrix(const TAffine &aff) -{ - m_imp->m_affine *= aff; -} - -//------------------------------------------------------------------- - -void TFlash::putSound(TSoundTrackP st, int offset) -{ - m_imp->m_soundSize = 0; - m_imp->m_sound.clear(); - - TSoundTrackP st1 = st; - - if (st1->getBitPerSample() != c_soundBps || - st1->isSampleSigned() != c_soundIsSigned || - st1->getChannelCount() != c_soundChannelNum) - st1 = TSop::convert(st, TSoundTrackFormat(m_imp->m_soundRate, c_soundBps, c_soundChannelNum, c_soundIsSigned)); - else if (st1->getSampleRate() != (UINT)m_imp->m_soundRate) - st1 = TSop::resample(st1, m_imp->m_soundRate); - - int frameCount = st1->getSampleCount() / (st1->getSampleRate() / m_imp->m_frameRate); - if (!frameCount) - return; - int averagePerFrame = st1->getSampleCount() / frameCount; - int sampleCount = st1->getSampleCount(); - TINT32 firstSample = 0; - m_imp->m_soundOffset = offset; - - while (sampleCount > 0) { - sampleCount -= averagePerFrame; - if (sampleCount >= 0) { - TSoundTrackP snd = st1->extract(firstSample, firstSample + averagePerFrame - 1); - m_imp->m_sound.push_back(snd); - firstSample += averagePerFrame; - } else { - //deversamente dalla documentazione anche x il raw data deve essere - //sempre lo stesso il numero di campioni per ogni blocco aggiunto - //allo streaming audio - TSoundTrackP snd = st1->extract(firstSample, st1->getSampleCount() - 1); - snd = TSop::insertBlank(snd, snd->getSampleCount(), abs(sampleCount)); - m_imp->m_sound.push_back(snd); - } - } - m_imp->m_soundSize = m_imp->m_sound.size(); -} - -//------------------------------------------------------------------- - -void TFlash::writeMovie(FILE *fp) -{ - //m_imp->writeFrame(this, true); - - //if (m_imp->m_putCameraClip) - // m_imp->addCameraClip(); - - if (m_imp->m_properties.m_isCompressed.getValue()) - m_imp->m_tags.CreateCompressedMovie(fp, - FRect(0, 0, m_imp->m_lx * m_imp->m_tw, - m_imp->m_ly * m_imp->m_tw), - m_imp->m_frameRate); - else - m_imp->m_tags.CreateMovie(fp, - FRect(0, 0, m_imp->m_lx * m_imp->m_tw, - m_imp->m_ly * m_imp->m_tw), - m_imp->m_frameRate, - m_imp->m_version); -} - -//------------------------------------------------------------------- -void TFlash::drawRegion(const TRegion &r, int clippedShapes) -{ - int i; - vector polylines; - TPointD firstPoint, lastPoint; - - if (clippedShapes > 0 || m_imp->m_isMask) { - if (clippedShapes > 0) - m_imp->drawHangedObjects(); - - //setFillColor(TPixel::Black); - } - - TPointD pBegin, pEnd, pBeginRegion; - - pEnd = r.getEdge(r.getEdgeCount() - 1)->m_s->getPoint(r.getEdge(r.getEdgeCount() - 1)->m_w1); - for (i = 0; i < (int)r.getEdgeCount(); i++) - m_imp->addEdge(*r.getEdge(i), pBegin, pEnd); - - //m_imp->closeRegion(r.getEdgeCount()); - - m_imp->m_regionDepth++; - - for (i = 0; i < (int)r.getSubregionCount(); i++) { - TRegion &rr = *r.getSubregion(i); - pEnd = rr.getEdge(0)->m_s->getPoint(rr.getEdge(0)->m_w0); - for (int j = rr.getEdgeCount() - 1; j >= 0; j--) { - TEdge *e = rr.getEdge(j); - tswap(e->m_w0, e->m_w1); - m_imp->addEdge(*e, pBegin, pEnd); - tswap(e->m_w0, e->m_w1); - } - } - - m_imp->m_regionDepth--; - - if (clippedShapes > 0) { - m_imp->doDrawPolygon(m_imp->m_polylinesArray, clippedShapes); - //clearPointerContainer(m_imp->m_polylinesArray); - m_imp->m_polylinesArray.clear(); - m_imp->m_edgeMap.clear(); - m_imp->m_strokeMap.clear(); - m_imp->m_autocloseMap.clear(); - } -} - -//------------------------------------------------------------------- - -USHORT TFlash::buildImage(const TImageP img, bool isMask) -{ - double scalefactor; - return m_imp->buildImage(img, this, scalefactor, isMask); - assert(scalefactor == 1.0); -} - -void TFlash::beginFrame(int frameIndex) -{ - m_imp->m_frameData = new TFlash::Imp::FrameData; - m_imp->m_currFrameIndex = frameIndex; - assert(m_imp->m_matrixStack.empty()); - m_imp->m_affine = TAffine(); -} - -//------------------------------------------------------------------- -int TFlash::endFrame(bool isLast, int frameCountLoader, bool lastScene) -{ - m_imp->writeFrame(this, isLast, frameCountLoader, lastScene); - if (m_imp->m_oldFrameData) - delete m_imp->m_oldFrameData; - m_imp->m_oldFrameData = m_imp->m_frameData; - m_imp->m_frameData = 0; - - //QString msg = "mem: " + QString::number(m_imp->m_totMem/1024.0)+"\n"; - //TSystem::outputDebug(msg.toStdString()); - return m_imp->m_currFrameIndex; -} - -//------------------------------------------------------------------- - -//void TFlash::addPauseAtStart() -//{ -// m_imp->addPauseAtStart(); -//} - -//------------------------------------------------------------------- - -void TFlash::enableMask() -{ - m_imp->m_maskEnabled = true; -} - -//------------------------------------------------------------------- - -void TFlash::disableMask() -{ - m_imp->m_maskEnabled = false; -} - -//------------------------------------------------------------------- - -void TFlash::beginMask() -{ - m_imp->beginMask(); -} - -//------------------------------------------------------------------- - -void TFlash::endMask() -{ - m_imp->endMask(); -} - -//------------------------------------------------------------------- -void TFlash::draw(const TImageP img, const TColorFunction *cf) -{ - //std::map::iterator it; - - if (m_imp->m_currMask) { - if (img->getType() == TImage::VECTOR) - m_imp->m_currMask->mergeImage((TVectorImageP)img, m_imp->m_affine); - } else if (img) - m_imp->m_frameData->push_back(FlashImageData(m_imp->m_affine, img, cf ? cf->clone() : 0, false, m_imp->m_maskEnabled)); -} - -//------------------------------------------------------------------- - -wstring TFlash::getLineQuality() -{ - return m_imp->m_properties.m_lineQuality.getValue(); -} - -//------------------------------------------------------------------- - -bool TFlash::drawOutline(TStroke *s) -{ - assert(m_imp->m_polyData.m_type == Solid); - - m_imp->drawHangedObjects(); - - TThickPoint p0 = s->getThickPoint(0.0), p1 = s->getThickPoint(1.0); - - if (tdistance(p0, p1) < (p0.thick + p1.thick)) //pezza infame!nelle curve che si autochiudono, lo sweepboundary fa casini. - //le splitto in due pezzi, e per poter metterli nello steso poligono - //senza vedere le sovrapposizioni cambio leggermente il colore al secondo....eh eh eh - { - TStroke *s0 = new TStroke(), *s1 = new TStroke(); - - s->split(0.5, *s0, *s1); - m_imp->drawOutline(s0, true); - int aux = m_imp->m_polyData.m_color1.b; - m_imp->m_polyData.m_color1.b = (m_imp->m_polyData.m_color1.b == 255) ? 254 : m_imp->m_polyData.m_color1.b + 1; - - //m_imp->drawHangedObjects(); - m_imp->drawOutline(s1, false); - m_imp->m_polyData.m_color1.b = aux; - //m_imp->drawHangedObjects(); - m_imp->m_strokesToBeDeleted.push_back(s0); - m_imp->m_strokesToBeDeleted.push_back(s1); - return true; - } - - return m_imp->drawOutline(s, true); -} -//------------------------------------------------------------- diff --git a/toonz/sources/include/tflash.h b/toonz/sources/include/tflash.h index 340a1da..74ff81f 100644 --- a/toonz/sources/include/tflash.h +++ b/toonz/sources/include/tflash.h @@ -50,251 +50,60 @@ public: }; } -//========================================================= -//! This class is an interface to Flash File Format (SWF) SDK. -/*! - Macromedia Flash File Format (SWF) SDK is an interface to write SWF files. - It includes a set of C++ classes that mirror the tag structure of SWF. - There is a C++ class for each tag that SWF defines. - There are classes for creating movies, frames, circles, rectangles, text and bitmaps. - */ + class DVAPI TFlash { class Imp; Imp *m_imp; public: - static const wstring ConstantLines; - static const wstring MixedLines; - static const wstring VariableLines; - - //enum LineQuality{_ConstantLines=0, _MixedLines, _VariableLines}; - - /* - struct PropertiesForTab - { - LineQuality m_lineQuality; - bool m_isCompressed; - bool m_stopAtStart; - bool m_looping; - bool m_loader; - int m_jpgQuality; - std::wstring m_url; - PropertiesForTab() - : m_lineQuality(_ConstantLines), m_isCompressed(true), m_stopAtStart(false), m_looping(true) - , m_loader(false), m_jpgQuality(90), m_url(std::wstring()) {} - - PropertiesForTab(LineQuality q, - bool isCompr, - bool stopAtStart, - bool looping, - bool loader, - int m_jpgQ, - std::wstring url) - : m_lineQuality(q), m_isCompressed(isCompr), m_stopAtStart(stopAtStart), m_looping(looping) - , m_loader(loader), m_jpgQuality(m_jpgQ), m_url(url) {if (m_jpgQ>99) m_jpgQ=99; else if (m_jpgQ<1) m_jpgQ=1;} - }; - - void setProperties(const TFlash::PropertiesForTab& prop);*/ - - /*! - This constructor initialize internal main environment as follows: - \li frame index is set to -1, - \li line thickness is set to 0, - \li line color is set to black, - \li strokes, regions and polylines are set to 0, - \li sound environment is reset, - \li palette pointer is reset, - \li a new empty affine transformation is created. - - The object is associate with a drawing style wich have in general two colors, thickness of the stroke, - smoothness of the gradient if any and type of the style that can be a texture, a line ,a solid style, - and radial or linear gradient. - - - - \param lx x-measure of the scene where the measure units are twips (a twips is an absolute length measure - of about 1/1440 inch ). It is used passing it the camera width view. - \param ly y-measure of the scene where the measure units are twips. - It is used passing the camera height view. - \param frameCount number of frames in the scene. - \param frameRate number of frame per second. - \param properties vector of swf properties as line and jpeg quality; - compression, looping, autoplay and preloading capabilities. - - - */ - TFlash(int lx, int ly, int frameCount, int frameRate, TPropertyGroup *properties, bool keepImages = true); - /*! - Deletes \p this object. - */ - ~TFlash(); - /*! - Sets scene' background to \p bgColor. - */ - - //if set to false, it does not save the alpha channel; default is on true - void enableAlphaChannelForRaster(bool doSaveIt); - - //default soundrate is at 5512 - void setSoundRate(int soundrate); - - // Nota: per ora va chiamata una sola volta e prima di ogni altra cosa - void setBackgroundColor(const TPixel &bgColor); - //void setCameraDpi(double dpix, double dpiy, double inchFactor); - //void getCameraDpi(double &dpix, double &dpiy); - /*! - Sets the thickness pf the stroke for painting the object. - */ - void setThickness(double thickness); - /*! - Sets the fill color of the drawing object. - Sets the type of style to Solid. - */ - void setFillColor(const TPixel32 &color); - /*! - Sets the stroke color used to paint the object. - */ - void setLineColor(const TPixel32 &color); - /*! - Sets the style to Texture. - Sets texture of the object. - */ - void setTexture(const TRaster32P &texture); - /*! - Sets the affine transformation of the filling style with texture. - */ - void setFillStyleMatrix(const TAffine &aff); - /*! - Sets parameters for filling with a gradient style. - */ - void setGradientFill(bool isLinear, const TPixel &color1, const TPixel &color2, double smooth); - //void setProperties(TPropertyGroup* properties); - /*! - Draws a segment line. - */ - void drawLine(const TPointD &a, const TPointD &b); - /*! - Draws a polygon given the vertices. - */ - void drawPolygon(vector> &quads, int clippedShapes = 0); //first polyline outside, other are holes - /*! - Draws a raster image. - */ - int drawRaster(TRaster32P r); - /*! - Draws a closed region. - */ - void drawRegion(const TRegion &r, int clippedShapes = 0); - /*! - Draws a line given a stroke style. - */ - void drawCenterline(const TStroke *s, bool drawAll); - /*! - Draws the outline of the stroke \p s. - */ - bool drawOutline(TStroke *s); - /*! - Draws the vector of segment lines \p segmentArray. - */ - void drawSegments(const vector segmentArray, bool isGradientColor); - /*! - Draws an array of boxes. - */ - void drawquads(const vector quadsArray); - /*!this function puts objects in an image in current sprite; - useful for image patterns - */ - USHORT buildImage(const TImageP img, bool isMask); - /*! - Adds the image \p vi to the current data frame. - */ - void draw(const TImageP vi, const TColorFunction *cf); - /*! - Initialize flash frame data and egins with frame \e frameIndex. - */ - void beginFrame(int frameIndex); - /*! - Ends the flash frame data. - */ - int endFrame(bool isLast, int frameCountLoader, bool lastScene); - /*! - Draws a rectangle. - */ - int drawRectangle(const TRectD &rect); - /*! - Draws a polyline. - */ - int drawPolyline(vector &poly); - /*! - Draws an ellipse. - */ - int drawEllipse(const TPointD ¢er, double radiusX, double radiusY); - /*! - Draws a point. - */ - void drawDot(const TPointD ¢er, double radius); - /*! - Puts the current affine matrix on the stack of the affine tansformations. - This stacks contains the transfomation sequence. - */ - void pushMatrix(); - /*! - Gets the matrix transformation from the stack and puts it - in the current affine matrix. - */ - void popMatrix(); - /*! - Multiplies current affine matrix by \p aff. - */ - void multMatrix(const TAffine &aff); - /*! - Puts audio stream to the scene beginning from the frame \p offset. - */ - void putSound(TSoundTrackP st, int offset); - /*! - Write the flash movie to file. - */ - void writeMovie(FILE *fp); - - void drawPolygon(const list &poly, bool isOutline); // tolgo???? - /*! - Returns the quality of the line, i.e. - "Low: Constant Thickness", "Medium: Mixed Thickness", "High: Variable Thickness". - */ - wstring getLineQuality(); - //void addPauseAtStart(); - /*! - Clears the tables of images used in the drawing. - */ - void cleanCachedImages(); - /*! - Enables the mask layer. - */ - void enableMask(); - /*! - Disables the mask layer. - */ - void disableMask(); - /*! - Create a new vector image with new palette, used as a mask layer. - */ - void beginMask(); - /*! - Puts current mask layer to the frame data. - */ - void endMask(); - /*! - Draws appended polylines and clears the tables of temporary images. - */ - void drawHangedObjects(); - /*! - Sets a global scale factor. - */ - void setGlobalScale(const TAffine &aff); + static const wstring ConstantLines; + static const wstring MixedLines; + static const wstring VariableLines; + + TFlash(int lx, int ly, int frameCount, int frameRate, TPropertyGroup *properties, bool keepImages = true) {} + ~TFlash() {} + void enableAlphaChannelForRaster(bool doSaveIt) {} + void setSoundRate(int soundrate) {} + void setBackgroundColor(const TPixel &bgColor) {} + void setThickness(double thickness) {} + void setFillColor(const TPixel32 &color) {} + void setLineColor(const TPixel32 &color) {} + void setTexture(const TRaster32P &texture) {} + void setFillStyleMatrix(const TAffine &aff) {} + void setGradientFill(bool isLinear, const TPixel &color1, const TPixel &color2, double smooth) {} + void drawLine(const TPointD &a, const TPointD &b) {} + void drawPolygon(vector> &quads, int clippedShapes = 0) {} + int drawRaster(TRaster32P r) { return 0; } + void drawRegion(const TRegion &r, int clippedShapes = 0) {} + void drawCenterline(const TStroke *s, bool drawAll) {} + bool drawOutline(TStroke *s) { return false; } + void drawSegments(const vector segmentArray, bool isGradientColor) {} + void drawquads(const vector quadsArray) {} + USHORT buildImage(const TImageP img, bool isMask) { return 0; } + void draw(const TImageP vi, const TColorFunction *cf) {} + void beginFrame(int frameIndex) {} + int endFrame(bool isLast, int frameCountLoader, bool lastScene) { return 0; } + int drawRectangle(const TRectD &rect) { return 0; } + int drawPolyline(vector &poly) { return 0; } + int drawEllipse(const TPointD ¢er, double radiusX, double radiusY) { return 0; } + void drawDot(const TPointD ¢er, double radius) {} + void pushMatrix() {} + void popMatrix() {} + void multMatrix(const TAffine &aff) {} + void putSound(TSoundTrackP st, int offset) {} + void writeMovie(FILE *fp) {} + void drawPolygon(const list &poly, bool isOutline) {} + wstring getLineQuality() { return nullptr; } + void cleanCachedImages() {} + void enableMask() {} + void disableMask() {} + void beginMask() {} + void endMask() {} + void drawHangedObjects() {} + void setGlobalScale(const TAffine &aff) {} private: - // not implemented TFlash(); TFlash(const TFlash &); TFlash &operator=(const TFlash &); diff --git a/toonz/sources/tnzcore/CMakeLists.txt b/toonz/sources/tnzcore/CMakeLists.txt index b402795..2ef803d 100644 --- a/toonz/sources/tnzcore/CMakeLists.txt +++ b/toonz/sources/tnzcore/CMakeLists.txt @@ -19,23 +19,6 @@ set(HEADERS ${MOC_HEADERS} ../include/trastercm.h ../include/trasterfx.h ../include/ttile.h - ../common/flash/F3SDK.h - ../common/flash/FAction.h - ../common/flash/FCT.h - ../common/flash/FDT.h - ../common/flash/FDTBitmaps.h - ../common/flash/FDTButtons.h - ../common/flash/FDTFonts.h - ../common/flash/FDTShapes.h - ../common/flash/FDTSounds.h - ../common/flash/FDTSprite.h - ../common/flash/FDTText.h - ../common/flash/FFixed.h - ../common/flash/FObj.h - ../common/flash/FPrimitive.h - ../common/flash/FSound.h - ../common/flash/FSWFStream.h - ../common/flash/Macromedia.h ../common/psdlib/psd.h ../common/psdlib/psdutils.h ../common/trop/runsmap.h @@ -211,20 +194,6 @@ set(SOURCES ../common/tvrender/ttessellator.cpp ../common/tvrender/tvectorbrush.cpp ../common/tvrender/tvectorbrushstyle.cpp - ../common/flash/FAction.cpp - ../common/flash/FCT.cpp - ../common/flash/FDT.cpp - ../common/flash/FDTBitmaps.cpp - ../common/flash/FDTButtons.cpp - ../common/flash/FDTFonts.cpp - ../common/flash/FDTShapes.cpp - ../common/flash/FDTSounds.cpp - ../common/flash/FDTSprite.cpp - ../common/flash/FDTText.cpp - ../common/flash/FObj.cpp - ../common/flash/FPrimitive.cpp - ../common/flash/FSound.cpp - ../common/flash/FSWFStream.cpp ../common/psdlib/psd.cpp ../common/psdlib/psdutils.cpp ../common/trop/bbox.cpp