[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11511: Implement salign and scale p
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11511: Implement salign and scale parameters. Only manually tested; should fix |
Date: |
Mon, 14 Sep 2009 18:34:35 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11511 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-09-14 18:34:35 +0200
message:
Implement salign and scale parameters. Only manually tested; should fix
bug #27293.
modified:
gui/Player.cpp
gui/Player.h
libcore/asobj/Globals.cpp
libcore/asobj/flash/display/Stage_as.cpp
libcore/asobj/flash/display/Stage_as.h
libcore/movie_root.cpp
libcore/movie_root.h
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp 2009-07-21 15:59:57 +0000
+++ b/gui/Player.cpp 2009-09-14 10:25:45 +0000
@@ -346,14 +346,12 @@
_url = infile;
}
- // These flags are here so we can construct
- // the correct URL for base url later.
- // If the URL class was not immutable we could do something smarter...
- bool hasOverriddenBaseUrl=false;
- std::string overriddenBaseUrl;
- URL baseURL = hasOverriddenBaseUrl ? URL(overriddenBaseUrl, URL(_baseurl))
- : URL(_baseurl);
+ // Parse player parameters. These are not passed to the SWF, but rather
+ // control stage properties etc.
+ Params::const_iterator it = params.find("base");
+ const URL baseURL = (it == params.end()) ? _baseurl :
+ URL(it->second, _baseurl);
/// The RunResources should be populated before parsing.
_runResources.reset(new RunResources(baseURL.str()));
@@ -373,35 +371,20 @@
// Initialize gui (we need argc/argv for this)
// note that this will also initialize the renderer
// which is *required* during movie loading
- if ( ! _gui->init(argc, &argv) )
+ if (!_gui->init(argc, &argv))
{
std::cerr << "Could not initialize gui." << std::endl;
return EXIT_FAILURE;
}
+
// Parse querystring (before FlashVars, see
// testsuite/misc-ming.all/FlashVarsTest*)
setFlashVars(URL(_url).querystring());
- // Parse parameters
- StringNoCaseEqual noCaseCompare;
- for ( std::map<std::string,std::string>::const_iterator it=params.begin(),
- itEnd=params.end(); it != itEnd; ++it)
- {
- if ( noCaseCompare(it->first, "flashvars") )
- {
- setFlashVars(it->second);
- continue;
- }
-
- if ( noCaseCompare(it->first, "base") )
- {
- hasOverriddenBaseUrl=true;
- overriddenBaseUrl=it->second;
- continue;
- }
- }
-
+ // Add FlashVars.
+ Params::const_iterator fv = params.find("flashvars");
+ if (fv != params.end()) setFlashVars(fv->second);
// Load the actual movie.
_movieDef = load_movie();
@@ -438,7 +421,7 @@
_gui->createWindow(_url.c_str(), _width, _height);
movie_root root(*_movieDef, _gui->getClock(), *_runResources);
-
+
_callbacksHandler.reset(new CallbacksHandler(*_gui, *this));
// Register Player to receive events from the core (Mouse, Stage,
@@ -452,6 +435,7 @@
if ( _hostfd != -1 ) root.setHostFD(_hostfd);
_gui->setStage(&root);
+
// When startStopped is true, stop here after the stage has been
// registered, but before the movie has started. Initial loading
@@ -494,6 +478,33 @@
_gui->hideMenu();
}
+ // Now handle stage alignment and scale mode. This should be done after
+ // the GUI is created, after its stage member is set, and after the
+ // interface callbacks are registered.
+ it = params.find("salign");
+ if (it != params.end()) {
+ log_debug("Setting align");
+ const short align = stringToStageAlign(it->second);
+ root.setStageAlignment(align);
+ }
+
+ it = params.find("scale");
+ if (it != params.end()) {
+
+ StringNoCaseEqual noCaseCompare;
+ const std::string& str = it->second;
+
+ movie_root::ScaleMode mode = movie_root::showAll;
+
+ if (noCaseCompare(str, "noScale")) mode = movie_root::noScale;
+ else if (noCaseCompare(str, "exactFit")) mode =
movie_root::exactFit;
+ else if (noCaseCompare(str, "noBorder")) mode =
movie_root::noBorder;
+
+ log_debug("Setting scale mode");
+ root.setStageScaleMode(mode);
+ }
+
+
_gui->run();
log_debug("Main loop ended, cleaning up");
=== modified file 'gui/Player.h'
--- a/gui/Player.h 2009-07-13 09:15:53 +0000
+++ b/gui/Player.h 2009-09-14 09:31:10 +0000
@@ -220,8 +220,10 @@
void setFlashVars(const std::string& varstr);
+ typedef std::map<std::string, std::string, StringNoCaseLessThan> Params;
+
// Movie parameters (for -P)
- std::map<std::string, std::string> params;
+ Params params;
unsigned int _bitDepth;
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-08-27 12:08:59 +0000
+++ b/libcore/asobj/Globals.cpp 2009-09-14 09:40:43 +0000
@@ -23,6 +23,7 @@
#endif
#include "as_object.h"
+#include "movie_root.h"
#include "PropFlags.h"
#include "as_value.h"
#include "as_function.h" // for function_class_init
=== modified file 'libcore/asobj/flash/display/Stage_as.cpp'
--- a/libcore/asobj/flash/display/Stage_as.cpp 2009-08-20 10:16:35 +0000
+++ b/libcore/asobj/flash/display/Stage_as.cpp 2009-09-14 10:24:53 +0000
@@ -185,6 +185,8 @@
}
+
+
as_value
stage_align(const fn_call& fn)
{
@@ -199,29 +201,8 @@
else // setter
{
const std::string& str = fn.arg(0).to_string();
- short am = 0;
-
- // Easy enough to do bitwise - std::bitset is not
- // really necessary!
- if (str.find_first_of("lL") != std::string::npos)
- {
- am |= 1 << movie_root::STAGE_ALIGN_L;
- }
-
- if (str.find_first_of("tT") != std::string::npos)
- {
- am |= 1 << movie_root::STAGE_ALIGN_T;
- }
-
- if (str.find_first_of("rR") != std::string::npos)
- {
- am |= 1 << movie_root::STAGE_ALIGN_R;
- }
-
- if (str.find_first_of("bB") != std::string::npos)
- {
- am |= 1 << movie_root::STAGE_ALIGN_B;
- }
+
+ const short am = stringToStageAlign(str);
m.setStageAlignment(am);
=== modified file 'libcore/asobj/flash/display/Stage_as.h'
--- a/libcore/asobj/flash/display/Stage_as.h 2009-08-17 11:47:12 +0000
+++ b/libcore/asobj/flash/display/Stage_as.h 2009-09-14 09:41:14 +0000
@@ -19,13 +19,11 @@
#ifndef GNASH_ASOBJ_STAGE_H
#define GNASH_ASOBJ_STAGE_H
-#include "as_object.h" // for inheritance
-#include "movie_root.h" // for access to scaleMode
-
-#include <list>
-
namespace gnash {
+class ObjectURI;
+class as_object;
+
/// This is the Stage ActionScript object.
//
/// Some Stage methods are implemented in movie_root, because
@@ -48,7 +46,7 @@
/// Initialize the global Stage class
void stage_class_init(as_object& where, const ObjectURI& uri);
-
+
} // end of gnash namespace
#endif
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2009-08-21 07:28:09 +0000
+++ b/libcore/movie_root.cpp 2009-09-14 10:24:53 +0000
@@ -26,7 +26,6 @@
#include "Movie.h" // for implicit upcast to MovieClip
#include "VM.h"
#include "ExecutableCode.h"
-#include "flash/display/Stage_as.h"
#include "URL.h"
#include "namedStrings.h"
#include "GnashException.h"
@@ -1517,13 +1516,15 @@
if ( _scaleMode == sm ) return; // nothing to do
bool notifyResize = false;
- if ( sm == noScale || _scaleMode == noScale )
- {
- // If we go from or to noScale, we notify a resize
- // if and only if display viewport is != then actual
- // movie size
+
+ // If we go from or to noScale, we notify a resize
+ // if and only if display viewport is != then actual
+ // movie size. If there is not yet a _rootMovie (when scaleMode
+ // is passed as a parameter to the player), we also don't notify a
+ // resize.
+ if (_rootMovie && (sm == noScale || _scaleMode == noScale)) {
+
const movie_definition* md = _rootMovie->definition();
-
log_debug("Going to or from scaleMode=noScale. Viewport:%dx%d "
"Def:%dx%d", m_viewport_width, m_viewport_height,
md->get_width_pixels(), md->get_height_pixels());
@@ -2471,5 +2472,36 @@
_rootMovie->addChildAt(ch, depth);
}
+short
+stringToStageAlign(const std::string& str)
+{
+ short am = 0;
+
+ // Easy enough to do bitwise - std::bitset is not
+ // really necessary!
+ if (str.find_first_of("lL") != std::string::npos)
+ {
+ am |= 1 << movie_root::STAGE_ALIGN_L;
+ }
+
+ if (str.find_first_of("tT") != std::string::npos)
+ {
+ am |= 1 << movie_root::STAGE_ALIGN_T;
+ }
+
+ if (str.find_first_of("rR") != std::string::npos)
+ {
+ am |= 1 << movie_root::STAGE_ALIGN_R;
+ }
+
+ if (str.find_first_of("bB") != std::string::npos)
+ {
+ am |= 1 << movie_root::STAGE_ALIGN_B;
+ }
+
+ return am;
+
+}
+
} // namespace gnash
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2009-08-21 07:09:32 +0000
+++ b/libcore/movie_root.h 2009-09-14 10:24:53 +0000
@@ -1220,6 +1220,8 @@
unsigned int _lastMovieAdvancement;
};
+short stringToStageAlign(const std::string& s);
+
} // namespace gnash
#endif // GNASH_MOVIE_ROOT_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11511: Implement salign and scale parameters. Only manually tested; should fix,
Benjamin Wolsey <=