Drop the bool operator for ObjectURI, to avoid getting the kind of side-effect that...
[gnash.git] / libcore / parser / BitmapMovieDefinition.h
blob13d3f9408f3763336326580d5d33ec998ab5db92
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef GNASH_BITMAPMOVIEDEFINITION_H
19 #define GNASH_BITMAPMOVIEDEFINITION_H
21 #include "movie_definition.h" // for inheritance
22 #include "SWFRect.h"
23 #include "GnashNumeric.h"
25 #include <boost/intrusive_ptr.hpp>
26 #include <string>
27 #include <memory>
29 // Forward declarations
30 namespace gnash {
31 class Renderer;
32 namespace image {
33 class GnashImage;
37 namespace gnash
40 /// A "movie" definition for a bitmap file
42 /// The createMovie function will return a BitmapMovie
43 ///
44 class BitmapMovieDefinition : public movie_definition
46 public:
49 /// Construct a BitmapMovieDefinition for the given image (rgb)
51 /// Will be initialized with the following values
52 ///
53 /// - SWF version 6
54 /// - Framesize extracted from image
55 /// - Single frame (unlabeled)
56 /// - 12 FPS
57 /// - image->size() bytes (for get_bytes_loaded()/get_bytes_total())
58 /// - provided url
59 ///
60 BitmapMovieDefinition(std::auto_ptr<image::GnashImage> image,
61 Renderer* renderer, const std::string& url);
63 virtual DisplayObject* createDisplayObject(Global_as&, DisplayObject*)
64 const;
66 virtual int get_version() const {
67 return _version;
70 virtual size_t get_width_pixels() const {
71 return std::ceil(twipsToPixels(_framesize.width()));
74 virtual size_t get_height_pixels() const {
75 return std::ceil(twipsToPixels(_framesize.height()));
78 virtual size_t get_frame_count() const {
79 return _framecount;
82 virtual float get_frame_rate() const {
83 return _framerate;
86 virtual const SWFRect& get_frame_size() const {
87 return _framesize;
90 /// Return number of bytes loaded
92 /// Since no progressive load is implemented yet
93 /// we'll always return total bytes here..
94 ///
95 virtual size_t get_bytes_loaded() const {
96 return get_bytes_total();
99 /// Return total number of bytes which composed this movie
101 /// We actually cheat, and return the image size here...
103 virtual size_t get_bytes_total() const {
104 return _bytesTotal;
107 /// Create a playable Movie from this def.
108 virtual Movie* createMovie(Global_as& gl, DisplayObject* parent = 0);
110 virtual const std::string& get_url() const {
111 return _url;
114 // Inheritance from movie_definition requires this.
115 // we always return 1 so MovieClip::construct()
116 // doesn't skip our handling (TODO: check if it's correct to
117 // skip handling of 0-frames movies..).
118 size_t get_loading_frame() const
120 return 1;
123 const CachedBitmap* bitmap() const {
124 return _bitmap.get();
127 protected:
129 private:
131 int _version;
132 SWFRect _framesize;
133 size_t _framecount;
134 float _framerate;
135 std::string _url;
137 size_t _bytesTotal;
139 boost::intrusive_ptr<CachedBitmap> _bitmap;
142 } // namespace gnash
144 #endif // GNASH_BITMAPMOVIEDEFINITION_H