Gnash  0.8.10
BitmapMovieDefinition.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2007, 2008, 2009, 2010, 2011. 2012
00003 //   Free Software Foundation, Inc.
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_BITMAPMOVIEDEFINITION_H
00020 #define GNASH_BITMAPMOVIEDEFINITION_H
00021 
00022 #include "movie_definition.h" // for inheritance
00023 #include "SWFRect.h" 
00024 #include "GnashNumeric.h"
00025 
00026 #include <boost/intrusive_ptr.hpp>
00027 #include <string>
00028 #include <memory> 
00029 
00030 // Forward declarations
00031 namespace gnash {
00032     class Renderer;
00033     namespace image {
00034         class GnashImage;
00035     }
00036 }
00037 
00038 namespace gnash
00039 {
00040 
00042 //
00045 class BitmapMovieDefinition : public movie_definition
00046 {
00047 public:
00048 
00049 
00051         //
00061         BitmapMovieDefinition(std::auto_ptr<image::GnashImage> image,
00062             Renderer* renderer, const std::string& url);
00063 
00064     virtual DisplayObject* createDisplayObject(Global_as&, DisplayObject*)
00065         const;
00066 
00067         virtual int     get_version() const {
00068                 return _version;
00069         }
00070 
00071         virtual size_t get_width_pixels() const {
00072                 return std::ceil(twipsToPixels(_framesize.width()));
00073         }
00074 
00075         virtual size_t get_height_pixels() const {
00076                 return std::ceil(twipsToPixels(_framesize.height()));
00077         }
00078 
00079         virtual size_t get_frame_count() const {
00080                 return _framecount;
00081         }
00082 
00083         virtual float get_frame_rate() const {
00084                 return _framerate;
00085         }
00086 
00087         virtual const SWFRect& get_frame_size() const {
00088                 return _framesize;
00089         }
00090 
00092         //
00096         virtual size_t get_bytes_loaded() const {
00097                 return get_bytes_total();
00098         }
00099 
00101         //
00104         virtual size_t get_bytes_total() const {
00105                 return _bytesTotal;
00106         }
00107         
00109         virtual Movie* createMovie(Global_as& gl, DisplayObject* parent = 0);
00110 
00111         virtual const std::string& get_url() const {
00112                 return _url;
00113         }
00114 
00115         // Inheritance from movie_definition requires this.
00116         // we always return 1 so MovieClip::construct()
00117         // doesn't skip our handling (TODO: check if it's correct to
00118         // skip handling of 0-frames movies..).
00119         size_t  get_loading_frame() const 
00120         {
00121                 return 1;
00122         }
00123 
00124     const CachedBitmap* bitmap() const {
00125         return _bitmap.get();
00126     }
00127 
00128 protected:
00129 
00130 private:
00131 
00132         int _version;
00133         SWFRect _framesize;
00134         size_t _framecount;
00135         float _framerate;
00136         std::string _url;
00137 
00138         size_t _bytesTotal;
00139 
00140     boost::intrusive_ptr<CachedBitmap> _bitmap;
00141 };
00142 
00143 } // namespace gnash
00144 
00145 #endif // GNASH_BITMAPMOVIEDEFINITION_H