Fix test for bug #32625
[gnash.git] / libcore / Bitmap.h
blob8ccc1eb31456df273210dd108daca44e61e0ef08
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_BITMAP_H
20 #define GNASH_BITMAP_H
22 #include <boost/intrusive_ptr.hpp>
23 #include "DisplayObject.h"
24 #include "flash/display/BitmapData_as.h"
25 #include "BitmapMovieDefinition.h"
26 #include "DynamicShape.h"
28 namespace gnash {
29 class CachedBitmap;
33 namespace gnash {
36 /// A Bitmap DisplayObject. This is not AS-referencable, but can be
37 /// removed and placed using depths like normal DisplayObjects.
39 /// This can be constructed dynamically from a BitmapData, or non-dynamically
40 /// as part of a BitmapMovie.
42 /// For non-dynamic Bitmap DisplayObjects, the bitmap data never changes. The
43 /// update() function is called once on stage placement.
45 /// For dynamic Bitmap DisplayObjects, the attached BitmapData_as should call
46 /// update() whenever the data changes. This Bitmap registers itself with
47 /// the BitmapData_as on stage placement.
48 class Bitmap : public DisplayObject
50 public:
52 /// Construct a Bitmap character from a BitmapData.
53 Bitmap(movie_root& mr, as_object* object, BitmapData_as* bd,
54 DisplayObject* parent);
56 /// Construct a Bitmap character from a loaded image.
57 Bitmap(movie_root& mr, as_object* object, const BitmapMovieDefinition* def,
58 DisplayObject* parent);
60 virtual ~Bitmap();
62 /// Notify the Bitmap that it's been updated during ActionScript execution
63 virtual void update();
65 virtual void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
67 /// Display this Bitmap
68 virtual void display(Renderer& renderer, const Transform& xform);
70 /// Get the bounds of the Bitmap
71 virtual SWFRect getBounds() const;
73 /// Test whether a point is in the Bitmap's bounds.
74 virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const;
76 /// Called when the object is placed on stage.
77 virtual void construct(as_object* init = 0);
79 protected:
81 void markReachableObjects() const {
82 if (_bitmapData) _bitmapData->setReachable();
85 private:
87 /// Return the bitmap used for this Bitmap DisplayObject.
89 /// It comes either from the definition or the BitmapData_as.
90 const CachedBitmap* bitmap() const;
92 /// Checks whether an attached BitmapData_as is disposed.
94 /// If the BitmapData_as has been disposed, deletes _bitmapData.
95 /// and clears the DynamicShape.
96 void checkBitmapData();
98 /// This creates the DynamicShape for rendering.
100 /// It should be called every time the underlying bitmap changes; for
101 /// non-dynamic Bitmaps, this is only on construction.
102 const boost::intrusive_ptr<const BitmapMovieDefinition> _def;
104 BitmapData_as* _bitmapData;
106 /// A shape to hold the bitmap fill.
107 DynamicShape _shape;
109 /// This is cached to save querying the BitmapData often
110 size_t _width;
112 /// This is cached to save querying the BitmapData often
113 size_t _height;
117 } // end namespace gnash
120 #endif // GNASH_DYNAMIC_SHAPE_H
123 // Local Variables:
124 // mode: C++
125 // c-basic-offset: 8
126 // tab-width: 8
127 // indent-tabs-mode: t
128 // End: