[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/server Sprite.cpp dlist.h gnash.h impl.h ...
From: |
strk |
Subject: |
[Gnash-commit] gnash/server Sprite.cpp dlist.h gnash.h impl.h ... |
Date: |
Mon, 30 Jan 2006 10:29:28 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: strk <address@hidden> 06/01/30 10:29:28
Modified files:
server : Sprite.cpp dlist.h gnash.h impl.h types.h
Log message:
Doxygen for gnash::matrix and gnash::cxform,
some advancements in createTextField (far from complete)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Sprite.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/dlist.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/gnash.h.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.h.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/types.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnash/server/Sprite.cpp
diff -u gnash/server/Sprite.cpp:1.4 gnash/server/Sprite.cpp:1.5
--- gnash/server/Sprite.cpp:1.4 Sun Jan 29 10:19:51 2006
+++ gnash/server/Sprite.cpp Mon Jan 30 10:29:28 2006
@@ -183,19 +183,22 @@
static void sprite_create_text_field(const fn_call& fn)
{
-
- sprite_instance* sprite = (sprite_instance*) fn.this_ptr;
-
- if (sprite == NULL)
+ as_object_interface *target=fn.this_ptr;
+ if ( target == NULL )
{
- sprite = (sprite_instance*) fn.env->get_target();
- }
+ target=fn.env->get_target();
+ }
else
{
// I'm courious about when does fn.this_ptr
// actually has a value!
-log_msg("-- %s: this_ptr!=%p --\n", __PRETTY_FUNCTION__, sprite);
+ log_msg("-- %s: this_ptr(%p)!=target(%p) --\n",
+ __PRETTY_FUNCTION__,
+ fn.this_ptr, fn.env->get_target());
}
+
+ //sprite_instance* sprite = (sprite_instance*)target;
+ sprite_instance* sprite =
dynamic_cast<sprite_instance*>(target);
assert(sprite);
assert(fn.nargs==6); // name, depth, x, y, width, height
@@ -224,24 +227,55 @@
// TextField (text_character_def?)
//
+ // Get target's movie definition
movie_definition *m1 = sprite->get_movie_definition();
+
+
+ // text_character_def ctor insists in having
+ // a movie_definition_sub...
movie_definition_sub *mds =
dynamic_cast<movie_definition_sub*>(m1);
assert(mds);
log_msg("Target's movie definition at %p\n", mds);
- //movie_definition_sub *mds = sprite->mdef;
// Do I need the smart_ptr here ?
smart_ptr<text_character_def> txt = new text_character_def(mds);
+ // Now add a the new TextField to the display list.
+
+ // display_list::add wants a character, so we
+ // must construct one.
+ //
+ // Unfortunately our text_character_def does
+ // not inherit from character, but from character_def
+ // which seems to be in another inheritance branch...
+ //
+ // Should we make text_character_def inherit from
+ // character or define a new structure for TextField ?
+ //
+#if 0
+ movie *m = sprite->get_root_movie();
+ assert(m);
+
+ character *txt_char = new character(m);
+ assert(txt_char);
+#endif
+
+
log_error("FIXME: %s unfinished\n", __PRETTY_FUNCTION__);
- // Now add a the new TextField to the display list
- //character *txt_char = dynamic_cast<character *>(txt);
- //assert(txt_char);
+#if 0
+ // Here we add the character to the displayList.
- //sprite->m_display_list->add_display_object();
+ cxform txt_cxform;
+ matrix txt_matrix;
+ bool replace_if_depth_occupied = true;
+ sprite->m_display_list->add_display_object(
+ txt_char, txt_depth, replace_if_depth_occupied,
+ txt_cxform, txt_matrix, txt_ratio, clip_depth
+ );
+#endif
Index: gnash/server/dlist.h
diff -u gnash/server/dlist.h:1.2 gnash/server/dlist.h:1.3
--- gnash/server/dlist.h:1.2 Sun Jan 29 10:19:51 2006
+++ gnash/server/dlist.h Mon Jan 30 10:29:28 2006
@@ -62,8 +62,45 @@
int find_display_index(int depth);
int get_display_index(int depth);
- /// Add a new character in this display list,
- /// replacing anything else in the same depth.
+ /// Add a new character in this display list.
+ //
+ /// If applicable, the event_id::LOAD event
+ /// associated with the given character
+ /// is called as last step of addition.
+ ///
+ /// @param ch
+ /// the character to be added into the list
+ ///
+ /// @param depth
+ /// depth to be assign to the character
+ /// using character::set_depth
+ ///
+ /// @param replace_if_depth_is_occupied
+ /// If this is false, caller wants to allow multiple
+ /// objects with the same depth.
+ /// find_display_index() returns the first matching
+ /// depth, if there are any, so the new character
+ /// will get inserted before all the others with the
+ /// same depth. This matches the semantics
+ /// described by Alexi's SWF ref. (This is all
+ /// for legacy SWF compatibility anyway.)
+ ///
+ /// @param color_xform
+ /// Color transform to be applied to the character
+ /// using character::set_cxform
+ ///
+ /// @param mat
+ /// matrix to be assigned to the character
+ /// using character::set_matrix
+ ///
+ /// @param ratio
+ /// ratio (scale?) to be assigned to the character
+ /// using character::set_ratio
+ ///
+ /// @param clip_depth
+ /// clip_depth (?) to be assigned to the character
+ /// using character::set_clip_depth
+ ///
void add_display_object(
character* ch,
Uint16 depth,
Index: gnash/server/gnash.h
diff -u gnash/server/gnash.h:1.5 gnash/server/gnash.h:1.6
--- gnash/server/gnash.h:1.5 Sat Jan 28 01:14:33 2006
+++ gnash/server/gnash.h Mon Jan 30 10:29:28 2006
@@ -692,32 +692,99 @@
//
struct point;
+
+/// Matrix type, used by render handler
struct matrix
{
+ /// [x,y][scale,rotate,translate]
float m_[2][3];
+ /// The identity matrix (no transforms)
static matrix identity;
+ /// Defaults to identity
matrix();
+
+ /// Check validity of the matrix values
bool is_valid() const;
+
+ /// Set the matrix to identity.
void set_identity();
+
+ /// Concatenate m's transform onto ours.
+ //
+ /// When transforming points, m happens first,
+ /// then our original xform.
void concatenate(const matrix& m);
+
+ /// Concatenate a translation onto the front of our matrix.
+ //
+ /// When transforming points, the translation
+ /// happens first, then our original xform.
+ ///
void concatenate_translation(float tx, float ty);
+
+ /// Concatenate a uniform scale onto the front of our matrix.
+ //
+ /// When transforming points, the scale
+ /// happens first, then our original xform.
+ ///
void concatenate_scale(float s);
+
+ /// Set this matrix to a blend of m1 and m2, parameterized by t.
void set_lerp(const matrix& m1, const matrix& m2, float t);
+
+ /// Set the scale & rotation part of the matrix. angle in radians.
void set_scale_rotation(float x_scale, float y_scale, float
rotation);
+
+ /// Initialize from the SWF input stream.
void read(stream* in);
+
+ /// Debug log.
void print() const;
+
+ /// Transform point 'p' by our matrix.
+ //
+ /// Put the result in *result.
+ ///
void transform(point* result, const point& p) const;
+
+ /// Transform vector 'v' by our matrix. Doesn't apply translation.
+ //
+ /// Put the result in *result.
+ ///
void transform_vector(point* result, const point& p) const;
+
+ /// Transform point 'p' by the inverse of our matrix.
+ //
+ /// Put result in *result.
+ ///
void transform_by_inverse(point* result, const point& p) const;
+
+ /// Set this matrix to the inverse of the given matrix.
void set_inverse(const matrix& m);
- bool does_flip() const; // return true if we flip handedness
- float get_determinant() const; // determinant of the 2x2
rotation/scale part only
- float get_max_scale() const; // return the maximum scale factor that
this transform applies
- float get_x_scale() const; // return the magnitude scale of our x
coord output
- float get_y_scale() const; // return the magnitude scale of our y
coord output
- float get_rotation() const; // return our rotation component (in
radians)
+
+ /// Return true if this matrix reverses handedness.
+ bool does_flip() const;
+
+ /// Return the determinant of the 2x2 rotation/scale part only.
+ float get_determinant() const;
+
+ /// Return the maximum scale factor that this transform applies.
+ //
+ /// For assessing scale, when determining acceptable
+ /// errors in tesselation.
+ ///
+ float get_max_scale() const;
+
+ /// return the magnitude scale of our x coord output
+ float get_x_scale() const;
+
+ /// return the magnitude scale of our y coord output
+ float get_y_scale() const;
+
+ /// return our rotation component (in radians)
+ float get_rotation() const;
};
@@ -770,20 +837,35 @@
};
-//
-// cxform: color transform type, used by render handler
-//
+/// Color transform type, used by render handler
struct cxform
{
- float m_[4][2]; // [RGBA][mult, add]
+ /// [RGBA][multiply, add]
+ float m_[4][2];
+ /// Initialize to the identity color transform (no transform)
cxform();
+
+ /// Concatenate c's transform onto ours.
+ //
+ /// When transforming colors, c's transform is applied
+ /// first, then ours.
+ ///
void concatenate(const cxform& c);
+
+ /// Apply our transform to the given color; return the result.
rgba transform(const rgba in) const;
+
+ /// Read RGB from the SWF input stream.
void read_rgb(stream* in);
+
+ /// Read RGBA from the SWF input stream.
void read_rgba(stream* in);
+
+ /// Debug log.
void print() const;
+ /// The identity color transform (no transform)
static cxform identity;
};
@@ -792,10 +874,10 @@
// texture and render callback handler.
//
-// Your render_handler creates bitmap_info's for gnash. You
-// need to subclass bitmap_info in order to add the
-// information and functionality your app needs to render
-// using textures.
+/// Your render_handler creates bitmap_info's for gnash. You
+/// need to subclass bitmap_info in order to add the
+/// information and functionality your app needs to render
+/// using textures.
struct bitmap_info : public ref_counted
{
unsigned int m_texture_id; // nuke?
@@ -811,8 +893,8 @@
}
};
-// You must define a subclass of render_handler, and pass an
-// instance to set_render_handler().
+/// You must define a subclass of render_handler, and pass an
+/// instance to set_render_handler().
struct render_handler
{
virtual ~render_handler() {}
@@ -825,37 +907,43 @@
virtual void delete_bitmap_info(bitmap_info* bi) = 0;
- // Bracket the displaying of a frame from a movie.
- // Fill the background color, and set up default
- // transforms, etc.
+ /// Bracket the displaying of a frame from a movie.
+ /// Fill the background color, and set up default
+ /// transforms, etc.
virtual void begin_display(
rgba background_color,
int viewport_x0, int viewport_y0,
int viewport_width, int viewport_height,
float x0, float x1, float y0, float y1) = 0;
+
virtual void end_display() = 0;
- // Geometric and color transforms for mesh and line_strip rendering.
+ /// Geometric transforms for mesh and line_strip rendering.
virtual void set_matrix(const matrix& m) = 0;
+
+ /// Color transforms for mesh and line_strip rendering.
virtual void set_cxform(const cxform& cx) = 0;
- // Draw triangles using the current fill-style 0.
- // Clears the style list after rendering.
+ /// Draw triangles using the current fill-style 0.
//
- // coords is a list of (x,y) coordinate pairs, in
- // triangle-strip order. The type of the array should
- // be Sint16[vertex_count*2]
+ /// Clears the style list after rendering.
+ ///
+ /// coords is a list of (x,y) coordinate pairs, in
+ /// triangle-strip order. The type of the array should
+ /// be Sint16[vertex_count*2]
+ ///
virtual void draw_mesh_strip(const void* coords, int vertex_count) =
0;
- // Draw a line-strip using the current line style.
- // Clear the style list after rendering.
+ /// Draw a line-strip using the current line style.
//
- // Coords is a list of (x,y) coordinate pairs, in
- // sequence. Each coord is a 16-bit signed integer.
+ /// Clear the style list after rendering.
+ ///
+ /// Coords is a list of (x,y) coordinate pairs, in
+ /// sequence. Each coord is a 16-bit signed integer.
+ ///
virtual void draw_line_strip(const void* coords, int vertex_count) =
0;
- // Set line and fill styles for mesh & line_strip
- // rendering.
+ /// Set line and fill styles for mesh & line_strip rendering.
enum bitmap_wrap_mode
{
WRAP_REPEAT,
@@ -869,9 +957,11 @@
virtual void line_style_color(rgba color) = 0;
virtual void line_style_width(float width) = 0;
- // Special function to draw a rectangular bitmap;
- // intended for textured glyph rendering. Ignores
- // current transforms.
+ /// Special function to draw a rectangular bitmap.
+ //
+ /// Intended for textured glyph rendering. Ignores
+ /// current transforms.
+ ///
virtual void draw_bitmap(
const matrix& m,
const bitmap_info* bi,
@@ -886,7 +976,7 @@
virtual void disable_mask() = 0;
};
-// Keyboard handling
+/// Keyboard handling
namespace key {
enum code
{
@@ -994,18 +1084,23 @@
};
} // end namespace key
- // Key events are global throughout gnash.
- // @@ Maybe someday make these local to the movie_interface?
+/// Key events are global throughout gnash.
+/// @@ Maybe someday make these local to the movie_interface?
void notify_key_event(key::code k, bool down);
-// Some optional helpers.
+/// Some optional helpers.
namespace tools
{
+
struct process_options
{
- bool m_zip_whole_file; // @@ not implemented yet (low
priority?)
- bool m_remove_image_data; // removes existing image data; leaves
minimal placeholder tags
+ /// @@ not implemented yet (low priority?)
+ bool m_zip_whole_file;
+
+ /// removes existing image data; leaves minimal placeholder tags
+ bool m_remove_image_data;
+
bool m_remove_font_glyph_shapes;
process_options()
@@ -1017,12 +1112,12 @@
}
};
-// Copy tags from *in to *out, applying the given
-// options. *in should be a SWF-format stream. The
-// output will be a SWF-format stream.
-//
-// Returns 0 on success, or a non-zero error-code on
-// failure.
+/// Copy tags from *in to *out, applying the given
+/// options. *in should be a SWF-format stream. The
+/// output will be a SWF-format stream.
+///
+/// Returns 0 on success, or a non-zero error-code on
+/// failure.
int process_swf(tu_file* swf_out, tu_file* swf_in, const process_options&
options);
}
Index: gnash/server/impl.h
diff -u gnash/server/impl.h:1.7 gnash/server/impl.h:1.8
--- gnash/server/impl.h:1.7 Sun Jan 29 10:19:51 2006
+++ gnash/server/impl.h Mon Jan 30 10:29:28 2006
@@ -293,7 +293,7 @@
log_msg("FIXME: %s: unimplemented\n", __FUNCTION__);
}
- // Special event handler; sprites also execute their frame1
actions on this event.
+ /// Special event handler; sprites also execute their frame1
actions on this event.
virtual void on_event_load() { on_event(event_id::LOAD); }
#if 0
@@ -329,8 +329,8 @@
return result;
}
+ /// Override this if you implement call_method.
virtual const char* call_method_args(const char*
method_name, const char* method_arg_fmt, va_list args)
- // Override this if you implement call_method.
{
assert(0);
return NULL;
Index: gnash/server/types.h
diff -u gnash/server/types.h:1.1 gnash/server/types.h:1.2
--- gnash/server/types.h:1.1 Tue Dec 20 21:01:18 2005
+++ gnash/server/types.h Mon Jan 30 10:29:28 2006
@@ -31,22 +31,43 @@
namespace gnash {
struct stream; // forward declaration
+ /// RGBA record
struct rgba
{
Uint8 m_r, m_g, m_b, m_a;
+ /// Default RGBA value is FF.FF.FF.FF
rgba() : m_r(255), m_g(255), m_b(255), m_a(255) {}
+ /// Construct an RGBA with the provided values
+ //
+ /// @param r Red
+ /// @param g Green
+ /// @param b Blue
+ /// @param a Alpha (transparency)
+ ///
rgba(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
:
m_r(r), m_g(g), m_b(b), m_a(a)
{
}
+ /// Initialize from intput stream.
+ //
+ /// @param tag_type
+ /// I don't know by which logic but
+ /// a value <= 22 makes it read RGB
+ /// and value > 22 makes it read RGBA
+ ///
void read(stream* in, int tag_type);
+
+ /// Initialize from intput stream (reads RGBA)
void read_rgba(stream* in);
+
+ /// Initialize from intput stream (reads RGB)
void read_rgb(stream* in);
+ /// Set r,g,b.a values
void set(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
m_r = r;
@@ -57,6 +78,7 @@
void set_lerp(const rgba& a, const rgba& b, float f);
+ /// Debug log.
void print();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash/server Sprite.cpp dlist.h gnash.h impl.h ...,
strk <=