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.
15 //
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
19 //
20 
21 #include "Shape.h"
22 #include "Transform.h"
23 
24 namespace gnash {
25 
26 bool
pointInShape(std::int32_t x,std::int32_t y) const27 Shape::pointInShape(std::int32_t x, std::int32_t y) const
28 {
29     SWFMatrix wm = getWorldMatrix(*this);
30     wm.invert();
31     point lp(x, y);
32     wm.transform(lp);
33 
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);
46 }
47 
48 void
display(Renderer & renderer,const Transform & base)49 Shape::display(Renderer& renderer, const Transform& base)
50 {
51     const Transform xform = base * transform();
52 
53     _def->display(renderer, xform);
54     clear_invalidated();
55 }
56 
57 } // namespace gnash
58 
59 // Local Variables:
60 // mode: C++
61 // indent-tabs-mode: t
62 // End:
63