Gnash  0.8.11dev
BitmapData_as.h
Go to the documentation of this file.
1 // BitmapData_as.h: ActionScript "BitmapData" class, for Gnash.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 
21 #ifndef GNASH_ASOBJ_BITMAPDATA_H
22 #define GNASH_ASOBJ_BITMAPDATA_H
23 
24 #include <list>
25 #include <boost/cstdint.hpp>
26 #include <boost/scoped_ptr.hpp>
27 #include <cassert>
28 #include <boost/intrusive_ptr.hpp>
29 #include <memory>
30 
31 #include "Relay.h"
32 #include "CachedBitmap.h"
33 #include "GnashImage.h"
34 #include "ImageIterators.h"
35 
36 namespace gnash {
37  class as_object;
38  struct ObjectURI;
39  class MovieClip;
40  class Transform;
41  class DisplayObject;
42  namespace image {
43  class GnashImage;
44  }
45 }
46 
47 namespace gnash {
48 
50 //
55 //
59 //
63 class BitmapData_as : public Relay
64 {
65 public:
66 
67  enum Channel {
72  };
73 
75 
77  //
80  BitmapData_as(as_object* owner, std::auto_ptr<image::GnashImage> im);
81 
82  virtual ~BitmapData_as() {}
83 
85  //
87  size_t width() const {
88  assert(data());
89  return data()->width();
90  }
91 
93  //
95  size_t height() const {
96  assert(data());
97  return data()->height();
98  }
99 
101  //
103  bool transparent() const {
104  assert(data());
105  return (data()->type() == image::TYPE_RGBA);
106  }
107 
109  //
111  const CachedBitmap* bitmapInfo() const {
112  return _cachedBitmap.get();
113  }
114 
116  //
118  void dispose();
119 
121  void draw(MovieClip& mc, const Transform& transform);
122 
124  //
126  void attach(DisplayObject* obj) {
127  _attachedObjects.push_back(obj);
128  }
129 
131  virtual void setReachable();
132 
134  //
139  bool disposed() const {
140  return !data();
141  }
142 
144  iterator begin() const {
145  assert(!disposed());
146  return image::begin<image::ARGB>(*data());
147  }
148 
150  iterator end() const {
151  assert(!disposed());
152  return image::end<image::ARGB>(*data());
153  }
154 
156  void updateObjects() const;
157 
158 private:
159 
160  image::GnashImage* data() const {
161  return _cachedBitmap.get() ? &_cachedBitmap->image() : _image.get();
162  }
163 
165  as_object* _owner;
166 
167  boost::intrusive_ptr<CachedBitmap> _cachedBitmap;
168 
169  boost::scoped_ptr<image::GnashImage> _image;
170 
171  std::list<DisplayObject*> _attachedObjects;
172 
173 };
174 
176 void bitmapdata_class_init(as_object& where, const ObjectURI& uri);
177 
178 void registerBitmapDataNative(as_object& global);
179 
180 } // end of gnash namespace
181 
182 #endif