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 <cstdint>
26 #include <memory>
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 {
68  CHANNEL_RED = 1,
69  CHANNEL_GREEN = 2,
70  CHANNEL_BLUE = 4,
71  CHANNEL_ALPHA = 8
72  };
73 
75 
77  //
80  BitmapData_as(as_object* owner, std::unique_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  std::unique_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
void registerBitmapDataNative(as_object &global)
Definition: BitmapData_as.cpp:673
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:83
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
size_t width() const
Return the width of the image.
Definition: BitmapData_as.h:87
uri
Definition: test.py:12
iterator begin() const
Return a BitmapData_as::iterator to the first pixel in the data.
Definition: BitmapData_as.h:144
const CachedBitmap * bitmapInfo() const
Return the image data.
Definition: BitmapData_as.h:111
image::pixel_iterator< image::ARGB > iterator
Definition: BitmapData_as.h:74
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
bool disposed() const
Whether the BitmapData has been disposed.
Definition: BitmapData_as.h:139
size_t height() const
Return the height of the image.
Definition: BitmapData_as.h:95
type
Definition: GnashKey.h:329
Channel
Definition: BitmapData_as.h:67
The base class for all ActionScript objects.
Definition: as_object.h:161
iterator end() const
Return a BitmapData_as::iterator to a one-past-the end pixel.
Definition: BitmapData_as.h:150
The pixel_iterator class is a pixel-level adaptor for a GnashImage.
Definition: ImageIterators.h:122
Definition: GnashImage.h:50
A URI for describing as_objects.
Definition: ObjectURI.h:44
void bitmapdata_class_init(as_object &where, const ObjectURI &uri)
Initialize the global BitmapData class.
Definition: BitmapData_as.cpp:664
void attach(DisplayObject *obj)
Attach this BitmapData to an object.
Definition: BitmapData_as.h:126
Base class for different types of bitmaps.
Definition: GnashImage.h:77
This is the base class for type-specific object data.
Definition: Relay.h:49
bool transparent() const
Whether the BitmapData_as has transparency.
Definition: BitmapData_as.h:103
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:37
Implements the BitmapData native type.
Definition: BitmapData_as.h:63
virtual ~BitmapData_as()
Definition: BitmapData_as.h:82
The Transform class expresses a stage in a cumulative transformation.
Definition: Transform.h:33