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 
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
gnash::BitmapMovieDefinition::BitmapMovieDefinition
BitmapMovieDefinition(std::unique_ptr< image::GnashImage > image, Renderer *renderer, std::string url)
Construct a BitmapMovieDefinition for the given image (rgb)
Definition: BitmapMovieDefinition.cpp:41
gnash::BitmapMovieDefinition::get_url
virtual const std::string & get_url() const
Return the URL of the SWF stream this definition has been read from.
Definition: BitmapMovieDefinition.h:111
gnash::NSV::CLASS_MOVIE_CLIP
@ CLASS_MOVIE_CLIP
Definition: namedStrings.h:227
gnash::BitmapMovieDefinition
A "movie" definition for a bitmap file.
Definition: BitmapMovieDefinition.h:46
gnash::BitmapMovieDefinition::get_version
virtual int get_version() const
Definition: BitmapMovieDefinition.h:67
height
@ height
Definition: klash_part.cpp:329
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
BitmapMovieDefinition.h
gnash::BitmapMovieDefinition::get_frame_count
virtual size_t get_frame_count() const
Definition: BitmapMovieDefinition.h:79
Bitmap.h
Renderer.h
Geometry.h
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::Renderer
Base class for render handlers.
Definition: Renderer.h:189
Global_as.h
SWFRect.h
GnashImage.h
gnash::twipsToPixels
double twipsToPixels(int i)
Definition: GnashNumeric.h:97
gnash::movie_definition
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
CachedBitmap.h
gnash::SWFRect
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:45
gnash::BitmapMovieDefinition::get_bytes_loaded
virtual size_t get_bytes_loaded() const
Return number of bytes loaded.
Definition: BitmapMovieDefinition.h:96
gnash::BitmapMovieDefinition::bitmap
const CachedBitmap * bitmap() const
Definition: BitmapMovieDefinition.h:124
gnash::SWFRect::height
std::int32_t height() const
Return height of this rectangle in TWIPS.
Definition: SWFRect.h:109
GnashNumeric.h
gnash::Movie
A top-level, standalone Movie that can be loaded and played.
Definition: Movie.h:47
log.h
gnash::BitmapMovieDefinition::createDisplayObject
virtual DisplayObject * createDisplayObject(Global_as &, DisplayObject *) const
Create a DisplayObject with the given parent.
Definition: BitmapMovieDefinition.cpp:56
url
std::string url
Definition: gnash.cpp:59
namedStrings.h
gnash::Global_as
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:50
gnash::BitmapMovieDefinition::createMovie
virtual Movie * createMovie(Global_as &gl, DisplayObject *parent=nullptr)
Create a playable Movie from this def.
Definition: BitmapMovieDefinition.cpp:35
gnash::getObjectWithPrototype
as_object * getObjectWithPrototype(Global_as &gl, const ObjectURI &c)
Definition: as_object.cpp:1109
gnash::SWFRect::width
std::int32_t width() const
Return width of this rectangle in TWIPS.
Definition: SWFRect.h:103
gnash::BitmapMovieDefinition::get_frame_rate
virtual float get_frame_rate() const
Definition: BitmapMovieDefinition.h:83
movie_definition.h
gnash::DisplayObject
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
gnash::BitmapMovieDefinition::get_loading_frame
size_t get_loading_frame() const
Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded.
Definition: BitmapMovieDefinition.h:119
gnash::BitmapMovieDefinition::get_frame_size
virtual const SWFRect & get_frame_size() const
Return size of frame, in TWIPS.
Definition: BitmapMovieDefinition.h:87
BitmapMovie.h
gnash::key::o
@ o
Definition: GnashKey.h:161
gnash::BitmapMovieDefinition::get_width_pixels
virtual size_t get_width_pixels() const
Frame width in pixels.
Definition: BitmapMovieDefinition.h:71
width
@ width
Definition: klash_part.cpp:329
gnash::BitmapMovieDefinition::get_bytes_total
virtual size_t get_bytes_total() const
Return total number of bytes which composed this movie.
Definition: BitmapMovieDefinition.h:104
gnash::CachedBitmap
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:38
gnash::BitmapMovieDefinition::get_height_pixels
virtual size_t get_height_pixels() const
Frame height in pixels.
Definition: BitmapMovieDefinition.h:75
gnash::BitmapMovie
A top-level movie displaying a still bitmap.
Definition: BitmapMovie.h:41