Gnash
0.8.11dev
|
This class represents the 'Stage' and top-level movie. More...
#include <movie_root.h>
Classes | |
class | LoadCallback |
Public Member Functions | |
movie_root (VirtualClock &clock, const RunResources &runResources) | |
Default constructor. More... | |
~movie_root () | |
Movie * | init (movie_definition *def, const MovieClip::MovieVariables &variables) |
Initialize movie_root with a parsed movie definition. More... | |
MovieClip * | getLevel (unsigned int num) const |
Return the movie at the given level (0 if unloaded level). More... | |
void | setLevel (unsigned int num, Movie *movie) |
Put the given movie at the given level. More... | |
void | replaceLevel (unsigned int num, Movie *external_movie) |
Replace an existing level with a new movie. More... | |
void | swapLevels (MovieClip *sp, int depth) |
Swap depth of a level (or two) More... | |
void | dropLevel (int depth) |
Drop level at given depth. More... | |
void | setDimensions (size_t w, size_t h) |
Change stage size. More... | |
size_t | getStageWidth () const |
Notional width of the stage, actual value depending on scaleMode. More... | |
size_t | getStageHeight () const |
Notional height of the stage, actual value depending on scaleMode. More... | |
DSOEXPORT bool | mouseMoved (std::int32_t x, std::int32_t y) |
Inform the Stage that the mouse has moved. More... | |
DSOEXPORT bool | mouseClick (bool press) |
Inform the Stage that a mouse click has occurred. More... | |
DSOEXPORT bool | mouseWheel (int delta) |
Inform the Stage that a mouse wheel has moved. More... | |
DSOEXPORT bool | keyEvent (key::code k, bool down) |
Tell the movie when the user pressed or released a key. More... | |
std::pair< std::int32_t, std::int32_t > | mousePosition () const |
Use this to retrieve the last state of the mouse. More... | |
void | setDragState (const DragState &st) |
Movie & | getRootMovie () |
Access the originating root movie (not necessarily _level0) More... | |
void | stop_drag () |
std::uint32_t | addIntervalTimer (std::unique_ptr< Timer > timer) |
Add an interval timer. More... | |
void | addLoadableObject (as_object *obj, std::unique_ptr< IOChannel > str) |
Register an object for loading data to. More... | |
void | addAdvanceCallback (ActiveRelay *obj) |
void | removeAdvanceCallback (ActiveRelay *obj) |
bool | clearIntervalTimer (std::uint32_t x) |
Remove timer identified by given integer. More... | |
void | set_background_color (const rgba &color) |
void | set_background_alpha (float alpha) |
VM & | getVM () |
Return the VM used by this movie_root. More... | |
bool | advance () |
int | timeToNextFrame () const |
Return the number of milliseconds available before it's time to advance the timeline again. More... | |
void | advanceMovie () |
Entry point for movie advancement. More... | |
void | display () |
size_t | nextUnnamedInstance () |
Get a unique number for unnamed instances. More... | |
void | registerButton (Button *listener) |
Push a new DisplayObject listener for key events. More... | |
void | removeButton (Button *listener) |
Remove a DisplayObject listener for key events. More... | |
DisplayObject * | getFocus () |
Get the DisplayObject having focus. More... | |
bool | setFocus (DisplayObject *to) |
Set the DisplayObject having focus. More... | |
DSOEXPORT void | add_invalidated_bounds (InvalidatedRanges &ranges, bool force) |
DisplayObject * | getActiveEntityUnderPointer () const |
Return the topmost active entity under the pointer. More... | |
const DisplayObject * | getEntityUnderPointer () const |
Return the topmost non-dragging entity under the pointer. More... | |
DisplayObject * | getDraggingCharacter () const |
Return the DisplayObject currently being dragged, if any. More... | |
bool | testInvariant () const |
void | setQuality (Quality q) |
Set the current display quality of the entire SWF. More... | |
Quality | getQuality () const |
Get the current display quality. More... | |
void | setStageAlignment (short s) |
void | setAllowScriptAccess (AllowScriptAccessMode mode) |
The mode is one of never, always, with sameDomain the default. More... | |
AllowScriptAccessMode | getAllowScriptAccess () |
Gets the current Access Mode for ExternalInterface. More... | |
StageAlign | getStageAlignment () const |
bool | getShowMenuState () const |
void | setShowMenuState (bool state) |
void | setStageScaleMode (ScaleMode sm) |
Sets the Stage object's align mode. More... | |
ScaleMode | getStageScaleMode () const |
Returns the Stage object's align mode. More... | |
std::string | getStageAlignMode () const |
DisplayState | getStageDisplayState () const |
Returns the Stage object's align mode. More... | |
void | setStageDisplayState (const DisplayState ds) |
void | pushAction (std::unique_ptr< ExecutableCode > code, size_t lvl) |
Push an executable code to the ActionQueue. More... | |
void | pushAction (const action_buffer &buf, DisplayObject *target) |
Push an executable code to the ActionQueue. More... | |
void | markReachableResources () const |
Mark all reachable resources (for GC) More... | |
void | addLiveChar (MovieClip *ch) |
Register a newly born advanceable DisplayObject to the list of DisplayObjects to be advanced on next ::advance call. More... | |
void | reset () |
Reset stage to its initial state. More... | |
void | disableScripts () |
Call this method for disabling run of actions. More... | |
bool | scriptsDisabled () const |
Return true if scripts execution is disabled. More... | |
void | flushHigherPriorityActionQueues () |
DisplayObject * | findCharacterByTarget (const std::string &tgtstr) const |
void | loadMovie (const std::string &url, const std::string &target, const std::string &data, MovieClip::VariablesMethod method, as_object *handler=nullptr) |
Queue a request for loading a movie. More... | |
void | getURL (const std::string &urlstr, const std::string &target, const std::string &data, MovieClip::VariablesMethod method) |
Send a request to the hosting application (e.g. browser). More... | |
key::code | lastKeyEvent () const |
const Keys & | unreleasedKeys () const |
void | registerClass (const SWF::DefinitionTag *sprite, as_function *cls) |
Register an actionscript class for construction of a MovieClip. More... | |
as_function * | getRegisteredClass (const SWF::DefinitionTag *sprite) const |
Get the actionscript class for constructing a MovieClip. More... | |
void | setHostFD (int fd) |
void | setControlFD (int fd) |
int | getHostFD () const |
int | getControlFD () const |
DSOEXPORT void | registerFSCommandCallback (FsCallback *handler) |
DSOEXPORT void | handleFsCommand (const std::string &cmd, const std::string &arg) const |
Call this to notify FS commands. More... | |
DSOEXPORT void | registerEventCallback (HostInterface *handler) |
void | callInterface (const HostInterface::Message &e) const |
Call the hosting application without expecting a reply. More... | |
template<typename T > | |
T | callInterface (const HostInterface::Message &e) const |
Call the hosting application, ensuring a return of the requested type. More... | |
void | setScriptLimits (std::uint16_t recursion, std::uint16_t timeout) |
std::uint16_t | getRecursionLimit () const |
std::uint16_t | getTimeoutLimit () const |
const RunResources & | runResources () const |
void | addExternalCallback (const std::string &name, as_object *callback, as_object *instance) |
Add an ExternalInterface callback object with an associated name. More... | |
bool | processInvoke (ExternalInterface::invoke_t *) |
std::string | callExternalCallback (const std::string &name, const std::vector< as_value > &args) |
std::string | callExternalJavascript (const std::string &name, const std::vector< as_value > &args) |
void | removeQueuedConstructor (MovieClip *target) |
Removes a queued constructor from the execution queue. More... | |
GC & | gc () |
bool | queryInterface (const std::string &what) const |
Ask the host interface a question. More... | |
void | setStreamBlock (int id, int block) |
Set the current stream block for the driving streaming sound. More... | |
void | stopStream (int id) |
Notify the stage that a sound stream has stopped. More... | |
![]() | |
virtual | ~GcRoot () |
Public Attributes | |
ExternalCallbackMethods | _externalCallbackMethods |
ExternalCallbackInstances | _externalCallbackInstances |
This class represents the 'Stage' and top-level movie.
It is a wrapper around the set of loaded levels being played. Each 'run' of a SWF movie, including all further movies loaded during the run, has exactly one movie_root, which is kept for the entire run. Loading a new top-level movie does not create a new movie_root. The 'Stage' part of movie_root is accessible through the ActionScript Stage object, implemented in Stage_as.cpp. The movie_root class is responsible for accepting and passing on user events (mouse or key events), for maintaining the heart-beat mechanism, and for advancing all MovieClips on request from the hosting application. The _root object is provided by getAsRoot().
typedef std::array<boost::ptr_deque<ExecutableCode>, PRIORITY_SIZE> gnash::movie_root::ActionQueue |
A number of queues of code to execute.
This is a ptr_deque because it needs no insertion in the middle but frequent push_back and pop_front. We also have to traverse it, so a queue is not usable.
typedef std::map<std::string, as_object*> gnash::movie_root::ExternalCallbackInstances |
typedef std::map<std::string, as_object*> gnash::movie_root::ExternalCallbackMethods |
typedef std::bitset<key::KEYCOUNT> gnash::movie_root::Keys |
typedef std::list<LoadCallback> gnash::movie_root::LoadCallbacks |
typedef std::pair<StageHorizontalAlign, StageVerticalAlign> gnash::movie_root::StageAlign |
gnash::movie_root::movie_root | ( | VirtualClock & | clock, |
const RunResources & | runResources | ||
) |
Default constructor.
Make sure to call setRootMovie() before using any of this class methods !
gnash::movie_root::~movie_root | ( | ) |
References gnash::fontlib::clear(), gnash::MovieLoader::clear(), and testInvariant().
void gnash::movie_root::add_invalidated_bounds | ( | InvalidatedRanges & | ranges, |
bool | force | ||
) |
References gnash::key::e, gnash::key::i, gnash::key::l, gnash::log_debug(), PRIORITY_SIZE, gnash::key::q, and gnash::geometry::SnappingRanges2d< T >::setWorld().
Referenced by gnash::Gui::notify_key_event().
void gnash::movie_root::addAdvanceCallback | ( | ActiveRelay * | obj | ) |
void gnash::movie_root::addExternalCallback | ( | const std::string & | name, |
as_object * | callback, | ||
as_object * | instance | ||
) |
Add an ExternalInterface callback object with an associated name.
This should store a callback object in movie_root.
name | Callback name, exposed to host container. |
callback | ActionScript function to be invoked if the callback is called. |
instance | ActionScript Object to be used as "this" instance inside the callback. ActionScript null value is allowed. |
References _, _externalCallbackInstances, _externalCallbackMethods, gnash::log_error(), gnash::ExternalInterface::makeInvoke(), and gnash::ExternalInterface::writeBrowser().
Referenced by gnash::externalinterface_class_init().
std::uint32_t gnash::movie_root::addIntervalTimer | ( | std::unique_ptr< Timer > | timer | ) |
Add an interval timer.
timer | A Timer, ownership will be transferred. Must not be NULL. |
internal | If true, this is an internal timer, so will get a negative id. |
References testInvariant().
Referenced by gnash::Global_as::makeObject().
|
inline |
Register a newly born advanceable DisplayObject to the list of DisplayObjects to be advanced on next ::advance call.
The DisplayObject will only be advanced if not unloaded when its turn comes. Characters are advanced in reverse-placement order (first registered is advanced last)
Referenced by gnash::MovieClip::construct().
Register an object for loading data to.
When complete, the object's onData function is called. The callback is removed when the load is complete, including failed loads. There is no restriction on the type of as_object that can registered.
obj | The object to update when data is received. |
str | The stream to load from. TODO: this function could be improved, e.g. by handling the URL checking and stream construction as well. It may be possible for this function to handle all connections if it also takes a callback function to call on each advance. |
bool gnash::movie_root::advance | ( | ) |
Main and only callback from hosting application. Expected to be called at 10ms resolution.
References _, advanceMovie(), gnash::fontlib::clear(), gnash::key::e, gnash::SystemClock::elapsed(), gnash::sound::sound_handler::getStreamBlock(), gnash::VM::getTime(), getTimeoutLimit(), gnash::log_error(), queryInterface(), gnash::key::s, gnash::RunResources::soundHandler(), and gnash::sound::sound_handler::streamingSound().
Referenced by gnash::Gui::advanceMovie().
void gnash::movie_root::advanceMovie | ( | ) |
Entry point for movie advancement.
This function does:
References gnash::MovieLoader::processCompletedRequests(), and testInvariant().
Referenced by advance().
std::string gnash::movie_root::callExternalCallback | ( | const std::string & | name, |
const std::vector< as_value > & | args | ||
) |
References _, _externalCallbackInstances, _externalCallbackMethods, gnash::getGlobal(), getVM(), gnash::invoke(), gnash::log_error(), gnash::as_value::set_undefined(), gnash::as_value::to_object(), gnash::ExternalInterface::toXML(), and gnash::ExternalInterface::writeBrowser().
Referenced by processInvoke().
std::string gnash::movie_root::callExternalJavascript | ( | const std::string & | name, |
const std::vector< as_value > & | args | ||
) |
void gnash::movie_root::callInterface | ( | const HostInterface::Message & | e | ) | const |
Call the hosting application without expecting a reply.
e | The message to send to the interface. |
References _, gnash::HostInterface::call(), and gnash::log_error().
Referenced by gnash::mouse_class_init(), gnash::NetStream_as::play(), processInvoke(), gnash::registerSystemNative(), setShowMenuState(), setStageAlignment(), setStageDisplayState(), and setStageScaleMode().
T gnash::movie_root::callInterface | ( | const HostInterface::Message & | e | ) | const |
Call the hosting application, ensuring a return of the requested type.
If the return type is other than the requested type, this represents a bug in the hosting application. An error is logged and the default constructed type T is returned. This may cause unexpected ActionScript behaviour, but is otherwise safe.
T | The return type expected. |
e | The message to send to the interface. |
References _, gnash::log_error(), and gnash::key::T.
bool gnash::movie_root::clearIntervalTimer | ( | std::uint32_t | x | ) |
Remove timer identified by given integer.
void gnash::movie_root::disableScripts | ( | ) |
Call this method for disabling run of actions.
NOTE: this will only work for queued actions, not for every action. Supposedly all actions should be queued, but this is not really always the case. Notable exceptions are:
Referenced by getRegisteredClass().
void gnash::movie_root::display | ( | ) |
References _, gnash::callMethod(), gnash::NSV::CLASS_MOUSE, gnash::fontlib::clear(), gnash::DisplayObject::clear_invalidated(), gnash::MovieClip::display(), gnash::key::e, gnash::event_id::functionName(), gnash::MovieClip::get_frame_size(), gnash::SWFRect::get_x_max(), gnash::SWFRect::get_x_min(), gnash::SWFRect::get_y_max(), gnash::SWFRect::get_y_min(), gnash::getURI(), gnash::SWFRect::is_null(), gnash::log_debug(), gnash::log_error(), gnash::NSV::PROP_BROADCAST_MESSAGE, gnash::RunResources::renderer(), testInvariant(), and gnash::DisplayObject::visible().
Referenced by gnash::Gui::notify_key_event().
void gnash::movie_root::dropLevel | ( | int | depth | ) |
Drop level at given depth.
depth | Depth of the level to drop. Note that this is -DisplayObject::staticDepthOffset for the root movie. Must be >=0 and <= 1048575 or an assertion will fail. Note that if the depth evaluates to the original root movie nothing happens (not allowed to remove that). It is not tested if it's allowed to remove _level0 after loading into it. |
References _, gnash::MovieClip::destroy(), IF_VERBOSE_ASCODING_ERRORS, gnash::log_aserror(), gnash::log_error(), testInvariant(), and gnash::DisplayObject::unload().
Referenced by gnash::MovieClip::removeMovieClip().
DisplayObject * gnash::movie_root::findCharacterByTarget | ( | const std::string & | tgtstr | ) | const |
void gnash::movie_root::flushHigherPriorityActionQueues | ( | ) |
Process action queues with higher priority then the priority of the action queue currently being processed. This is intended to be called at the end of any function call and at the end of an action block.
TODO: be aware of infinite loops !
cleanup anything pushed later..
References gnash::fontlib::clear().
Referenced by gnash::ActionExec::operator()().
|
inline |
References y.
Referenced by gnash::Gui::setInvalidatedRegions().
DisplayObject * gnash::movie_root::getActiveEntityUnderPointer | ( | ) | const |
Return the topmost active entity under the pointer.
This method returns cached info, with cache updated by notify_mouse_moved (and should be updated also by movie advancement or actions execution maybe, not currently implmented).
References gnash::MouseButtonState::activeEntity.
Referenced by gnash::Gui::notifyMouseMove(), and gnash::Gui::setInvalidatedRegions().
movie_root::AllowScriptAccessMode gnash::movie_root::getAllowScriptAccess | ( | ) |
Gets the current Access Mode for ExternalInterface.
Referenced by gnash::externalinterface_class_init().
|
inline |
Referenced by gnash::externalinterface_class_init().
DisplayObject * gnash::movie_root::getDraggingCharacter | ( | ) | const |
Return the DisplayObject currently being dragged, if any.
Referenced by getEntityUnderPointer(), mouseClick(), setDragState(), and gnash::Gui::setInvalidatedRegions().
const DisplayObject * gnash::movie_root::getEntityUnderPointer | ( | ) | const |
Return the topmost non-dragging entity under the pointer.
This method triggers a displaylist scan
References getDraggingCharacter(), gnash::pixelsToTwips(), x, and y.
Referenced by gnash::Gui::setInvalidatedRegions().
DisplayObject * gnash::movie_root::getFocus | ( | ) |
Get the DisplayObject having focus.
The DisplayObject having focus will receive mouse button and key presses/releases.
Referenced by gnash::registerSelectionNative(), and gnash::DisplayObject::set_visible().
|
inline |
Get the filedescriptor to use for host application requests (for browser communication mostly)
Referenced by gnash::externalinterface_class_init().
MovieClip * gnash::movie_root::getLevel | ( | unsigned int | num | ) | const |
Return the movie at the given level (0 if unloaded level).
POST CONDITIONS:
References gnash::key::i, and gnash::DisplayObject::staticDepthOffset.
Referenced by gnash::externalinterface_class_init(), gnash::getDisplayObjectProperty(), and processInvoke().
|
inline |
Get the current display quality.
Referenced by gnash::SWF::SWFHandlers::execute(), gnash::Gui::getQuality(), and gnash::DisplayObject::MaskRenderer::~MaskRenderer().
|
inline |
Get the current global recursion limit for this movie: it can be changed by loaded movies.
Referenced by gnash::VM::pushCallFrame().
as_function * gnash::movie_root::getRegisteredClass | ( | const SWF::DefinitionTag * | sprite | ) | const |
Get the actionscript class for constructing a MovieClip.
sprite | The definition tag for the MovieClip to be placed on stage |
References gnash::fontlib::clear(), disableScripts(), gnash::GC::fuzzyCollect(), gnash::VM::getStack(), gnash::log_debug(), and gnash::VM::setConstantPool().
Referenced by gnash::MovieClip::constructAsScriptObject().
|
inline |
Access the originating root movie (not necessarily _level0)
Referenced by gnash::Gui::advanceMovie(), gnash::GtkAggVaapiGlue::beforeRendering(), gnash::MovieClip::getAsRoot(), gnash::DisplayObject::getTargetPath(), gnash::Gui::notify_key_event(), gnash::DumpGui::run(), and gnash::textformat_class_init().
bool gnash::movie_root::getShowMenuState | ( | ) | const |
Returns the current value of _showMenu which instructs the gui about how much to display in the context menu
Returns a string that represents the boolean state of the _showMenu variable
Referenced by gnash::registerStageNative().
movie_root::StageAlign gnash::movie_root::getStageAlignment | ( | ) | const |
Returns the current alignment of the stage (left/right/centre, top/ bottom/centre) as a std::pair
Returns a pair of enum values giving the actual alignment of the stage after align mode flags are evaluated.
L takes precedence over R. Default is centred.
T takes precedence over B. Default is centred.
References STAGE_ALIGN_B, STAGE_ALIGN_L, STAGE_ALIGN_R, STAGE_ALIGN_T, STAGE_H_ALIGN_C, STAGE_H_ALIGN_L, STAGE_H_ALIGN_R, STAGE_V_ALIGN_B, STAGE_V_ALIGN_C, and STAGE_V_ALIGN_T.
Referenced by gnash::Gui::updateStageMatrix().
std::string gnash::movie_root::getStageAlignMode | ( | ) | const |
Returns the string representation of the current align mode, which must always be in the order: LTRB
References STAGE_ALIGN_B, STAGE_ALIGN_L, STAGE_ALIGN_R, and STAGE_ALIGN_T.
Referenced by gnash::registerStageNative().
|
inline |
Returns the Stage object's align mode.
Referenced by gnash::registerStageNative().
size_t gnash::movie_root::getStageHeight | ( | ) | const |
Notional height of the stage, actual value depending on scaleMode.
Get actionscript height of stage, in pixels. The height returned depends on the scale mode.
References gnash::Movie::heightPixels(), and SCALEMODE_NOSCALE.
Referenced by gnash::registerStageNative().
|
inline |
Returns the Stage object's align mode.
Referenced by gnash::registerStageNative(), and gnash::Gui::updateStageMatrix().
size_t gnash::movie_root::getStageWidth | ( | ) | const |
Notional width of the stage, actual value depending on scaleMode.
Get actionscript width of stage, in pixels. The width returned depends on the scale mode.
References SCALEMODE_NOSCALE, and gnash::Movie::widthPixels().
Referenced by gnash::registerStageNative().
|
inline |
Get the current global script timeout limit for this movie: it can be changed by loaded movies.
Referenced by advance(), and gnash::ActionExec::operator()().
void gnash::movie_root::getURL | ( | const std::string & | urlstr, |
const std::string & | target, | ||
const std::string & | data, | ||
MovieClip::VariablesMethod | method | ||
) |
Send a request to the hosting application (e.g. browser).
This function constructs the URL and, if required, the postdata from the arguments. The variables to send should not be appended to
urlstr | before calling this function. |
urlstr | The url exactly as requested. This may already contain a query string. |
target | Target for request. |
data | The variables data to send, URL encoded in key/value pairs |
method | The VariablesMethod to use for sending the data. If MovieClip::METHOD_NONE, no data will be sent. |
If there is no hosting application, call the URL launcher. For safety, we resolve the URL against the base URL for this run. The data is not sent at all.
Try to avoid letting flash movies execute arbitrary commands (sic).
NOTE: it is assumed that the user-provided command puts the url place-holder within single quotes. Failing that, there will be the possibility for malicious SWF files to run arbitrary commands.
Check safety of user provided command
TODO: improve this check
This is when there is a hosting application.
References _, __FUNCTION__, gnash::StreamProvider::baseURL(), gnash::RcInitFile::getDefaultInstance(), gnash::log_debug(), gnash::log_error(), gnash::log_network(), gnash::ExternalInterface::makeInvoke(), gnash::MovieClip::METHOD_GET, gnash::MovieClip::METHOD_NONE, gnash::MovieClip::METHOD_POST, gnash::RunResources::streamProvider(), url, and gnash::ExternalInterface::writeBrowser().
Referenced by gnash::TextField::mouseEvent(), and gnash::registerMovieClipNative().
|
inline |
Return the VM used by this movie_root.
Referenced by callExternalCallback(), gnash::MovieLoader::clear(), gnash::DisplayObject::getNextUnnamedInstanceName(), gnash::DisplayObject::getTarget(), gnash::DisplayObject::pathElement(), processInvoke(), gnash::DumpGui::run(), gnash::Gui::setInvalidatedRegions(), and testInvariant().
void gnash::movie_root::handleFsCommand | ( | const std::string & | cmd, |
const std::string & | arg | ||
) | const |
Call this to notify FS commands.
References gnash::FsCallback::notify().
Movie * gnash::movie_root::init | ( | movie_definition * | def, |
const MovieClip::MovieVariables & | variables | ||
) |
Initialize movie_root with a parsed movie definition.
The definition may be a SWF or Bitmap movie definition. The created Movie is returned; it is non-const so may be stored, queried, and changed by the caller for debugging or manipulation. Direct use of the pointer may result in unexpected behaviour during SWF playback, so for normal playback this pointer should not be used.
References _, gnash::movie_definition::createMovie(), gnash::Movie::definition(), gnash::key::e, gnash::movie_definition::get_frame_rate(), gnash::movie_definition::get_height_pixels(), gnash::movie_definition::get_version(), gnash::movie_definition::get_width_pixels(), gnash::VM::getGlobal(), gnash::VM::getTime(), gnash::log_error(), gnash::DisplayObject::set_depth(), setLevel(), gnash::VM::setSWFVersion(), gnash::MovieClip::setVariables(), and gnash::DisplayObject::staticDepthOffset.
Referenced by gnash::Gui::start().
bool gnash::movie_root::keyEvent | ( | key::code | k, |
bool | down | ||
) |
Tell the movie when the user pressed or released a key.
This function should return TRUE if any action triggered by the event requires redraw, see Handling of user events for more info.
References _, gnash::callMethod(), gnash::NSV::CLASS_KEY, gnash::fontlib::clear(), gnash::key::codeMap, gnash::key::e, gnash::getURI(), gnash::key::INVALID, gnash::key::k, gnash::key::KEY, gnash::event_id::KEY_DOWN, gnash::event_id::KEY_PRESS, gnash::event_id::KEY_UP, gnash::key::KEYCOUNT, gnash::TextField::keyInput(), gnash::log_error(), and gnash::NSV::PROP_BROADCAST_MESSAGE.
Referenced by gnash::Gui::notify_key_event().
|
inline |
Referenced by gnash::key_get_ascii(), and gnash::key_get_code().
|
inline |
Queue a request for loading a movie.
This function constructs the URL and, if required, the postdata from the arguments. The variables to send should not be appended to
urlstr | before calling this function. |
urlstr | The url exactly as requested. This may already contain a query string. |
target | Target for request. |
data | The variables data to send, URL encoded in key/value pairs |
method | The VariablesMethod to use for sending the data. If MovieClip::METHOD_NONE, no data will be sent. |
handler | An object which will be signalled of load events (onLoadStart, onLoadComplete, onLoadInit, onLoadError). Can be null if caller doesn't care. |
References data.
Referenced by gnash::moviecliploader_class_init(), and gnash::registerMovieClipNative().
|
virtual |
Mark all reachable resources (for GC)
Resources reachable from movie_root are:
Implements gnash::GcRoot.
References _externalCallbackInstances, _externalCallbackMethods, gnash::key::e, gnash::renderer::opengl::for_each(), gnash::foreachSecond(), gnash::key::i, gnash::ExecutableCode::markReachableResources(), gnash::MouseButtonState::markReachableResources(), gnash::Timer::markReachableResources(), gnash::VM::markReachableResources(), PRIORITY_SIZE, gnash::key::q, gnash::MovieLoader::setReachable(), gnash::GcResource::setReachable(), gnash::ActiveRelay::setReachable(), gnash::movie_root::LoadCallback::setReachable(), x, and y.
bool gnash::movie_root::mouseClick | ( | bool | press | ) |
Inform the Stage that a mouse click has occurred.
press | true for a mouse click, false for a release |
References getDraggingCharacter(), gnash::DisplayObject::getTargetPath(), gnash::MouseButtonState::isDown, gnash::event_id::MOUSE_DOWN, gnash::event_id::MOUSE_UP, gnash::pixelsToTwips(), gnash::MovieClip::setDropTarget(), testInvariant(), gnash::DisplayObject::to_movie(), gnash::MouseButtonState::topmostEntity, x, and y.
Referenced by gnash::Gui::notifyMouseClick().
bool gnash::movie_root::mouseMoved | ( | std::int32_t | x, |
std::int32_t | y | ||
) |
Inform the Stage that the mouse has moved.
Coordinates are in Stage Coordinate Space (pseudo-pixels units).
x | The x co-ordinate in pixels. |
y | The y co-ordinate in pixels. |
TODO: take twips (or float pixels), or we won't be able to support sub-pixel accuracy in collision detection.
References gnash::event_id::MOUSE_MOVE, testInvariant(), x, and y.
Referenced by gnash::Gui::notifyMouseMove().
std::pair< std::int32_t, std::int32_t > gnash::movie_root::mousePosition | ( | ) | const |
Use this to retrieve the last state of the mouse.
Coordinates are in PIXELS, NOT TWIPS.
References testInvariant().
Referenced by gnash::TextField::mouseEvent(), and gnash::DisplayObject::MaskRenderer::~MaskRenderer().
bool gnash::movie_root::mouseWheel | ( | int | delta | ) |
Inform the Stage that a mouse wheel has moved.
delta | The direction of the scroll: positive for up, negative for down. Although values from about -3 to 3 are documented, only -1 and 1 have been observed. |
References gnash::callMethod(), gnash::NSV::CLASS_MOUSE, gnash::getObject(), gnash::getURI(), gnash::key::i, gnash::pixelsToTwips(), gnash::NSV::PROP_BROADCAST_MESSAGE, x, and y.
Referenced by gnash::Gui::notifyMouseWheel().
|
inline |
Get a unique number for unnamed instances.
References DSOEXPORT.
Referenced by gnash::DisplayObject::getNextUnnamedInstanceName().
bool gnash::movie_root::processInvoke | ( | ExternalInterface::invoke_t * | invoke | ) |
References _, gnash::ExternalInterface::invoke_t::args, callExternalCallback(), callInterface(), gnash::Timer::cleared(), gnash::Timer::executeAndReset(), gnash::HostInterface::exit(), gnash::Timer::expired(), gnash::HostMessage::EXTERNALINTERFACE_ISPLAYING, gnash::HostMessage::EXTERNALINTERFACE_PAN, gnash::HostMessage::EXTERNALINTERFACE_PLAY, gnash::HostMessage::EXTERNALINTERFACE_REWIND, gnash::HostMessage::EXTERNALINTERFACE_SETZOOMRECT, gnash::HostMessage::EXTERNALINTERFACE_STOPPLAY, gnash::HostMessage::EXTERNALINTERFACE_ZOOM, gnash::foreachSecond(), gnash::MovieClip::get_bytes_loaded(), gnash::MovieClip::get_bytes_total(), gnash::MovieClip::get_environment(), gnash::MovieClip::get_loaded_frames(), getLevel(), gnash::getObject(), gnash::VM::getSWFVersion(), gnash::VM::getTime(), gnash::getURI(), gnash::getVariable(), getVM(), GNASH_REPORT_FUNCTION, gnash::log_debug(), gnash::log_error(), gnash::log_unimpl(), gnash::ExternalInterface::invoke_t::name, gnash::as_object::set_member(), gnash::as_value::to_string(), gnash::ExternalInterface::toXML(), and gnash::amf::write().
Referenced by pushAction().
void gnash::movie_root::pushAction | ( | std::unique_ptr< ExecutableCode > | code, |
size_t | lvl | ||
) |
Push an executable code to the ActionQueue.
References PRIORITY_SIZE.
Referenced by gnash::MovieLoader::clear(), gnash::MovieClip::construct(), gnash::MovieClip::execute_init_action_buffer(), gnash::Button::mouseEvent(), gnash::MovieClip::queueAction(), and gnash::MovieClip::queueEvent().
void gnash::movie_root::pushAction | ( | const action_buffer & | buf, |
DisplayObject * | target | ||
) |
Push an executable code to the ActionQueue.
References _, gnash::key::_1, gnash::ExternalInterface::ExternalEventCheck(), gnash::renderer::opengl::for_each(), gnash::DisplayObject::getTargetPath(), gnash::invoke(), gnash::log_debug(), gnash::log_error(), gnash::ActiveRelay::owner(), PRIORITY_DOACTION, processInvoke(), and gnash::movie_root::LoadCallback::processLoad().
bool gnash::movie_root::queryInterface | ( | const std::string & | what | ) | const |
Ask the host interface a question.
what | The question to pose. |
References _, gnash::log_error(), and gnash::HostMessage::QUERY.
Referenced by advance(), and gnash::ActionExec::operator()().
void gnash::movie_root::registerButton | ( | Button * | listener | ) |
Push a new DisplayObject listener for key events.
References gnash::image::begin(), gnash::MovieClip::cleanupDisplayList(), gnash::MovieClip::destroy(), gnash::image::end(), gnash::foreachSecond(), gnash::DisplayObject::getTarget(), gnash::DisplayObject::isDestroyed(), gnash::log_debug(), gnash::typeName(), and gnash::DisplayObject::unloaded().
Referenced by gnash::Button::construct().
void gnash::movie_root::registerClass | ( | const SWF::DefinitionTag * | sprite, |
as_function * | cls | ||
) |
Register an actionscript class for construction of a MovieClip.
sprite | The definition tag for the MovieClip to be placed on stage |
class | The ActionScript class to be used in construction. |
Referenced by gnash::initObjectClass().
|
inline |
A callback to the GUI (or whatever is listening) for sending events and receiving replies. Used for ActionScript interface with the gui (Mouse visibility, Stage alignment etc and System information, for instance).
See callInterface method
References gnash::key::e, and gnash::key::T.
|
inline |
ActionScript embedded in a movie can use the built-in fscommand() function to send data back to the host application. If you are interested in this data, register a handler, which will be called when the embedded scripts call fscommand().
The handler gets the MovieClip* that the script is embedded in, and the two string arguments passed by the script to fscommand().
References DSOEXPORT.
void gnash::movie_root::removeAdvanceCallback | ( | ActiveRelay * | obj | ) |
void gnash::movie_root::removeButton | ( | Button * | listener | ) |
Remove a DisplayObject listener for key events.
Referenced by gnash::Button::destroy().
void gnash::movie_root::removeQueuedConstructor | ( | MovieClip * | target | ) |
Removes a queued constructor from the execution queue.
This is used to prevent construction of targets that are placed and then removed in skipped frames. Callers are responsible for determining whether it should be removed, for instance by checking for an onUnload handler.
References PRIORITY_CONSTRUCT.
Referenced by gnash::MovieClip::unloadChildren().
void gnash::movie_root::replaceLevel | ( | unsigned int | num, |
Movie * | external_movie | ||
) |
Replace an existing level with a new movie.
Depth will be assigned to external_movie by this function. If the give level number doesn't exist an error is logged and nothing else happens.
This method is intended for use by xxx.loadMovie(yyy) when 'xxx' is a top-level movie.
References _, gnash::DisplayObject::get_depth(), gnash::log_error(), gnash::DisplayObject::set_depth(), setLevel(), and gnash::DisplayObject::staticDepthOffset.
Referenced by gnash::MovieClip::getLoadedMovie().
void gnash::movie_root::reset | ( | ) |
Reset stage to its initial state.
References gnash::fontlib::clear(), gnash::MovieLoader::clear(), gnash::GC::fuzzyCollect(), gnash::VM::getStack(), gnash::sound::sound_handler::reset(), and gnash::RunResources::soundHandler().
Referenced by gnash::Gui::restart().
|
inline |
Referenced by gnash::externalinterface_class_init(), gnash::getRunResources(), gnash::MovieLoader::loadMovie(), gnash::MovieClip::loadVariables(), gnash::MovieLoader::MovieLoader(), gnash::Gui::pause(), gnash::Gui::play(), gnash::registerSystemNative(), gnash::MovieClip::setStreamSoundId(), gnash::Gui::start(), gnash::Gui::stop(), and gnash::Gui::toggleSound().
|
inline |
Return true if scripts execution is disabled.
Referenced by gnash::ActionExec::operator()().
void gnash::movie_root::set_background_alpha | ( | float | alpha | ) |
References gnash::key::f, gnash::frnd(), and gnash::rgba::m_a.
Referenced by gnash::Gui::start().
void gnash::movie_root::set_background_color | ( | const rgba & | color | ) |
References color, and gnash::rgba::m_a.
Referenced by gnash::MovieClip::set_background_color().
void gnash::movie_root::setAllowScriptAccess | ( | AllowScriptAccessMode | mode | ) |
The mode is one of never, always, with sameDomain the default.
Sets the flag to allow interfacing with JavaScript in the browser. This is disabled by default, but enabled for ExternalInterface.
|
inline |
Set a filedescriptor to use for host application requests (for browser communication mostly)
void gnash::movie_root::setDimensions | ( | size_t | w, |
size_t | h | ||
) |
Change stage size.
This may be smaller than the size of the root movie. It determines how much of the movie is visible.
w | The width of the stage |
h | The height of the stage. |
References gnash::callMethod(), gnash::NSV::CLASS_STAGE, gnash::getURI(), gnash::key::h, gnash::NSV::PROP_BROADCAST_MESSAGE, SCALEMODE_NOSCALE, testInvariant(), and test::w.
Referenced by gnash::Gui::resize_view().
void gnash::movie_root::setDragState | ( | const DragState & | st | ) |
References gnash::SWFRect::clamp(), gnash::SWFRect::enclose_transformed_rect(), getDraggingCharacter(), gnash::getMatrix(), gnash::getWorldMatrix(), gnash::SWFMatrix::invert(), gnash::key::p, gnash::DisplayObject::parent(), gnash::pixelsToTwips(), gnash::SWFMatrix::set_translation(), gnash::DisplayObject::setMatrix(), testInvariant(), gnash::SWFMatrix::transform(), gnash::DisplayObject::unloaded(), gnash::geometry::Point2d::x, and gnash::geometry::Point2d::y.
Referenced by gnash::SWF::SWFHandlers::execute(), and gnash::registerMovieClipNative().
bool gnash::movie_root::setFocus | ( | DisplayObject * | to | ) |
Set the DisplayObject having focus.
to | The DisplayObject to receive focus. NULL to kill focus. |
A valid focus must have an associated object.
References gnash::callMethod(), gnash::NSV::CLASS_SELECTION, gnash::getObject(), gnash::DisplayObject::handleFocus(), gnash::DisplayObject::killFocus(), gnash::NSV::PROP_BROADCAST_MESSAGE, gnash::NSV::PROP_ON_KILL_FOCUS, gnash::NSV::PROP_ON_SET_FOCUS, and testInvariant().
Referenced by gnash::registerSelectionNative(), gnash::DisplayObject::set_visible(), and testInvariant().
|
inline |
Set a filedescriptor to use for host application requests (for browser communication mostly)
void gnash::movie_root::setLevel | ( | unsigned int | num, |
Movie * | movie | ||
) |
Put the given movie at the given level.
movie | The Movie to store at the given level. Its depth will be set to <num>+DisplayObject::staticDepthOffset and its name to _level<num> |
Notify placement
References gnash::HostInterface::call(), gnash::MovieClip::construct(), gnash::key::e, gnash::DisplayObject::get_depth(), gnash::Movie::heightPixels(), gnash::log_debug(), gnash::HostMessage::RESIZE_STAGE, gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::staticDepthOffset, testInvariant(), and gnash::Movie::widthPixels().
Referenced by gnash::MovieLoader::clear(), init(), and replaceLevel().
void gnash::movie_root::setQuality | ( | Quality | q | ) |
Set the current display quality of the entire SWF.
Overridden quality if not negative.
References gnash::RcInitFile::getDefaultInstance(), gnash::key::q, gnash::QUALITY_BEST, gnash::RcInitFile::qualityLevel(), gnash::RunResources::renderer(), and gnash::Renderer::setQuality().
Referenced by gnash::SWF::SWFHandlers::execute(), gnash::Gui::setQuality(), and gnash::DisplayObject::MaskRenderer::~MaskRenderer().
void gnash::movie_root::setScriptLimits | ( | std::uint16_t | recursion, |
std::uint16_t | timeout | ||
) |
Called from the ScriptLimits tag parser to set the global script limits. It is expected behaviour that each new loaded movie should override this. Can be overridden from gnashrc.
recursion | the maximum number of recursions when finding 'super'. The default value for this (i.e. when no ScriptLimits tag is present) is documented to be 256, but this may change and appears not to be crucial for (backward) compatibility. |
timeout | the timeout in seconds for script execution. The default value for this (i.e. when no ScriptLimits tag is present) is documented to be 15 to 20 seconds, depending on platform. |
References _, gnash::image::begin(), gnash::Movie::definition(), gnash::key::e, gnash::image::end(), gnash::movie_definition::get_height_pixels(), gnash::movie_definition::get_url(), gnash::movie_definition::get_version(), gnash::movie_definition::get_width_pixels(), gnash::RcInitFile::getDefaultInstance(), gnash::key::i, gnash::movie_definition::isAS3(), gnash::log_debug(), and LOG_ONCE.
Referenced by gnash::SWF::ScriptLimitsTag::executeState().
void gnash::movie_root::setShowMenuState | ( | bool | state | ) |
Sets the value of _showMenu and calls the fscommand handler for the current gui
Sets the value of _showMenu and calls the gui handler to process the fscommand to change the display of the context menu
References callInterface(), and gnash::HostMessage::SHOW_MENU.
Referenced by gnash::registerStageNative().
void gnash::movie_root::setStageAlignment | ( | short | s | ) |
Sets movie_root's horizontal and vertical alignment to one of the three possible positions for each dimension.
Takes a short int bitfield: the four bits correspond to the AlignMode enum
References callInterface(), gnash::key::s, and gnash::HostMessage::UPDATE_STAGE.
Referenced by gnash::registerStageNative().
void gnash::movie_root::setStageDisplayState | ( | const DisplayState | ds | ) |
References callInterface(), gnash::callMethod(), gnash::NSV::CLASS_STAGE, DISPLAYSTATE_FULLSCREEN, gnash::key::e, gnash::NSV::PROP_BROADCAST_MESSAGE, and gnash::HostMessage::SET_DISPLAYSTATE.
Referenced by gnash::Gui::notify_key_event(), gnash::registerStageNative(), and gnash::Gui::toggleFullscreen().
void gnash::movie_root::setStageScaleMode | ( | ScaleMode | sm | ) |
Sets the Stage object's align mode.
References callInterface(), gnash::callMethod(), gnash::NSV::CLASS_STAGE, gnash::Movie::definition(), gnash::movie_definition::get_height_pixels(), gnash::movie_definition::get_width_pixels(), gnash::log_debug(), gnash::NSV::PROP_BROADCAST_MESSAGE, SCALEMODE_NOSCALE, and gnash::HostMessage::UPDATE_STAGE.
Referenced by gnash::Gui::allowScale(), and gnash::registerStageNative().
void gnash::movie_root::setStreamBlock | ( | int | id, |
int | block | ||
) |
Set the current stream block for the driving streaming sound.
The frame rate will be changed so that it advances only when the block for a particular frame is reached. Only one sound can drive the frame: the first one to be registered.
id | The id of the stream; if another stream is already driving the frame rate, nothing happens. |
block | The block of sound currently being played. The current frame will be advanced or delayed until the frame corresponding to this block is reached. |
Referenced by gnash::SWF::StreamSoundBlockTag::executeActions().
|
inline |
Referenced by gnash::SWF::SWFHandlers::execute(), and gnash::registerMovieClipNative().
void gnash::movie_root::stopStream | ( | int | id | ) |
Notify the stage that a sound stream has stopped.
If it's the one driving the frame rate, the frame rate will return to the nominal rate
id | The id of the streaming sound. |
Referenced by gnash::MovieClip::setStreamSoundId().
void gnash::movie_root::swapLevels | ( | MovieClip * | sp, |
int | depth | ||
) |
Swap depth of a level (or two)
Character's depths are updated.
sp | The level to change depth/level of. A pointer to it is expected to be found in the _level# container, or an error will be printed and the call would result in a no-op. |
depth | New depth to assign to the DisplayObject. If another level exists at the target depth the latter is moved in place of the former, with its depth also updated. |
References _, gnash::key::e, gnash::DisplayObject::get_depth(), gnash::DisplayObject::getTarget(), gnash::key::i, IF_VERBOSE_ASCODING_ERRORS, gnash::log_aserror(), gnash::log_debug(), gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::staticDepthOffset, and testInvariant().
Referenced by gnash::registerMovieClipNative().
|
inline |
References gnash::MouseButtonState::activeEntity, gnash::MovieClip::advance(), gnash::event_id::DRAG_OUT, gnash::event_id::DRAG_OVER, gnash::as_object::get_member(), gnash::VM::getGlobal(), gnash::DisplayObject::getTarget(), getVM(), gnash::MouseButtonState::isDown, gnash::isReferenceable(), gnash::log_debug(), gnash::InteractiveObject::mouseEvent(), gnash::key::o, gnash::DisplayObject::parent(), gnash::event_id::PRESS, gnash::MovieClip::queueLoad(), gnash::event_id::RELEASE, gnash::event_id::RELEASE_OUTSIDE, gnash::event_id::ROLL_OUT, gnash::event_id::ROLL_OVER, setFocus(), gnash::toObject(), gnash::MouseButtonState::topmostEntity, gnash::DisplayObject::unloaded(), gnash::MouseButtonState::wasDown, and gnash::MouseButtonState::wasInsideActiveEntity.
Referenced by addIntervalTimer(), advanceMovie(), display(), dropLevel(), mouseClick(), mouseMoved(), mousePosition(), setDimensions(), setDragState(), setFocus(), setLevel(), swapLevels(), and ~movie_root().
int gnash::movie_root::timeToNextFrame | ( | ) | const |
Return the number of milliseconds available before it's time to advance the timeline again.
Return value can be negative if we're late...
References gnash::VM::getTime().
|
inline |
Referenced by gnash::key_is_down().
ExternalCallbackInstances gnash::movie_root::_externalCallbackInstances |
Referenced by addExternalCallback(), callExternalCallback(), and markReachableResources().
ExternalCallbackMethods gnash::movie_root::_externalCallbackMethods |
Referenced by addExternalCallback(), callExternalCallback(), and markReachableResources().