2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_DUMMYMOVIEDEFINITION_H
20 #define GNASH_DUMMYMOVIEDEFINITION_H
22 #include "SWFMovieDefinition.h" // for inheritance
23 #include "SWFRect.h" // for composition
24 #include "SWFMovie.h" // for createMovie
25 #include "Global_as.h"
26 #include "namedStrings.h"
30 #include <memory> // for auto_ptr
36 /// A dummy movie definition, for use by unit tests
38 /// This class provides implementation of all virtual
39 /// methods of movie_definition by returning user-defined
40 /// values for version/size/frame rate etc..
42 /// The createMovie function will return the same
43 /// object created by createEmptyMovieClip() calls
44 /// (an empty movieclip... still to be designed)
46 class DummyMovieDefinition
: public SWFMovieDefinition
51 std::vector
<PlayList
> _playlist
;
58 /// Default constructor
60 /// Will be initialized with the following values
64 /// - Single frame (unlabeled)
66 /// - 0 bytes (for get_bytes_loaded()/get_bytes_total())
69 DummyMovieDefinition(const RunResources
& ri
)
71 SWFMovieDefinition(ri
),
73 _framesize(0, 0, 640*20, 480*20),
75 _playlist(_framecount
),
77 _url("http://www.gnu.org/software/gnash")
81 /// Overloaded constructor for specifying target version
83 /// This is particularly useful for unit tests.
84 /// All but the target version will be initialized
85 /// exactly as with the default constructor.
87 DummyMovieDefinition(const RunResources
& ri
, int version
)
89 SWFMovieDefinition(ri
),
91 _framesize(0, 0, 640*20, 480*20),
93 _playlist(_framecount
),
95 _url("http://www.gnu.org/software/gnash")
99 virtual bool ensure_frame_loaded(size_t) const {
103 virtual int get_version() const {
107 virtual size_t get_width_pixels() const {
108 return _framesize
.width()/20;
111 virtual size_t get_height_pixels() const {
112 return _framesize
.height()/20;
115 virtual size_t get_frame_count() const {
119 virtual float get_frame_rate() const {
123 virtual const SWFRect
& get_frame_size() const {
127 virtual size_t get_bytes_loaded() const {
131 virtual size_t get_bytes_total() const {
135 /// Create a playable movie instance from a def.
136 virtual Movie
* createMovie(Global_as
& gl
, DisplayObject
* parent
=NULL
)
138 as_object
* o
= getObjectWithPrototype(gl
, NSV::CLASS_MOVIE_CLIP
);
139 return new SWFMovie(o
, this, parent
);
142 virtual const PlayList
& get_playlist(size_t frame_number
) const
144 assert ( frame_number
< _playlist
.size() );
145 return _playlist
[frame_number
];
149 // For use during creation.
152 /// Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded
153 virtual size_t get_loading_frame() const {
157 virtual const std::string
& get_url() const {
165 #endif // GNASH_DUMMYMOVIEDEFINITION_H