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::unique_ptr<image::GnashImage> image,
62  Renderer* renderer, std::string url);
63 
64  virtual DisplayObject* createDisplayObject(Global_as&, DisplayObject*)
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 = nullptr);
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
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
double twipsToPixels(int i)
Definition: GnashNumeric.h:97
virtual const std::string & get_url() const
Return the URL of the SWF stream this definition has been read from.
Definition: BitmapMovieDefinition.h:111
virtual size_t get_bytes_total() const
Return total number of bytes which composed this movie.
Definition: BitmapMovieDefinition.h:104
A top-level, standalone Movie that can be loaded and played.
Definition: Movie.h:46
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
virtual int get_version() const
Definition: BitmapMovieDefinition.h:67
virtual size_t get_frame_count() const
Definition: BitmapMovieDefinition.h:79
virtual float get_frame_rate() const
Definition: BitmapMovieDefinition.h:83
Base class for render handlers.
Definition: Renderer.h:188
virtual const SWFRect & get_frame_size() const
Return size of frame, in TWIPS.
Definition: BitmapMovieDefinition.h:87
A "movie" definition for a bitmap file.
Definition: BitmapMovieDefinition.h:45
size_t get_loading_frame() const
Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded.
Definition: BitmapMovieDefinition.h:119
virtual size_t get_width_pixels() const
Frame width in pixels.
Definition: BitmapMovieDefinition.h:71
virtual size_t get_height_pixels() const
Frame height in pixels.
Definition: BitmapMovieDefinition.h:75
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:49
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
std::string url
Definition: gnash.cpp:59
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:37
virtual size_t get_bytes_loaded() const
Return number of bytes loaded.
Definition: BitmapMovieDefinition.h:96
const CachedBitmap * bitmap() const
Definition: BitmapMovieDefinition.h:124