Gnash
0.8.10
|
Holds information needed to draw a shape. More...
#include <ShapeRecord.h>
Public Types | |
typedef std::vector< FillStyle > | FillStyles |
typedef std::vector< LineStyle > | LineStyles |
typedef std::vector< Path > | Paths |
Public Member Functions | |
ShapeRecord () | |
Construct a ShapeRecord. | |
ShapeRecord (SWFStream &in, SWF::TagType tag, movie_definition &m, const RunResources &r) | |
Construct a ShapeRecord from a SWFStream. | |
ShapeRecord (const ShapeRecord &other) | |
Copy constructor. | |
ShapeRecord & | operator= (const ShapeRecord &other) |
Assignment operator. | |
~ShapeRecord () | |
void | read (SWFStream &in, SWF::TagType tag, movie_definition &m, const RunResources &r) |
Parse path data from a SWFStream. | |
const FillStyles & | fillStyles () const |
const LineStyles & | lineStyles () const |
const Paths & | paths () const |
const SWFRect & | getBounds () const |
Path & | currentPath () |
For DynamicShape. | |
void | setLerp (const ShapeRecord &a, const ShapeRecord &b, const double ratio) |
Set to the lerp of two ShapeRecords. | |
void | clear () |
Reset all shape data. | |
void | addFillStyle (const FillStyle &fs) |
void | addPath (const Path &path) |
void | addLineStyle (const LineStyle &ls) |
void | setBounds (const SWFRect &bounds) |
Holds information needed to draw a shape.
This does not correspond exactly to parsed record in a SWF file, but is used to create both mutable and immutable shapes. A ShapeRecord should have enough methods to implement the AS3 Graphics object (the drawing API of Shape and Sprite). This is restricted to adding fills, paths and line styles (which must be constructed outside this ShapeRecord before being added) and clearing everything. There is no support for removing single elements. ShapeRecord objects are not ref-counted, so they may be stack-allocated or used in smart pointers.
typedef std::vector<FillStyle> gnash::SWF::ShapeRecord::FillStyles |
typedef std::vector<LineStyle> gnash::SWF::ShapeRecord::LineStyles |
typedef std::vector<Path> gnash::SWF::ShapeRecord::Paths |
gnash::SWF::ShapeRecord::ShapeRecord | ( | ) |
Construct a ShapeRecord.
This should only really be used for DynamicShapes. Ideally all immutable ShapeRecords should be constructed with the ctor taking an SWFStream, but some tag formats do not allow this.
gnash::SWF::ShapeRecord::ShapeRecord | ( | SWFStream & | in, |
SWF::TagType | tag, | ||
movie_definition & | m, | ||
const RunResources & | r | ||
) |
Construct a ShapeRecord from a SWFStream.
This is useful for constructing immutable tags.
References read().
gnash::SWF::ShapeRecord::ShapeRecord | ( | const ShapeRecord & | other | ) |
Copy constructor.
gnash::SWF::ShapeRecord::~ShapeRecord | ( | ) |
void gnash::SWF::ShapeRecord::addFillStyle | ( | const FillStyle & | fs | ) |
Referenced by gnash::DynamicShape::addFillStyle().
void gnash::SWF::ShapeRecord::addLineStyle | ( | const LineStyle & | ls | ) | [inline] |
Referenced by gnash::DynamicShape::add_line_style().
void gnash::SWF::ShapeRecord::addPath | ( | const Path & | path | ) | [inline] |
Referenced by gnash::DynamicShape::add_path().
void gnash::SWF::ShapeRecord::clear | ( | ) |
Reset all shape data.
References gnash::SWFRect::set_null().
Referenced by gnash::DynamicShape::clear().
Path& gnash::SWF::ShapeRecord::currentPath | ( | ) | [inline] |
For DynamicShape.
TODO: rewrite DynamicShape to push paths when they're finished and drop this.
Referenced by gnash::DynamicShape::add_path().
const FillStyles& gnash::SWF::ShapeRecord::fillStyles | ( | ) | const [inline] |
const SWFRect& gnash::SWF::ShapeRecord::getBounds | ( | ) | const [inline] |
Referenced by gnash::SWF::DefineShapeTag::bounds(), gnash::DynamicShape::lineTo(), gnash::DynamicShape::curveTo(), gnash::DynamicShape::getBounds(), gnash::MorphShape::pointInShape(), gnash::MorphShape::getBounds(), gnash::renderer::openvg::Renderer_ovg::drawGlyph(), setLerp(), and gnash::SWF::operator<<().
const LineStyles& gnash::SWF::ShapeRecord::lineStyles | ( | ) | const [inline] |
Referenced by gnash::SWF::DefineShapeTag::pointTestLocal(), gnash::DynamicShape::lineTo(), gnash::DynamicShape::curveTo(), gnash::DynamicShape::add_line_style(), gnash::DynamicShape::pointTestLocal(), gnash::MorphShape::pointInShape(), gnash::renderer::openvg::Renderer_ovg::drawShape(), gnash::Renderer_cairo::drawShape(), setLerp(), and read().
ShapeRecord & gnash::SWF::ShapeRecord::operator= | ( | const ShapeRecord & | other | ) |
Assignment operator.
const Paths& gnash::SWF::ShapeRecord::paths | ( | ) | const [inline] |
Referenced by gnash::SWF::DefineShapeTag::pointTestLocal(), gnash::DynamicShape::finalize(), gnash::DynamicShape::pointTestLocal(), gnash::MorphShape::pointInShape(), gnash::renderer::openvg::Renderer_ovg::drawShape(), gnash::renderer::openvg::Renderer_ovg::drawGlyph(), gnash::Renderer_cairo::drawShape(), gnash::Renderer_cairo::drawGlyph(), and setLerp().
void gnash::SWF::ShapeRecord::read | ( | SWFStream & | in, |
SWF::TagType | tag, | ||
movie_definition & | m, | ||
const RunResources & | r | ||
) |
Parse path data from a SWFStream.
This is used by DefineMorphShapeTag as part of parsing its more complex ShapeRecords.
TODO: is this correct?
When reading font glyphs it happens to read 1 byte past end boundary of a glyph due to fill/line bits being zero.
Generally returning here seems to break morphs: http://savannah.gnu.org/bugs/?21747 And other normal shapes: http://savannah.gnu.org/bugs/?21923 http://savannah.gnu.org/bugs/?22000
So for now we only return if NOT reading a morph shape. Pretty ugly... till next bug report.
References gnash::key::SWF, gnash::SWF::DEFINESHAPE, gnash::SWF::DEFINESHAPE2, gnash::SWF::DEFINESHAPE3, gnash::SWF::DEFINESHAPE4, gnash::SWF::DEFINESHAPE4_, gnash::readRect(), IF_VERBOSE_PARSE, gnash::key::b, gnash::SWFRect::toString(), _, UNUSED, gnash::SWFStream::ensureBytes(), gnash::SWFStream::read_u8(), LOG_ONCE, gnash::SWF::DEFINEFONT, gnash::SWF::DEFINEFONT2, assert, gnash::SWF::DEFINEFONT3, x, y, gnash::SWFStream::ensureBits(), gnash::SWFStream::read_bit(), gnash::SWFStream::read_uint(), gnash::Path::empty(), gnash::Path::m_edges, gnash::SWFStream::read_sint(), gnash::Path::ap, gnash::geometry::Point2d::x, gnash::geometry::Point2d::y, IF_VERBOSE_MALFORMED_SWF, gnash::Path::setLeftFill(), gnash::Path::getLeftFill(), gnash::Path::setRightFill(), gnash::Path::getRightFill(), gnash::Path::setLineStyle(), gnash::Path::getLineStyle(), gnash::Path::clear(), gnash::movie_definition::get_version(), gnash::SWFStream::read_u16(), gnash::key::i, gnash::readFills(), lineStyles(), gnash::SWFRect::set_null(), gnash::key::p, gnash::Path::m_line, and gnash::Path::expandBounds().
Referenced by ShapeRecord().
void gnash::SWF::ShapeRecord::setBounds | ( | const SWFRect & | bounds | ) | [inline] |
Referenced by gnash::DynamicShape::lineTo(), gnash::DynamicShape::curveTo(), and gnash::DynamicShape::setBounds().
void gnash::SWF::ShapeRecord::setLerp | ( | const ShapeRecord & | a, |
const ShapeRecord & | b, | ||
const double | ratio | ||
) |
Set to the lerp of two ShapeRecords.
Used in shape morphing.
References gnash::SWFRect::set_lerp(), getBounds(), fillStyles(), gnash::renderer::opengl::for_each(), lineStyles(), paths(), gnash::key::i, gnash::key::k, gnash::key::n, gnash::key::p, gnash::Path::ap, gnash::geometry::Point2d::x, gnash::geometry::Point2d::y, gnash::Path::reset(), gnash::Path::getLeftFill(), gnash::Path::getRightFill(), gnash::Path::getLineStyle(), gnash::Path::size(), gnash::Path::m_edges, gnash::key::j, gnash::key::e, gnash::Edge::cp, and gnash::Edge::ap.