[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/stream.cpp server/stream...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/stream.cpp server/stream... |
Date: |
Tue, 12 Feb 2008 16:48:39 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/02/12 16:48:38
Modified files:
. : ChangeLog
server : stream.cpp stream.h
server/parser : shape_character_def.cpp
server/swf : PlaceObject2Tag.cpp PlaceObject2Tag.h
tag_loaders.cpp
Log message:
* server/stream.{cpp,h}: drop buggy char* read_string()
and (unused) char* read_string_with_length(...), which
sometimes
returned NULL causing a parser exception. Fixes parsing of
http://www.e4.com/reaper/games/soulslapper/flas/main.swf
(SWF9)
(to an extent).
* server/swf/tag_loaders.cpp: use read_string (std::string& to)
everywhere.
* server/swf/PlaceObject2Tag.{cpp,h}: use std::string, not
char* for
m_name.
* server/parser/shape_character_def.cpp: bring indentation into
some sort of shape.
Next thing might be to get add_display_object and
replace_display_object to take C++ strings.
shape_character_def.cpp had incredibly bad indentation. This doesn't
conform to the suggestions on the wiki (though I prefer this style :)), but at
least makes it consistent and readable (I used bcpp to indent).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5623&r2=1.5624
http://cvs.savannah.gnu.org/viewcvs/gnash/server/stream.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/stream.h?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.cpp?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/PlaceObject2Tag.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/PlaceObject2Tag.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.182&r2=1.183
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5623
retrieving revision 1.5624
diff -u -b -r1.5623 -r1.5624
--- ChangeLog 12 Feb 2008 14:43:26 -0000 1.5623
+++ ChangeLog 12 Feb 2008 16:48:37 -0000 1.5624
@@ -1,3 +1,17 @@
+2008-02-12 Benjamin Wolsey <address@hidden>
+
+ * server/stream.{cpp,h}: drop buggy char* read_string()
+ and (unused) char* read_string_with_length(...), which sometimes
+ returned NULL causing a parser exception. Fixes parsing of
+ http://www.e4.com/reaper/games/soulslapper/flas/main.swf (SWF9)
+ (to an extent).
+ * server/swf/tag_loaders.cpp: use read_string (std::string& to)
+ everywhere.
+ * server/swf/PlaceObject2Tag.{cpp,h}: use std::string, not char* for
+ m_name.
+ * server/parser/shape_character_def.cpp: bring indentation into
+ some sort of shape.
+
2008-02-12 Sandro Santilli <address@hidden>
* server/asobj/MovieClipLoader.cpp: send the onLoadInit event
Index: server/stream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/stream.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/stream.cpp 28 Jan 2008 15:16:51 -0000 1.43
+++ server/stream.cpp 12 Feb 2008 16:48:38 -0000 1.44
@@ -1,4 +1,4 @@
-// stream.cpp - SWF stream reading clas, for Gnash
+// stream.cpp - SWF stream reading class, for Gnash
//
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
//
@@ -298,20 +298,6 @@
return read_u32();
}
-
-char* stream::read_string()
-{
- std::string to;
- read_string(to); // throws ParserException
-
- if (to.empty()) return NULL;
-
- char* retval = new char[to.length()+1];
- strcpy(retval, to.c_str());
-
- return retval;
-}
-
void
stream::read_string(std::string& to)
{
@@ -329,20 +315,6 @@
}
-
-char* stream::read_string_with_length()
-{
- std::string to;
- read_string_with_length(to);
-
- if (to.empty()) return NULL;
-
- char* buffer = new char[to.length() + 1];
- strcpy(buffer, to.c_str());
-
- return buffer;
-}
-
void stream::read_string_with_length(std::string& to)
{
align();
Index: server/stream.h
===================================================================
RCS file: /sources/gnash/gnash/server/stream.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/stream.h 28 Jan 2008 15:16:51 -0000 1.40
+++ server/stream.h 12 Feb 2008 16:48:38 -0000 1.41
@@ -1,4 +1,4 @@
-// stream.h - SWF stream reading clas, for Gnash
+// stream.h - SWF stream reading class, for Gnash
//
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
//
@@ -245,17 +245,6 @@
};
/// \brief
- /// Reads *and new[]'s* the string from the given file.
- /// Ownership passes to the caller; caller must delete[] the
- /// string when it is done with it.
- ///
- /// aligned read
- ///
- /// Will throw ParserException if no terminating null is found within
tag boundaries
- ///
- char* read_string();
-
- /// \brief
/// Reads a null-terminated string from the given file and
/// assigns it to the given std::string, overriding any
/// previous value of it.
@@ -266,18 +255,6 @@
///
void read_string(std::string& to);
- /// \brief
- /// Reads *and new[]'s* the string from the given file.
- /// Ownership passes to the caller; caller must delete[] the
- /// string when it is done with it.
- /// Length of string is read from the first byte.
- ///
- /// aligned read
- ///
- /// Will throw ParserException if advertised length crosses tag
boundaries
- ///
- char* read_string_with_length();
-
/// Reads a sized string into a provided std::string.
//
/// Length of string is read from the first byte.
Index: server/parser/shape_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/shape_character_def.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/parser/shape_character_def.cpp 12 Feb 2008 09:38:37 -0000
1.65
+++ server/parser/shape_character_def.cpp 12 Feb 2008 16:48:38 -0000
1.66
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: shape_character_def.cpp,v 1.65 2008/02/12 09:38:37 bwy Exp $ */
+/* $Id: shape_character_def.cpp,v 1.66 2008/02/12 16:48:38 bwy Exp $ */
// Based on the public domain shape.cpp of Thatcher Ulrich <address@hidden>
2003
@@ -51,32 +51,30 @@
bool gnash_debug_show_paths = false;
#endif // DEBUG_DISPLAY_SHAPE_PATHS
+namespace gnash
+{
-namespace gnash {
-
-static float s_curve_max_pixel_error = 1.0f;
-
+ static float s_curve_max_pixel_error = 1.0f;
-//
-// helper functions.
-//
+ //
+ // helper functions.
+ //
-void set_curve_max_pixel_error(float pixel_error)
-{
+ void set_curve_max_pixel_error(float pixel_error)
+ {
s_curve_max_pixel_error = fclamp(pixel_error, 1e-6f, 1e6f);
-}
+ }
-float get_curve_max_pixel_error()
-{
+ float get_curve_max_pixel_error()
+ {
return s_curve_max_pixel_error;
-}
-
+ }
-// Read fill styles, and push them onto the given style array.
-static void
-read_fill_styles(std::vector<fill_style>& styles, stream* in,
+ // Read fill styles, and push them onto the given style array.
+ static void
+ read_fill_styles(std::vector<fill_style>& styles, stream* in,
int tag_type, movie_definition* m)
-{
+ {
// Get the count.
in->ensureBytes(1);
@@ -107,14 +105,13 @@
styles.push_back(fs);
}
-}
-
+ }
-static void
-read_line_styles(std::vector<line_style>& styles, stream* in, int tag_type,
+ static void
+ read_line_styles(std::vector<line_style>& styles, stream* in, int
tag_type,
movie_definition *md)
// Read line styles and push them onto the back of the given array.
-{
+ {
// Get the count.
in->ensureBytes(1);
int line_style_count = in->read_u8();
@@ -127,7 +124,8 @@
// @@ does the 0xFF flag apply to all tag types?
// if (tag_type > 2)
// {
- if (line_style_count == 0xFF) {
+ if (line_style_count == 0xFF)
+ {
in->ensureBytes(2);
line_style_count = in->read_u16();
IF_VERBOSE_PARSE
@@ -138,15 +136,15 @@
// }
// Read the styles.
- for (int i = 0; i < line_style_count; i++) {
+ for (int i = 0; i < line_style_count; i++)
+ {
styles.resize(styles.size() + 1);
//styles[styles.size() - 1].read(in, tag_type);
styles.back().read(in, tag_type, md);
}
-}
-
+ }
-shape_character_def::shape_character_def()
+ shape_character_def::shape_character_def()
:
character_def(),
m_fill_styles(),
@@ -154,10 +152,10 @@
m_paths(),
m_bound()
//,m_cached_meshes()
-{
-}
+ {
+ }
-shape_character_def::shape_character_def(const shape_character_def& o)
+ shape_character_def::shape_character_def(const shape_character_def& o)
:
character_def(o),
m_fill_styles(o.m_fill_styles),
@@ -165,20 +163,18 @@
m_paths(o.m_paths),
m_bound(o.m_bound)
//,m_cached_meshes()
-{
-}
-
+ {
+ }
-shape_character_def::~shape_character_def()
-{
+ shape_character_def::~shape_character_def()
+ {
//clear_meshes();
-}
-
+ }
-void
-shape_character_def::read(stream* in, int tag_type, bool with_style,
+ void
+ shape_character_def::read(stream* in, int tag_type, bool with_style,
movie_definition* m)
-{
+ {
if (with_style)
{
m_bound.read(in);
@@ -219,7 +215,6 @@
//m_fill_styles.push_back(fill_style());
}
-
//log_msg("Read %u fill styles, %u line styles", m_fill_styles.size(),
m_line_styles.size());
// Use read_u8 to force alignment.
@@ -273,14 +268,17 @@
#define SHAPE_LOG 0
// SHAPERECORDS
- for (;;) {
+ for (;;)
+ {
in->ensureBits(1);
bool isEdgeRecord = in->read_bit();
- if (!isEdgeRecord) {
+ if (!isEdgeRecord)
+ {
// Parse the record.
in->ensureBits(5);
int flags = in->read_uint(5);
- if (flags == flagEnd) {
+ if (flags == flagEnd)
+ {
// End of shape records.
// Store the current path if any.
@@ -292,11 +290,13 @@
break;
}
- if (flags & flagMove) {
+ if (flags & flagMove)
+ {
// move_to = 1;
// Store the current path if any, and prepare a fresh one.
- if (! current_path.is_empty()) {
+ if (! current_path.is_empty())
+ {
m_paths.push_back(current_path);
current_path.m_edges.resize(0);
}
@@ -323,7 +323,8 @@
if ((flags & flagFillStyle0Change) && num_fill_bits > 0)
{
// fill_style_0_change = 1;
- if (! current_path.is_empty()) {
+ if (! current_path.is_empty())
+ {
m_paths.push_back(current_path);
current_path.m_edges.resize(0);
current_path.ap.x = x;
@@ -331,7 +332,8 @@
}
in->ensureBits(num_fill_bits);
unsigned style = in->read_uint(num_fill_bits);
- if (style > 0) {
+ if (style > 0)
+ {
style += fill_base;
}
@@ -347,7 +349,8 @@
}
else
{
- if ( style > m_fill_styles.size() ) // 1-based index
+ // 1-based index
+ if ( style > m_fill_styles.size() )
{
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("Invalid fill style %d in fillStyle0Change record - "
SIZET_FMT " defined. Set to 0."), style, m_fill_styles.size());
@@ -367,7 +370,8 @@
if ((flags & flagFillStyle1Change) && num_fill_bits > 0)
{
// fill_style_1_change = 1;
- if (! current_path.is_empty()) {
+ if (! current_path.is_empty())
+ {
m_paths.push_back(current_path);
current_path.m_edges.resize(0);
current_path.ap.x = x;
@@ -375,7 +379,8 @@
}
in->ensureBits(num_fill_bits);
unsigned style = in->read_uint(num_fill_bits);
- if (style > 0) {
+ if (style > 0)
+ {
style += fill_base;
}
@@ -391,7 +396,8 @@
}
else
{
- if ( style > m_fill_styles.size() ) // 1-based index
+ // 1-based index
+ if ( style > m_fill_styles.size() )
{
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("Invalid fill style %d in fillStyle1Change record - "
SIZET_FMT " defined. Set to 0."), style, m_fill_styles.size());
@@ -399,17 +405,19 @@
style = 0;
}
}
- current_path.setRightFill(style); // getRightFill() = style;
+ // getRightFill() = style;
+ current_path.setRightFill(style);
#if SHAPE_LOG
IF_VERBOSE_PARSE (
log_parse(_(" shape_character read: fill1 (right) = %d"),
current_path.getRightFill());
)
-#endif
+ #endif
}
if ((flags & flagLineStyleChange) && num_line_bits > 0)
{
// line_style_change = 1;
- if (! current_path.is_empty()) {
+ if (! current_path.is_empty())
+ {
m_paths.push_back(current_path);
current_path.m_edges.resize(0);
current_path.ap.x = x;
@@ -417,7 +425,8 @@
}
in->ensureBits(num_line_bits);
unsigned style = in->read_uint(num_line_bits);
- if (style > 0) {
+ if (style > 0)
+ {
style += line_base;
}
if ( tag_type == SWF::DEFINEFONT || tag_type == SWF::DEFINEFONT2 )
@@ -432,7 +441,8 @@
}
else
{
- if ( style > m_line_styles.size() ) // 1-based index
+ // 1-based index
+ if ( style > m_line_styles.size() )
{
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("Invalid fill style %d in lineStyleChange record - "
SIZET_FMT " defined. Set to 0."), style, m_line_styles.size());
@@ -445,7 +455,7 @@
IF_VERBOSE_PARSE (
log_parse(_(" shape_character_read: line = %d"),
current_path.getLineStyle());
)
-#endif
+ #endif
}
if (flags & flagHasNewStyles)
{
@@ -464,7 +474,8 @@
);
// Store the current path if any.
- if (! current_path.is_empty()) {
+ if (! current_path.is_empty())
+ {
m_paths.push_back(current_path);
current_path.clear();
}
@@ -484,11 +495,14 @@
num_fill_bits = in->read_uint(4);
num_line_bits = in->read_uint(4);
}
- } else {
+ }
+ else
+ {
// EDGERECORD
in->ensureBits(1);
bool edge_flag = in->read_bit();
- if (edge_flag == 0) {
+ if (edge_flag == 0)
+ {
in->ensureBits(4);
int num_bits = 2 + in->read_uint(4);
// curved edge
@@ -508,25 +522,33 @@
x = ax;
y = ay;
- } else {
+ }
+ else
+ {
// straight edge
in->ensureBits(5);
int num_bits = 2 + in->read_uint(4);
bool line_flag = in->read_bit();
int dx = 0, dy = 0;
- if (line_flag) {
+ if (line_flag)
+ {
// General line.
in->ensureBits(2 * num_bits);
dx = in->read_sint(num_bits);
dy = in->read_sint(num_bits);
- } else {
+ }
+ else
+ {
in->ensureBits(1);
bool vert_flag = in->read_bit();
- if (vert_flag == 0) {
+ if (vert_flag == 0)
+ {
// Horizontal line.
in->ensureBits(num_bits);
dx = in->read_sint(num_bits);
- } else {
+ }
+ else
+ {
// Vertical line.
in->ensureBits(num_bits);
dy = in->read_sint(num_bits);
@@ -565,37 +587,33 @@
}
}
#endif // GNASH_DEBUG_SHAPE_BOUNDS
-}
-
+ }
-void shape_character_def::display(character* inst)
+ void shape_character_def::display(character* inst)
// Draw the shape using our own inherent styles.
-{
+ {
//GNASH_REPORT_FUNCTION;
-
gnash::render::draw_shape_character(this, inst);
-
-/*
+ /*
matrix mat = inst->get_world_matrix();
cxform cx = inst->get_world_cxform();
float pixel_scale = inst->get_parent()->get_pixel_scale();
display(mat, cx, pixel_scale, m_fill_styles, m_line_styles);
*/
-}
-
+ }
#ifdef DEBUG_DISPLAY_SHAPE_PATHS
#include "ogl.h"
-
-static void point_normalize(point* p)
-{
+ static void point_normalize(point* p)
+ {
float mag2 = p->x * p->x + p->y * p->y;
- if (mag2 < 1e-9f) {
+ if (mag2 < 1e-9f)
+ {
// Very short vector.
// @@ log error
@@ -607,11 +625,10 @@
float inv_mag = 1.0f / sqrtf(mag2);
p->x *= inv_mag;
p->y *= inv_mag;
-}
-
+ }
-static void show_fill_number(const point& p, int fill_number)
-{
+ static void show_fill_number(const point& p, int fill_number)
+ {
// We're inside a glBegin(GL_LINES)
// Eh, let's do it in binary, least sig four bits...
@@ -619,12 +636,16 @@
float y = p.y;
int mask = 8;
- while (mask) {
- if (mask & fill_number) {
+ while (mask)
+ {
+ if (mask & fill_number)
+ {
// Vert line --> 1.
glVertex2f(x, y - 40.0f);
glVertex2f(x, y + 40.0f);
- } else {
+ }
+ else
+ {
// Rectangle --> 0.
glVertex2f(x - 10.0f, y - 40.0f);
glVertex2f(x + 10.0f, y - 40.0f);
@@ -641,20 +662,22 @@
x += 40.0f;
mask >>= 1;
}
-}
+ }
-static void debug_display_shape_paths(
+ static void debug_display_shape_paths(
const matrix& mat,
float /* object_space_max_error */,
const std::vector<path>& paths,
const std::vector<fill_style>& /* fill_styles */,
const std::vector<line_style>& /* line_styles */)
-{
- for (unsigned int i = 0; i < paths.size(); i++) {
-// if (i > 0) break;//xxxxxxxx
+ {
+ for (unsigned int i = 0; i < paths.size(); i++)
+ {
+ // if (i > 0) break;//xxxxxxxx
const path& p = paths[i];
- if (p.getLeftFill() == 0 && p.getRightFill() == 0) {
+ if (p.getLeftFill() == 0 && p.getRightFill() == 0)
+ {
continue;
}
@@ -680,7 +703,8 @@
mat.transform(&pt, point(p.ap.x, p.ap.y));
glVertex2f(pt.x, pt.y);
- for (unsigned int j = 0; j < p.m_edges.size(); j++) {
+ for (unsigned int j = 0; j < p.m_edges.size(); j++)
+ {
mat.transform(&pt, point(p.m_edges[j].cp.x, p.m_edges[j].cp.y));
glVertex2f(pt.x, pt.y);
mat.transform(&pt, point(p.m_edges[j].ap.x, p.m_edges[j].ap.y));
@@ -692,7 +716,8 @@
// Draw arrowheads.
point dir, right, p0, p1;
glBegin(GL_LINES);
- {for (unsigned int j = 0; j < p.m_edges.size(); j++)
+ {
+ for (unsigned int j = 0; j < p.m_edges.size(); j++)
{
mat.transform(&p0, point(p.m_edges[j].cp.x, p.m_edges[j].cp.y));
mat.transform(&p1, point(p.m_edges[j].ap.x, p.m_edges[j].ap.y));
@@ -725,32 +750,31 @@
p0.y + right.y * ARROW_MAG * 4),
p.getRightFill());
}
- }}
+ }
+ }
glEnd();
glPopMatrix();
}
-}
+ }
#endif // DEBUG_DISPLAY_SHAPE_PATHS
-
-
-void shape_character_def::display(
+ void shape_character_def::display(
const matrix& mat,
const cxform& cx,
float pixel_scale,
const std::vector<fill_style>& fill_styles,
const std::vector<line_style>& line_styles) const
-{
+ {
shape_character_def* this_non_const = const_cast<shape_character_def*>(this);
render_handler* renderer = get_render_handler();
renderer->draw_shape_character(this_non_const, mat, cx, pixel_scale,
fill_styles, line_styles);
-}
+ }
-// TODO: this should be moved to libgeometry or something
-int curve_x_crossings(float x0, float y0, float x1, float y1,
+ // TODO: this should be moved to libgeometry or something
+ int curve_x_crossings(float x0, float y0, float x1, float y1,
float cx, float cy, float y, float &cross1, float &cross2)
// Finds the quadratic bezier curve crossings with the line Y.
// The function can have zero, one or two solutions (cross1, cross2). The
@@ -759,12 +783,13 @@
// x1, y1 = end point of the curve (anchor, aka ax|ay)
// cx, cy = control point of the curve
// If there are two crossings, cross1 is the nearest to x0|y0 on the
curve.
-{
+ {
int count=0;
// check if any crossings possible
if ( ((y0 < y) && (y1 < y) && (cy < y))
- || ((y0 > y) && (y1 > y) && (cy > y)) ) {
+ || ((y0 > y) && (y1 > y) && (cy > y)) )
+ {
// all above or below -- no possibility of crossing
return 0;
}
@@ -781,21 +806,26 @@
// q = -0.5 [b +sgn(b) sqrt(b^2 - 4ac)]
// x1 = q/a; x2 = c/q;
-
float A = y1 + y0 - 2 * cy;
float B = 2 * (cy - y0);
float C = y0 - y;
float rad = B * B - 4 * A * C;
- if (rad < 0) {
+ if (rad < 0)
+ {
return 0;
- } else {
+ }
+ else
+ {
float q;
float sqrt_rad = sqrtf(rad);
- if (B < 0) {
+ if (B < 0)
+ {
q = -0.5f * (B - sqrt_rad);
- } else {
+ }
+ else
+ {
q = -0.5f * (B + sqrt_rad);
}
@@ -803,9 +833,11 @@
// float t0 = (-B + sqrt_rad) / (2 * A);
// float t1 = (-B - sqrt_rad) / (2 * A);
- if (q != 0) {
+ if (q != 0)
+ {
float t1 = C / q;
- if (t1 >= 0 && t1 < 1) {
+ if (t1 >= 0 && t1 < 1)
+ {
float x_at_t1 =
x0 + 2 * (cx - x0) * t1 + (x1 + x0 - 2 * cx) * t1 * t1;
@@ -815,9 +847,11 @@
}
}
- if (A != 0) {
+ if (A != 0)
+ {
float t0 = q / A;
- if (t0 >= 0 && t0 < 1) {
+ if (t0 >= 0 && t0 < 1)
+ {
float x_at_t0 =
x0 + 2 * (cx - x0) * t0 + (x1 + x0 - 2 * cx) * t0 * t0;
@@ -829,21 +863,18 @@
}
}
-
}
return count;
-}
-
+ }
-bool shape_character_def::point_test_local(float x, float y)
+ bool shape_character_def::point_test_local(float x, float y)
// Return true if the specified point is on the interior of our shape.
// Incoming coords are local coords.
-{
-
-//#define DEBUG_POINT_TEST
-//#define DEBUG_POINT_TEST_EXT
+ {
+ //#define DEBUG_POINT_TEST
+ //#define DEBUG_POINT_TEST_EXT
#ifdef DEBUG_POINT_TEST
printf("=== point_test_local ===\n");
@@ -867,7 +898,6 @@
- intersecting paths
*/
-
// Align test coordinates to TWIP coordinate system and shift by a half
// TWIP to avoid line junction situations which are hard to handle.
Oversample
// everything by 100 to get some degree of accuracy (ie. this won't produce
@@ -881,17 +911,18 @@
bool even_odd = true; // later we will need non-zero for glyphs... (TODO)
- if (m_bound.point_test(x, y) == false) {
+ if (m_bound.point_test(x, y) == false)
+ {
// Early out.
return false;
}
-
unsigned npaths = m_paths.size();
int counter = 0;
// browse all paths
- for (unsigned pno=0; pno<npaths; pno++) {
+ for (unsigned pno=0; pno<npaths; pno++)
+ {
const path& pth = m_paths[pno];
unsigned nedges = pth.m_edges.size();
@@ -900,9 +931,11 @@
float next_pen_y = pth.ap.y;
float pen_x, pen_y;
- if (pth.m_new_shape) {
+ if (pth.m_new_shape)
+ {
if ( (even_odd && (counter % 2) != 0) ||
- (!even_odd && (counter != 0)) ) {
+ (!even_odd && (counter != 0)) )
+ {
// the point is inside the previous subshape, so exit now
#ifdef DEBUG_POINT_TEST
@@ -923,7 +956,8 @@
continue;
// If the path has a line style, check for strokes there
- if (pth.m_line != 0 ) {
+ if (pth.m_line != 0 )
+ {
assert(m_line_styles.size() >= pth.m_line);
@@ -932,10 +966,13 @@
int thickness = ls.get_width();
float sqdist;
- if (thickness == 0) {
+ if (thickness == 0)
+ {
// hairline has always a tolerance of a single twip
sqdist = 1;
- } else {
+ }
+ else
+ {
float dist = thickness/2;
sqdist = dist*dist;
}
@@ -946,7 +983,8 @@
}
// browse all edges of the path
- for (unsigned eno=0; eno<nedges; eno++) {
+ for (unsigned eno=0; eno<nedges; eno++)
+ {
const edge& edg = pth.m_edges[eno];
@@ -971,7 +1009,8 @@
int dir1, dir2=0; // +1 = downward, -1 = upward
int crosscount=0;
- if (edg.is_straight()) {
+ if (edg.is_straight())
+ {
// ==> straight line case
@@ -980,7 +1019,8 @@
#endif
// ignore horizontal lines
- if (edg.ap.y == pen_y) { // TODO: better check for small difference?
+ if (edg.ap.y == pen_y) // TODO: better check for
small difference?
+ {
#ifdef DEBUG_POINT_TEST_EXT
printf(" #%02d, #%02d [%s] horizontal line\n", pno, eno, debug);
#endif
@@ -989,7 +1029,8 @@
// does this line cross the Y coordinate?
if ( ((pen_y <= y) && (edg.ap.y >= y))
- || ((pen_y >= y) && (edg.ap.y <= y)) ) {
+ || ((pen_y >= y) && (edg.ap.y <= y)) )
+ {
// calculate X crossing
cross1 = pen_x + (edg.ap.x - pen_x) *
@@ -1002,14 +1043,18 @@
crosscount=1;
- } else {
+ }
+ else
+ {
// no crossing found
crosscount = 0;
}
- } else {
+ }
+ else
+ {
// ==> curve case
@@ -1025,16 +1070,15 @@
} // curve
-
// ==> we have now:
// - one (cross1) or two (cross1, cross2) ray crossings (X coordinate)
// - dir1/dir2 tells the direction of the crossing
// (+1 = downward, -1 = upward)
// - crosscount tells the number of crossings
-
// need at least one crossing
- if (crosscount==0) {
+ if (crosscount==0)
+ {
#ifdef DEBUG_POINT_TEST_EXT
printf(" #%02d, #%02d [%s] no crossing\n", pno, eno, debug);
#endif
@@ -1044,7 +1088,8 @@
bool touched=false;
// check first crossing
- if (cross1 <= x) {
+ if (cross1 <= x)
+ {
if (pth.m_fill0 > 0) counter += dir1;
if (pth.m_fill1 > 0) counter -= dir1;
@@ -1057,7 +1102,8 @@
}
// check optional second crossing (only possible with curves)
- if ((crosscount>1) && (cross2 <= x)) {
+ if ((crosscount>1) && (cross2 <= x))
+ {
if (pth.m_fill0 > 0) counter += dir2;
if (pth.m_fill1 > 0) counter -= dir2;
@@ -1074,36 +1120,32 @@
printf(" #%02d, #%02d [%s] no crossing at left side\n", pno, eno,
debug);
#endif
-
} // for edge
} // for path
-
#ifdef DEBUG_POINT_TEST
printf(" all paths processed. counter=%d\n", counter);
#endif
return ( (even_odd && (counter % 2) != 0) ||
(!even_odd && (counter != 0)) );
-}
-
+ }
-float shape_character_def::get_height_local() const
-{
+ float shape_character_def::get_height_local() const
+ {
return m_bound.height();
-}
+ }
-float shape_character_def::get_width_local() const
-{
+ float shape_character_def::get_width_local() const
+ {
return m_bound.width();
-}
-
+ }
-void shape_character_def::compute_bound(rect* r) const
+ void shape_character_def::compute_bound(rect* r) const
// Find the bounds of this shape, and store them in
// the given rectangle.
-{
+ {
r->set_null();
for (unsigned int i = 0; i < m_paths.size(); i++)
@@ -1129,31 +1171,30 @@
}
p.expandBounds(*r, thickness);
}
-}
-
+ }
#ifdef GNASH_USE_GC
-void
-shape_character_def::markReachableResources() const
-{
+ void
+ shape_character_def::markReachableResources() const
+ {
assert(isReachable());
for (FillStyleVect::const_iterator i=m_fill_styles.begin(),
e=m_fill_styles.end();
i != e; ++i)
{
i->markReachableResources();
}
-}
+ }
#endif // GNASH_USE_GC
-size_t
-shape_character_def::numPaths() const
-{
+ size_t
+ shape_character_def::numPaths() const
+ {
return m_paths.size();
-}
+ }
-size_t
-shape_character_def::numEdges() const
-{
+ size_t
+ shape_character_def::numEdges() const
+ {
typedef std::vector<path> PathList;
size_t count = 0;
@@ -1162,7 +1203,7 @@
count += i->size();
}
return count;
-}
+ }
} // end namespace gnash
Index: server/swf/PlaceObject2Tag.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/PlaceObject2Tag.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/swf/PlaceObject2Tag.cpp 21 Jan 2008 20:56:02 -0000 1.30
+++ server/swf/PlaceObject2Tag.cpp 12 Feb 2008 16:48:38 -0000 1.31
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: PlaceObject2Tag.cpp,v 1.30 2008/01/21 20:56:02 rsavoye Exp $ */
+/* $Id: PlaceObject2Tag.cpp,v 1.31 2008/02/12 16:48:38 bwy Exp $ */
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h"
@@ -221,7 +221,7 @@
else
m_ratio = character::noRatioValue;
- if (has_name) m_name = in.read_string();
+ if (has_name) in.read_string(m_name);
if (has_clip_depth)
m_clip_depth = in.read_u16()+character::staticDepthOffset;
@@ -267,7 +267,7 @@
m_color_transform.print();
}
if ( has_ratio ) log_parse(_(" ratio: %d"), m_ratio);
- if ( has_name ) log_parse(_(" name = %s"), m_name ? m_name :
"<null>");
+ if ( has_name ) log_parse(_(" name = %s"), m_name.empty() ? "<null>"
: m_name.c_str());
if ( has_clip_depth ) log_parse(_(" clip_depth = %d (%d)"),
m_clip_depth, m_clip_depth-character::staticDepthOffset);
log_parse(_(" m_place_type: %d"), m_place_type);
);
@@ -336,7 +336,7 @@
else
m_ratio = character::noRatioValue;
- if (has_name) m_name = in.read_string();
+ if (has_name) in.read_string(m_name);
if (has_clip_depth)
m_clip_depth = in.read_u16()+character::staticDepthOffset;
@@ -400,7 +400,7 @@
m_color_transform.print();
}
if ( has_ratio ) log_parse(_(" ratio: %d"), m_ratio);
- if ( has_name ) log_parse(_(" name = %s"), m_name ? m_name :
"<null>");
+ if ( has_name ) log_parse(_(" name = %s"), m_name.empty() ? "<null>":
m_name.c_str());
if ( hasClassName ) log_parse(_(" class name = %s"),
className.c_str());
if ( has_clip_depth ) log_parse(_(" clip_depth = %d (%d)"),
m_clip_depth, m_clip_depth-character::staticDepthOffset);
log_parse(_(" m_place_type: %d"), m_place_type);
@@ -438,7 +438,7 @@
case PLACE:
m->add_display_object(
m_character_id,
- m_name,
+ m_name.c_str(),
m_event_handlers,
m_depth,
m_color_transform,
@@ -459,7 +459,7 @@
case REPLACE:
m->replace_display_object(
m_character_id,
- m_name,
+ m_name.c_str(),
m_depth,
m_has_cxform ? &m_color_transform : NULL,
m_has_matrix ? &m_matrix : NULL,
@@ -474,9 +474,6 @@
PlaceObject2Tag::~PlaceObject2Tag()
{
- delete [] m_name;
-
- m_name = NULL;
for(size_t i=0; i<m_event_handlers.size(); ++i)
{
Index: server/swf/PlaceObject2Tag.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf/PlaceObject2Tag.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/swf/PlaceObject2Tag.h 21 Jan 2008 20:56:02 -0000 1.17
+++ server/swf/PlaceObject2Tag.h 12 Feb 2008 16:48:38 -0000 1.18
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: PlaceObject2Tag.h,v 1.17 2008/01/21 20:56:02 rsavoye Exp $ */
+/* $Id: PlaceObject2Tag.h,v 1.18 2008/02/12 16:48:38 bwy Exp $ */
#ifndef GNASH_SWF_PLACEOBJECT2TAG_H
#define GNASH_SWF_PLACEOBJECT2TAG_H
@@ -65,7 +65,7 @@
:
DisplayListTag(0), // why is it 0 here and -1 for
RemoveObjectTag ??
m_tag_type(0),
- m_name(NULL),
+ m_name(""),
m_ratio(0),
m_has_matrix(false),
m_has_cxform(false),
@@ -104,7 +104,7 @@
private:
int m_tag_type;
- char* m_name;
+ std::string m_name;
int m_ratio;
cxform m_color_transform;
matrix m_matrix;
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -b -r1.182 -r1.183
--- server/swf/tag_loaders.cpp 8 Feb 2008 18:38:34 -0000 1.182
+++ server/swf/tag_loaders.cpp 12 Feb 2008 16:48:38 -0000 1.183
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: tag_loaders.cpp,v 1.182 2008/02/08 18:38:34 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.183 2008/02/12 16:48:38 bwy Exp $ */
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h"
@@ -187,8 +187,10 @@
{
assert(tag == SWF::FRAMELABEL); // 43
- char* n = in->read_string();
- m->add_frame_name(n);
+ std::string name;
+ in->read_string(name);
+
+ m->add_frame_name(name);
// FIXME: support SWF6 "named anchors"
//
@@ -219,8 +221,6 @@
);
}
}
-
- delete [] n;
}
// Load JPEG compression tables that can be used to load
@@ -987,34 +987,34 @@
for (int i = 0; i < count; i++)
{
boost::uint16_t id = in->read_u16();
- char* symbol_name = in->read_string();
+ std::string symbolName;
+ in->read_string(symbolName);
IF_VERBOSE_PARSE (
- log_parse(_(" export: id = %d, name = %s"), id, symbol_name);
+ log_parse(_(" export: id = %d, name = %s"), id,
symbolName.c_str());
);
if (font* f = m->get_font(id))
{
// Expose this font for export.
- m->export_resource(symbol_name, f);
+ m->export_resource(symbolName.c_str(), f);
}
else if (character_def* ch = m->get_character_def(id))
{
// Expose this movie/button/whatever for export.
- m->export_resource(symbol_name, ch);
+ m->export_resource(symbolName.c_str(), ch);
}
else if (sound_sample* ch = m->get_sound_sample(id))
{
- m->export_resource(symbol_name, ch);
+ m->export_resource(symbolName.c_str(), ch);
}
else
{
log_error(_("don't know how to export resource '%s' "
"with id %d (can't find that id)"),
- symbol_name, id);
+ symbolName.c_str(), id);
}
- delete [] symbol_name;
}
}
@@ -1084,16 +1084,16 @@
for (int i = 0; i < count; i++)
{
boost::uint16_t id = in->read_u16();
- std::string symbol_name;
- in->read_string(symbol_name);
+ std::string symbolName;
+ in->read_string(symbolName);
IF_VERBOSE_PARSE
(
- log_parse(_(" import: id = %d, name = %s"), id,
symbol_name.c_str());
+ log_parse(_(" import: id = %d, name = %s"), id,
symbolName.c_str());
);
if (s_no_recurse_while_loading)
{
- m->add_import(source_url, id, symbol_name.c_str()); // TODO: pass
the const ref of string instead
+ m->add_import(source_url, id, symbolName.c_str()); // TODO: pass
the const ref of string instead
}
else
{
@@ -1101,11 +1101,11 @@
// s_no_recurse_while_loading, change
// create_movie().
- boost::intrusive_ptr<resource> res =
source_movie->get_exported_resource(symbol_name.c_str()); // TODO: pass const
string&
+ boost::intrusive_ptr<resource> res =
source_movie->get_exported_resource(symbolName.c_str()); // TODO: pass const
string&
if (res == NULL)
{
log_error(_("import error: could not find resource '%s' in
movie '%s'"),
- symbol_name.c_str(), source_url.c_str());
+ symbolName.c_str(), source_url.c_str());
}
else if (font* f = res->cast_to_font())
{
@@ -1120,7 +1120,7 @@
else
{
log_error(_("import error: resource '%s' from movie '%s' has
unknown type"),
- symbol_name.c_str(), source_url.c_str());
+ symbolName.c_str(), source_url.c_str());
}
}
@@ -1571,19 +1571,18 @@
assert(tag == SWF::METADATA); // 77
// this is supposed to be an XML string
- char* metadata = in->read_string();
+ std::string metadata;
+ in->read_string(metadata);
IF_VERBOSE_PARSE (
- log_parse(_(" metadata = [[\n%s\n]]"), metadata);
+ log_parse(_(" metadata = [[\n%s\n]]"), metadata.c_str());
);
- log_unimpl(_("METADATA tag unused: %s"), metadata);
+ log_unimpl(_("METADATA tag unused: %s"), metadata.c_str());
// TODO: attach to movie_definition instead
// (should we parse the XML maybe?)
- delete [] metadata;
-
}
void
@@ -1645,9 +1644,11 @@
if (tag == SWF::DOABCDEFINE)
{
+
// Skip the 'flags' until they are actually used.
static_cast<void> (in->read_u32());
- std::string name = in->read_string();
+ std::string name;
+ in->read_string(name);
name.c_str();
}
- [Gnash-commit] gnash ChangeLog server/stream.cpp server/stream...,
Benjamin Wolsey <=