[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10792: Test that BitmapMovies can h
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10792: Test that BitmapMovies can have child sprites (they can). |
Date: |
Wed, 15 Apr 2009 15:10:54 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10792
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-04-15 15:10:54 +0200
message:
Test that BitmapMovies can have child sprites (they can).
Unify bitmap creation.
Const correct fill_style's BitmapInfo, and adapt the renderers to it.
OGL performs a kind of lazy initialization and currently needs mutable members
due to this.
modified:
backend/render_handler_agg.cpp
backend/render_handler_agg_style.h
backend/render_handler_cairo.cpp
backend/render_handler_ogl.cpp
backend/render_handler_ogl.h
libcore/Bitmap.cpp
libcore/Bitmap.h
libcore/fill_style.cpp
libcore/fill_style.h
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
testsuite/misc-ming.all/loadMovieTest.c
------------------------------------------------------------
revno: 10791.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 13:22:17 +0200
message:
Test that a BitmapMovie can have child sprites.
modified:
testsuite/misc-ming.all/loadMovieTest.c
------------------------------------------------------------
revno: 10791.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 13:24:05 +0200
message:
Update totals.
modified:
testsuite/misc-ming.all/loadMovieTest.c
------------------------------------------------------------
revno: 10791.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 14:27:37 +0200
message:
Make a Bitmap, not a Shape, for a BitmapMovie, and use the same code
to construct DynamicShapes for displaying bitmaps instead of doing it
in two places.
Const correct fill_style and other things that rely on it.
modified:
backend/render_handler_agg.cpp
backend/render_handler_agg_style.h
libcore/Bitmap.cpp
libcore/Bitmap.h
libcore/fill_style.cpp
libcore/fill_style.h
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
=== modified file 'backend/render_handler_agg.cpp'
--- a/backend/render_handler_agg.cpp 2009-04-07 14:32:06 +0000
+++ b/backend/render_handler_agg.cpp 2009-04-15 12:27:37 +0000
@@ -1345,7 +1345,7 @@
}
}
- sh.add_bitmap(dynamic_cast<agg_bitmap_info*>
+ sh.add_bitmap(dynamic_cast<const agg_bitmap_info*>
(fill_styles[fno].get_bitmap_info()), m, cx,
(fill_type==SWF::FILL_TILED_BITMAP) ||
(fill_type==SWF::FILL_TILED_BITMAP_HARD),
=== modified file 'backend/render_handler_agg_style.h'
--- a/backend/render_handler_agg_style.h 2009-01-22 20:10:39 +0000
+++ b/backend/render_handler_agg_style.h 2009-04-15 12:27:37 +0000
@@ -309,7 +309,7 @@
}
/// Adds a new bitmap fill style
- void add_bitmap(agg_bitmap_info* bi, const gnash::SWFMatrix& mat,
+ void add_bitmap(const agg_bitmap_info* bi, const gnash::SWFMatrix& mat,
const gnash::cxform& cx, bool repeat, bool smooth)
{
@@ -382,7 +382,7 @@
// === RGB24 ===
- void add_bitmap_repeat_nn_rgb24(agg_bitmap_info* bi,
+ void add_bitmap_repeat_nn_rgb24(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -407,7 +407,7 @@
- void add_bitmap_clip_nn_rgb24(agg_bitmap_info* bi,
+ void add_bitmap_clip_nn_rgb24(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -430,7 +430,7 @@
- void add_bitmap_repeat_aa_rgb24(agg_bitmap_info* bi,
+ void add_bitmap_repeat_aa_rgb24(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -453,7 +453,7 @@
}
- void add_bitmap_clip_aa_rgb24(agg_bitmap_info* bi,
+ void add_bitmap_clip_aa_rgb24(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -478,7 +478,7 @@
// === RGBA32 ===
- void add_bitmap_repeat_nn_rgba32(agg_bitmap_info* bi,
+ void add_bitmap_repeat_nn_rgba32(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -503,7 +503,7 @@
- void add_bitmap_clip_nn_rgba32(agg_bitmap_info* bi,
+ void add_bitmap_clip_nn_rgba32(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -526,7 +526,7 @@
- void add_bitmap_repeat_aa_rgba32(agg_bitmap_info* bi,
+ void add_bitmap_repeat_aa_rgba32(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
@@ -549,7 +549,7 @@
}
- void add_bitmap_clip_aa_rgba32(agg_bitmap_info* bi,
+ void add_bitmap_clip_aa_rgba32(const agg_bitmap_info* bi,
const gnash::SWFMatrix& mat, const gnash::cxform& cx)
{
=== modified file 'backend/render_handler_cairo.cpp'
--- a/backend/render_handler_cairo.cpp 2009-04-07 14:38:20 +0000
+++ b/backend/render_handler_cairo.cpp 2009-04-15 13:10:54 +0000
@@ -164,7 +164,7 @@
cairo_pattern_destroy(_pattern);
}
- cairo_pattern_t* apply(const cairo_matrix_t* mat, int fill_type)
+ cairo_pattern_t* apply(const cairo_matrix_t* mat, int fill_type) const
{
assert(mat);
assert(_pattern);
@@ -255,8 +255,8 @@
{
SWFMatrix m = style.getBitmapMatrix();
- bitmap_info_cairo* binfo
- = dynamic_cast<bitmap_info_cairo*>(style.get_bitmap_info());
+ const bitmap_info_cairo* binfo
+ = dynamic_cast<const bitmap_info_cairo*>(style.get_bitmap_info());
if (!binfo) {
return NULL;
@@ -315,7 +315,7 @@
cairo_fill(_cr);
- // Surfaces are owned by bitmap_info_cairo
+ // Surfaces are owned by const bitmap_info_cairo
if (cairo_pattern_get_type(_pattern) != CAIRO_PATTERN_TYPE_SURFACE) {
cairo_pattern_destroy(_pattern);
_pattern = 0;
=== modified file 'backend/render_handler_ogl.cpp'
--- a/backend/render_handler_ogl.cpp 2009-04-07 14:45:34 +0000
+++ b/backend/render_handler_ogl.cpp 2009-04-15 13:10:54 +0000
@@ -456,7 +456,7 @@
}
void
-bitmap_info_ogl::setup()
+bitmap_info_ogl::setup() const
{
oglScopeEnable enabler(_ogl_img_type);
@@ -505,7 +505,7 @@
}
void
-bitmap_info_ogl::upload(boost::uint8_t* data, size_t width, size_t height)
+bitmap_info_ogl::upload(boost::uint8_t* data, size_t width, size_t height)
const
{
glTexParameteri(_ogl_img_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -524,7 +524,7 @@
void
bitmap_info_ogl::apply(const gnash::SWFMatrix& bitmap_matrix,
- bitmap_wrap_mode wrap_mode)
+ bitmap_wrap_mode wrap_mode) const
{
glEnable(_ogl_img_type);
@@ -1229,7 +1229,8 @@
case SWF::FILL_FOCAL_GRADIENT:
{
- bitmap_info_ogl* binfo =
static_cast<bitmap_info_ogl*>(style.need_gradient_bitmap());
+ const bitmap_info_ogl* binfo =
+ static_cast<const
bitmap_info_ogl*>(style.need_gradient_bitmap());
SWFMatrix m = style.getGradientMatrix();
binfo->apply(m, bitmap_info_ogl::WRAP_CLAMP);
@@ -1239,7 +1240,8 @@
case SWF::FILL_TILED_BITMAP_HARD:
case SWF::FILL_TILED_BITMAP:
{
- bitmap_info_ogl* binfo =
static_cast<bitmap_info_ogl*>(style.get_bitmap_info());
+ const bitmap_info_ogl* binfo =
+ static_cast<const bitmap_info_ogl*>(style.get_bitmap_info());
binfo->apply(style.getBitmapMatrix(), bitmap_info_ogl::WRAP_REPEAT);
break;
@@ -1249,7 +1251,8 @@
// smooth=true;
case SWF::FILL_CLIPPED_BITMAP_HARD:
{
- bitmap_info_ogl* binfo =
dynamic_cast<bitmap_info_ogl*>(style.get_bitmap_info());
+ const bitmap_info_ogl* binfo =
+ dynamic_cast<const bitmap_info_ogl*>(style.get_bitmap_info());
assert(binfo);
=== modified file 'backend/render_handler_ogl.h'
--- a/backend/render_handler_ogl.h 2009-04-07 14:45:34 +0000
+++ b/backend/render_handler_ogl.h 2009-04-15 13:10:54 +0000
@@ -161,17 +161,17 @@
~bitmap_info_ogl();
void apply(const gnash::SWFMatrix& bitmap_matrix,
- bitmap_wrap_mode wrap_mode);
+ bitmap_wrap_mode wrap_mode) const;
private:
inline bool ogl_accessible() const;
- void setup();
- void upload(boost::uint8_t* data, size_t width, size_t height);
+ void setup() const;
+ void upload(boost::uint8_t* data, size_t width, size_t height) const;
- std::auto_ptr<GnashImage> _img;
+ mutable std::auto_ptr<GnashImage> _img;
GLenum _pixel_format;
GLenum _ogl_img_type;
- bool _ogl_accessible;
- GLuint _texture_id;
+ mutable bool _ogl_accessible;
+ mutable GLuint _texture_id;
size_t _orig_width;
size_t _orig_height;
};
=== modified file 'libcore/Bitmap.cpp'
--- a/libcore/Bitmap.cpp 2009-04-07 09:19:54 +0000
+++ b/libcore/Bitmap.cpp 2009-04-15 12:27:37 +0000
@@ -33,21 +33,37 @@
_width(_bitmapData->getWidth()),
_height(_bitmapData->getHeight())
{
- _shape.setBounds(rect(0, 0, _width * 20, _height * 20));
+ _shape.setBounds(rect(0, 0, pixelsToTwips(_width),
pixelsToTwips(_height)));
}
+Bitmap::Bitmap(const BitmapMovieDefinition* const def, DisplayObject* parent,
+ int id)
+ :
+ DisplayObject(parent, id),
+ _def(def),
+ _bitmapInfo(0),
+ _width(twipsToPixels(def->get_frame_size().width())),
+ _height(twipsToPixels(def->get_frame_size().height()))
+{
+ _shape.setBounds(def->get_frame_size());
+}
Bitmap::~Bitmap()
{
}
+const BitmapInfo*
+Bitmap::bitmap() const
+{
+ if (_def) return _def->bitmap();
+ return _bitmapInfo.get();
+}
void
Bitmap::stagePlacementCallback(as_object* initObj)
{
assert(!initObj);
-
- _bitmapData->registerBitmap(this);
+ if (_bitmapData) _bitmapData->registerBitmap(this);
update();
}
@@ -60,8 +76,10 @@
void
Bitmap::display()
{
+ /// Don't display cleared Bitmaps.
+ if (!_def && !_bitmapData) return;
+
_shape.display(*this);
-
clear_invalidated();
}
@@ -85,7 +103,7 @@
}
void
-Bitmap::drawBitmap()
+Bitmap::makeBitmap()
{
const BitmapData_as::BitmapArray& data = _bitmapData->getBitmapData();
@@ -112,10 +130,11 @@
void
-Bitmap::finalize()
+Bitmap::checkBitmapData()
{
- if (!_bitmapData) return;
+ /// Nothing to do for disposed bitmaps.
+ if (_def && !_bitmapData) return;
const BitmapData_as::BitmapArray& data = _bitmapData->getBitmapData();
@@ -126,20 +145,26 @@
_shape.clear();
return;
}
-
- drawBitmap();
+}
+
+void
+Bitmap::makeBitmapShape()
+{
+
+ if (!_def && !_bitmapData) return;
+
+ if (_bitmapData) makeBitmap();
// Width and height are a maximum of 2880, so there is no risk of
// overflow
- const int w = _width * 20;
- const int h = _height * 20;
+ const int w = pixelsToTwips(_width);
+ const int h = pixelsToTwips(_height);
SWFMatrix mat;
mat.set_scale(1.0 / 20, 1.0 / 20);
- fill_style fill(_bitmapInfo.get(), mat);
+ fill_style fill(bitmap(), mat);
const size_t fillLeft = _shape.add_fill_style(fill);
-
Path bmpath(w, h, fillLeft, 0, 0, false);
bmpath.drawLineTo(w, 0);
bmpath.drawLineTo(0, 0);
@@ -155,11 +180,9 @@
void
Bitmap::update()
{
-
set_invalidated();
-
- finalize();
-
+ checkBitmapData();
+ makeBitmapShape();
}
}
=== modified file 'libcore/Bitmap.h'
--- a/libcore/Bitmap.h 2009-04-15 07:01:39 +0000
+++ b/libcore/Bitmap.h 2009-04-15 12:27:37 +0000
@@ -23,7 +23,7 @@
#include "BitmapInfo.h"
#include "flash/display/BitmapData_as.h"
#include "render.h"
-
+#include "BitmapMovieDefinition.h"
#include "DynamicShape.h"
@@ -32,15 +32,32 @@
/// A Bitmap DisplayObject. This is not AS-referencable, but can be
/// removed and placed using depths like normal DisplayObjects.
+//
+/// This can be constructed dynamically from a BitmapData, or non-dynamically
+/// as part of a BitmapMovie.
+//
+/// For non-dynamic Bitmap DisplayObjects, the bitmap data never changes. The
+/// update() function is called once on stage placement.
+//
+/// For dynamic Bitmap DisplayObjects, the attached BitmapData_as should call
+/// update() whenever the data changes. This Bitmap registers itself with
+/// the BitmapData_as on stage placement.
class Bitmap : public DisplayObject
{
public:
Bitmap(boost::intrusive_ptr<BitmapData_as> bd, DisplayObject* parent,
int id);
+
+ Bitmap(const BitmapMovieDefinition* const def, DisplayObject* parent,
+ int id);
~Bitmap();
+ /// Called to update the Bitmap's DynamicShape for display.
+ //
+ /// For non-dynamic bitmaps, this should only be called once (for
+ /// efficiency - there are no harmful side-effects)
void update();
virtual void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
@@ -58,17 +75,32 @@
void markReachableObjects() const {
if (_bitmapData) _bitmapData->setReachable();
if (_bitmapInfo) _bitmapInfo->setReachable();
+ if (_def) _def->setReachable();
}
private:
- /// This must convert the BitmapData to a BitmapInfo.
- //
- /// The result must be stored in _bitmapInfo.
- void drawBitmap();
-
- /// Call this before rendering to make sure the BitmapInfo is updated.
- void finalize();
+ /// Return the bitmap used for this Bitmap DisplayObject.
+ //
+ /// It comes either from the definition or the BitmapData_as.
+ const BitmapInfo* bitmap() const;
+
+ /// This updates _bitmapInfo from the BitmapData_as
+ void makeBitmap();
+
+ /// Checks whether an attached BitmapData_as is disposed.
+ //
+ /// If the BitmapData_as has been disposed, deletes _bitmapData.
+ /// and clears the DynamicShape.
+ void checkBitmapData();
+
+ /// This creates the DynamicShape for rendering.
+ //
+ /// It should be called every time the underlying bitmap changes; for
+ /// non-dynamic Bitmaps, this is only on construction.
+ void makeBitmapShape();
+
+ const boost::intrusive_ptr<const BitmapMovieDefinition> _def;
boost::intrusive_ptr<BitmapData_as> _bitmapData;
=== modified file 'libcore/fill_style.cpp'
--- a/libcore/fill_style.cpp 2009-04-03 09:18:40 +0000
+++ b/libcore/fill_style.cpp 2009-04-15 12:27:37 +0000
@@ -320,7 +320,7 @@
}
-BitmapInfo*
+const BitmapInfo*
fill_style::get_bitmap_info() const
{
assert(m_type != SWF::FILL_SOLID);
@@ -432,7 +432,7 @@
return m_gradients.back().m_color;
}
-BitmapInfo*
+const BitmapInfo*
fill_style::create_gradient_bitmap() const
{
assert(m_type == SWF::FILL_LINEAR_GRADIENT
@@ -499,14 +499,14 @@
break;
}
- BitmapInfo* bi = render::createBitmapInfo(
+ const BitmapInfo* bi = render::createBitmapInfo(
static_cast<std::auto_ptr<GnashImage> >(im));
return bi;
}
-BitmapInfo*
+const BitmapInfo*
fill_style::need_gradient_bitmap() const
{
@@ -593,7 +593,7 @@
return m_gradients[index];
}
-fill_style::fill_style(BitmapInfo* bitmap, const SWFMatrix& mat)
+fill_style::fill_style(const BitmapInfo* const bitmap, const SWFMatrix& mat)
:
_matrix(mat),
_bitmapInfo(bitmap),
=== modified file 'libcore/fill_style.h'
--- a/libcore/fill_style.h 2009-04-08 09:23:48 +0000
+++ b/libcore/fill_style.h 2009-04-15 12:27:37 +0000
@@ -115,7 +115,7 @@
/// @param mat
/// The SWFMatrix to apply to the bitmap.
///
- fill_style(BitmapInfo* bitmap, const SWFMatrix& mat);
+ fill_style(const BitmapInfo* const bitmap, const SWFMatrix& mat);
void setSolid(const rgba& color);
@@ -176,12 +176,12 @@
/// \brief
/// Make a BitmapInfo* corresponding to our gradient.
/// We can use this to set the gradient fill style.
- BitmapInfo* create_gradient_bitmap() const;
+ const BitmapInfo* create_gradient_bitmap() const;
/// \brief
/// Makes sure that _gradientBitmapInfo is not NULL. Calls
/// create_gradient_bitmap() if necessary and returns
_gradientBitmapInfo.
- BitmapInfo* need_gradient_bitmap() const;
+ const BitmapInfo* need_gradient_bitmap() const;
rgba get_color() const { return m_color; }
@@ -209,7 +209,7 @@
/// to a DisplayObject defined in the DisplayObjects dictionary.
/// (it happens..)
///
- BitmapInfo* get_bitmap_info() const;
+ const BitmapInfo* get_bitmap_info() const;
BitmapSmoothingPolicy getBitmapSmoothingPolicy() const {
return _bitmapSmoothingPolicy;
@@ -257,7 +257,7 @@
SWFMatrix _matrix;
// For BITMAP or GRADIENT types
- boost::intrusive_ptr<BitmapInfo> _bitmapInfo;
+ boost::intrusive_ptr<const BitmapInfo> _bitmapInfo;
// For SOLID type (and arguably GRADIENT too)
rgba m_color;
=== modified file 'libcore/parser/BitmapMovieDefinition.cpp'
--- a/libcore/parser/BitmapMovieDefinition.cpp 2009-04-15 09:08:37 +0000
+++ b/libcore/parser/BitmapMovieDefinition.cpp 2009-04-15 12:27:37 +0000
@@ -25,7 +25,7 @@
#include "render.h" // for ::display
#include "GnashImage.h"
#include "log.h"
-#include "Shape.h"
+#include "Bitmap.h"
namespace gnash {
@@ -46,51 +46,14 @@
_bytesTotal(image->size()),
_bitmap(render::createBitmapInfo(image))
{
-
- if (!_bitmap.get()) return;
-
- _shape.reset(new DynamicShape);
-
- // Set its boundaries
- _shape->setBounds(_framesize);
-
- // Add the bitmap fill style (fill style 0)
- SWFMatrix mat;
- mat.set_scale(1.0/20, 1.0/20); // bitmap fills get SWFMatrix reversed
- fill_style bmFill(_bitmap.get(), mat);
- const size_t fillLeft = _shape->add_fill_style(bmFill);
-
- // Define a rectangle filled with the bitmap style
-
- // We use one twip for each pixel in the image
- // The DisplayObject will be scaled * 20
- // when placed in BitmapMovie's DisplayList
- boost::int32_t w = _framesize.width();
- boost::int32_t h = _framesize.height();
-
- IF_VERBOSE_PARSE(
- log_parse(_("Creating a shape_definition wrapping a %g x %g
bitmap"),
- w, h);
- );
-
- Path bmPath(w, h, fillLeft, 0, 0, false);
- bmPath.drawLineTo(w, 0);
- bmPath.drawLineTo(0, 0);
- bmPath.drawLineTo(0, h);
- bmPath.drawLineTo(w, h);
-
- // Add the path
- _shape->add_path(bmPath);
-
}
DisplayObject*
BitmapMovieDefinition::createDisplayObject(DisplayObject* parent, int id) const
{
- // It's possible for this to fail.
- if (!_shape.get()) return 0;
-
- return new Shape(_shape, parent, id);
+ /// What should we do if construction of the bitmap fails?
+ if (!_bitmap.get()) return 0;
+ return new Bitmap(this, parent, id);
}
#ifdef GNASH_USE_GC
=== modified file 'libcore/parser/BitmapMovieDefinition.h'
--- a/libcore/parser/BitmapMovieDefinition.h 2009-04-15 09:08:37 +0000
+++ b/libcore/parser/BitmapMovieDefinition.h 2009-04-15 12:27:37 +0000
@@ -116,6 +116,10 @@
return 1;
}
+ const BitmapInfo* bitmap() const {
+ return _bitmap.get();
+ }
+
protected:
#ifdef GNASH_USE_GC
@@ -139,9 +143,6 @@
size_t _bytesTotal;
boost::intrusive_ptr<BitmapInfo> _bitmap;
-
- boost::shared_ptr<DynamicShape> _shape;
-
};
} // namespace gnash
=== modified file 'testsuite/misc-ming.all/loadMovieTest.c'
--- a/testsuite/misc-ming.all/loadMovieTest.c 2009-02-25 22:33:03 +0000
+++ b/testsuite/misc-ming.all/loadMovieTest.c 2009-04-15 11:24:05 +0000
@@ -134,6 +134,9 @@
//" _root.note(this+'.onUnload called');"
//"};"
"_level0.coverart.onMouseDown = function() {"
+ "t = this.createEmptyMovieClip('tc', 8);"
+ "_root.check(tc instanceof MovieClip);"
+ "_root.check(t instanceof MovieClip);"
//" _root.note('_url is '+this._url);"
" var lastUrlComponent =
this._url.substring(this._url.lastIndexOf('/')+1);"
//" _root.note('last component of _url is '+lastUrlComponent);"
@@ -145,7 +148,7 @@
" if ( Key.isDown(Key.SHIFT) ) { "
" trace('SHIFT-click on coverart...');"
//" _root.note('SHIFT-click on coverart...');"
- " _root.totals(18, '"__FILE__"');"
+ " _root.totals(26, '"__FILE__"');"
" _root.END_OF_TEST = true;"
" }"
" else _root.note('2 tests run');"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10792: Test that BitmapMovies can have child sprites (they can).,
Benjamin Wolsey <=