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