19
19
#include "Bitmap.h"
20
20
#include "flash/display/BitmapData_as.h"
21
21
#include "GnashImage.h"
22
#include "fill_style.h"
22
23
#include "DynamicShape.h"
27
#include "movie_root.h"
27
Bitmap::Bitmap(boost::intrusive_ptr<BitmapData_as> bd, character* parent,
31
Bitmap::Bitmap(boost::intrusive_ptr<BitmapData_as> bd, DisplayObject* parent,
30
character(parent, id),
34
DisplayObject(parent, id),
33
_shapeDef(new DynamicShape),
34
37
_width(_bitmapData->getWidth()),
35
38
_height(_bitmapData->getHeight())
37
_shapeDef->set_bound(rect(0, 0, _width * 20, _height * 20));
40
_shape.setBounds(rect(0, 0, pixelsToTwips(_width), pixelsToTwips(_height)));
43
Bitmap::Bitmap(const BitmapMovieDefinition* const def, DisplayObject* parent,
46
DisplayObject(parent, id),
49
_width(twipsToPixels(def->get_frame_size().width())),
50
_height(twipsToPixels(def->get_frame_size().height()))
52
_shape.setBounds(def->get_frame_size());
60
Bitmap::bitmap() const
62
if (_def) return _def->bitmap();
63
return _bitmapInfo.get();
47
67
Bitmap::stagePlacementCallback(as_object* initObj)
51
_bitmapData->registerBitmap(this);
70
if (_bitmapData) _bitmapData->registerBitmap(this);
81
Bitmap::display(Renderer& renderer)
66
_shapeDef->display(this);
83
/// Don't display cleared Bitmaps.
84
if (!_def && !_bitmapData) return;
86
_shape.display(renderer, *this);
68
87
clear_invalidated();
112
_bitmapInfo = render::createBitmapInfo(im);
131
Renderer* renderer = getRunResources(*this).renderer();
132
if (renderer) _bitmapInfo = renderer->createBitmapInfo(im);
138
Bitmap::checkBitmapData()
121
if (!_bitmapData) return;
141
/// Nothing to do for disposed bitmaps.
142
if (_def && !_bitmapData) return;
123
144
const BitmapData_as::BitmapArray& data = _bitmapData->getBitmapData();
126
147
/// set _bitmapData to 0 to avoid any further interaction.
127
148
if (data.empty()) {
129
_shapeDef->set_bound(rect());
156
Bitmap::makeBitmapShape()
159
if (!_def && !_bitmapData) return;
161
if (_bitmapData) makeBitmap();
135
163
// Width and height are a maximum of 2880, so there is no risk of
137
const int w = _width * 20;
138
const int h = _height * 20;
165
const int w = pixelsToTwips(_width);
166
const int h = pixelsToTwips(_height);
144
169
mat.set_scale(1.0 / 20, 1.0 / 20);
145
fill_style fill(_bitmapInfo.get(), mat);
146
const size_t fillLeft = _shapeDef->add_fill_style(fill);
149
path bmpath(w, h, fillLeft, 0, 0, false);
170
fill_style fill(bitmap(), mat);
171
const size_t fillLeft = _shape.add_fill_style(fill);
173
Path bmpath(w, h, fillLeft, 0, 0, false);
150
174
bmpath.drawLineTo(w, 0);
151
175
bmpath.drawLineTo(0, 0);
152
176
bmpath.drawLineTo(0, h);
153
177
bmpath.drawLineTo(w, h);
155
_shapeDef->add_path(bmpath);
179
_shape.add_path(bmpath);
157
_shapeDef->finalize();
165
188
set_invalidated();