use the VERSION instead of master in the revno.h generated from a src tarball
[gnash.git] / libcore / Shape.cpp
blob1c4f933a4f49c13d4099ba883cd1c7abd50b504b
1 // Shape.cpp: Shape DisplayObject implementation for Gnash.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
4 // Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "smart_ptr.h"
22 #include "Shape.h"
23 #include "Transform.h"
25 namespace gnash
28 bool
29 Shape::pointInShape(boost::int32_t x, boost::int32_t y) const
31 SWFMatrix wm = getWorldMatrix(*this);
32 wm.invert();
33 point lp(x, y);
34 wm.transform(lp);
36 // FIXME: if the shape contains non-scaled strokes
37 // we can't rely on boundary itself for a quick
38 // way out. Bounds supposedly already include
39 // thickness, so we might keep a flag telling us
40 // whether *non_scaled* strokes are present
41 // and if not still use the boundary check.
42 // NOTE: just skipping this test breaks a corner-case
43 // in DrawingApiTest (kind of a fill-leakage making
44 // the collision detection find you inside a self-crossing
45 // shape).
46 if (_def) {
47 if (!_def->bounds().point_test(lp.x, lp.y)) return false;
48 return _def->pointTestLocal(lp.x, lp.y, wm);
50 assert(_shape.get());
52 if (!_shape->getBounds().point_test(lp.x, lp.y)) return false;
53 return _shape->pointTestLocal(lp.x, lp.y, wm);
57 void
58 Shape::display(Renderer& renderer, const Transform& base)
60 const Transform xform = base * transform();
62 if (_def) _def->display(renderer, xform);
63 else _shape->display(renderer, xform);
64 clear_invalidated();
67 } // namespace gnash
69 // Local Variables:
70 // mode: C++
71 // indent-tabs-mode: t
72 // End: