Gnash  0.8.10
Public Types | Public Member Functions
gnash::SWF::ShapeRecord Class Reference

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

#include <ShapeRecord.h>

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::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]
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: