Update with current status
[gnash.git] / libcore / Shape.cpp
blobcfb1c3b1c9a45e645eb55d414c3874040cb8dc5e
1 // Shape.cpp: Shape DisplayObject implementation for Gnash.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software 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 "Shape.h"
22 #include "Transform.h"
24 namespace gnash {
26 bool
27 Shape::pointInShape(std::int32_t x, std::int32_t y) const
29 SWFMatrix wm = getWorldMatrix(*this);
30 wm.invert();
31 point lp(x, y);
32 wm.transform(lp);
34 // FIXME: if the shape contains non-scaled strokes
35 // we can't rely on boundary itself for a quick
36 // way out. Bounds supposedly already include
37 // thickness, so we might keep a flag telling us
38 // whether *non_scaled* strokes are present
39 // and if not still use the boundary check.
40 // NOTE: just skipping this test breaks a corner-case
41 // in DrawingApiTest (kind of a fill-leakage making
42 // the collision detection find you inside a self-crossing
43 // shape).
44 if (!_def->bounds().point_test(lp.x, lp.y)) return false;
45 return _def->pointTestLocal(lp.x, lp.y, wm);
48 void
49 Shape::display(Renderer& renderer, const Transform& base)
51 const Transform xform = base * transform();
53 _def->display(renderer, xform);
54 clear_invalidated();
57 } // namespace gnash
59 // Local Variables:
60 // mode: C++
61 // indent-tabs-mode: t
62 // End: