[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11541: Clean up a couple of interfa
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11541: Clean up a couple of interfaces. |
Date: |
Fri, 02 Oct 2009 11:47:29 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11541 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-10-02 11:47:29 +0200
message:
Clean up a couple of interfaces.
modified:
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/rect.cpp
libcore/rect.h
testsuite/movies.all/gravity_embedded-TestRunner.cpp
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-10-01 08:50:26 +0000
+++ b/libcore/DisplayObject.cpp 2009-10-01 09:08:33 +0000
@@ -900,7 +900,7 @@
}
os.str("");
- os << get_width() << "x" << get_height();
+ os << getBounds().width() << "x" << getBounds().height();
tr.append_child(it, StringPair(_("Dimensions"), os.str()));
tr.append_child(it, StringPair(_("Dynamic"), isDynamic() ? yes : no));
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2009-09-30 15:20:47 +0000
+++ b/libcore/DisplayObject.h 2009-10-01 09:08:33 +0000
@@ -441,24 +441,6 @@
return 0;
}
- /// Returns local, untransformed height of this DisplayObject in TWIPS
- //
- /// Use getBounds() if you need more then simply the height.
- ///
- boost::int32_t get_height() const
- {
- return getBounds().height();
- }
-
- /// Returns local, untransformed width of this DisplayObject in TWIPS
- //
- /// Use getBounds() if you need more then simply the width.
- ///
- boost::int32_t get_width() const
- {
- return getBounds().width();
- }
-
virtual rect getBounds() const = 0;
/// Return true if the given point falls in this DisplayObject's bounds
=== modified file 'libcore/rect.cpp'
--- a/libcore/rect.cpp 2009-03-17 11:39:48 +0000
+++ b/libcore/rect.cpp 2009-10-01 09:16:13 +0000
@@ -25,6 +25,9 @@
namespace gnash {
+const boost::int32_t rect::rectNull;
+const boost::int32_t rect::rectMax;
+
void rect::read(SWFStream& in)
{
in.align();
@@ -51,37 +54,9 @@
}
}
-point
-rect::get_point(int i) const
-// Get one of the rect verts.
-{
- assert( !is_null() );
-
- point p;
- switch(i)
- {
- case 0:
- p.x = _xMin; p.y = _yMin;
- break;
- case 1:
- p.x = _xMax; p.y = _yMin;
- break;
- case 2:
- p.x = _xMax; p.y = _yMax;
- break;
- case 3:
- p.x = _xMin; p.y = _yMax;
- break;
- default:
- assert(0);
- break;
- }
- return p;
-}
-
-
-void rect::enclose_transformed_rect(const SWFMatrix& m, const rect& r)
// Set ourself to bound a rectangle that has been transformed by m.
+void
+rect::enclose_transformed_rect(const SWFMatrix& m, const rect& r)
{
boost::int32_t x1 = r.get_x_min();
boost::int32_t y1 = r.get_y_min();
=== modified file 'libcore/rect.h'
--- a/libcore/rect.h 2009-03-04 20:30:04 +0000
+++ b/libcore/rect.h 2009-10-01 09:16:13 +0000
@@ -40,12 +40,6 @@
///
class rect
{
-private:
-
- boost::int32_t _xMin; // TWIPS
- boost::int32_t _yMin; // TWIPS
- boost::int32_t _xMax; // TWIPS
- boost::int32_t _yMax; // TWIPS
public:
/// Read a bit-packed rectangle from an SWF stream
@@ -67,12 +61,8 @@
///
void read(SWFStream& in);
- // constants used for this class.
- enum rect_flags_e
- {
- RECT_NULL_MARK = 0x80000000,
- RECT_MAX_INT32 = 0x7fffffff
- };
+ static const boost::int32_t rectNull = 0x80000000;
+ static const boost::int32_t rectMax = 0x7fffffff;
/// Ouput operator
friend std::ostream& operator<< (std::ostream& os, const rect& rect);
@@ -80,138 +70,111 @@
/// Construct a NULL rectangle
rect()
:
- _xMin(RECT_NULL_MARK), _yMin(RECT_NULL_MARK),
- _xMax(RECT_NULL_MARK), _yMax(RECT_NULL_MARK)
+ _xMin(rectNull),
+ _yMin(rectNull),
+ _xMax(rectNull),
+ _yMax(rectNull)
{}
/// Construct a rectangle with given coordinates
rect(int xmin, int ymin, int xmax, int ymax)
:
- _xMin(xmin), _yMin(ymin), _xMax(xmax), _yMax(ymax)
+ _xMin(xmin),
+ _yMin(ymin),
+ _xMax(xmax),
+ _yMax(ymax)
{
}
/// returns true if this is a NULL rectangle
bool is_null() const
{
- return (_xMin == (boost::int32_t)(RECT_NULL_MARK))
- && (_xMax == (boost::int32_t)(RECT_NULL_MARK));
+ return (_xMin == rectNull && _xMax == rectNull);
}
/// set the rectangle to the NULL value
void set_null()
{
- _xMin = _yMin = _xMax = _yMax = RECT_NULL_MARK;
+ _xMin = _yMin = _xMax = _yMax = rectNull;
}
/// TODO: deprecate this 'world' concept.
bool is_world() const
{
- return _xMin == (- RECT_MAX_INT32 >> 9)
- && _yMin == (- RECT_MAX_INT32 >> 9)
- && _xMax == (RECT_MAX_INT32 >> 9)
- && _yMax == (RECT_MAX_INT32 >> 9);
+ return _xMin == (- rectMax >> 9)
+ && _yMin == (- rectMax >> 9)
+ && _xMax == (rectMax >> 9)
+ && _yMax == (rectMax >> 9);
}
/// set the rectangle to the WORLD value
void set_world()
{
- _xMin = _yMin = - RECT_MAX_INT32 >> 9;
- _xMax = _yMax = RECT_MAX_INT32 >> 9;
+ _xMin = _yMin = - rectMax >> 9;
+ _xMax = _yMax = rectMax >> 9;
}
/// Return width of this rectangle in TWIPS
- boost::int32_t width() const
+ boost::int32_t width() const
{
return _xMax - _xMin;
}
/// Return height of this rectangle in TWIPS
- boost::int32_t height() const
+ boost::int32_t height() const
{
return _yMax - _yMin;
}
/// Get the x coordinate of the left-up corner.
- boost::int32_t get_x_min() const
+ boost::int32_t get_x_min() const
{
- assert( !is_null() );
+ assert(!is_null());
return _xMin;
}
/// Get the x coordinate of the right-down corner.
- boost::int32_t get_x_max() const
+ boost::int32_t get_x_max() const
{
- assert( !is_null() );
+ assert(!is_null());
return _xMax;
}
/// Get the y coordinate of the left-up corner.
- boost::int32_t get_y_min() const
+ boost::int32_t get_y_min() const
{
- assert( !is_null() );
+ assert(!is_null());
return _yMin;
}
/// Get the y coordinate of the right-down corner.
- boost::int32_t get_y_max() const
+ boost::int32_t get_y_max() const
{
- assert( !is_null() );
+ assert(!is_null());
return _yMax;
}
-
- /// Shift this rectangle horizontally
- //
- /// A positive offset will shift to the right,
- /// A negative offset will shift to the left.
- ///
- void shift_x(boost::int32_t offset)
- {
- if( !is_null() ) {
- _xMin += offset;
- _xMax += offset;
- }
- }
-
- /// Shift this rectangle vertically
- //
- /// A positive offset will increment y values.
- /// A negative offset will decrement y values.
- ///
- void shift_y(boost::int32_t offset)
- {
- if( !is_null() ) {
- _yMin += offset;
- _yMax += offset;
- }
- }
-
- /// Get one of the rect verts.
- point get_point(int i) const;
/// Return true if the given point is inside this rect.
- bool point_test(boost::int32_t x, boost::int32_t y) const
+ bool point_test(boost::int32_t x, boost::int32_t y) const
{
- if( is_null() ) {
- return false;
- }
+ if (is_null()) return false;
if (x < _xMin || x > _xMax || y < _yMin || y > _yMax) {
return false;
- }else {
- return true;
- }
+ }
+ return true;
}
/// Set ourself to bound the given point
- void set_to_point(boost::int32_t x, boost::int32_t y)
+ void set_to_point(boost::int32_t x, boost::int32_t y)
{
_xMin = _xMax = x;
_yMin = _yMax = y;
}
- void set_to_rect(boost::int32_t x1, boost::int32_t y1, boost::int32_t x2,
boost::int32_t y2)
+ void set_to_rect(boost::int32_t x1, boost::int32_t y1, boost::int32_t x2,
+ boost::int32_t y2)
{
_xMin = x1;
_yMin = y1;
@@ -220,11 +183,11 @@
}
/// Expand this rectangle to enclose the given point.
- void expand_to_point(boost::int32_t x, boost::int32_t y)
+ void expand_to_point(boost::int32_t x, boost::int32_t y)
{
- if( is_null() ) {
+ if (is_null()) {
set_to_point(x, y);
- }else {
+ } else {
expand_to(x, y);
}
}
@@ -232,20 +195,20 @@
/// Set ourself to bound a rectangle that has been transformed by m.
/// This is an axial bound of an oriented (and/or
/// sheared, scaled, etc) box.
- void enclose_transformed_rect(const SWFMatrix& m, const rect& r);
+ void enclose_transformed_rect(const SWFMatrix& m, const rect& r);
/// Expand this rectangle to enclose the given circle.
- void expand_to_circle(boost::int32_t x, boost::int32_t y,
boost::int32_t radius)
+ void expand_to_circle(boost::int32_t x, boost::int32_t y, boost::int32_t
radius)
{
// I know it's easy to make code work for minus radius.
// would do that untill I see the requirement for a SWF RECTANGLE.
assert(radius >= 0);
- if( is_null() ) {
+ if (is_null()) {
_xMin = x - radius;
_yMin = y - radius;
_xMax = x + radius;
_yMax = y + radius;
- }else {
+ } else {
_xMin = std::min(_xMin, x - radius);
_yMin = std::min(_yMin, y - radius);
_xMax = std::max(_xMax, x + radius);
@@ -255,12 +218,12 @@
/// Same as enclose_transformed_rect but expanding the current rect instead
/// of replacing it.
- DSOEXPORT void expand_to_transformed_rect(const SWFMatrix& m, const rect&
r);
+ DSOEXPORT void expand_to_transformed_rect(const SWFMatrix& m, const rect&
r);
/// Makes union of the given and the current rect
- DSOEXPORT void expand_to_rect(const rect& r);
+ DSOEXPORT void expand_to_rect(const rect& r);
- void set_lerp(const rect& a, const rect& b, float t);
+ void set_lerp(const rect& a, const rect& b, float t);
/// \brief
/// Make sure that the given point falls in this rectangle,
@@ -271,7 +234,7 @@
// TODO: deprecate this.
geometry::Range2d<float> getRange() const
{
- if( is_null() )
+ if (is_null())
{
// Range2d has a differnt idea about what is a null rect.
return geometry::Range2d<float>(geometry::nullRange); //null range
@@ -300,15 +263,12 @@
_yMax = std::max(_yMax, y);
}
- boost::int32_t min4(boost::int32_t x1, boost::int32_t x2, boost::int32_t
x3, boost::int32_t x4)
- {
- return std::min(std::min(x1, x2), std::min(x3, x4));
- }
+private:
- boost::int32_t max4(boost::int32_t x1, boost::int32_t x2, boost::int32_t
x3, boost::int32_t x4)
- {
- return std::max(std::max(x1, x2), std::max(x3, x4));
- }
+ boost::int32_t _xMin; // TWIPS
+ boost::int32_t _yMin; // TWIPS
+ boost::int32_t _xMax; // TWIPS
+ boost::int32_t _yMax; // TWIPS
};
=== modified file 'testsuite/movies.all/gravity_embedded-TestRunner.cpp'
--- a/testsuite/movies.all/gravity_embedded-TestRunner.cpp 2009-08-21
12:29:40 +0000
+++ b/testsuite/movies.all/gravity_embedded-TestRunner.cpp 2009-10-01
09:32:43 +0000
@@ -74,8 +74,8 @@
check(const_cast<DisplayObject*>(loaded)->get_member(xscale, &tmp));
check_equals(tmp, as_value(50));
- check_equals(loaded->get_height(), 2056);
- check_equals(loaded->get_width(), 2056);
+ check_equals(loaded->getBounds().height(), 2056);
+ check_equals(loaded->getBounds().width(), 2056);
const TextField* text =
dynamic_cast<const TextField*>(
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11541: Clean up a couple of interfaces.,
Benjamin Wolsey <=