2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef GNASH_BITMAP_H
21 #define GNASH_BITMAP_H
23 #include <boost/intrusive_ptr.hpp>
24 #include "DisplayObject.h"
25 #include "flash/display/BitmapData_as.h"
26 #include "DynamicShape.h"
30 class BitmapMovieDefinition
;
37 /// A Bitmap DisplayObject. This is not AS-referencable, but can be
38 /// removed and placed using depths like normal DisplayObjects.
40 /// This can be constructed dynamically from a BitmapData, or non-dynamically
41 /// as part of a BitmapMovie.
43 /// For non-dynamic Bitmap DisplayObjects, the bitmap data never changes. The
44 /// update() function is called once on stage placement.
46 /// For dynamic Bitmap DisplayObjects, the attached BitmapData_as should call
47 /// update() whenever the data changes. This Bitmap registers itself with
48 /// the BitmapData_as on stage placement.
49 class Bitmap
: public DisplayObject
53 /// Construct a Bitmap character from a BitmapData.
54 Bitmap(movie_root
& mr
, as_object
* object
, BitmapData_as
* bd
,
55 DisplayObject
* parent
);
57 /// Construct a Bitmap character from a loaded image.
58 Bitmap(movie_root
& mr
, as_object
* object
, const BitmapMovieDefinition
* def
,
59 DisplayObject
* parent
);
63 /// Notify the Bitmap that it's been updated during ActionScript execution
64 virtual void update();
66 virtual void add_invalidated_bounds(InvalidatedRanges
& ranges
, bool force
);
68 /// Display this Bitmap
69 virtual void display(Renderer
& renderer
, const Transform
& xform
);
71 /// Get the bounds of the Bitmap
72 virtual SWFRect
getBounds() const;
74 /// Test whether a point is in the Bitmap's bounds.
75 virtual bool pointInShape(std::int32_t x
, std::int32_t y
) const;
77 /// Called when the object is placed on stage.
78 virtual void construct(as_object
* init
= nullptr);
82 void markReachableObjects() const {
83 if (_bitmapData
) _bitmapData
->setReachable();
88 /// Return the bitmap used for this Bitmap DisplayObject.
90 /// It comes either from the definition or the BitmapData_as.
91 const CachedBitmap
* bitmap() const;
93 /// Checks whether an attached BitmapData_as is disposed.
95 /// If the BitmapData_as has been disposed, deletes _bitmapData.
96 /// and clears the DynamicShape.
97 void checkBitmapData();
99 /// This creates the DynamicShape for rendering.
101 /// It should be called every time the underlying bitmap changes; for
102 /// non-dynamic Bitmaps, this is only on construction.
103 const boost::intrusive_ptr
<const BitmapMovieDefinition
> _def
;
105 BitmapData_as
* _bitmapData
;
107 /// A shape to hold the bitmap fill.
110 /// This is cached to save querying the BitmapData often
113 /// This is cached to save querying the BitmapData often
118 } // end namespace gnash
121 #endif // GNASH_DYNAMIC_SHAPE_H
128 // indent-tabs-mode: t