forked from lightspark/lightspark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.cpp
120 lines (103 loc) · 3.33 KB
/
frame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**************************************************************************
Lightspark, a free flash player implementation
Copyright (C) 2009,2010 Alessandro Pignotti ([email protected])
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "scripting/abc.h"
#include "frame.h"
#include "parsing/tags.h"
#include "swf.h"
#include "compat.h"
using namespace std;
using namespace lightspark;
Frame::~Frame()
{
list <pair<PlaceInfo, DisplayObject*> >::iterator i=displayList.begin();
if(sys && !sys->finalizingDestruction)
{
//Decrease the refcount of childs
for(;i!=displayList.end();++i)
{
assert(i->second);
i->second->decRef();
}
}
}
void Frame::Render(bool maskEnabled)
{
list <pair<PlaceInfo, DisplayObject*> >::iterator i=displayList.begin();
//Render objects of this frame;
for(;i!=displayList.end();++i)
{
assert(i->second);
//Assign object data from current transformation
i->second->setMatrix(i->first.Matrix);
i->second->Render(maskEnabled);
}
}
void dumpDisplayList(list<DisplayObject*>& l)
{
list<DisplayObject*>::iterator it=l.begin();
for(;it!=l.end();++it)
{
cout << *it << endl;
}
}
void Frame::init(MovieClip* parent, list <pair<PlaceInfo, DisplayObject*> >& d)
{
if(!initialized)
{
//Execute control tags for this frame
//Only the root movie clip can have control tags
if(!controls.empty())
{
assert_and_throw(parent->getRoot()==parent);
for(unsigned int i=0;i<controls.size();i++)
controls[i]->execute(parent->getRoot());
controls.clear();
if(sys->currentVm)
{
//We stop execution until execution engine catches up
SynchronizationEvent* se=new SynchronizationEvent;
bool added=sys->currentVm->addEvent(NULL, se);
if(!added)
{
se->decRef();
throw RunTimeException("Could not add event");
}
se->wait();
se->decRef();
//Now the bindings are effective for all tags
}
}
//Update the displayList using the tags in this frame
std::list<DisplayListTag*>::iterator it=blueprint.begin();
for(;it!=blueprint.end();++it)
(*it)->execute(parent, d);
blueprint.clear();
displayList=d;
//Acquire a new reference to every child
list <pair<PlaceInfo, DisplayObject*> >::const_iterator dit=displayList.begin();
for(;dit!=displayList.end();++dit)
dit->second->incRef();
initialized=true;
//As part of initialization set the transformation matrix for the child objects
list <pair<PlaceInfo, DisplayObject*> >::iterator i=displayList.begin();
for(;i!=displayList.end();++i)
{
i->second->setMatrix(i->first.Matrix);
//Take a chance to also invalidate the content
if(i->second->isOnStage())
i->second->invalidate();
}
}
}