Public Types | Public Member Functions

gnash::SWF::ShapeRecord Class Reference

Holds information needed to draw a shape. More...

#include <ShapeRecord.h>

Collaboration diagram for gnash::SWF::ShapeRecord:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector< FillStyleFillStyles
typedef std::vector< LineStyleLineStyles
typedef std::vector< PathPaths

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.
ShapeRecordoperator= (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 FillStylesfillStyles () const
const LineStyleslineStyles () const
const Pathspaths () const
const SWFRectgetBounds () const
PathcurrentPath ()
 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)

Detailed Description

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.


Member Typedef Documentation

typedef std::vector<Path> gnash::SWF::ShapeRecord::Paths

Constructor & Destructor Documentation

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 (  ) 

Member Function Documentation

void gnash::SWF::ShapeRecord::addFillStyle ( const FillStyle fs  ) 
void gnash::SWF::ShapeRecord::addLineStyle ( const LineStyle ls  )  [inline]
void gnash::SWF::ShapeRecord::addPath ( const Path path  )  [inline]
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]
const LineStyles& gnash::SWF::ShapeRecord::lineStyles (  )  const [inline]
ShapeRecord & gnash::SWF::ShapeRecord::operator= ( const ShapeRecord other  ) 

Assignment operator.

const Paths& gnash::SWF::ShapeRecord::paths (  )  const [inline]
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::Path::ap, gnash::key::b, gnash::Path::clear(), gnash::SWF::DEFINEFONT, gnash::SWF::DEFINEFONT2, gnash::SWF::DEFINEFONT3, gnash::SWF::DEFINESHAPE, gnash::SWF::DEFINESHAPE2, gnash::SWF::DEFINESHAPE3, gnash::SWF::DEFINESHAPE4, gnash::SWF::DEFINESHAPE4_, gnash::Path::empty(), gnash::SWFStream::ensureBits(), gnash::SWFStream::ensureBytes(), gnash::Path::expandBounds(), gnash::movie_definition::get_version(), getBounds(), gnash::Path::getLeftFill(), gnash::Path::getLineStyle(), gnash::Path::getRightFill(), gnash::key::i, IF_VERBOSE_MALFORMED_SWF, IF_VERBOSE_PARSE, lineStyles(), LOG_ONCE, gnash::Path::m_edges, gnash::Path::m_line, gnash::key::o, gnash::SWF::operator<<(), gnash::key::p, gnash::SWFRect::read(), gnash::SWFStream::read_bit(), gnash::SWFStream::read_sint(), gnash::SWFStream::read_u16(), gnash::SWFStream::read_u8(), gnash::SWFStream::read_uint(), gnash::readFills(), gnash::SWFRect::set_null(), gnash::Path::setLeftFill(), gnash::Path::setLineStyle(), gnash::Path::setRightFill(), gnash::SWFRect::toString(), gnash::geometry::Point2d::x, gnash::key::x, gnash::geometry::Point2d::y, and gnash::key::y.

Referenced by ShapeRecord().

void gnash::SWF::ShapeRecord::setBounds ( const SWFRect bounds  )  [inline]
void gnash::SWF::ShapeRecord::setLerp ( const ShapeRecord a,
const ShapeRecord b,
const double  ratio 
)

The documentation for this class was generated from the following files: