1
// shape.h -- Thatcher Ulrich <tu@tulrich.com> 2003
3
// This source code has been donated to the Public Domain. Do
4
// whatever you want with it.
6
// Quadratic bezier outline shapes, the basis for most SWF rendering.
8
/* $Id: shape_character_def.h,v 1.20 2007/12/01 15:40:59 strk Exp $ */
10
#ifndef GNASH_SHAPE_CHARACTER_DEF_H
11
#define GNASH_SHAPE_CHARACTER_DEF_H
14
#include "character_def.h" // for inheritance of shape_character_def
15
#include "shape.h" // for path
16
#include "rect.h" // for composition
18
#include <vector> // for composition
29
/// Represents the outline of one or more shapes, along with
30
/// information on fill and line styles.
32
class shape_character_def : public character_def
36
typedef std::vector<fill_style> FillStyleVect;
37
typedef std::vector<line_style> LineStyleVect;
38
typedef std::vector<path> PathVect;
40
shape_character_def();
41
virtual ~shape_character_def();
43
virtual void display(character* inst);
44
virtual bool point_test_local(float x, float y);
46
float get_height_local() const;
47
float get_width_local() const;
50
/// Read a shape definition as included in DEFINEFONT*,
51
/// DEFINESHAPE* or DEFINEMORPH* tag
54
/// The stream to read the shape from
57
/// The SWF::tag_type this shape definition is read for.
58
/// TODO: change to an actual SWF::tag_type type
61
/// If true, this definition includes bounds, fill styles and line styles.
62
/// Tipically, this is only false for DEFINEFONT* tags.
63
/// NOTE: if with_style is false, bounds of the shape will be computed
65
/// TODO: drop this function, set based on tag_type ?
68
/// The movie definition corresponding to the SWF we/re parsing.
69
/// This is used to resolve bitmap characters for fill styles, never
70
/// used if with_style is false.
72
void read(stream* in, int tag_type, bool with_style, movie_definition* m);
78
const std::vector<fill_style>& fill_styles,
79
const std::vector<line_style>& line_styles) const;
81
/// Get cached bounds of this shape.
82
const rect& get_bound() const { return m_bound; }
84
/// Compute bounds by looking at the component paths
85
void compute_bound(rect* r) const;
87
const FillStyleVect& get_fill_styles() const { return m_fill_styles; }
88
const LineStyleVect& get_line_styles() const { return m_line_styles; }
90
const std::vector<path>& get_paths() const { return m_paths; }
93
void set_bound(const rect& r) { m_bound = r; /* should do some verifying */ }
95
size_t numEdges() const;
97
size_t numPaths() const;
100
friend class morph2_character_def;
103
/// Mark reachable resources (for the GC)
105
/// Reachable resources are:
106
/// - Associated fill styles (m_fill_styles).
107
/// These are not actual resources, but may contain some.
109
virtual void markReachableResources() const;
110
#endif // GNASH_USE_GC
112
// derived morph classes changes these
113
FillStyleVect m_fill_styles;
114
LineStyleVect m_line_styles;
118
/// Free all meshes (deprecated)
119
//void clear_meshes();
121
/// Copy a shape character definition
122
shape_character_def(const shape_character_def& o);
126
/// Shape record flags
127
enum ShapeRecordFlags {
130
flagFillStyle0Change = 0x02,
131
flagFillStyle1Change = 0x04,
132
flagLineStyleChange = 0x08,
133
flagHasNewStyles = 0x10
136
void sort_and_clean_meshes() const;
138
// Don't assign to a shape character definition
139
shape_character_def& operator= (const shape_character_def&)
147
} // end namespace gnash
150
#endif // GNASH_SHAPE_CHARACTER_DEF_H
157
// indent-tabs-mode: t