• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

BitmapData_as.h

Go to the documentation of this file.
00001 // BitmapData_as.h:  ActionScript "BitmapData" class, for Gnash.
00002 //
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00004 //   Foundation, Inc
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 
00021 #ifndef GNASH_ASOBJ_BITMAPDATA_H
00022 #define GNASH_ASOBJ_BITMAPDATA_H
00023 
00024 #include <list>
00025 #include <boost/cstdint.hpp>
00026 #include <boost/scoped_ptr.hpp>
00027 #include <cassert>
00028 #include "smart_ptr.h"
00029 #include <boost/intrusive_ptr.hpp>
00030 #include <memory>
00031 
00032 #include "Relay.h"
00033 #include "CachedBitmap.h"
00034 #include "GnashImage.h"
00035 
00036 namespace gnash {
00037     class as_object;
00038     struct ObjectURI;
00039     class DisplayObject;
00040     class GnashImage;
00041 }
00042 
00043 namespace gnash {
00044 
00046 //
00049 class BitmapData_as : public Relay
00050 {
00051 
00052 public:
00053 
00055     //
00058         BitmapData_as(as_object* owner, std::auto_ptr<GnashImage> im,
00059                       boost::uint32_t fillColor);
00060 
00061     virtual ~BitmapData_as() {}
00062 
00064     //
00066     size_t width() const {
00067         assert(data());
00068         return data()->width();
00069     }
00070     
00072     //
00074     size_t height() const {
00075         assert(data());
00076         return data()->height();
00077     }
00078 
00079     bool transparent() const {
00080         assert(data());
00081         return (data()->type() == GNASH_IMAGE_RGBA);
00082     }
00083 
00084     const CachedBitmap* bitmapInfo() const {
00085         return _cachedBitmap.get();
00086     }
00087 
00089     //
00091     void setPixel(size_t x, size_t y, boost::uint32_t color);
00092 
00094     void setPixel32(size_t x, size_t y, boost::uint32_t color);
00095 
00097     //
00099     boost::uint32_t getPixel(size_t x, size_t y) const;
00100 
00102     //
00104     void fillRect(int x, int y, int w, int h, boost::uint32_t color);
00105     
00107     void dispose();
00108 
00110     //
00112     void attach(DisplayObject* obj) {
00113         _attachedObjects.push_back(obj);
00114     }
00115 
00117     virtual void setReachable();
00118 
00120     bool disposed() const {
00121         return !data();
00122     }
00123 
00124 private:
00125     
00126     GnashImage* data() const {
00127         return _cachedBitmap.get() ? &_cachedBitmap->image() : _image.get();
00128     }
00129 
00131     void updateObjects();
00132 
00134     as_object* _owner;
00135 
00136     boost::intrusive_ptr<CachedBitmap> _cachedBitmap;
00137 
00138     boost::scoped_ptr<GnashImage> _image;
00139 
00140     std::list<DisplayObject*> _attachedObjects;
00141 
00142 };
00143 
00145 void bitmapdata_class_init(as_object& where, const ObjectURI& uri);
00146 
00147 } // end of gnash namespace
00148 
00149 #endif

Generated on Fri Mar 16 2012 15:46:09 for Gnash by  doxygen 1.7.1