[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10780: Use and draw a DynamicShape
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10780: Use and draw a DynamicShape directly in MovieClip, as there's no longer |
Date: |
Wed, 08 Apr 2009 11:09:05 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10780
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-04-08 11:09:05 +0200
message:
Use and draw a DynamicShape directly in MovieClip, as there's no longer
any need to have a containing Shape character.
modified:
libcore/Bitmap.h
libcore/DisplayObject.h
libcore/FreetypeGlyphsProvider.cpp
libcore/FreetypeGlyphsProvider.h
libcore/MorphShape.h
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/SWFMatrix.cpp
libcore/SWFMatrix.h
libcore/Shape.cpp
libcore/StaticText.cpp
libcore/StaticText.h
libcore/swf/TextRecord.cpp
------------------------------------------------------------
revno: 10779.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2009-04-07 19:33:15 +0200
message:
Update comment.
modified:
libcore/Bitmap.h
------------------------------------------------------------
revno: 10779.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2009-04-07 19:48:48 +0200
message:
Provide setter and getter for selection colour.
modified:
libcore/StaticText.cpp
libcore/StaticText.h
------------------------------------------------------------
revno: 10779.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2009-04-07 20:14:07 +0200
message:
Correct comments and signature of FreetypeGlyphsProvider stub.
modified:
libcore/FreetypeGlyphsProvider.cpp
libcore/FreetypeGlyphsProvider.h
------------------------------------------------------------
revno: 10779.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-04-08 06:56:20 +0200
message:
Render MovieClip's drawable directly.
modified:
libcore/MovieClip.cpp
------------------------------------------------------------
revno: 10779.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-04-08 09:08:06 +0200
message:
Drop _drawable_inst. Hold _drawable(DynamicShape) by value instead of
pointer. This makes MovieClip size still larger, but occupies much less
memory and reduces fragmentation.
Drop const on return of SWFMatrix::invert, as it is returns non-const
*this.
Update some documentation.
modified:
libcore/DisplayObject.h
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/SWFMatrix.cpp
libcore/SWFMatrix.h
libcore/Shape.cpp
------------------------------------------------------------
revno: 10779.1.6
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-04-08 10:35:37 +0200
message:
Notes on morph shape.
modified:
libcore/MorphShape.h
------------------------------------------------------------
revno: 10779.1.7
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-04-08 10:58:27 +0200
message:
Minor cleanup.
modified:
libcore/swf/TextRecord.cpp
=== modified file 'libcore/Bitmap.h'
--- a/libcore/Bitmap.h 2009-04-07 12:34:43 +0000
+++ b/libcore/Bitmap.h 2009-04-07 17:33:15 +0000
@@ -74,7 +74,7 @@
/// The current bitmap information is stored here.
boost::intrusive_ptr<BitmapInfo> _bitmapInfo;
- /// FIXME: using DefineShapeTag is unpleasant.
+ /// A shape to hold the bitmap fill.
DynamicShape _shape;
/// This is cached to save querying the BitmapData often
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2009-04-07 13:13:16 +0000
+++ b/libcore/DisplayObject.h 2009-04-08 07:08:06 +0000
@@ -460,6 +460,11 @@
return bounds.point_test(x, y);
}
+ /// Return true if the given point falls in this DisplayObject's shape
+ //
+ /// @param x Point x coordinate in world space
+ /// @param y Point y coordinate in world space
+ /// @return Whether (x, y) is within the DisplayObject's bounds.
virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const =
0;
/// true if the given point falls in this DisplayObject's visible shape
=== modified file 'libcore/FreetypeGlyphsProvider.cpp'
--- a/libcore/FreetypeGlyphsProvider.cpp 2009-04-07 12:23:59 +0000
+++ b/libcore/FreetypeGlyphsProvider.cpp 2009-04-07 18:14:07 +0000
@@ -507,7 +507,7 @@
}
#else // ndef(USE_FREETYPE)
-SWF::ShapeRecord*
+std::auto_ptr<SWF::ShapeRecord>
FreetypeGlyphsProvider::getGlyph(boost::uint16_t, float& advance)
{
abort(); // should never be called...
=== modified file 'libcore/FreetypeGlyphsProvider.h'
--- a/libcore/FreetypeGlyphsProvider.h 2009-04-07 12:34:43 +0000
+++ b/libcore/FreetypeGlyphsProvider.h 2009-04-07 18:14:07 +0000
@@ -52,7 +52,7 @@
/// but I think the actual size could change between glyphs (see the 'box'
/// parameter of getRenderedGlyph() method).
///
-/// Vectorial glyphs are instances of a DefineShapeTag, same class
+/// Vectorial glyphs are instances of a SWF::ShapeRecord, same class
/// resulting from parsing of embedded fonts.
///
class FreetypeGlyphsProvider
=== modified file 'libcore/MorphShape.h'
--- a/libcore/MorphShape.h 2009-04-07 14:32:06 +0000
+++ b/libcore/MorphShape.h 2009-04-08 08:35:37 +0000
@@ -32,6 +32,15 @@
/// A MorphShape has no properties of its own, but its inherited properties
/// may be read in AS3 using a reference to the object created with
/// getChildAt().
+//
+/// Morphing is controlled using a SWF::PlaceObject2 tag with a ratio flag.
+/// The most common and efficient way is to combine this with a move flag,
+/// so that this object is moved to the position specified by the ratio.
+/// However, it is also possible to remove and replace, in which case a
+/// new MorphShape is created.
+//
+/// The starting position is not necessarily identical with shape1, though in
+/// practice it often is.
class MorphShape : public DisplayObject
{
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-04-07 12:56:44 +0000
+++ b/libcore/MovieClip.cpp 2009-04-08 07:08:06 +0000
@@ -484,8 +484,6 @@
:
InteractiveObject(parent, id),
m_root(r),
- _drawable(new DynamicShape()),
- _drawable_inst(new Shape(_drawable, this, 0)),
m_play_state(PLAY),
m_current_frame(0),
m_has_looped(false),
@@ -774,7 +772,6 @@
boost::intrusive_ptr<DisplayObject>
MovieClip::add_textfield(const std::string& name, int depth, int x, int y,
float width, float height)
{
- // Create a definition (TODO: cleanup this thing, definitions should be
immutable!)
// Set textfield bounds
rect bounds(0, 0, pixelsToTwips(width), pixelsToTwips(height));
@@ -829,7 +826,7 @@
newmovieclip->set_event_handlers(get_event_handlers());
// Copy drawable
- newmovieclip->_drawable.reset(new DynamicShape(*_drawable));
+ newmovieclip->_drawable = _drawable;
newmovieclip->set_cxform(get_cxform());
newmovieclip->copyMatrix(*this); // copy SWFMatrix and caches
@@ -1442,29 +1439,17 @@
void MovieClip::display()
{
- //GNASH_REPORT_FUNCTION;
// Note:
// DisplayList::Display() will take care of the visibility checking.
//
- // Whether a DisplayObject should be rendered or not is dependent on its
parent.
- // i.e. if its parent is a mask, this DisplayObject should be rendered to
the mask
- // buffer even it is invisible.
- //
-
+ // Whether a DisplayObject should be rendered or not is dependent
+ // on its parent: i.e. if its parent is a mask, this DisplayObject
+ // should be rendered to the mask buffer even it is invisible.
// render drawable (ActionScript generated graphics)
-
- _drawable->finalize();
- // TODO: I'd like to draw the definition directly..
- // but it seems that the backend insists in
- // accessing the *parent* of the DisplayObject
- // passed as "instance" for the drawing.
- // When displaying top-level movie this will
- // be NULL and gnash will segfault
- // Thus, this drawable_instance is basically just
- // a container for a parent :(
- _drawable_inst->display();
+ _drawable.finalize();
+ _drawable.display(*this);
// descend the display list
@@ -1696,7 +1681,7 @@
ShapeContainerFinder finder(x, y);
const_cast<DisplayList&>(m_display_list).visitBackward(finder);
if ( finder.hitFound() ) return true;
- return _drawable_inst->pointInShape(x, y);
+ return hitTestDrawable(x, y);
}
bool
@@ -1724,35 +1709,34 @@
}
VisibleShapeContainerFinder finder(x, y);
const_cast<DisplayList&>(m_display_list).visitBackward(finder);
- if ( finder.hitFound() ) return true;
- return _drawable_inst->pointInVisibleShape(x, y);
+ if (finder.hitFound()) return true;
+ return hitTestDrawable(x, y);
+}
+
+inline bool
+MovieClip::hitTestDrawable(boost::int32_t x, boost::int32_t y) const
+{
+ SWFMatrix wm = getWorldMatrix();
+ wm.invert();
+ point lp(x, y);
+ wm.transform(lp);
+ if (!_drawable.getBounds().point_test(lp.x, lp.y)) return false;
+ return _drawable.pointTestLocal(lp.x, lp.y, wm);
}
bool
MovieClip::pointInHitableShape(boost::int32_t x, boost::int32_t y) const
{
- if ( isDynamicMask() && !mouseEnabled() )
- {
- return false;
- }
+ if (isDynamicMask() && !mouseEnabled()) return false;
- DisplayObject* mask = getMask();
- if ( mask && ! mask->pointInShape(x, y) )
- {
- return false;
- }
+ const DisplayObject* mask = getMask();
+ if (mask && !mask->pointInShape(x, y)) return false;
HitableShapeContainerFinder finder(x, y);
m_display_list.visitBackward(finder);
-
- if ( finder.hitFound() )
- {
- return true;
- }
- else
- {
- return _drawable_inst->pointInShape(x, y);
- }
+ if (finder.hitFound()) return true;
+
+ return hitTestDrawable(x, y);
}
InteractiveObject*
@@ -1789,9 +1773,8 @@
m_display_list.visitAll(finder);
InteractiveObject* ch = finder.getEntity();
- // It doesn't make any sense to query _drawable_inst, as it's
- // a generic DisplayObject and not a referencable DisplayObject.
-
+ // It doesn't make any sense to query _drawable, as it's
+ // not an InteractiveObject.
return ch;
}
@@ -1927,12 +1910,9 @@
}
// does it hit us ?
- if ( _drawable_inst->pointInVisibleShape(x, y) )
- {
- return this;
- }
+ if (hitTestDrawable(x, y)) return this;
- return NULL;
+ return 0;
}
bool
@@ -2097,7 +2077,10 @@
m_display_list.add_invalidated_bounds(ranges, force||m_invalidated);
- _drawable_inst->add_invalidated_bounds(ranges, force||m_invalidated);
+ /// Add drawable.
+ rect bounds;
+ bounds.expand_to_transformed_rect(getWorldMatrix(), _drawable.getBounds());
+ ranges.add(bounds.getRange());
}
@@ -2323,10 +2306,7 @@
// We won't be displayed again, so worth releasing
// some memory. The drawable might take a lot of memory
// on itself.
- _drawable->clear();
- // TODO: drop the _drawable_inst too ?
- // it would require _drawable_inst to possibly be NULL,
- // which wouldn't be bad at all actually...
+ _drawable.clear();
bool selfHaveUnloadHandler = DisplayObject::unload();
@@ -2562,7 +2542,7 @@
rect bounds;
BoundsFinder f(bounds);
const_cast<DisplayList&>(m_display_list).visitAll(f);
- rect drawableBounds = _drawable->getBounds();
+ rect drawableBounds = _drawable.getBounds();
bounds.expand_to_rect(drawableBounds);
return bounds;
@@ -2647,8 +2627,6 @@
m_display_list.visitAll(marker);
- _drawable_inst->setReachable();
-
m_as_environment.markReachableResources();
// Mark our own definition
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2009-04-07 12:34:43 +0000
+++ b/libcore/MovieClip.h 2009-04-08 07:08:06 +0000
@@ -696,7 +696,7 @@
join_style_e joinStyle=JOIN_ROUND,
float miterLimitFactor=1.0f)
{
- _drawable->lineStyle(thickness, color, vScale, hScale,
+ _drawable.lineStyle(thickness, color, vScale, hScale,
pixelHinting, noClose,
startCapStyle, endCapStyle, joinStyle,
miterLimitFactor);
@@ -704,51 +704,51 @@
void resetLineStyle()
{
- _drawable->resetLineStyle();
+ _drawable.resetLineStyle();
}
void beginFill(const rgba& color)
{
- _drawable->beginFill(color);
+ _drawable.beginFill(color);
}
void beginLinearGradientFill(const std::vector<gradient_record>& grad,
const SWFMatrix& mat)
{
- _drawable->beginLinearGradientFill(grad, mat);
+ _drawable.beginLinearGradientFill(grad, mat);
}
void beginRadialGradientFill(const std::vector<gradient_record>& grad,
const SWFMatrix& mat)
{
- _drawable->beginRadialGradientFill(grad, mat);
+ _drawable.beginRadialGradientFill(grad, mat);
}
void endFill()
{
- _drawable->endFill();
+ _drawable.endFill();
}
void moveTo(boost::int32_t x, boost::int32_t y)
{
- _drawable->moveTo(x, y);
+ _drawable.moveTo(x, y);
}
void lineTo(boost::int32_t x, boost::int32_t y)
{
set_invalidated();
- _drawable->lineTo(x, y, getSWFVersion());
+ _drawable.lineTo(x, y, getSWFVersion());
}
void curveTo(boost::int32_t cx, boost::int32_t cy,
boost::int32_t ax, boost::int32_t ay)
{
set_invalidated();
- _drawable->curveTo(cx, cy, ax, ay, getSWFVersion());
+ _drawable.curveTo(cx, cy, ax, ay, getSWFVersion());
}
void clear()
{
set_invalidated();
- _drawable->clear();
+ _drawable.clear();
}
/// Set focus to this MovieClip
@@ -820,20 +820,24 @@
///
void registerAsListener();
- /// \brief
- /// Return value of the 'enabled' property, casted to a boolean value.
- /// True if not found (undefined to bool evaluates to false).
+ /// Return value of the 'enabled' property cast to a boolean value.
+ //
+ /// This is true if not found (undefined to bool evaluates to false).
//
/// When a MovieClip is "disabled", its handlers of button-like events
/// are disabled, and automatic tab ordering won't include it.
- ///
- /// See event_id::is_button_event().
- ///
bool isEnabled() const;
// See dox in DisplayObject.h
bool allowHandCursor() const;
+ /// Check whether a point hits our drawable shape.
+ //
+ /// This is possible because the drawable does not have its own
+ /// transform, so we can use our own. The points are expressed in
+ /// world space.
+ bool hitTestDrawable(boost::int32_t x, boost::int32_t y) const;
+
/// Advance to a previous frame.
//
/// This function will basically restore the DisplayList as it supposedly
@@ -895,14 +899,7 @@
DisplayList m_display_list;
/// The canvas for dynamic drawing
- //
- boost::shared_ptr<DynamicShape> _drawable;
-
- /// The need of an instance here is due to the renderer
- /// insising on availability a DefineShapeTag instance
- /// that has a parent (why?)
- ///
- boost::intrusive_ptr<DisplayObject> _drawable_inst;
+ DynamicShape _drawable;
// this is deprecated, we'll be pushing gotoframe target
// actions to the global action queue
@@ -1019,7 +1016,6 @@
/// sprite-specific reachable resources are:
/// - DisplayList items (current, backup and frame0 ones)
/// - Canvas for dynamic drawing (_drawable)
- /// - Drawable instance (_drawable_inst)
/// - sprite environment
/// - definition the sprite has been instantiated from
/// - Textfields having an associated variable registered in this instance.
=== modified file 'libcore/SWFMatrix.cpp'
--- a/libcore/SWFMatrix.cpp 2009-03-17 12:01:42 +0000
+++ b/libcore/SWFMatrix.cpp 2009-04-08 07:08:06 +0000
@@ -300,9 +300,9 @@
r.expand_to_point(p3.x, p3.y);
}
-const SWFMatrix&
+// invert this SWFMatrix and return the result.
+SWFMatrix&
SWFMatrix::invert()
-// invert this SWFMatrix and return the result.
{
boost::int64_t det = determinant();
if(det == 0)
=== modified file 'libcore/SWFMatrix.h'
--- a/libcore/SWFMatrix.h 2009-02-25 22:33:03 +0000
+++ b/libcore/SWFMatrix.h 2009-04-08 07:08:06 +0000
@@ -164,7 +164,7 @@
void transform(rect& r) const;
/// Invert this SWFMatrix and return the result.
- const SWFMatrix& invert();
+ SWFMatrix& invert();
/// return the magnitude scale of our x coord output
double get_x_scale() const;
=== modified file 'libcore/Shape.cpp'
--- a/libcore/Shape.cpp 2009-04-07 13:42:26 +0000
+++ b/libcore/Shape.cpp 2009-04-08 07:08:06 +0000
@@ -23,12 +23,12 @@
{
bool
-Shape::pointInShape(boost::int32_t x, boost::int32_t y) const
+Shape::pointInShape(boost::int32_t x, boost::int32_t y) const
{
SWFMatrix wm = getWorldMatrix();
- SWFMatrix wm_inverse = wm.invert();
+ wm.invert();
point lp(x, y);
- wm_inverse.transform(lp);
+ wm.transform(lp);
// FIXME: if the shape contains non-scaled strokes
// we can't rely on boundary itself for a quick
=== modified file 'libcore/StaticText.cpp'
--- a/libcore/StaticText.cpp 2009-04-07 12:34:43 +0000
+++ b/libcore/StaticText.cpp 2009-04-07 17:48:48 +0000
@@ -37,6 +37,13 @@
return 0;
}
+void
+StaticText::setSelectionColor(boost::uint32_t color)
+{
+ // Drop any alpha value
+ _selectionColor.parseRGB(color & 0xffffff);
+}
+
bool
StaticText::pointInShape(boost::int32_t /*x*/, boost::int32_t /*y*/) const
{
=== modified file 'libcore/StaticText.h'
--- a/libcore/StaticText.h 2009-04-07 12:34:43 +0000
+++ b/libcore/StaticText.h 2009-04-07 17:48:48 +0000
@@ -48,7 +48,8 @@
int id)
:
DisplayObject(parent, id),
- _def(def)
+ _def(def),
+ _selectionColor(0, 255, 255, 255)
{
assert(_def);
}
@@ -90,7 +91,11 @@
return _def->get_bound();
}
- virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const;
+ virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const;
+
+ const rgba& selectionColor() const {
+ return _selectionColor;
+ }
protected:
=== modified file 'libcore/swf/TextRecord.cpp'
--- a/libcore/swf/TextRecord.cpp 2009-04-07 11:14:10 +0000
+++ b/libcore/swf/TextRecord.cpp 2009-04-08 08:58:27 +0000
@@ -145,7 +145,7 @@
// Render the given glyph records.
void
TextRecord::displayRecords(const SWFMatrix& this_mat,
- const DisplayObject& inst, const std::vector<SWF::TextRecord>& records,
+ const DisplayObject& inst, const std::vector<TextRecord>& records,
bool embedded)
{
@@ -195,7 +195,7 @@
je = rec.glyphs().end(); j != je; ++j)
{
// the glyph entry
- const SWF::TextRecord::GlyphEntry& ge = *j;
+ const TextRecord::GlyphEntry& ge = *j;
const int index = ge.index;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10780: Use and draw a DynamicShape directly in MovieClip, as there's no longer,
Benjamin Wolsey <=