Gnash  0.8.11dev
BitmapMovieDefinition.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010, 2011. 2012
3 // Free Software Foundation, Inc.
4 //
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.
9 //
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.
14 //
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
18 
19 #ifndef GNASH_BITMAPMOVIEDEFINITION_H
20 #define GNASH_BITMAPMOVIEDEFINITION_H
21 
22 #include "movie_definition.h" // for inheritance
23 #include "SWFRect.h"
24 #include "GnashNumeric.h"
25 
26 #include <boost/intrusive_ptr.hpp>
27 #include <string>
28 #include <memory>
29 
30 // Forward declarations
31 namespace gnash {
32  class Renderer;
33  namespace image {
34  class GnashImage;
35  }
36 }
37 
38 namespace gnash
39 {
40 
42 //
46 {
47 public:
48 
49 
51  //
61  BitmapMovieDefinition(std::auto_ptr<image::GnashImage> image,
62  Renderer* renderer, const std::string& url);
63 
65  const;
66 
67  virtual int get_version() const {
68  return _version;
69  }
70 
71  virtual size_t get_width_pixels() const {
72  return std::ceil(twipsToPixels(_framesize.width()));
73  }
74 
75  virtual size_t get_height_pixels() const {
76  return std::ceil(twipsToPixels(_framesize.height()));
77  }
78 
79  virtual size_t get_frame_count() const {
80  return _framecount;
81  }
82 
83  virtual float get_frame_rate() const {
84  return _framerate;
85  }
86 
87  virtual const SWFRect& get_frame_size() const {
88  return _framesize;
89  }
90 
92  //
96  virtual size_t get_bytes_loaded() const {
97  return get_bytes_total();
98  }
99 
101  //
104  virtual size_t get_bytes_total() const {
105  return _bytesTotal;
106  }
107 
109  virtual Movie* createMovie(Global_as& gl, DisplayObject* parent = 0);
110 
111  virtual const std::string& get_url() const {
112  return _url;
113  }
114 
115  // Inheritance from movie_definition requires this.
116  // we always return 1 so MovieClip::construct()
117  // doesn't skip our handling (TODO: check if it's correct to
118  // skip handling of 0-frames movies..).
119  size_t get_loading_frame() const
120  {
121  return 1;
122  }
123 
124  const CachedBitmap* bitmap() const {
125  return _bitmap.get();
126  }
127 
128 protected:
129 
130 private:
131 
132  int _version;
133  SWFRect _framesize;
134  size_t _framecount;
135  float _framerate;
136  std::string _url;
137 
138  size_t _bytesTotal;
139 
140  boost::intrusive_ptr<CachedBitmap> _bitmap;
141 };
142 
143 } // namespace gnash
144 
145 #endif // GNASH_BITMAPMOVIEDEFINITION_H