[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog ./configure.ac ./README macro...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash ./ChangeLog ./configure.ac ./README macro... |
Date: |
Wed, 29 Mar 2006 05:42:42 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Rob Savoye <address@hidden> 06/03/29 05:42:42
Modified files:
. : ChangeLog configure.ac README
macros : atk.m4 cairo.m4 firefox.m4 ghelp.m4 glib.m4
gstreamer.m4 gtk2.m4 gtkglext.m4 opengl.m4
pango.m4
libbase : Makefile.am demo.cpp image_filters.cpp log.cpp
log.h
libgeometry : Makefile.am
server : Movie.cpp Sprite.cpp Sprite.h action.cpp
button.cpp dlist.cpp impl.h morph2.cpp
shape.cpp styles.cpp styles.h text.cpp
backend : Makefile.am gnash.cpp render_handler_ogl.cpp
utilities : Makefile.am
Added files:
backend : gtksup.cpp gtksup.h
Log message:
* README: Add text from web site about the mailing lists, and
where to submit bug reports and patches.
* configure.ac: Use $glext instead of $plugin for GTK.
* backend/Makefile.am: Add new files gtksup.h and gtksup.cpp.
* backend/gtksup.{h,cpp}: New files for GTK menu and event support.
* backend/gnash.cpp: Use GTK2 and GtkGLExt if they exist. Use GTK
event handlers and menus. Default to SDL.
* libbase/Makefile.am: Don't both to build the demo.
* libbase/image_filters.cpp: Add debugging trace messages.
* libbase/log.{h,cpp}: Handle just a single char.
* libgeometry/Makefile.am: Add the library paths.
* macros/atk.m4: Define ac_cv_path_atk_lib correctly for when we
do find it in the list of paths.
* macros/cairo.m4: Don't do anything unless $glext is enabled.
* macros/firefox.m4: Don't do anything unless $plugin is enabled.
* macros/ghelp.m4: Move the conditional.
* macros/glib.m4: Define ac_cv_path_glib_lib correctly for when we
do find it in the list of paths.
* macros/gstreamer.m4: Add error message if only the older
gstreamer version is found. 0.10 is required.
* macros/gtk2.m4: Don't do anything unless $glext and $plugin are
enabled. Define the library names with the version or we get the
wrong one.
* macros/gtkglext.m4: Enable by default, but support --disable.
* macros/opengl.m4: Define ac_cv_path_opengl_lib correctly for when we
do find it in the list of paths.
* macros/pango.m4: Define ac_cv_path_pango_lib correctly for when we
do find it in the list of paths.
* server/shape.cpp: Reformat into GNU style.
* server/styles.cpp: Reformat into GNU style.
* utilities/Makefile.am: Add the graphics libraries.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.190&tr2=1.191&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/configure.ac.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/README.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/atk.m4.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/cairo.m4.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/firefox.m4.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/ghelp.m4.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/glib.m4.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/gstreamer.m4.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/gtk2.m4.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/gtkglext.m4.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/opengl.m4.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/pango.m4.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/Makefile.am.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/demo.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/image_filters.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/log.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/log.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libgeometry/Makefile.am.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Movie.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Sprite.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Sprite.h.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.56&tr2=1.57&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/button.cpp.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/dlist.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.h.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/morph2.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/shape.cpp.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/styles.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/styles.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/text.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/Makefile.am.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/gnash.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/gtksup.cpp?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/gtksup.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/render_handler_ogl.cpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/utilities/Makefile.am.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.190 gnash/ChangeLog:1.191
--- gnash/ChangeLog:1.190 Mon Mar 20 19:54:29 2006
+++ gnash/ChangeLog Wed Mar 29 05:42:41 2006
@@ -1,3 +1,37 @@
+2006-03-28 Rob Savoye <address@hidden>
+
+ * README: Add text from web site about the mailing lists, and
+ where to submit bug reports and patches.
+ * configure.ac: Use $glext instead of $plugin for GTK.
+ * backend/Makefile.am: Add new files gtksup.h and gtksup.cpp.
+ * backend/gtksup.{h,cpp}: New files for GTK menu and event support.
+ * backend/gnash.cpp: Use GTK2 and GtkGLExt if they exist. Use GTK
+ event handlers and menus. Default to SDL.
+ * libbase/Makefile.am: Don't both to build the demo.
+ * libbase/image_filters.cpp: Add debugging trace messages.
+ * libbase/log.{h,cpp}: Handle just a single char.
+ * libgeometry/Makefile.am: Add the library paths.
+ * macros/atk.m4: Define ac_cv_path_atk_lib correctly for when we
+ do find it in the list of paths.
+ * macros/cairo.m4: Don't do anything unless $glext is enabled.
+ * macros/firefox.m4: Don't do anything unless $plugin is enabled.
+ * macros/ghelp.m4: Move the conditional.
+ * macros/glib.m4: Define ac_cv_path_glib_lib correctly for when we
+ do find it in the list of paths.
+ * macros/gstreamer.m4: Add error message if only the older
+ gstreamer version is found. 0.10 is required.
+ * macros/gtk2.m4: Don't do anything unless $glext and $plugin are
+ enabled. Define the library names with the version or we get the
+ wrong one.
+ * macros/gtkglext.m4: Enable by default, but support --disable.
+ * macros/opengl.m4: Define ac_cv_path_opengl_lib correctly for when we
+ do find it in the list of paths.
+ * macros/pango.m4: Define ac_cv_path_pango_lib correctly for when we
+ do find it in the list of paths.
+ * server/shape.cpp: Reformat into GNU style.
+ * server/styles.cpp: Reformat into GNU style.
+ * utilities/Makefile.am: Add the graphics libraries.
+
2006-03-20 Rob Savoye <address@hidden>
* doc/C/Makefile.am: Optionally use dblatex or pdfxmltex to build
@@ -6,7 +40,7 @@
2006-03-19 Rob Savoye <address@hidden>
- * macros/gstreamer.m4: Look for Gstreamer.
+ * configure.ac, macros/gstreamer.m4: Look for Gstreamer.
2006-03-18 Rob Savoye <address@hidden>
Index: gnash/README
diff -u gnash/README:1.2 gnash/README:1.3
--- gnash/README:1.2 Sun Dec 25 20:49:31 2005
+++ gnash/README Wed Mar 29 05:42:41 2006
@@ -37,3 +37,36 @@
plugin is limited at this time, it has worked in a variety of
different versions of Mozilla and Firefox.
+----------------------------------
+
+Gnash has three mailing lists hosted at gnu.org. Archives of these
+lists are stored at http://mail.gnu.org/pipermail/:
+
+ * address@hidden is for discussion of Gnash. Ideas for the future,
+ general gnash usage or problems, etc... New alpha and stable
+ releases are announced here. To subscribe, go the
+ http://mail.gnu.org/mailman/listinfo/gnash. Volume is typically
+ low.
+ * address@hidden is for discussion of gnash development,
+ porting to new platforms, ideas for the future. This is where
+ the nitty-gritty gets discussed about Gnash, and is the best
+ list for technical questions. To subscribe, go the
+ http://mail.gnu.org/mailman/listinfo/gnash-dev
+ * address@hidden is where summaries of changes commited to
+ the CVS repository are automatically posted. If you wish to see
+ these changes as they happen,
+ http://mail.gnu.org/mailman/listinfo/gnash-commit Volume is
+ sporadic, but typically low.
+
+If you would like any new feature to be included in future versions of
+Gnash, please send a request to <address@hidden>. You can also
+submit patches at https://savannah.gnu.org/patch/?group=gnash.
+
+Please remember that development of Gnash is a volunteer effort, and
+you can also contribute to its development. For information about
+contributing to the GNU Project, please read How to help GNU.
+
+If you think you have found a bug in Gnash, then you should fill as
+complete a report as possible at
+https://savannah.gnu.org/bugs/?group=gnash.
+
Index: gnash/backend/Makefile.am
diff -u gnash/backend/Makefile.am:1.16 gnash/backend/Makefile.am:1.17
--- gnash/backend/Makefile.am:1.16 Thu Mar 9 19:37:09 2006
+++ gnash/backend/Makefile.am Wed Mar 29 05:42:41 2006
@@ -38,6 +38,10 @@
$(OPENGL_LIBS) \
$(GLEXT_LIBS) \
$(GTK2_LIBS) \
+ $(PANGO_LIBS) \
+ $(CAIRO_LIBS) \
+ $(ATK_LIBS) \
+ $(GLIB_LIBS) \
$(X_LIBS) \
$(DMALLOC_LIBS) \
$(MP3_LIBS) \
@@ -56,6 +60,10 @@
$(OPENGL_CFLAGS) \
$(GLEXT_CFLAGS) \
$(GTK2_CFLAGS) \
+ $(PANGO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(CAIRO_CFLAGS) \
+ $(ATK_CFLAGS) \
$(DMALLOC_CFLAGS) \
$(PNG_CFLAGS) \
$(JPEG_CFLAGS) \
@@ -69,7 +77,8 @@
libgnashbackend_la_SOURCES = \
render_handler_ogl.cpp \
- sound_handler_sdl.cpp
+ sound_handler_sdl.cpp \
+ gtksup.cpp gtksup.h
gnash_SOURCES = gnash.cpp
gnash_LDFLAGS = -module -avoid-version -no-undefined
Index: gnash/backend/gnash.cpp
diff -u gnash/backend/gnash.cpp:1.18 gnash/backend/gnash.cpp:1.19
--- gnash/backend/gnash.cpp:1.18 Sat Mar 18 23:39:34 2006
+++ gnash/backend/gnash.cpp Wed Mar 29 05:42:41 2006
@@ -40,14 +40,28 @@
#include "config.h"
#endif
+#ifdef HAVE_SDL_H
#include "SDL.h"
#include "SDL_thread.h"
+#endif
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#ifdef HAVE_GTK2
+#include <gtk/gtk.h>
+#include "gtksup.h"
+# ifdef USE_GTKGLEXT
+# include <gdk/gdkx.h>
+# include <gdk/gdkgl.h>
+# include <gtk/gtkgl.h>
+# endif
+#endif
+
#include "gnash.h"
#include "log.h"
#include "ogl.h"
@@ -92,7 +106,18 @@
static bool s_event_thread = false;
static bool s_start_waiting = false;
+#ifndef HAVE_GTK2
extern SDL_mutex *glMutex;
+#else
+extern movie_state_e movie_menu_state;
+#endif
+
+extern int mouse_x;
+extern int mouse_y;
+extern int mouse_buttons;
+
+// Define is you just want a hard coded OpenGL graphic
+//#define TEST_GRAPHIC
static tu_file*
file_opener(const char* url)
@@ -119,6 +144,7 @@
log_msg("'\n");
}
+#ifndef HAVE_GTK2
static void
key_event(SDLKey key, bool down)
// For forwarding SDL key events.
@@ -159,6 +185,7 @@
gnash::notify_key_event(c, down);
}
}
+#endif
int
main(int argc, char *argv[])
@@ -166,7 +193,43 @@
int c;
int render_arg;
std::vector<const char*> infiles;
-
+#ifdef HAVE_GTK2
+ GdkGLConfig *glconfig;
+ GdkGLConfigMode glcmode;
+ gint major, minor;
+
+ GtkWidget *window;
+ GtkWidget *drawing_area;
+
+ gtk_init (&argc, &argv);
+ gtk_gl_init (&argc, &argv);
+ gdk_gl_query_version (&major, &minor);
+ dbglogfile << "OpenGL extension version - "
+ << (int)major << "." << (int)minor << endl;
+ glcmode = (GdkGLConfigMode)(GDK_GL_MODE_RGB
+ | GDK_GL_MODE_DEPTH
+ | GDK_GL_MODE_DOUBLE);
+ glconfig = gdk_gl_config_new_by_mode (glcmode);
+
+ if (glconfig == NULL) {
+ dbglogfile << "Cannot find the double-buffered visual." << endl;
+ dbglogfile << "Trying single-buffered visual." << endl;
+
+ // Try single-buffered visual
+ glcmode = (GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH);
+ glconfig = gdk_gl_config_new_by_mode (glcmode);
+ if (glconfig == NULL) {
+ dbglogfile << "No appropriate OpenGL-capable visual found." <<
endl;
+ exit (1);
+ } else {
+ dbglogfile << "Got single-buffered visual." << endl;
+ }
+ } else {
+ dbglogfile << "Got double-buffered visual." << endl;
+ }
+// examine_gl_config_attrib (glconfig);
+#endif
+
assert(tu_types_validate());
float exit_timeout = 0;
@@ -176,7 +239,11 @@
bool sdl_abort = true;
int delay = 31;
float tex_lod_bias;
+#ifndef HAVE_GTK2
int windowid = 0;
+#else
+ GdkNativeWindow windowid = 0;
+#endif
// -1.0 tends to look good.
tex_lod_bias = -1.2f;
@@ -208,7 +275,7 @@
case 'w':
// dbglogfile.openLog();
dbglogfile.setWriteDisk(true);
- dbglogfile << "Logging to disk disabled." << endl;
+ dbglogfile << "Logging to disk enabled." << endl;
break;
case 'a':
gnash::set_verbose_action(true);
@@ -288,7 +355,6 @@
}
gnash::register_file_opener_callback(file_opener);
-
gnash::register_fscommand_callback(fs_callback);
gnash::sound_handler *sound = NULL;
@@ -320,6 +386,7 @@
int height = int(movie_height * s_scale);
if (do_render) {
+#ifndef HAVE_GTK2
if (windowid) {
char SDL_windowhack[32];
sprintf (SDL_windowhack,"SDL_WINDOWID=%d", windowid);
@@ -380,6 +447,73 @@
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
}
+#else
+// if (windowid) {
+// window = gtk_plug_new(windowid);
+// dbglogfile << "Created GTK Plug window" << endl;
+// } else {
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ dbglogfile << "Created top level window" << endl;
+// }
+// if (!glconfig) {
+// static const int attrib_list[] = {
+// // GDK_GL_ALPHA_SIZE, 1,
+// GDK_GL_DOUBLEBUFFER,
+// GDK_GL_DEPTH_SIZE, 1,
+// GDK_GL_RGBA,
+// GDK_GL_RED_SIZE, 8,
+// GDK_GL_ATTRIB_LIST_NONE
+// };
+// glconfig = gdk_gl_config_new(attrib_list);
+// }
+
+ gtk_window_set_title(GTK_WINDOW (window), "Gnash Player");
+ gtk_container_set_reallocate_redraws(GTK_CONTAINER (window), TRUE);
+ g_signal_connect(G_OBJECT(window), "delete_event",
+ G_CALLBACK(delete_event), NULL);
+ g_signal_connect(G_OBJECT(window), "key_press_event",
+ G_CALLBACK(key_press_event), NULL);
+
+ GtkMenu *popup_menu = GTK_MENU(gtk_menu_new());
+
+ drawing_area = gtk_drawing_area_new();
+ gtk_widget_set_size_request(drawing_area, width, height);
+ // Set OpenGL-capability to the widget.
+ gtk_widget_set_gl_capability(drawing_area, glconfig,
+ NULL, TRUE, GDK_GL_RGBA_TYPE);
+ g_signal_connect_after(G_OBJECT (drawing_area), "realize",
+ G_CALLBACK (realize_event), NULL);
+ g_signal_connect(G_OBJECT (drawing_area), "configure_event",
+ G_CALLBACK (configure_event), NULL);
+ g_signal_connect(G_OBJECT (drawing_area), "expose_event",
+ G_CALLBACK (expose_event), NULL);
+
+ gtk_widget_add_events(drawing_area, GDK_EXPOSURE_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_KEY_RELEASE_MASK
+ | GDK_KEY_PRESS_MASK
+ | GDK_POINTER_MOTION_MASK);
+
+ g_signal_connect_swapped(G_OBJECT(drawing_area),
+ "button_press_event",
+ G_CALLBACK(popup_handler),
+ GTK_OBJECT(popup_menu));
+
+ add_menuitems(popup_menu);
+ gtk_widget_realize(window);
+
+ g_signal_connect(G_OBJECT(drawing_area), "button_press_event",
+ G_CALLBACK(button_press_event), NULL);
+ g_signal_connect(G_OBJECT(drawing_area), "button_release_event",
+ G_CALLBACK(button_release_event), NULL);
+ g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event",
+ G_CALLBACK(motion_notify_event), NULL);
+
+ gtk_container_add(GTK_CONTAINER(window), drawing_area);
+ gtk_widget_show(drawing_area);
+ gtk_widget_show(window);
+#endif
// Change the LOD BIAS values to tweak blurriness.
if (tex_lod_bias != 0.0f) {
@@ -399,7 +533,7 @@
#endif // FIX_I810_LOD_BIAS
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT,
tex_lod_bias);
}
-
+#ifndef HAVE_GTK2
// Set the video mode.
if (SDL_SetVideoMode(width, height, s_bit_depth, SDL_OPENGL) == 0) {
fprintf(stderr, "SDL_SetVideoMode() failed.\n");
@@ -411,9 +545,9 @@
strcpy(window_title, "gnash: ");
strcat(window_title, infiles[0]);
SDL_WM_SetCaption(window_title, window_title);
-
//
ogl::open();
+#endif
// Turn on alpha blending.
glEnable(GL_BLEND);
@@ -450,10 +584,6 @@
gnash::set_current_root(m);
// Mouse state.
- int mouse_x = 0;
- int mouse_y = 0;
- int mouse_buttons = 0;
-
float speed_scale = 1.0f;
Uint32 start_ticks = 0;
if (do_render) {
@@ -494,9 +624,10 @@
}
if (do_render) {
+#ifndef HAVE_GTK2
SDL_Event event;
- // Handle input.
bool ret = true;
+ // Handle input.
while (ret) {
// printf("xml_fd is %d, gofast is %d, s_start_waiting is %d,
s_event_thread is %d\n",
// xml_fd, gofast, s_start_waiting, s_event_thread);
@@ -637,19 +768,76 @@
break;
}
}
+#else
+ // Poll for events instead of letting gtk_main() handle them
+ while (gtk_events_pending ()) {
+// dbglogfile << "Making GTK main iteration!" << endl;
+ switch (movie_menu_state) {
+ case PLAY_MOVIE:
+ m->set_play_state(gnash::movie_interface::PLAY);
+ break;
+ // Control-R restarts the movie
+ case RESTART_MOVIE:
+ m->restart();
+ break;
+ case STOP_MOVIE:
+ m->set_play_state(gnash::movie_interface::STOP);
+ break;
+ case PAUSE_MOVIE:
+ if (m->get_play_state() == gnash::movie_interface::STOP)
{
+ m->set_play_state(gnash::movie_interface::PLAY);
+ } else {
+ m->set_play_state(gnash::movie_interface::STOP);
+ }
+ break;
+ // go backward one frame
+ case STEP_BACKWARD:
+ m->goto_frame(m->get_current_frame()-1);
+ break;
+ // go forward one frame
+ case STEP_FORWARD:
+ m->goto_frame(m->get_current_frame()+1);
+ break;
+ // jump goes backward 10 frames
+ case JUMP_BACKWARD:
+ m->goto_frame(m->get_current_frame()-10);
+ break;
+ // jump goes forward 10 frames
+ case JUMP_FORWARD:
+ if ((m->get_current_frame()+10) < md->get_frame_count())
{
+ m->goto_frame(m->get_current_frame()+10);
+ }
+ break;
+ case QUIT_MOVIE:
+ goto done;
+ break;
+ default:
+ break;
+ };
+ movie_menu_state = IDLE_MOVIE;
+ gtk_main_iteration();
+ }
+#endif
}
-
+
+#ifndef TEST_GRAPHIC
// printf("%s(%d): Frame count is %d\n", __PRETTY_FUNCTION__, __LINE__,
// md->get_frame_count());
m = gnash::get_current_root();
gnash::delete_unused_root();
-
+#ifdef HAVE_GTK2
+ GdkGLContext *glcontext = gtk_widget_get_gl_context (drawing_area);
+ GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (drawing_area);
+ if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) {
+ dbglogfile << "ERROR: Couldn't start drawable!" << endl;
+ }
+#endif
m->set_display_viewport(0, 0, width, height);
m->set_background_alpha(s_background ? 1.0f : 0.05f);
m->notify_mouse_state(mouse_x, mouse_y, mouse_buttons);
- m->advance(delta_t * speed_scale);
+ m->advance(delta_t *speed_scale);
if (do_render) {
glDisable(GL_DEPTH_TEST); // Disable depth testing.
@@ -657,10 +845,67 @@
}
m->display();
frame_counter++;
+
+#ifdef HAVE_GTK2
+ if (gdk_gl_drawable_is_double_buffered (gldrawable)) {
+ gdk_gl_drawable_swap_buffers (gldrawable);
+ } else {
+ glFlush();
+ }
+
+ gdk_gl_drawable_gl_end (gldrawable);
+#endif
+#else
+ GdkGLContext *glcontext = gtk_widget_get_gl_context (drawing_area);
+ GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (drawing_area);
+
+ GLUquadricObj *qobj;
+ static GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0};
+ static GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};
+
+ // OpenGL BEGIN
+ if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) {
+ dbglogfile << "ERROR: Couldn't start drawable!" << endl;
+ return false;
+ }
+
+ qobj = gluNewQuadric ();
+ gluQuadricDrawStyle (qobj, GLU_FILL);
+ glNewList (1, GL_COMPILE);
+ gluSphere (qobj, 1.0, 20, 20);
+ glEndList ();
+
+ glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+ glLightfv (GL_LIGHT0, GL_POSITION, light_position);
+ glEnable (GL_LIGHTING);
+ glEnable (GL_LIGHT0);
+ glEnable (GL_DEPTH_TEST);
+
+ glClearColor (1.0, 1.0, 1.0, 1.0);
+ glClearDepth (1.0);
+
+ glViewport (0, 0, width, height);
+
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+ gluPerspective (40.0, 1.0, 1.0, 10.0);
+
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ gluLookAt (0.0, 0.0, 3.0,
+ 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0);
+ glTranslatef (0.0, 0.0, -3.0);
+
+ gdk_gl_drawable_gl_end (gldrawable);
+// end of TEST_GRAPHIC
+#endif
if (do_render) {
+#ifndef HAVE_GTK2
SDL_GL_SwapBuffers();
//glPopAttrib ();
+#endif
if (s_measure_performance == false) {
// Don't hog the CPU.
@@ -684,7 +929,7 @@
}
}
}
-
+
// See if we should exit.
if (do_loop == false
&& m->get_current_frame() + 1 == md->get_frame_count())
@@ -695,6 +940,7 @@
}
done:
+
doneYet = 1;
SDL_KillThread(thread); // kill the network read thread
//SDL_Quit();
@@ -831,4 +1077,3 @@
" CTRL-B Toggle background color\n", name
);
}
-
Index: gnash/backend/render_handler_ogl.cpp
diff -u gnash/backend/render_handler_ogl.cpp:1.9
gnash/backend/render_handler_ogl.cpp:1.10
--- gnash/backend/render_handler_ogl.cpp:1.9 Sat Mar 18 23:39:34 2006
+++ gnash/backend/render_handler_ogl.cpp Wed Mar 29 05:42:42 2006
@@ -134,7 +134,7 @@
// Push our style into OpenGL.
void apply(/*const matrix& current_matrix*/) const
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(m_mode != INVALID);
if (m_mode == COLOR) {
@@ -354,7 +354,7 @@
// coordinates of the movie that correspond to the viewport
// bounds.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
m_display_width = fabsf(x1 - x0);
m_display_height = fabsf(y1 - y0);
@@ -387,45 +387,45 @@
// Old unused code. Might get revived someday.
// #if 0
-// // See if we want to, and can, use multitexture
-// // antialiasing.
-// s_multitexture_antialias = false;
-// if (m_enable_antialias)
-// {
-// int tex_units = 0;
-// glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,
&tex_units);
-// if (tex_units >= 2)
-// {
-// s_multitexture_antialias = true;
-// }
-
-// // Make sure we have an edge texture
available.
-// if (s_multitexture_antialias == true
-// && s_edge_texture_id == 0)
-// {
-// // Very simple texture: 2
texels wide, 1 texel high.
-// // Both texels are white; left
texel is all clear, right texel is all opaque.
-// unsigned char edge_data[8] =
{ 255, 255, 255, 0, 255, 255, 255, 255 };
-
-//
ogl::active_texture(GL_TEXTURE1_ARB);
-// glEnable(GL_TEXTURE_2D);
-// glGenTextures(1,
&s_edge_texture_id);
-// glBindTexture(GL_TEXTURE_2D,
s_edge_texture_id);
-
-// glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-// glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-// glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-// glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-// glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, edge_data);
-
-// glTexEnvf(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE, GL_MODULATE); // @@ should we use a 1D texture???
-
-// glDisable(GL_TEXTURE_2D);
-//
ogl::active_texture(GL_TEXTURE0_ARB);
-// glDisable(GL_TEXTURE_2D);
-// }
-// }
+// // See if we want to, and can, use multitexture
+// // antialiasing.
+// s_multitexture_antialias = false;
+// if (m_enable_antialias)
+// {
+// int tex_units = 0;
+// glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &tex_units);
+// if (tex_units >= 2)
+// {
+// s_multitexture_antialias = true;
+// }
+
+// // Make sure we have an edge texture available.
+// if (s_multitexture_antialias == true
+// && s_edge_texture_id == 0)
+// {
+// // Very simple texture: 2 texels wide, 1 texel high.
+// // Both texels are white; left texel is all clear,
right texel is all opaque.
+// unsigned char edge_data[8] = { 255, 255, 255,
0, 255, 255, 255, 255 };
+
+// ogl::active_texture(GL_TEXTURE1_ARB);
+// glEnable(GL_TEXTURE_2D);
+// glGenTextures(1, &s_edge_texture_id);
+// glBindTexture(GL_TEXTURE_2D, s_edge_texture_id);
+
+// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
+// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
+// glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+// glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 1, 0,
GL_RGBA, GL_UNSIGNED_BYTE, edge_data);
+
+// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
GL_MODULATE); // @@ should we use a 1D texture???
+
+// glDisable(GL_TEXTURE_2D);
+// ogl::active_texture(GL_TEXTURE0_ARB);
+// glDisable(GL_TEXTURE_2D);
+// }
+// }
// #endif // 0
}
@@ -434,7 +434,7 @@
// Clean up after rendering a frame. Client program is still
// responsible for calling glSwapBuffers() or whatever.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
@@ -526,7 +526,7 @@
void draw_mesh_strip(const void* coords, int vertex_count)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
#define NORMAL_RENDERING
//#define MULTIPASS_ANTIALIASING
@@ -645,7 +645,7 @@
void draw_line_strip(const void* coords, int vertex_count)
// Draw the line strip formed by the sequence of points.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
// Set up current style.
m_current_styles[LINE_STYLE].apply();
@@ -675,7 +675,7 @@
//
// Intended for textured glyph rendering.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(bi);
apply_color(color);
@@ -711,7 +711,7 @@
void begin_submit_mask()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
glEnable(GL_STENCIL_TEST);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
@@ -748,7 +748,7 @@
// Sets the current texture to a resampled/expanded version of the
// given image data.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
unsigned int in_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
@@ -797,7 +797,7 @@
// DESTRUCTIVELY generate mipmaps of the given image. The image data
// and width/height of im are munged in this process.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int level = 1;
while (im->m_width > 1 || im->m_height > 1)
{
@@ -831,7 +831,7 @@
// resampled version of the given src image. Does a bilinear
// resampling to create the dst image.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
assert(dst_width >= src_width);
@@ -950,7 +950,7 @@
// Make a placeholder bitmap_info. Must be filled in later before
// using.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
m_texture_id = 0;
m_original_width = 0;
m_original_height = 0;
@@ -963,7 +963,7 @@
//
// !! Munges *data in order to create mipmaps !!
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(width > 0);
assert(height > 0);
assert(data);
@@ -1008,7 +1008,7 @@
bitmap_info_ogl::bitmap_info_ogl(image::rgb* im)
// NOTE: This function destroys im's data in the process of making mipmaps.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(im);
// Create the texture.
@@ -1088,7 +1088,7 @@
// Version of the constructor that takes an image with alpha.
// NOTE: This function destroys im's data in the process of making mipmaps.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
assert(im);
// Create the texture.
@@ -1167,7 +1167,7 @@
gnash::render_handler* gnash::create_render_handler_ogl()
// Factory.
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
return new render_handler_ogl;
}
Index: gnash/configure.ac
diff -u gnash/configure.ac:1.52 gnash/configure.ac:1.53
--- gnash/configure.ac:1.52 Sun Mar 26 01:00:00 2006
+++ gnash/configure.ac Wed Mar 29 05:42:41 2006
@@ -110,9 +110,21 @@
fi
AM_CONDITIONAL(TESTING, test x$testing = xyes)
+dnl dnl Add methods to enable gtk2
+dnl AC_ARG_ENABLE(gtk2, [ --enable-gtk2 Enable GTK2 support for standalone
player],
+dnl [case "${enableval}" in
+dnl yes) gtk2=yes ;;
+dnl no) gtk2=no ;;
+dnl *) AC_MSG_ERROR([bad value ${enableval} for enable-gtk2 option]) ;;
+dnl esac], gtk2=yes)
+
+dnl if test x"${gtk2}" != x"no"; then
+dnl AC_DEFINE([ENABLE_GTK2], [], [Unit gtk2 support])
+dnl fi
+dnl AM_CONDITIONAL(GTK2, test x$gtk2 = xyes)
+
dnl Use the Dom parser from libxml2, not the xmlReader one
dnl The default is to use the Dom parser
-dom=yes
AC_ARG_ENABLE(dom, [ --enable-dom Enable support for Dom parser],
[case "${enableval}" in
yes) dom=yes ;;
@@ -236,9 +248,9 @@
GNASH_PATH_OPENGL
GNASH_PATH_GLEXT
GNASH_PATH_GTK2
-GNASH_PATH_PANGO
-GNASH_PATH_GLIB
GNASH_PATH_CAIRO
+GNASH_PATH_GLIB
+GNASH_PATH_PANGO
GNASH_PATH_ATK
GNASH_PATH_PTHREADS
GNASH_PATH_GHELP
@@ -253,6 +265,29 @@
AC_DEFINE(HAVE_WINSOCK,1,[This is defined is we are on Win32])
fi
+dnl if test "$GCC" = "yes"; then
+dnl # Source do not build with -ansi -pedantic yet
+dnl CXXFLAGS="$CXXFLAGS \
+dnl -W \
+dnl -Wall \
+dnl -Wcast-align \
+dnl -Wcast-qual \
+dnl -Wpointer-arith \
+dnl -Wreturn-type \
+dnl "
+dnl CFLAGS="$CFLAGS \
+dnl -W \
+dnl -Wall \
+dnl -Wcast-align \
+dnl -Wcast-qual \
+dnl -Wpointer-arith \
+dnl -Wreturn-type \
+dnl -Wmissing-declarations \
+dnl -Wmissing-prototypes \
+dnl -Wstrict-prototypes \
+dnl "
+dnl fi
+
dnl AC_CONFIG_LINKS(doc/C/images)
plugmk=""
if test x"$plugin" = x"yes"; then
@@ -339,12 +374,6 @@
echo " GNOME help disabled (default). Use --enable-ghelp to enable."
fi
-if test x$gtkplug = xno; then
- echo " GTK PLUG support disabled (default). Use --enable-gtkplug to
enable."
-else
- echo " GTK Plug support enabled"
-fi
-
if test x"$testing" = x"yes"; then
echo " Unit testing support enabled (default)"
else
@@ -479,7 +508,7 @@
fi
fi
-if test x"$glext" = x"yes"; then
+if test x"$plugin" = x"yes" -a x"$glext" = x"yes"; then
if test x"$GTK2_LIBS" != x; then
if test x"$GTK2_CFLAGS" != x; then
echo " Gtk2 flags are: $GTK2_CFLAGS"
Index: gnash/libbase/Makefile.am
diff -u gnash/libbase/Makefile.am:1.17 gnash/libbase/Makefile.am:1.18
--- gnash/libbase/Makefile.am:1.17 Sat Mar 11 19:24:27 2006
+++ gnash/libbase/Makefile.am Wed Mar 29 05:42:41 2006
@@ -68,7 +68,6 @@
libgnashbase_la_SOURCES = \
config.cpp \
container.cpp \
- demo.cpp \
$(DMALLOC_FILE) \
image.cpp \
image_filters.cpp \
Index: gnash/libbase/demo.cpp
diff -u gnash/libbase/demo.cpp:1.2 gnash/libbase/demo.cpp:1.3
--- gnash/libbase/demo.cpp:1.2 Sun Feb 26 15:49:29 2006
+++ gnash/libbase/demo.cpp Wed Mar 29 05:42:41 2006
@@ -12,116 +12,110 @@
#include "ogl.h"
#include "SDL.h"
-
-namespace demo
+void init_video(int width, int height, int depth)
{
- void init_video(int width, int height, int depth)
+ // Display.
+ // Initialize the SDL subsystems we're using.
+ if (SDL_Init(SDL_INIT_VIDEO /* | SDL_INIT_JOYSTICK | SDL_INIT_CDROM |
SDL_INIT_AUDIO*/))
{
- // Display.
- // Initialize the SDL subsystems we're using.
- if (SDL_Init(SDL_INIT_VIDEO /* | SDL_INIT_JOYSTICK |
SDL_INIT_CDROM | SDL_INIT_AUDIO*/))
- {
- fprintf(stderr, "Unable to init SDL: %s\n",
SDL_GetError());
- exit(1);
- }
- atexit(SDL_Quit);
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- // Set the video mode.
- if (SDL_SetVideoMode(width, height, depth, SDL_OPENGL) == 0)
- {
- fprintf(stderr, "SDL_SetVideoMode() failed.");
- exit(1);
- }
-
- ogl::open();
+ fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
+ exit(1);
+ }
+ atexit(SDL_Quit);
+
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+ // Set the video mode.
+ if (SDL_SetVideoMode(width, height, depth, SDL_OPENGL) == 0)
+ {
+ fprintf(stderr, "SDL_SetVideoMode() failed.");
+ exit(1);
}
+ ogl gl;
+ gl.open();
+}
- bool update_nav2d(nav2d_state* state)
- {
- // Handle input.
- SDL_Event event;
- while (SDL_PollEvent(&event))
+
+bool update_nav2d(nav2d_state* state)
+{
+ // Handle input.
+ SDL_Event event;
+ while (SDL_PollEvent(&event))
+ { switch (event.type)
{
- switch (event.type)
- {
- case SDL_KEYDOWN:
- {
- int key = event.key.keysym.sym;
-
- if (key == SDLK_q || key == SDLK_ESCAPE)
- {
- return true;
- } else if (key == SDLK_EQUALS) {
- state->m_scale *= 0.5f;
- } else if (key == SDLK_MINUS) {
- state->m_scale *= 2.0f;
- }
- break;
- }
-
- case SDL_MOUSEMOTION:
- {
- int new_x = (int) (event.motion.x);
- int new_y = (int) (event.motion.y);
- state->m_mouse_dx = new_x - state->m_mouse_x;
- state->m_mouse_dy = new_y - state->m_mouse_y;
- if (state->m_mouse_buttons & 2) {
- // Left drag: move.
- state->m_center_x -= state->m_mouse_dx
* state->m_scale;
- state->m_center_y += state->m_mouse_dy
* state->m_scale;
- }
- state->m_mouse_x = new_x;
- state->m_mouse_y = new_y;
- break;
- }
-
- case SDL_MOUSEBUTTONDOWN:
- case SDL_MOUSEBUTTONUP:
- {
- int mask = 1 << (event.button.button);
- if (event.button.state == SDL_PRESSED)
- {
- state->m_mouse_buttons |= mask;
- }
- else
- {
- state->m_mouse_buttons &= ~mask;
- }
- break;
- }
-
- case SDL_QUIT:
- return true;
- break;
-
- default:
- break;
- }
- }
+ case SDL_KEYDOWN:
+ {
+ int key = event.key.keysym.sym;
+
+ if (key == SDLK_q || key == SDLK_ESCAPE)
+ {
+ return true;
+ } else if (key == SDLK_EQUALS) {
+ state->m_scale *= 0.5f;
+ } else if (key == SDLK_MINUS) {
+ state->m_scale *= 2.0f;
+ }
+ break;
+ }
+
+ case SDL_MOUSEMOTION:
+ {
+ int new_x = (int) (event.motion.x);
+ int new_y = (int) (event.motion.y);
+ state->m_mouse_dx = new_x - state->m_mouse_x;
+ state->m_mouse_dy = new_y - state->m_mouse_y;
+ if (state->m_mouse_buttons & 2) {
+ // Left drag: move.
+ state->m_center_x -= state->m_mouse_dx *
state->m_scale;
+ state->m_center_y += state->m_mouse_dy *
state->m_scale;
+ }
+ state->m_mouse_x = new_x;
+ state->m_mouse_y = new_y;
+ break;
+ }
+
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ {
+ int mask = 1 << (event.button.button);
+ if (event.button.state == SDL_PRESSED)
+ {
+ state->m_mouse_buttons |= mask;
+ }
+ else
+ {
+ state->m_mouse_buttons &= ~mask;
+ }
+ break;
+ }
+
+ case SDL_QUIT:
+ return true;
+ break;
- return false;
+ default:
+ break;
+ }
}
+ return false;
+}
- void set_nav2d_viewport(const nav2d_state& state)
- {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(state.m_center_x - 500 * state.m_scale,
state.m_center_x + 500 * state.m_scale,
- state.m_center_y - 500 * state.m_scale,
state.m_center_y + 500 * state.m_scale, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
+
+void set_nav2d_viewport(const nav2d_state& state)
+{
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(state.m_center_x - 500 * state.m_scale, state.m_center_x + 500 *
state.m_scale,
+ state.m_center_y - 500 * state.m_scale, state.m_center_y + 500 *
state.m_scale, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
}
// Local Variables:
// mode: C++
-// c-basic-offset: 8
-// tab-width: 8
// indent-tabs-mode: t
// End:
Index: gnash/libbase/image_filters.cpp
diff -u gnash/libbase/image_filters.cpp:1.4 gnash/libbase/image_filters.cpp:1.5
--- gnash/libbase/image_filters.cpp:1.4 Sun Feb 26 15:49:30 2006
+++ gnash/libbase/image_filters.cpp Wed Mar 29 05:42:41 2006
@@ -16,9 +16,11 @@
#include "utility.h"
#include "container.h"
#include "tu_math.h"
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
+#include "log.h"
+using namespace gnash;
namespace {
// anonymous namespace to hold local stuff.
@@ -26,42 +28,41 @@
inline void* my_calloc(int count, int size)
{
- void* mem = (void*) new char[count * size];
- memset(mem, 0, count * size);
- return mem;
+ void *mem = (void *)new char[count * size];
+ memset(mem, 0, count * size);
+ return mem;
}
-
inline void my_cfree(void* mem)
{
- delete [] (char*) mem;
+ delete [] (char*) mem;
}
void get_row(Uint8* row, image::rgb* image, int x0, int xsize, int y)
// Copy RGB data from the specified row into the given buffer.
{
- y = iclamp(y, 0, image->m_height - 1);
- int x1 = x0 + xsize - 1;
- if (x1 >= image->m_width) {
- // clip, then extend.
- int extra_pixels = x1 - image->m_width + 1;
- Uint8* p = ((Uint8*) image->m_data) + (y * image->m_pitch);
- memcpy(row, p + x0 * 3, (3 * (image->m_width - x0)));
- // repeat last pixel
- p = p + (image->m_width - 1) * 3;
- Uint8* q = row + (image->m_width - x0) * 3;
- while (extra_pixels > 0) {
- *(q + 0) = *(p + 0);
- *(q + 1) = *(p + 1);
- *(q + 2) = *(p + 2);
- q += 3;
- extra_pixels--;
- }
+ y = iclamp(y, 0, image->m_height - 1);
+ int x1 = x0 + xsize - 1;
+ if (x1 >= image->m_width) {
+ // clip, then extend.
+ int extra_pixels = x1 - image->m_width + 1;
+ Uint8* p = ((Uint8*) image->m_data) + (y * image->m_pitch);
+ memcpy(row, p + x0 * 3, (3 * (image->m_width - x0)));
+ // repeat last pixel
+ p = p + (image->m_width - 1) * 3;
+ Uint8* q = row + (image->m_width - x0) * 3;
+ while (extra_pixels > 0) {
+ *(q + 0) = *(p + 0);
+ *(q + 1) = *(p + 1);
+ *(q + 2) = *(p + 2);
+ q += 3;
+ extra_pixels--;
}
- else
+ }
+ else
{
- memcpy(row, ((Uint8*) image->m_data) + (y * image->m_pitch) +
x0 * 3, (3 * xsize));
+ memcpy(row, ((Uint8*) image->m_data) + (y * image->m_pitch) + x0 *
3, (3 * xsize));
}
}
@@ -69,28 +70,28 @@
void get_row(Uint8* row, image::rgba* image, int x0, int xsize, int y)
// Copy RGBA data from the specified row into the given buffer.
{
- y = iclamp(y, 0, image->m_height - 1);
- int x1 = x0 + xsize - 1;
- if (x1 >= image->m_width) {
- // clip, then extend.
- int extra_pixels = x1 - image->m_width + 1;
- Uint8* p = ((Uint8*) image->m_data) + (y * image->m_pitch);
- memcpy(row, p + x0 * 4, (4 * (image->m_width - x0)));
- // repeat last pixel
- p = p + (image->m_width - 1) * 4;
- Uint8* q = row + (image->m_width - x0) * 4;
- while (extra_pixels > 0) {
- *(q + 0) = *(p + 0);
- *(q + 1) = *(p + 1);
- *(q + 2) = *(p + 2);
- *(q + 3) = *(p + 3);
- q += 4;
- extra_pixels--;
- }
+ y = iclamp(y, 0, image->m_height - 1);
+ int x1 = x0 + xsize - 1;
+ if (x1 >= image->m_width) {
+ // clip, then extend.
+ int extra_pixels = x1 - image->m_width + 1;
+ Uint8* p = ((Uint8*) image->m_data) + (y * image->m_pitch);
+ memcpy(row, p + x0 * 4, (4 * (image->m_width - x0)));
+ // repeat last pixel
+ p = p + (image->m_width - 1) * 4;
+ Uint8* q = row + (image->m_width - x0) * 4;
+ while (extra_pixels > 0) {
+ *(q + 0) = *(p + 0);
+ *(q + 1) = *(p + 1);
+ *(q + 2) = *(p + 2);
+ *(q + 3) = *(p + 3);
+ q += 4;
+ extra_pixels--;
}
- else
+ }
+ else
{
- memcpy(row, ((Uint8*) image->m_data) + (y * image->m_pitch) +
x0 * 4, (4 * xsize));
+ memcpy(row, ((Uint8*) image->m_data) + (y * image->m_pitch) + x0 *
4, (4 * xsize));
}
}
@@ -98,41 +99,41 @@
void get_column(Uint8* column, image::rgb* image, int x)
// Copy RGB data from the specified column into the given buffer.
{
- int i, d;
- Uint8* p;
+ int i, d;
+ Uint8* p;
- if ((x < 0) || (x >= image->m_width)) {
- assert(0);
- x = iclamp(x, 0, image->m_width - 1);
- }
+ if ((x < 0) || (x >= image->m_width)) {
+ assert(0);
+ x = iclamp(x, 0, image->m_width - 1);
+ }
- d = image->m_pitch;
- for (i = image->m_height, p = ((Uint8*) image->m_data) + x * 3; i-- >
0; p += d) {
- *column++ = *p;
- *column++ = *(p + 1);
- *column++ = *(p + 2);
- }
+ d = image->m_pitch;
+ for (i = image->m_height, p = ((Uint8*) image->m_data) + x * 3; i-- > 0; p
+= d) {
+ *column++ = *p;
+ *column++ = *(p + 1);
+ *column++ = *(p + 2);
+ }
}
void get_column(Uint8* column, image::rgba* image, int x)
// Copy RGBA data from the specified column into the given buffer.
{
- int i, d;
- Uint8* p;
+ int i, d;
+ Uint8* p;
- if ((x < 0) || (x >= image->m_width)) {
- assert(0);
- x = iclamp(x, 0, image->m_width - 1);
- }
+ if ((x < 0) || (x >= image->m_width)) {
+ assert(0);
+ x = iclamp(x, 0, image->m_width - 1);
+ }
- d = image->m_pitch;
- for (i = image->m_height, p = ((Uint8*) image->m_data) + x * 4; i-- >
0; p += d) {
- *column++ = *p;
- *column++ = *(p + 1);
- *column++ = *(p + 2);
- *column++ = *(p + 3);
- }
+ d = image->m_pitch;
+ for (i = image->m_height, p = ((Uint8*) image->m_data) + x * 4; i-- > 0; p
+= d) {
+ *column++ = *p;
+ *column++ = *(p + 1);
+ *column++ = *(p + 2);
+ *column++ = *(p + 3);
+ }
}
@@ -140,22 +141,22 @@
// Clamp {r, g, b} to [0,255], and write pixel data to the given image
// at (x, y).
{
- static image::rgb* im = NULL;
- static int yy = -1;
- static Uint8* p = NULL;
-
- if ((x < 0) || (x >= image->m_width) || (y < 0) || (y >=
image->m_height)) {
- assert(0);
- return;
- }
- if ((im != image) || (yy != y)) {
- im = image;
- yy = y;
- p = ((Uint8*) image->m_data) + (y * image->m_pitch);
- }
- p[x * 3 + 0] = iclamp(frnd(r), 0, 255);
- p[x * 3 + 1] = iclamp(frnd(g), 0, 255);
- p[x * 3 + 2] = iclamp(frnd(b), 0, 255);
+ static image::rgb* im = NULL;
+ static int yy = -1;
+ static Uint8* p = NULL;
+
+ if ((x < 0) || (x >= image->m_width) || (y < 0) || (y >= image->m_height))
{
+ assert(0);
+ return;
+ }
+ if ((im != image) || (yy != y)) {
+ im = image;
+ yy = y;
+ p = ((Uint8*) image->m_data) + (y * image->m_pitch);
+ }
+ p[x * 3 + 0] = iclamp(frnd(r), 0, 255);
+ p[x * 3 + 1] = iclamp(frnd(g), 0, 255);
+ p[x * 3 + 2] = iclamp(frnd(b), 0, 255);
}
@@ -163,23 +164,23 @@
// Clamp {r, g, b, a} to [0,255], and write pixel data to the given image
// at (x, y).
{
- static image::rgba* im = NULL;
- static int yy = -1;
- static Uint8* p = NULL;
-
- if ((x < 0) || (x >= image->m_width) || (y < 0) || (y >=
image->m_height)) {
- assert(0);
- return;
- }
- if ((im != image) || (yy != y)) {
- im = image;
- yy = y;
- p = ((Uint8*) image->m_data) + (y * image->m_pitch);
- }
- p[x * 4 + 0] = iclamp(frnd(r), 0, 255);
- p[x * 4 + 1] = iclamp(frnd(g), 0, 255);
- p[x * 4 + 2] = iclamp(frnd(b), 0, 255);
- p[x * 4 + 3] = iclamp(frnd(a), 0, 255);
+ static image::rgba* im = NULL;
+ static int yy = -1;
+ static Uint8* p = NULL;
+
+ if ((x < 0) || (x >= image->m_width) || (y < 0) || (y >= image->m_height))
{
+ assert(0);
+ return;
+ }
+ if ((im != image) || (yy != y)) {
+ im = image;
+ yy = y;
+ p = ((Uint8*) image->m_data) + (y * image->m_pitch);
+ }
+ p[x * 4 + 0] = iclamp(frnd(r), 0, 255);
+ p[x * 4 + 1] = iclamp(frnd(g), 0, 255);
+ p[x * 4 + 2] = iclamp(frnd(b), 0, 255);
+ p[x * 4 + 3] = iclamp(frnd(a), 0, 255);
}
@@ -195,10 +196,10 @@
float cubic_filter(float t)
// Cubix approximation to the central hump of Sinc.
{
- /* f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1 */
- if(t < 0.0f) t = -t;
- if(t < 1.0f) return((2.0f * t - 3.0f) * t * t + 1.0f);
- return(0.0f);
+ /* f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1 */
+ if(t < 0.0f) t = -t;
+ if(t < 1.0f) return((2.0f * t - 3.0f) * t * t + 1.0f);
+ return(0.0f);
}
@@ -208,8 +209,8 @@
float box_filter(float t)
{
- if((t > -0.5) && (t <= 0.5)) return(1.0);
- return(0.0);
+ if((t > -0.5) && (t <= 0.5)) return(1.0);
+ return(0.0);
}
@@ -219,9 +220,9 @@
float triangle_filter(float t)
{
- if(t < 0.0f) t = -t;
- if(t < 1.0f) return(1.0f - t);
- return(0.0f);
+ if(t < 0.0f) t = -t;
+ if(t < 1.0f) return(1.0f - t);
+ return(0.0f);
}
@@ -232,13 +233,13 @@
float bell_filter(float t)
/* box (*) box (*) box */
{
- if(t < 0) t = -t;
- if(t < 0.5f) return(0.75f - (t * t));
- if(t < 1.5f) {
- t = (t - 1.5f);
- return(0.5f * (t * t));
- }
- return(0.0f);
+ if(t < 0) t = -t;
+ if(t < 0.5f) return(0.75f - (t * t));
+ if(t < 1.5f) {
+ t = (t - 1.5f);
+ return(0.5f * (t * t));
+ }
+ return(0.0f);
}
@@ -249,17 +250,17 @@
float B_spline_filter(float t)
/* box (*) box (*) box (*) box */
{
- float tt;
+ float tt;
- if(t < 0.0f) t = -t;
- if(t < 1.0f) {
- tt = t * t;
- return((0.5f * tt * t) - tt + (2.0f / 3.0f));
- } else if (t < 2.0f) {
- t = 2.0f - t;
- return((1.0f / 6.0f) * (t * t * t));
- }
- return(0.0f);
+ if(t < 0.0f) t = -t;
+ if(t < 1.0f) {
+ tt = t * t;
+ return((0.5f * tt * t) - tt + (2.0f / 3.0f));
+ } else if (t < 2.0f) {
+ t = 2.0f - t;
+ return((1.0f / 6.0f) * (t * t * t));
+ }
+ return(0.0f);
}
@@ -267,18 +268,18 @@
float sinc(float x)
{
- x *= (float) M_PI;
- if (x != 0.0f) return(sinf(x) / x);
- return(1.0f);
+ x *= (float) M_PI;
+ if (x != 0.0f) return(sinf(x) / x);
+ return(1.0f);
}
#define Lanczos3_support (3.0f)
float Lanczos3_filter(float t)
{
- if (t < 0.0f) t = -t;
- if (t < 3.0f) return(sinc(t) * sinc(t/3.0f));
- return(0.0f);
+ if (t < 0.0f) t = -t;
+ if (t < 3.0f) return(sinc(t) * sinc(t/3.0f));
+ return(0.0f);
}
@@ -291,37 +292,37 @@
float Mitchell_filter(float t)
{
- float tt;
+ float tt;
- tt = t * t;
- if (t < 0.0f) t = -t;
- if (t < 1.0f) {
- t = (((12.0f - 9.0f * B - 6.0f * C) * (t * tt))
- + ((-18.0f + 12.0f * B + 6.0f * C) * tt)
- + (6.0f - 2.0f * B));
- return(t / 6.0f);
- } else if(t < 2.0f) {
- t = (((-1.0f * B - 6.0f * C) * (t * tt))
- + ((6.0f * B + 30.0f * C) * tt)
- + ((-12.0f * B - 48.0f * C) * t)
- + (8.0f * B + 24 * C));
- return(t / 6.0f);
- }
- return(0.0f);
+ tt = t * t;
+ if (t < 0.0f) t = -t;
+ if (t < 1.0f) {
+ t = (((12.0f - 9.0f * B - 6.0f * C) * (t * tt))
+ + ((-18.0f + 12.0f * B + 6.0f * C) * tt)
+ + (6.0f - 2.0f * B));
+ return(t / 6.0f);
+ } else if(t < 2.0f) {
+ t = (((-1.0f * B - 6.0f * C) * (t * tt))
+ + ((6.0f * B + 30.0f * C) * tt)
+ + ((-12.0f * B - 48.0f * C) * t)
+ + (8.0f * B + 24 * C));
+ return(t / 6.0f);
+ }
+ return(0.0f);
}
struct CONTRIB {
- int pixel;
- float weight;
+ int pixel;
+ float weight;
- CONTRIB()
- : pixel(0), weight(0.f)
+ CONTRIB()
+ : pixel(0), weight(0.f)
{
}
- CONTRIB(int p, float w)
- : pixel(p), weight(w)
+ CONTRIB(int p, float w)
+ : pixel(p), weight(w)
{
}
};
@@ -334,30 +335,30 @@
enum filter_type {
- FILTER0 = 0,
- BOX = FILTER0,
- TRIANGLE,
- BELL,
- B_SPLINE,
- SOME_CUBIC, // Cubic approximation of Sinc's hump (but no tails).
- LANCZOS3,
- MITCHELL, // This one is alleged to be pretty nice.
+FILTER0 = 0,
+ BOX = FILTER0,
+ TRIANGLE,
+ BELL,
+ B_SPLINE,
+ SOME_CUBIC, // Cubic approximation of Sinc's hump (but no tails).
+ LANCZOS3,
+ MITCHELL, // This one is alleged to be pretty nice.
- FILTER_COUNT
-};
+ FILTER_COUNT
+ };
struct {
- float (*filter_function)(float);
- float support;
+ float (*filter_function)(float);
+ float support;
} filter_table[] =
{
- { box_filter, box_support },
- { triangle_filter, triangle_support },
- { bell_filter, bell_support },
- { B_spline_filter, B_spline_support },
- { cubic_filter, cubic_filter_support },
- { Lanczos3_filter, Lanczos3_support },
- { Mitchell_filter, Mitchell_support },
+ { box_filter, box_support },
+ { triangle_filter, triangle_support },
+ { bell_filter, bell_support },
+ { B_spline_filter, B_spline_support },
+ { cubic_filter, cubic_filter_support },
+ { Lanczos3_filter, Lanczos3_support },
+ { Mitchell_filter, Mitchell_support },
};
@@ -370,162 +371,164 @@
// Rescale the specified portion of the input image into the specified
// portion of the output image. Coordinates are *inclusive*.
{
- assert(out_x0 <= out_x1);
- assert(out_y0 <= out_y1);
- assert(out_x0 >= 0 && out_x0 < out->m_width);
- assert(out_x1 >= 0 && out_x1 < out->m_width);
- assert(out_y0 >= 0 && out_y0 < out->m_height);
- assert(out_y1 >= 0 && out_y1 < out->m_height);
-
- float (*filter_function)(float);
- float support;
-
- // Pick a filter function & support.
- assert(default_type >= FILTER0 && default_type < FILTER_COUNT);
- filter_function = filter_table[default_type].filter_function;
- support = filter_table[default_type].support;
-
-
- image::rgb* tmp; /* intermediate image */
- float xscale, yscale; /* zoom scale factors */
- int i, k; /* loop variables */
- unsigned int j; /* loop variables */
- int n; /* pixel number */
- float center; int left, right; /* filter calculation variables */
- float width, fscale, weight; /* filter calculation variables */
- Uint8* raster; /* a row or column of pixels */
-
- std::vector< std::vector<CONTRIB> > contrib;
-
- int out_width = out_x1 - out_x0 + 1;
- int out_height = out_y1 - out_y0 + 1;
- assert(out_width > 0);
- assert(out_height > 0);
-
- float in_width = in_x1 - in_x0;
- float in_height = in_y1 - in_y0;
- assert(in_width > 0);
- assert(in_height > 0);
-
- int in_window_w = int(ceilf(in_x1) - floorf(in_x0) + 1);
- int in_window_h = int(ceilf(in_y1) - floorf(in_y0) + 1);
-
- /* create intermediate image to hold horizontal zoom */
- tmp = image::create_rgb(out_width, in_window_h);
- xscale = (float) (out_width - 1) / in_width;
- yscale = (float) (out_height - 1) / in_height;
-
- // xxxx protect against division by 0
- if (yscale == 0) { yscale = 1.0f; }
- if (xscale == 0) { xscale = 1.0f; }
-
- /* pre-calculate filter contributions for a row */
- contrib.resize(tmp->m_width);
- if(xscale < 1.0f) {
- width = support / xscale;
- fscale = 1.0f / xscale;
- for (i = 0; i < tmp->m_width; ++i) {
- contrib[i].resize(0);
-
- center = (float) i / xscale;
- left = int(ceilf(center - width));
- right = int(floorf(center + width));
- for (k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight / fscale) /
fscale;
- n = iclamp(k, 0, in_window_w - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
- } else {
- for (i = 0; i < tmp->m_width; ++i) {
- contrib[i].resize(0);
- center = (float) i / xscale;
- left = int(ceilf(center - support));
- right = int(floorf(center + support));
- for(k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight);
- n = iclamp(k, 0, in_window_w - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
+ GNASH_REPORT_FUNCTION;
+
+ assert(out_x0 <= out_x1);
+ assert(out_y0 <= out_y1);
+ assert(out_x0 >= 0 && out_x0 < out->m_width);
+ assert(out_x1 >= 0 && out_x1 < out->m_width);
+ assert(out_y0 >= 0 && out_y0 < out->m_height);
+ assert(out_y1 >= 0 && out_y1 < out->m_height);
+
+ float (*filter_function)(float);
+ float support;
+
+ // Pick a filter function & support.
+ assert(default_type >= FILTER0 && default_type < FILTER_COUNT);
+ filter_function = filter_table[default_type].filter_function;
+ support = filter_table[default_type].support;
+
+
+ image::rgb* tmp; /* intermediate image */
+ float xscale, yscale; /* zoom scale factors */
+ int i, k; /* loop variables */
+ unsigned int j; /* loop variables */
+ int n; /* pixel number */
+ float center; int left, right; /* filter calculation variables */
+ float width, fscale, weight; /* filter calculation variables */
+ Uint8* raster; /* a row or column of pixels */
+
+ std::vector< std::vector<CONTRIB> > contrib;
+
+ int out_width = out_x1 - out_x0 + 1;
+ int out_height = out_y1 - out_y0 + 1;
+ assert(out_width > 0);
+ assert(out_height > 0);
+
+ float in_width = in_x1 - in_x0;
+ float in_height = in_y1 - in_y0;
+ assert(in_width > 0);
+ assert(in_height > 0);
+
+ int in_window_w = int(ceilf(in_x1) - floorf(in_x0) + 1);
+ int in_window_h = int(ceilf(in_y1) - floorf(in_y0) + 1);
+
+ /* create intermediate image to hold horizontal zoom */
+ tmp = image::create_rgb(out_width, in_window_h);
+ xscale = (float) (out_width - 1) / in_width;
+ yscale = (float) (out_height - 1) / in_height;
+
+ // xxxx protect against division by 0
+ if (yscale == 0) { yscale = 1.0f; }
+ if (xscale == 0) { xscale = 1.0f; }
+
+ /* pre-calculate filter contributions for a row */
+ contrib.resize(tmp->m_width);
+ if(xscale < 1.0f) {
+ width = support / xscale;
+ fscale = 1.0f / xscale;
+ for (i = 0; i < tmp->m_width; ++i) {
+ contrib[i].resize(0);
+
+ center = (float) i / xscale;
+ left = int(ceilf(center - width));
+ right = int(floorf(center + width));
+ for (k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight / fscale) / fscale;
+ n = iclamp(k, 0, in_window_w - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
+ }
+ } else {
+ for (i = 0; i < tmp->m_width; ++i) {
+ contrib[i].resize(0);
+ center = (float) i / xscale;
+ left = int(ceilf(center - support));
+ right = int(floorf(center + support));
+ for(k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight);
+ n = iclamp(k, 0, in_window_w - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
}
+ }
- /* apply filter to zoom horizontally from src to tmp */
- raster = (Uint8*) my_calloc(in_window_w, 3);
- for (k = 0; k < tmp->m_height; ++k) {
- get_row(raster, in, int(floorf(in_x0)), in_window_w, k);
- for (i = 0; i < tmp->m_width; ++i) {
- float red = 0.0f;
- float green = 0.0f;
- float blue = 0.0f;
- for(j = 0; j < contrib[i].size(); ++j) {
- int pixel = contrib[i][j].pixel;
- red += raster[pixel * 3 + 0] *
contrib[i][j].weight;
- green += raster[pixel * 3 + 1] *
contrib[i][j].weight;
- blue += raster[pixel * 3 + 2] *
contrib[i][j].weight;
- }
- put_pixel(tmp, i, k, red, green, blue);
- }
+ /* apply filter to zoom horizontally from src to tmp */
+ raster = (Uint8*) my_calloc(in_window_w, 3);
+ for (k = 0; k < tmp->m_height; ++k) {
+ get_row(raster, in, int(floorf(in_x0)), in_window_w, k);
+ for (i = 0; i < tmp->m_width; ++i) {
+ float red = 0.0f;
+ float green = 0.0f;
+ float blue = 0.0f;
+ for(j = 0; j < contrib[i].size(); ++j) {
+ int pixel = contrib[i][j].pixel;
+ red += raster[pixel * 3 + 0] * contrib[i][j].weight;
+ green += raster[pixel * 3 + 1] * contrib[i][j].weight;
+ blue += raster[pixel * 3 + 2] * contrib[i][j].weight;
+ }
+ put_pixel(tmp, i, k, red, green, blue);
}
- my_cfree(raster);
+ }
+ my_cfree(raster);
- contrib.resize(out_height);
+ contrib.resize(out_height);
- if (yscale < 1.0f) {
- width = support / yscale;
- fscale = 1.0f / yscale;
- for (i = 0; i < out_height; ++i) {
- contrib[i].resize(0);
-
- center = (float) i / yscale;
- left = int(ceilf(center - width));
- right = int(floorf(center + width));
- for (k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight / fscale) /
fscale;
- n = iclamp(k, 0, tmp->m_height - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
- } else {
- for (i = 0; i < out_height; ++i) {
- contrib[i].resize(0);
- center = (float) i / yscale;
- left = int(ceilf(center - support));
- right = int(floorf(center + support));
- for(k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight);
- n = iclamp(k, 0, tmp->m_height - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
+ if (yscale < 1.0f) {
+ width = support / yscale;
+ fscale = 1.0f / yscale;
+ for (i = 0; i < out_height; ++i) {
+ contrib[i].resize(0);
+
+ center = (float) i / yscale;
+ left = int(ceilf(center - width));
+ right = int(floorf(center + width));
+ for (k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight / fscale) / fscale;
+ n = iclamp(k, 0, tmp->m_height - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
+ }
+ } else {
+ for (i = 0; i < out_height; ++i) {
+ contrib[i].resize(0);
+ center = (float) i / yscale;
+ left = int(ceilf(center - support));
+ right = int(floorf(center + support));
+ for(k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight);
+ n = iclamp(k, 0, tmp->m_height - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
}
+ }
- /* apply filter to zoom vertically from tmp to dst */
- raster = (Uint8*) my_calloc(tmp->m_height, 3);
- for (k = 0; k < tmp->m_width; ++k) {
- get_column(raster, tmp, k);
- for (i = 0; i < out_height; ++i) {
- float red = 0.0f;
- float green = 0.0f;
- float blue = 0.0f;
- for (j = 0; j < contrib[i].size(); ++j) {
- int pixel = contrib[i][j].pixel;
- red += raster[pixel * 3 + 0] *
contrib[i][j].weight;
- green += raster[pixel * 3 + 1] *
contrib[i][j].weight;
- blue += raster[pixel * 3 + 2] *
contrib[i][j].weight;
- }
- put_pixel(out, k + out_x0, i + out_y0, red, green,
blue);
- }
+ /* apply filter to zoom vertically from tmp to dst */
+ raster = (Uint8*) my_calloc(tmp->m_height, 3);
+ for (k = 0; k < tmp->m_width; ++k) {
+ get_column(raster, tmp, k);
+ for (i = 0; i < out_height; ++i) {
+ float red = 0.0f;
+ float green = 0.0f;
+ float blue = 0.0f;
+ for (j = 0; j < contrib[i].size(); ++j) {
+ int pixel = contrib[i][j].pixel;
+ red += raster[pixel * 3 + 0] * contrib[i][j].weight;
+ green += raster[pixel * 3 + 1] * contrib[i][j].weight;
+ blue += raster[pixel * 3 + 2] * contrib[i][j].weight;
+ }
+ put_pixel(out, k + out_x0, i + out_y0, red, green, blue);
}
- my_cfree(raster);
+ }
+ my_cfree(raster);
- contrib.resize(0);
+ contrib.resize(0);
- delete tmp;
+ delete tmp;
}
@@ -536,166 +539,167 @@
//
// Same as above, but with an alpha channel.
{
- assert(out_x0 <= out_x1);
- assert(out_y0 <= out_y1);
- assert(out_x0 >= 0 && out_x0 < out->m_width);
- assert(out_x1 >= 0 && out_x1 < out->m_width);
- assert(out_y0 >= 0 && out_y0 < out->m_height);
- assert(out_y1 >= 0 && out_y1 < out->m_height);
-
- float (*filter_function)(float);
- float support;
-
- // Pick a filter function & support.
- assert(default_type >= FILTER0 && default_type < FILTER_COUNT);
- filter_function = filter_table[default_type].filter_function;
- support = filter_table[default_type].support;
-
-
- image::rgba* tmp; /* intermediate image */
- float xscale, yscale; /* zoom scale factors */
- int i, k; /* loop variables */
- unsigned int j; /* loop variables */
- int n; /* pixel number */
- float center; int left, right; /* filter calculation variables */
- float width, fscale, weight; /* filter calculation variables */
- Uint8* raster; /* a row or column of pixels */
-
- std::vector< std::vector<CONTRIB> > contrib;
-
- int out_width = out_x1 - out_x0 + 1;
- int out_height = out_y1 - out_y0 + 1;
- assert(out_width > 0);
- assert(out_height > 0);
-
- float in_width = in_x1 - in_x0;
- float in_height = in_y1 - in_y0;
- assert(in_width > 0);
- assert(in_height > 0);
-
- int in_window_w = int(ceilf(in_x1) - floorf(in_x0) + 1);
- int in_window_h = int(ceilf(in_y1) - floorf(in_y0) + 1);
-
- /* create intermediate image to hold horizontal zoom */
- tmp = image::create_rgba(out_width, in_window_h);
- xscale = (float) (out_width - 1) / in_width;
- yscale = (float) (out_height - 1) / in_height;
-
- // xxxx protect against division by 0
- if (yscale == 0) { yscale = 1.0f; }
- if (xscale == 0) { xscale = 1.0f; }
-
- /* pre-calculate filter contributions for a row */
- contrib.resize(tmp->m_width);
- if(xscale < 1.0f) {
- width = support / xscale;
- fscale = 1.0f / xscale;
- for (i = 0; i < tmp->m_width; ++i) {
- contrib[i].resize(0);
-
- center = (float) i / xscale;
- left = int(ceilf(center - width));
- right = int(floorf(center + width));
- for (k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight / fscale) /
fscale;
- n = iclamp(k, 0, in_window_w - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
- } else {
- for (i = 0; i < tmp->m_width; ++i) {
- contrib[i].resize(0);
- center = (float) i / xscale;
- left = int(ceilf(center - support));
- right = int(floorf(center + support));
- for(k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight);
- n = iclamp(k, 0, in_window_w - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
+ GNASH_REPORT_FUNCTION;
+ assert(out_x0 <= out_x1);
+ assert(out_y0 <= out_y1);
+ assert(out_x0 >= 0 && out_x0 < out->m_width);
+ assert(out_x1 >= 0 && out_x1 < out->m_width);
+ assert(out_y0 >= 0 && out_y0 < out->m_height);
+ assert(out_y1 >= 0 && out_y1 < out->m_height);
+
+ float (*filter_function)(float);
+ float support;
+
+ // Pick a filter function & support.
+ assert(default_type >= FILTER0 && default_type < FILTER_COUNT);
+ filter_function = filter_table[default_type].filter_function;
+ support = filter_table[default_type].support;
+
+
+ image::rgba* tmp; /* intermediate image */
+ float xscale, yscale; /* zoom scale factors */
+ int i, k; /* loop variables */
+ unsigned int j; /* loop variables */
+ int n; /* pixel number */
+ float center; int left, right; /* filter calculation variables */
+ float width, fscale, weight; /* filter calculation variables */
+ Uint8* raster; /* a row or column of pixels */
+
+ std::vector< std::vector<CONTRIB> > contrib;
+
+ int out_width = out_x1 - out_x0 + 1;
+ int out_height = out_y1 - out_y0 + 1;
+ assert(out_width > 0);
+ assert(out_height > 0);
+
+ float in_width = in_x1 - in_x0;
+ float in_height = in_y1 - in_y0;
+ assert(in_width > 0);
+ assert(in_height > 0);
+
+ int in_window_w = int(ceilf(in_x1) - floorf(in_x0) + 1);
+ int in_window_h = int(ceilf(in_y1) - floorf(in_y0) + 1);
+
+ /* create intermediate image to hold horizontal zoom */
+ tmp = image::create_rgba(out_width, in_window_h);
+ xscale = (float) (out_width - 1) / in_width;
+ yscale = (float) (out_height - 1) / in_height;
+
+ // xxxx protect against division by 0
+ if (yscale == 0) { yscale = 1.0f; }
+ if (xscale == 0) { xscale = 1.0f; }
+
+ /* pre-calculate filter contributions for a row */
+ contrib.resize(tmp->m_width);
+ if(xscale < 1.0f) {
+ width = support / xscale;
+ fscale = 1.0f / xscale;
+ for (i = 0; i < tmp->m_width; ++i) {
+ contrib[i].resize(0);
+
+ center = (float) i / xscale;
+ left = int(ceilf(center - width));
+ right = int(floorf(center + width));
+ for (k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight / fscale) / fscale;
+ n = iclamp(k, 0, in_window_w - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
+ }
+ } else {
+ for (i = 0; i < tmp->m_width; ++i) {
+ contrib[i].resize(0);
+ center = (float) i / xscale;
+ left = int(ceilf(center - support));
+ right = int(floorf(center + support));
+ for(k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight);
+ n = iclamp(k, 0, in_window_w - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
}
+ }
- /* apply filter to zoom horizontally from src to tmp */
- raster = (Uint8*) my_calloc(in_window_w, 4);
- for (k = 0; k < tmp->m_height; ++k) {
- get_row(raster, in, int(floorf(in_x0)), in_window_w, k);
- for (i = 0; i < tmp->m_width; ++i) {
- float red = 0.0f;
- float green = 0.0f;
- float blue = 0.0f;
- float alpha = 0.0f;
- for(j = 0; j < contrib[i].size(); ++j) {
- int pixel = contrib[i][j].pixel;
- red += raster[pixel * 4 + 0] *
contrib[i][j].weight;
- green += raster[pixel * 4 + 1] *
contrib[i][j].weight;
- blue += raster[pixel * 4 + 2] *
contrib[i][j].weight;
- alpha += raster[pixel * 4 + 3] *
contrib[i][j].weight;
- }
- put_pixel(tmp, i, k, red, green, blue, alpha);
- }
+ /* apply filter to zoom horizontally from src to tmp */
+ raster = (Uint8*) my_calloc(in_window_w, 4);
+ for (k = 0; k < tmp->m_height; ++k) {
+ get_row(raster, in, int(floorf(in_x0)), in_window_w, k);
+ for (i = 0; i < tmp->m_width; ++i) {
+ float red = 0.0f;
+ float green = 0.0f;
+ float blue = 0.0f;
+ float alpha = 0.0f;
+ for(j = 0; j < contrib[i].size(); ++j) {
+ int pixel = contrib[i][j].pixel;
+ red += raster[pixel * 4 + 0] * contrib[i][j].weight;
+ green += raster[pixel * 4 + 1] * contrib[i][j].weight;
+ blue += raster[pixel * 4 + 2] * contrib[i][j].weight;
+ alpha += raster[pixel * 4 + 3] * contrib[i][j].weight;
+ }
+ put_pixel(tmp, i, k, red, green, blue, alpha);
}
- my_cfree(raster);
+ }
+ my_cfree(raster);
- contrib.resize(out_height);
+ contrib.resize(out_height);
- if (yscale < 1.0f) {
- width = support / yscale;
- fscale = 1.0f / yscale;
- for (i = 0; i < out_height; ++i) {
- contrib[i].resize(0);
-
- center = (float) i / yscale;
- left = int(ceilf(center - width));
- right = int(floorf(center + width));
- for (k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight / fscale) /
fscale;
- n = iclamp(k, 0, tmp->m_height - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
- } else {
- for (i = 0; i < out_height; ++i) {
- contrib[i].resize(0);
- center = (float) i / yscale;
- left = int(ceilf(center - support));
- right = int(floorf(center + support));
- for(k = left; k <= right; ++k) {
- weight = center - (float) k;
- weight = (*filter_function)(weight);
- n = iclamp(k, 0, tmp->m_height - 1);
- contrib[i].push_back(CONTRIB(n, weight));
- }
- }
+ if (yscale < 1.0f) {
+ width = support / yscale;
+ fscale = 1.0f / yscale;
+ for (i = 0; i < out_height; ++i) {
+ contrib[i].resize(0);
+
+ center = (float) i / yscale;
+ left = int(ceilf(center - width));
+ right = int(floorf(center + width));
+ for (k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight / fscale) / fscale;
+ n = iclamp(k, 0, tmp->m_height - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
+ }
+ } else {
+ for (i = 0; i < out_height; ++i) {
+ contrib[i].resize(0);
+ center = (float) i / yscale;
+ left = int(ceilf(center - support));
+ right = int(floorf(center + support));
+ for(k = left; k <= right; ++k) {
+ weight = center - (float) k;
+ weight = (*filter_function)(weight);
+ n = iclamp(k, 0, tmp->m_height - 1);
+ contrib[i].push_back(CONTRIB(n, weight));
+ }
}
+ }
- /* apply filter to zoom vertically from tmp to dst */
- raster = (Uint8*) my_calloc(tmp->m_height, 4);
- for (k = 0; k < tmp->m_width; ++k) {
- get_column(raster, tmp, k);
- for (i = 0; i < out_height; ++i) {
- float red = 0.0f;
- float green = 0.0f;
- float blue = 0.0f;
- float alpha = 0.0f;
- for (j = 0; j < contrib[i].size(); ++j) {
- int pixel = contrib[i][j].pixel;
- red += raster[pixel * 4 + 0] *
contrib[i][j].weight;
- green += raster[pixel * 4 + 1] *
contrib[i][j].weight;
- blue += raster[pixel * 4 + 2] *
contrib[i][j].weight;
- alpha += raster[pixel * 4 + 3] *
contrib[i][j].weight;
- }
- put_pixel(out, k + out_x0, i + out_y0, red, green,
blue, alpha);
- }
+ /* apply filter to zoom vertically from tmp to dst */
+ raster = (Uint8*) my_calloc(tmp->m_height, 4);
+ for (k = 0; k < tmp->m_width; ++k) {
+ get_column(raster, tmp, k);
+ for (i = 0; i < out_height; ++i) {
+ float red = 0.0f;
+ float green = 0.0f;
+ float blue = 0.0f;
+ float alpha = 0.0f;
+ for (j = 0; j < contrib[i].size(); ++j) {
+ int pixel = contrib[i][j].pixel;
+ red += raster[pixel * 4 + 0] * contrib[i][j].weight;
+ green += raster[pixel * 4 + 1] * contrib[i][j].weight;
+ blue += raster[pixel * 4 + 2] * contrib[i][j].weight;
+ alpha += raster[pixel * 4 + 3] * contrib[i][j].weight;
+ }
+ put_pixel(out, k + out_x0, i + out_y0, red, green, blue, alpha);
}
- my_cfree(raster);
+ }
+ my_cfree(raster);
- contrib.resize(0);
+ contrib.resize(0);
- delete tmp;
+ delete tmp;
}
@@ -708,106 +712,107 @@
void zoom(image::rgba* src, image::rgba* dst)
{
- typedef struct
- {
- Uint8 r;
- Uint8 g;
- Uint8 b;
- Uint8 a;
- }
- rgba;
-
- int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy, ex, ey, t1, t2;
- rgba *c00, *c01, *c10, *c11, *sp, *csp, *dp;
- int sgap, dgap;
-
- /* For interpolation: assume source dimension is one pixel */
- /* smaller to avoid overflow on right and bottom edge. */
- sx = (int) (65536.0 * (float) (src->m_width - 1) / (float) dst->m_width);
- sy = (int) (65536.0 * (float) (src->m_height - 1) / (float)
dst->m_height);
-
- /* Allocate memory for row increments */
- sax = (int*) malloc ((dst->m_width + 1) * sizeof (Uint32));
- say = (int*) malloc ((dst->m_height + 1) * sizeof (Uint32));
-
- /* Precalculate row increments */
- csx = 0;
- csax = sax;
- for (x = 0; x <= dst->m_width; x++)
- {
- *csax = csx;
- csax++;
- csx &= 0xffff;
- csx += sx;
- }
- csy = 0;
- csay = say;
- for (y = 0; y <= dst->m_height; y++)
- {
- *csay = csy;
- csay++;
- csy &= 0xffff;
- csy += sy;
- }
-
- /* Pointer setup */
- sp = csp = (rgba *) src->m_data;
- dp = (rgba *) dst->m_data;
- sgap = src->m_pitch - src->m_width * 4;
- dgap = dst->m_pitch - dst->m_width * 4;
-
- /* Interpolating Zoom */
- /* Scan destination */
- csay = say;
- for (y = 0; y < dst->m_height; y++)
+ GNASH_REPORT_FUNCTION;
+ typedef struct
+ {
+ Uint8 r;
+ Uint8 g;
+ Uint8 b;
+ Uint8 a;
+ }
+ rgba;
+
+ int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy, ex, ey, t1, t2;
+ rgba *c00, *c01, *c10, *c11, *sp, *csp, *dp;
+ int sgap, dgap;
+
+ /* For interpolation: assume source dimension is one pixel */
+ /* smaller to avoid overflow on right and bottom edge. */
+ sx = (int) (65536.0 * (float) (src->m_width - 1) / (float) dst->m_width);
+ sy = (int) (65536.0 * (float) (src->m_height - 1) / (float) dst->m_height);
+
+ /* Allocate memory for row increments */
+ sax = (int*) malloc ((dst->m_width + 1) * sizeof (Uint32));
+ say = (int*) malloc ((dst->m_height + 1) * sizeof (Uint32));
+
+ /* Precalculate row increments */
+ csx = 0;
+ csax = sax;
+ for (x = 0; x <= dst->m_width; x++)
+ {
+ *csax = csx;
+ csax++;
+ csx &= 0xffff;
+ csx += sx;
+ }
+ csy = 0;
+ csay = say;
+ for (y = 0; y <= dst->m_height; y++)
+ {
+ *csay = csy;
+ csay++;
+ csy &= 0xffff;
+ csy += sy;
+ }
+
+ /* Pointer setup */
+ sp = csp = (rgba *) src->m_data;
+ dp = (rgba *) dst->m_data;
+ sgap = src->m_pitch - src->m_width * 4;
+ dgap = dst->m_pitch - dst->m_width * 4;
+
+ /* Interpolating Zoom */
+ /* Scan destination */
+ csay = say;
+ for (y = 0; y < dst->m_height; y++)
{
- /* Setup color source pointers */
- c00 = csp;
- c01 = csp;
- c01++;
- c10 = (rgba *) ((Uint8 *) csp + src->m_pitch);
- c11 = c10;
- c11++;
- csax = sax;
- for (x = 0; x < dst->m_width; x++)
+ /* Setup color source pointers */
+ c00 = csp;
+ c01 = csp;
+ c01++;
+ c10 = (rgba *) ((Uint8 *) csp + src->m_pitch);
+ c11 = c10;
+ c11++;
+ csax = sax;
+ for (x = 0; x < dst->m_width; x++)
{
- /* ABGR ordering */
- /* Interpolate colors */
- ex = (*csax & 0xffff);
- ey = (*csay & 0xffff);
- t1 = ((((c01->r - c00->r) * ex) >> 16) + c00->r) & 0xff;
- t2 = ((((c11->r - c10->r) * ex) >> 16) + c10->r) & 0xff;
- dp->r = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01->g - c00->g) * ex) >> 16) + c00->g) & 0xff;
- t2 = ((((c11->g - c10->g) * ex) >> 16) + c10->g) & 0xff;
- dp->g = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01->b - c00->b) * ex) >> 16) + c00->b) & 0xff;
- t2 = ((((c11->b - c10->b) * ex) >> 16) + c10->b) & 0xff;
- dp->b = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01->a - c00->a) * ex) >> 16) + c00->a) & 0xff;
- t2 = ((((c11->a - c10->a) * ex) >> 16) + c10->a) & 0xff;
- dp->a = (((t2 - t1) * ey) >> 16) + t1;
-
- /* Advance source pointers */
- csax++;
- int sstep = (*csax >> 16);
- c00 += sstep;
- c01 += sstep;
- c10 += sstep;
- c11 += sstep;
- /* Advance destination pointer */
- dp++;
- }
- /* Advance source pointer */
- csay++;
- csp = (rgba *) ((Uint8 *) csp + (*csay >> 16) * src->m_pitch);
- /* Advance destination pointers */
- dp = (rgba *) ((Uint8 *) dp + dgap);
- }
-
- /* Remove temp arrays */
- free (sax);
- free (say);
+ /* ABGR ordering */
+ /* Interpolate colors */
+ ex = (*csax & 0xffff);
+ ey = (*csay & 0xffff);
+ t1 = ((((c01->r - c00->r) * ex) >> 16) + c00->r) & 0xff;
+ t2 = ((((c11->r - c10->r) * ex) >> 16) + c10->r) & 0xff;
+ dp->r = (((t2 - t1) * ey) >> 16) + t1;
+ t1 = ((((c01->g - c00->g) * ex) >> 16) + c00->g) & 0xff;
+ t2 = ((((c11->g - c10->g) * ex) >> 16) + c10->g) & 0xff;
+ dp->g = (((t2 - t1) * ey) >> 16) + t1;
+ t1 = ((((c01->b - c00->b) * ex) >> 16) + c00->b) & 0xff;
+ t2 = ((((c11->b - c10->b) * ex) >> 16) + c10->b) & 0xff;
+ dp->b = (((t2 - t1) * ey) >> 16) + t1;
+ t1 = ((((c01->a - c00->a) * ex) >> 16) + c00->a) & 0xff;
+ t2 = ((((c11->a - c10->a) * ex) >> 16) + c10->a) & 0xff;
+ dp->a = (((t2 - t1) * ey) >> 16) + t1;
+
+ /* Advance source pointers */
+ csax++;
+ int sstep = (*csax >> 16);
+ c00 += sstep;
+ c01 += sstep;
+ c10 += sstep;
+ c11 += sstep;
+ /* Advance destination pointer */
+ dp++;
+ }
+ /* Advance source pointer */
+ csay++;
+ csp = (rgba *) ((Uint8 *) csp + (*csay >> 16) * src->m_pitch);
+ /* Advance destination pointers */
+ dp = (rgba *) ((Uint8 *) dp + dgap);
+ }
+
+ /* Remove temp arrays */
+ free (sax);
+ free (say);
}
@@ -818,8 +823,6 @@
// Local Variables:
// mode: C++
-// c-basic-offset: 8
-// tab-width: 8
// indent-tabs-mode: t
// End:
Index: gnash/libbase/log.cpp
diff -u gnash/libbase/log.cpp:1.2 gnash/libbase/log.cpp:1.3
--- gnash/libbase/log.cpp:1.2 Sat Mar 18 23:39:34 2006
+++ gnash/libbase/log.cpp Wed Mar 29 05:42:41 2006
@@ -273,6 +273,23 @@
return true;
}
+/// \brief print a char
+LogFile&
+LogFile::operator << (char x)
+{
+ if (_verbose) {
+ cout << x;
+ }
+
+ if (_write) {
+ _outstream << x;
+ }
+
+ _state = INPROGRESS;
+
+ return *this;
+}
+
/// \brief print a long
LogFile&
LogFile::operator << (long x)
Index: gnash/libbase/log.h
diff -u gnash/libbase/log.h:1.3 gnash/libbase/log.h:1.4
--- gnash/libbase/log.h:1.3 Sat Mar 18 23:39:34 2006
+++ gnash/libbase/log.h Wed Mar 29 05:42:41 2006
@@ -91,6 +91,7 @@
} _state;
file_state GetState (void) { return _state; }
+ LogFile& operator << (char x);
LogFile& operator << (int x);
LogFile& operator << (long x);
LogFile& operator << (unsigned int x);
Index: gnash/libgeometry/Makefile.am
diff -u gnash/libgeometry/Makefile.am:1.11 gnash/libgeometry/Makefile.am:1.12
--- gnash/libgeometry/Makefile.am:1.11 Thu Mar 9 19:29:06 2006
+++ gnash/libgeometry/Makefile.am Wed Mar 29 05:42:41 2006
@@ -82,6 +82,7 @@
#libgeometry_la_LDFLAGS = -module -avoid-version -no-undefined
#libgeometry_la_LIBDADD = address@hidden@ # $(LIBLTDL)
+libgnashgeo_la_LIBADD = -L../libbase -lgnashbase
# Rebuild with GCC 4.x Mudflap support
mudflap:
Index: gnash/macros/atk.m4
diff -u gnash/macros/atk.m4:1.2 gnash/macros/atk.m4:1.3
--- gnash/macros/atk.m4:1.2 Thu Mar 9 19:29:06 2006
+++ gnash/macros/atk.m4 Wed Mar 29 05:42:41 2006
@@ -129,7 +129,7 @@
for i in $libslist; do
if test -f $i/libatk-${version}.a -o -f $i/libatk-${version}.so;
then
if test x"$i" != x"/usr/lib"; then
- ac_cv_path_atk_lib="$i"
+ ac_cv_path_atk_lib="-L$i -latk-${version}"
break
else
ac_cv_path_atk_lib=""
@@ -145,7 +145,7 @@
else
if test -f $i/libatk-${version}.a -o -f $i/libatk-${version}.so; then
if test x"${ac_cv_path_atk_lib}" != x"/usr/lib"; then
- ac_cv_path_atk_lib="${ac_cv_path_atk_lib}"
+ ac_cv_path_atk_lib="-L${ac_cv_path_atk_lib}"
else
ac_cv_path_atk_lib=""
fi
Index: gnash/macros/cairo.m4
diff -u gnash/macros/cairo.m4:1.2 gnash/macros/cairo.m4:1.3
--- gnash/macros/cairo.m4:1.2 Thu Mar 9 19:29:06 2006
+++ gnash/macros/cairo.m4 Wed Mar 29 05:42:41 2006
@@ -50,10 +50,10 @@
fi
])
- if test x"$glext" = x"yes"; then
+ if test x"$plugin" = x"yes"; then
dnl If the path hasn't been specified, go look for it.
if test x"${ac_cv_path_cairo_incl}" = x; then
- AC_CHECK_HEADERS(cairio/cairo.h, [ac_cv_path_cairo_incl=""],[
+ AC_CHECK_HEADERS(cairo/cairo.h, [ac_cv_path_cairo_incl=""],[
if test x"${ac_cv_path_cairo_incl}" = x; then
AC_MSG_CHECKING([for Cairo header])
incllist="/sw/include /usr/local/include /home/latest/include
/opt/include /usr/include /usr/pkg/include .. ../.."
Index: gnash/macros/firefox.m4
diff -u gnash/macros/firefox.m4:1.13 gnash/macros/firefox.m4:1.14
--- gnash/macros/firefox.m4:1.13 Thu Mar 9 19:29:06 2006
+++ gnash/macros/firefox.m4 Wed Mar 29 05:42:41 2006
@@ -51,45 +51,48 @@
*) AC_MSG_ERROR([bad value ${enableval} for disable-plugin option]) ;;
esac], plugin=yes)
- FIREFOX_PLUGINS=""
- AC_ARG_WITH(plugindir, [ --with-plugindir=DIR Directory to install
Firefox plugin in],
- [FIREFOX_PLUGINS=$withval]
- )
+ if test x"${plugin}" = x"yes"; then
- if test x"${FIREFOX_PLUGINS}" = "x" ; then
- dnl this is the path to where the plugin gets installed
- AC_CHECK_PROG(mconfig, firefox-config, firefox-config)
+ FIREFOX_PLUGINS=""
+ AC_ARG_WITH(plugindir, [ --with-plugindir=DIR Directory to install
Firefox plugin in],
+ [FIREFOX_PLUGINS=$withval]
+ )
- if test x"${mconfig}" = "x" ; then
- AC_CHECK_PROG(mconfig, mozilla-config, mozilla-config)
- fi
+ if test x"${FIREFOX_PLUGINS}" = "x" ; then
+ dnl this is the path to where the plugin gets installed
+ AC_CHECK_PROG(mconfig, firefox-config, firefox-config)
+
+ if test x"${mconfig}" = "x" ; then
+ AC_CHECK_PROG(mconfig, mozilla-config, mozilla-config)
+ fi
- if test x"${mconfig}" != "x" ; then
- plugindir=`${mconfig} --libs plugin`
- FIREFOX_PLUGINS=`echo ${plugindir} | sed -e 's:-L\(@<:@^ @:>@*\)
.*$:\1:' -e 's:^-L::'`/plugins
+ if test x"${mconfig}" != "x" ; then
+ plugindir=`${mconfig} --libs plugin`
+ FIREFOX_PLUGINS=`echo ${plugindir} | sed -e 's:-L\(@<:@^ @:>@*\)
.*$:\1:' -e 's:^-L::'`/plugins
+ fi
fi
- fi
- if test x"${FIREFOX_PLUGINS}" = "x" ; then
- AC_MSG_CHECKING([for path to install plugin])
- dirlist="${prefix}/usr/lib64 /usr/lib64 /usr/lib /sw/lib /usr/local/lib
/opt/lib /usr/pkg/lib /usr/X11R6/lib"
- for i in $dirlist; do
- if test -f $i/firefox/libnullplugin.so; then
- FIREFOX_PLUGINS=$i/firefox/plugins
- break
- else
- if test -f $i/mozilla/libnullplugin.so; then
- FIREFOX_PLUGINS=$i/mozilla/plugins
+ if test x"${FIREFOX_PLUGINS}" = "x" ; then
+ AC_MSG_CHECKING([for path to install plugin])
+ dirlist="${prefix}/usr/lib64 /usr/lib64 /usr/lib /sw/lib /usr/local/lib
/opt/lib /usr/pkg/lib /usr/X11R6/lib"
+ for i in $dirlist; do
+ if test -f $i/firefox/libnullplugin.so; then
+ FIREFOX_PLUGINS=$i/firefox/plugins
break
+ else
+ if test -f $i/mozilla/libnullplugin.so; then
+ FIREFOX_PLUGINS=$i/mozilla/plugins
+ break
+ fi
fi
+ done
+ if test x"${FIREFOX_PLUGINS}" = "x"; then
+ AC_MSG_RESULT(no)
+ AC_MSG_WARN([no path was found for the plugin installation! ])
+ FIREFOX_PLUGINS=$HOME/.mozilla/plugins
+ else
+ AC_MSG_RESULT(yes)
fi
- done
- if test x"${FIREFOX_PLUGINS}" = "x"; then
- AC_MSG_RESULT(no)
- AC_MSG_WARN([no path was found for the plugin installation! ])
- FIREFOX_PLUGINS=$HOME/.mozilla/plugins
- else
- AC_MSG_RESULT(yes)
fi
fi
Index: gnash/macros/ghelp.m4
diff -u gnash/macros/ghelp.m4:1.6 gnash/macros/ghelp.m4:1.7
--- gnash/macros/ghelp.m4:1.6 Thu Mar 9 19:29:06 2006
+++ gnash/macros/ghelp.m4 Wed Mar 29 05:42:41 2006
@@ -65,6 +65,4 @@
ghelp=no
AC_MSG_WARN([You need to install scrollkeeper for gnome help])
fi
-
- AM_CONDITIONAL(GHELP, [test x$ghelp = xyes])
])
Index: gnash/macros/glib.m4
diff -u gnash/macros/glib.m4:1.2 gnash/macros/glib.m4:1.3
--- gnash/macros/glib.m4:1.2 Thu Mar 9 19:29:06 2006
+++ gnash/macros/glib.m4 Wed Mar 29 05:42:41 2006
@@ -134,7 +134,7 @@
for i in $libslist; do
if test -f $i/libglib-${version}.a -o -f $i/libglib-${version}.so;
then
if test x"$i" != x"/usr/lib"; then
- ac_cv_path_glib_lib="$i"
+ ac_cv_path_glib_lib="-L$i -lglib-${version}"
break
else
ac_cv_path_glib_lib=""
@@ -151,7 +151,7 @@
else
if test -f $i/libglib-${version}.a -o -f $i/libglib-${version}.so; then
if test x"${ac_cv_path_glib_lib}" != x"/usr/lib"; then
- ac_cv_path_glib_lib="${ac_cv_path_glib_lib}"
+ ac_cv_path_glib_lib="-L${ac_cv_path_glib_lib}"
else
ac_cv_path_glib_lib=""
fi
Index: gnash/macros/gstreamer.m4
diff -u gnash/macros/gstreamer.m4:1.1 gnash/macros/gstreamer.m4:1.2
--- gnash/macros/gstreamer.m4:1.1 Mon Mar 20 01:02:19 2006
+++ gnash/macros/gstreamer.m4 Wed Mar 29 05:42:41 2006
@@ -159,6 +159,7 @@
if test x"${ac_cv_path_gstreamer_lib}" != x ; then
GSTREAMER_LIBS="-L${ac_cv_path_gstreamer_lib} -lgstreamer-${version}"
+ AC_MSG_WARN([You need GStreamer 0.10 or greater for sound support!])
else
GSTREAMER_LIBS="-lgstreamer-${version}"
fi
Index: gnash/macros/gtk2.m4
diff -u gnash/macros/gtk2.m4:1.3 gnash/macros/gtk2.m4:1.4
--- gnash/macros/gtk2.m4:1.3 Sat Mar 18 23:39:34 2006
+++ gnash/macros/gtk2.m4 Wed Mar 29 05:42:41 2006
@@ -50,7 +50,7 @@
fi
])
- if test x"$glext" = x"yes" -o x"$gtkplug" = x"yes"; then
+ if test x"$plugin" = x"yes" -a x"$glext" = x"yes"; then
dnl Attempt to find the top level directory, which unfortunately has a
dnl version number attached. At least on Debain based systems, this
dnl doesn't seem to get a directory that is unversioned.
@@ -117,7 +117,7 @@
if test -f ${with_gtk2_lib}/libgtkgtk2-x11-${version}.a -o -f
${with_gtk2_lib}/libgtkgtk2-x11-${version}.so; then
ac_cv_path_gtk2_lib=`(cd ${with_gtk2_incl}; pwd)`
else
- AC_MSG_ERROR([${with_gtk2_lib} directory doesn't contain libgtkgtk2.])
+ AC_MSG_ERROR([${with_gtk2_lib} directory doesn't contain libgtk2.])
fi
fi
])
@@ -125,20 +125,20 @@
dnl If the header doesn't exist, there is no point looking for
dnl the library.
if test x"${ac_cv_path_gtk2_incl}" != x; then
- AC_CHECK_LIB(gtk, gtk_init, [ac_cv_path_gtk2_lib="-lgtk"],[
+ AC_CHECK_LIB(gtk-x11-2.0, gtk_init, [ac_cv_path_gtk2_lib="-lgtk-x11-2.0
-lgdk-x11-2.0"],[
AC_MSG_CHECKING([for libgtk2 library])
libslist="${prefix}/lib64 ${prefix}/lib /usr/lib64 /usr/lib /sw/lib
/usr/local/lib /home/latest/lib /opt/lib /usr/pkg/lib .. ../.."
for i in $libslist; do
- if test -f $i/libgtk.a -o -f $i/libgtk.so; then
+ if test -f $i/libgtk-x11-2.0.a -o -f $i/libgtk-x11-2.0.so; then
if test x"$i" != x"/usr/lib"; then
- ac_cv_path_gtk2_lib="$i"
+ ac_cv_path_gtk2_lib="-L$i -lgtk-x11-2.0 -lgdk-x11-2.0"
break
else
- ac_cv_path_gtk2_lib=""
+ ac_cv_path_gtk2_lib="-lgtk-x11-2.0 -lgdk-x11-2."
break
fi
else
- if test -f $i/libgtk.a -o -f $i/libgtk.so; then
+ if test -f $i/libgtk-x11-2.0.a -o -f $i/libgtk-x11-2.0.so; then
ac_cv_path_gtk2_lib="$i/${topdir}"
break
fi
@@ -146,11 +146,11 @@
done
])
else
- if test -f $i/libgtk.a -o -f $i/libgtk.so; then
+ if test -f $i/libgtk-x11-2.0.a -o -f $i/libgtk-x11-2.0.so; then
if test x"${ac_cv_path_gtk2_lib}" != x"/usr/lib"; then
- ac_cv_path_gtk2_lib="${ac_cv_path_gtk2_lib}"
+ ac_cv_path_gtk2_lib="-L${ac_cv_path_gtk2_lib} -lgtk-x11-2.0
-lgdk-x11-2.0"
else
- ac_cv_path_gtk2_lib=""
+ ac_cv_path_gtk2_lib="-lgtk-x11-2.0 -lgdk-x11-2.0"
fi
fi
fi
@@ -158,6 +158,7 @@
if test x"${ac_cv_path_gtk2_incl}" != x ; then
libincl=`echo ${ac_cv_path_gtk2_incl} | sed -e 's/include/lib/'`
+ AC_DEFINE([HAVE_GTK2], [], [Use GTK2 for windowing])
GTK2_CFLAGS="-I${ac_cv_path_gtk2_incl} -I${libincl}/include"
else
GTK2_CFLAGS=""
Index: gnash/macros/gtkglext.m4
diff -u gnash/macros/gtkglext.m4:1.2 gnash/macros/gtkglext.m4:1.3
--- gnash/macros/gtkglext.m4:1.2 Thu Mar 9 19:29:06 2006
+++ gnash/macros/gtkglext.m4 Wed Mar 29 05:42:41 2006
@@ -38,12 +38,12 @@
AC_DEFUN([GNASH_PATH_GLEXT],
[
- AC_ARG_ENABLE(glext, [ --enable-glext Enable support for glext
images],
+ AC_ARG_ENABLE(glext, [ --disable-glext Disable support for GTK
OpenGL extension],
[case "${enableval}" in
yes) glext=yes ;;
no) glext=no ;;
- *) AC_MSG_ERROR([bad value ${enableval} for enable-glext option]) ;;
- esac], glext=no)
+ *) AC_MSG_ERROR([bad value ${enableval} for disable-glext option]) ;;
+ esac], glext=yes)
if test x"$plugin" = x"no"; then
glext=no
@@ -171,9 +171,12 @@
fi
if test x"${ac_cv_path_glext_lib}" != x ; then
+ AC_DEFINE(USE_GTKGLEXT,[], [Use GtkGLExt extension])
GLEXT_LIBS="${ac_cv_path_glext_lib}"
else
GLEXT_LIBS=""
+dnl we can't build the plguin without GtkGlExt
+ glext=no
fi
AM_CONDITIONAL(HAVE_GLEXT, [test x$glext = xyes])
Index: gnash/macros/opengl.m4
diff -u gnash/macros/opengl.m4:1.13 gnash/macros/opengl.m4:1.14
--- gnash/macros/opengl.m4:1.13 Thu Mar 9 19:29:06 2006
+++ gnash/macros/opengl.m4 Wed Mar 29 05:42:41 2006
@@ -115,7 +115,7 @@
for i in $libslist; do
if test -f $i/libGL.a -o -f $i/libGL.so; then
if test x"$i" != x"/usr/lib"; then
- ac_cv_path_opengl_lib="$i"
+ ac_cv_path_opengl_lib="-L$i -lGL -lGLU"
# AC_MSG_RESULT(${ac_cv_path_opengl_lib})
break
else
Index: gnash/macros/pango.m4
diff -u gnash/macros/pango.m4:1.2 gnash/macros/pango.m4:1.3
--- gnash/macros/pango.m4:1.2 Thu Mar 9 19:29:06 2006
+++ gnash/macros/pango.m4 Wed Mar 29 05:42:41 2006
@@ -131,7 +131,7 @@
for i in $libslist; do
if test -f $i/libpango-${version}.a -o -f
$i/libpango-${version}.so; then
if test x"$i" != x"/usr/lib"; then
- ac_cv_path_pango_lib="$i"
+ ac_cv_path_pango_lib="-L$i -lpango-${version}"
break
else
ac_cv_path_pango_lib=""
@@ -148,7 +148,7 @@
else
if test -f $i/libpango-${version}.a -o -f $i/libpango-${version}.so;
then
if test x"${ac_cv_path_pango_lib}" != x"/usr/lib"; then
- ac_cv_path_pango_lib="${ac_cv_path_pango_lib}"
+ ac_cv_path_pango_lib="-L${ac_cv_path_pango_lib}"
else
ac_cv_path_pango_lib=""
fi
Index: gnash/server/Movie.cpp
diff -u gnash/server/Movie.cpp:1.11 gnash/server/Movie.cpp:1.12
--- gnash/server/Movie.cpp:1.11 Sat Mar 18 23:39:34 2006
+++ gnash/server/Movie.cpp Wed Mar 29 05:42:41 2006
@@ -39,6 +39,7 @@
#include <pthread.h>
#endif
+#include <iostream>
#include "Movie.h"
#include "tu_file.h"
#include "zlib_adapter.h"
@@ -46,9 +47,12 @@
#include "jpeg.h"
#include "fontlib.h"
#include "font.h"
+#include "log.h"
#include "Sprite.h"
#include "render.h"
+using namespace std;
+
namespace gnash
{
@@ -632,6 +636,9 @@
void movie_root::notify_mouse_state(int x, int y, int buttons)
{
+// GNASH_REPORT_FUNCTION;
+// dbglogfile << "X is: " << x << " Y is: " << y << " Button is: "
+// << buttons << endl;
m_mouse_x = x;
m_mouse_y = y;
m_mouse_buttons = buttons;
@@ -639,10 +646,15 @@
void movie_root::get_mouse_state(int* x, int* y, int* buttons)
{
+// GNASH_REPORT_FUNCTION;
+
assert(x);
assert(y);
assert(buttons);
+// dbglogfile << "X is: " << m_mouse_x << " Y is: " << m_mouse_y
+// << " Button is: "
+// << m_mouse_buttons << endl;
*x = m_mouse_x;
*y = m_mouse_y;
*buttons = m_mouse_buttons;
@@ -671,7 +683,7 @@
void movie_root::advance(float delta_time)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
if (m_on_event_load_called == false)
{
@@ -727,7 +739,7 @@
void movie_root::display()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
if (m_movie->get_visible() == false)
{
// Don't display.
Index: gnash/server/Sprite.cpp
diff -u gnash/server/Sprite.cpp:1.18 gnash/server/Sprite.cpp:1.19
--- gnash/server/Sprite.cpp:1.18 Sat Mar 18 23:39:34 2006
+++ gnash/server/Sprite.cpp Wed Mar 29 05:42:41 2006
@@ -676,6 +676,8 @@
void sprite_instance::clone_display_object(const tu_string& name,
const tu_string& newname, Uint16 depth)
{
+// GNASH_REPORT_FUNCTION;
+
character* ch = m_display_list.get_character_by_name(name);
if (ch)
{
@@ -698,6 +700,7 @@
void sprite_instance::remove_display_object(const tu_string& name)
{
+// GNASH_REPORT_FUNCTION;
character* ch = m_display_list.get_character_by_name(name);
if (ch)
{
@@ -1011,7 +1014,7 @@
void sprite_instance::advance(float delta_time)
{
- // printf("%s:\n", __PRETTY_FUNCTION__); // FIXME:
+// GNASH_REPORT_FUNCTION;
// Keep this (particularly m_as_environment) alive during execution!
smart_ptr<as_object> this_ptr(this);
@@ -1212,13 +1215,12 @@
void sprite_instance::display()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
- if (get_visible() == false)
- {
- // We're invisible, so don't display!
- return;
- }
+ if (get_visible() == false) {
+ // We're invisible, so don't display!
+ return;
+ }
m_display_list.display();
@@ -1233,6 +1235,7 @@
const cxform& color_transform, const matrix& matrix,
float ratio, Uint16 clip_depth)
{
+// GNASH_REPORT_FUNCTION;
assert(m_def != NULL);
character_def* cdef =
m_def->get_character_def(character_id);
Index: gnash/server/Sprite.h
diff -u gnash/server/Sprite.h:1.11 gnash/server/Sprite.h:1.12
--- gnash/server/Sprite.h:1.11 Thu Mar 9 19:29:06 2006
+++ gnash/server/Sprite.h Wed Mar 29 05:42:41 2006
@@ -69,6 +69,7 @@
#include "Movie.h"
#include "dlist.h" // display_list
#include "stream.h"
+#include "log.h"
namespace gnash
{
@@ -731,6 +732,8 @@
const char* path_to_object,
void (*callback)(void*), void* user_ptr)
{
+// GNASH_REPORT_FUNCTION;
+
// should only be called on the root movie.
assert(m_parent == NULL);
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.56 gnash/server/action.cpp:1.57
--- gnash/server/action.cpp:1.56 Sun Mar 12 00:35:15 2006
+++ gnash/server/action.cpp Wed Mar 29 05:42:41 2006
@@ -902,9 +902,9 @@
ko->remove_listener(listener);
}
-
void key_init()
{
+// GNASH_REPORT_FUNCTION;
// Create built-in key object.
as_object* key_obj = new key_as_object;
@@ -944,7 +944,9 @@
void notify_key_event(key::code k, bool down)
// External interface for the host to report key events.
{
- action_init(); // @@ put this in some global init somewhere
else...
+// GNASH_REPORT_FUNCTION;
+
+ action_init(); // @@ put this in some global init somewhere
else...
static tu_string key_obj_name("Key");
Index: gnash/server/button.cpp
diff -u gnash/server/button.cpp:1.8 gnash/server/button.cpp:1.9
--- gnash/server/button.cpp:1.8 Fri Mar 17 20:21:30 2006
+++ gnash/server/button.cpp Wed Mar 29 05:42:41 2006
@@ -380,7 +380,7 @@
void display()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
for (unsigned int i = 0; i <
m_def->m_button_records.size(); i++)
{
button_record& rec =
m_def->m_button_records[i];
Index: gnash/server/dlist.cpp
diff -u gnash/server/dlist.cpp:1.6 gnash/server/dlist.cpp:1.7
--- gnash/server/dlist.cpp:1.6 Sat Mar 18 23:39:34 2006
+++ gnash/server/dlist.cpp Wed Mar 29 05:42:41 2006
@@ -168,6 +168,7 @@
float ratio,
Uint16 clip_depth)
{
+// GNASH_REPORT_FUNCTION;
// IF_VERBOSE_DEBUG(log_msg("dl::add(%d, '%s')\n", depth,
ch->get_name()));//xxxxx
assert(ch);
Index: gnash/server/impl.h
diff -u gnash/server/impl.h:1.17 gnash/server/impl.h:1.18
--- gnash/server/impl.h:1.17 Sat Mar 18 23:39:34 2006
+++ gnash/server/impl.h Wed Mar 29 05:42:41 2006
@@ -180,6 +180,7 @@
/// user's mouse pointer is.
virtual void notify_mouse_state(int x, int y, int buttons)
{
+ GNASH_REPORT_FUNCTION;
}
/// Use this to retrieve the last state of the mouse, as set via
@@ -499,6 +500,8 @@
virtual void do_display_callback()
{
+// GNASH_REPORT_FUNCTION;
+
if (m_display_callback)
{
(*m_display_callback)(m_display_callback_user_ptr);
@@ -527,7 +530,7 @@
virtual void display()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
m_def->display(this); // pass in transform info
do_display_callback();
Index: gnash/server/morph2.cpp
diff -u gnash/server/morph2.cpp:1.5 gnash/server/morph2.cpp:1.6
--- gnash/server/morph2.cpp:1.5 Sat Mar 18 23:39:34 2006
+++ gnash/server/morph2.cpp Wed Mar 29 05:42:41 2006
@@ -28,7 +28,7 @@
void morph2_character_def::display(character* inst)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
unsigned int i;
float ratio = inst->m_ratio;
Index: gnash/server/shape.cpp
diff -u gnash/server/shape.cpp:1.10 gnash/server/shape.cpp:1.11
--- gnash/server/shape.cpp:1.10 Sat Mar 18 23:39:34 2006
+++ gnash/server/shape.cpp Wed Mar 29 05:42:41 2006
@@ -22,1082 +22,1006 @@
#define DEBUG_DISPLAY_SHAPE_PATHS
#ifdef DEBUG_DISPLAY_SHAPE_PATHS
- // For debugging only!
- bool gnash_debug_show_paths = false;
+// For debugging only!
+bool gnash_debug_show_paths = false;
#endif // DEBUG_DISPLAY_SHAPE_PATHS
namespace gnash {
- namespace tesselate {
- tesselating_shape::~tesselating_shape()
- {
- }
- }
-
- static float s_curve_max_pixel_error = 1.0f;
-
- 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()
- {
- return s_curve_max_pixel_error;
- }
-
-
- //
- // edge
- //
-
- edge::edge()
- :
- m_cx(0), m_cy(0),
- m_ax(0), m_ay(0)
- {}
-
- edge::edge(float cx, float cy, float ax, float ay)
- :
- m_cx(cx), m_cy(cy),
- m_ax(ax), m_ay(ay)
- {
- }
-
- void edge::tesselate_curve() const
- // Send this segment to the tesselator.
- {
- tesselate::add_curve_segment(m_cx, m_cy, m_ax, m_ay);
- }
-
-
- bool edge::is_straight() const
- {
- return m_cx == m_ax && m_cy == m_ay;
- }
-
-
- //
- // path
- //
-
-
- path::path()
- :
- m_new_shape(false)
- {
- reset(0, 0, 0, 0, 0);
- }
-
- path::path(float ax, float ay, int fill0, int fill1, int line)
- {
- reset(ax, ay, fill0, fill1, line);
- }
-
-
- void path::reset(float ax, float ay, int fill0, int fill1, int line)
- // Reset all our members to the given values, and clear our edge list.
- {
- m_ax = ax;
- m_ay = ay;
- m_fill0 = fill0;
- m_fill1 = fill1;
- m_line = line;
-
- m_edges.resize(0);
-
- assert(is_empty());
- }
-
-
- bool path::is_empty() const
- // Return true if we have no edges.
- {
- return m_edges.size() == 0;
- }
-
-
- bool path::point_test(float x, float y)
- // Point-in-shape test. Return true if the query point is on the filled
- // interior of this shape.
- {
- if (m_edges.size() <= 0)
- {
- return false;
- }
-
- if (m_fill0 < 0)
- {
- // No interior fill.
-
- // @@ This isn't quite right due to some paths
- // doing double-duty with both fill0 and fill1
- // styles.
-
- // TODO: get rid of this stupid fill0/fill1
- // business -- a path should always be
- // counterclockwise and have one fill. For
- // input paths with fill1, generate a separate
- // reversed path with fill set to fill1.
- // Group all paths with the same fill into a
- // path group; do the point_test on the whole
- // group.
- return false;
- }
+namespace tesselate {
+tesselating_shape::~tesselating_shape()
+{
+}
+}
+
+static float s_curve_max_pixel_error = 1.0f;
+
+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()
+{
+ return s_curve_max_pixel_error;
+}
+
+
+//
+// edge
+//
+
+edge::edge()
+ :
+ m_cx(0), m_cy(0),
+ m_ax(0), m_ay(0)
+{}
+
+edge::edge(float cx, float cy, float ax, float ay)
+ :
+ m_cx(cx), m_cy(cy),
+ m_ax(ax), m_ay(ay)
+{
+}
+
+void edge::tesselate_curve() const
+ // Send this segment to the tesselator.
+{
+ tesselate::add_curve_segment(m_cx, m_cy, m_ax, m_ay);
+}
+
+
+bool edge::is_straight() const
+{
+ return m_cx == m_ax && m_cy == m_ay;
+}
+
+
+//
+// path
+//
+
+
+path::path()
+ :
+ m_new_shape(false)
+{
+ reset(0, 0, 0, 0, 0);
+}
+
+path::path(float ax, float ay, int fill0, int fill1, int line)
+{
+ reset(ax, ay, fill0, fill1, line);
+}
+
+
+void path::reset(float ax, float ay, int fill0, int fill1, int line)
+ // Reset all our members to the given values, and clear our edge list.
+{
+ m_ax = ax;
+ m_ay = ay;
+ m_fill0 = fill0;
+ m_fill1 = fill1;
+ m_line = line;
+
+ m_edges.resize(0);
+
+ assert(is_empty());
+}
+
+
+bool path::is_empty() const
+ // Return true if we have no edges.
+{
+ return m_edges.size() == 0;
+}
+
+
+bool path::point_test(float x, float y)
+ // Point-in-shape test. Return true if the query point is on the filled
+ // interior of this shape.
+{
+ if (m_edges.size() <= 0) {
+ return false;
+ }
- // Shoot a horizontal ray from (x,y) to the right, and
- // count the number of edge crossings. An even number
- // of crossings means the point is outside; an odd
- // number means it's inside.
-
- float x0 = m_ax;
- float y0 = m_ay;
-
- int ray_crossings = 0;
- for (int i = 0, n = m_edges.size(); i < n; i++)
- {
- const edge& e = m_edges[i];
-
- float x1 = e.m_ax;
- float y1 = e.m_ay;
-
- if (e.is_straight()) {
- // Straight-line case.
-
- // See if (x0,y0)-(x1,y1) crosses
(x,y)-(infinity,y)
-
- // Does the segment straddle the horizontal ray?
- bool cross_up = (y0 < y && y1 >= y);
- bool cross_down = (!cross_up) && (y0 > y && y1
<= y);
- if (cross_up || cross_down)
- {
- // Straddles.
-
- // Is the crossing point to the right
of x?
- float dy = y1 - y0;
+ if (m_fill0 < 0) {
+ // No interior fill.
+
+ // @@ This isn't quite right due to some paths
+ // doing double-duty with both fill0 and fill1
+ // styles.
+
+ // TODO: get rid of this stupid fill0/fill1
+ // business -- a path should always be
+ // counterclockwise and have one fill. For
+ // input paths with fill1, generate a separate
+ // reversed path with fill set to fill1.
+ // Group all paths with the same fill into a
+ // path group; do the point_test on the whole
+ // group.
+ return false;
+ }
+
+ // Shoot a horizontal ray from (x,y) to the right, and
+ // count the number of edge crossings. An even number
+ // of crossings means the point is outside; an odd
+ // number means it's inside.
+
+ float x0 = m_ax;
+ float y0 = m_ay;
+
+ int ray_crossings = 0;
+ for (int i = 0, n = m_edges.size(); i < n; i++) {
+ const edge& e = m_edges[i];
+
+ float x1 = e.m_ax;
+ float y1 = e.m_ay;
+
+ if (e.is_straight()) {
+ // Straight-line case.
+
+ // See if (x0,y0)-(x1,y1) crosses (x,y)-(infinity,y)
+
+ // Does the segment straddle the horizontal ray?
+ bool cross_up = (y0 < y && y1 >= y);
+ bool cross_down = (!cross_up) && (y0 > y && y1 <= y);
+ if (cross_up || cross_down) {
+ // Straddles.
+
+ // Is the crossing point to the right of x?
+ float dy = y1 - y0;
- // x_intercept = x0 + (x1 - x0) * (y -
y0) / dy;
- float x_intercept_times_dy = x0 * dy +
(x1 - x0) * (y - y0);
- float x_times_dy = x * dy;
+ // x_intercept = x0 + (x1 - x0) * (y - y0) / dy;
+ float x_intercept_times_dy = x0 * dy + (x1 - x0) * (y - y0);
+ float x_times_dy = x * dy;
- // text x_intercept > x
+ // text x_intercept > x
- // factor out the division; two cases
depending on sign of dy
- if (cross_up)
- {
- assert(dy > 0);
- if (x_intercept_times_dy > x *
dy)
- {
- ray_crossings++;
- }
- }
- else
- {
- // dy is negative; reverse the
inequality test
- assert(dy < 0);
- if (x_intercept_times_dy < x *
dy)
- {
- ray_crossings++;
- }
- }
- }
- }
- else
- {
- // Curve case.
- float cx = e.m_cx;
- float cy = e.m_cy;
-
- // Find whether & where the curve crosses y
- if ((y0 < y && y1 < y && cy < y)
- || (y0 > y && y1 > y && cy > y))
- {
- // All above or all below -- no
possibility of crossing.
- }
- else if (x0 < x && x1 < x && cx < x)
- {
- // All to the left -- no possibility of
crossing to the right.
- }
- else
- {
- // Find points where the curve crosses
y.
-
- // Quadratic bezier is:
- //
- // p = (1-t)^2 * a0 + 2t(1-t) * c + t^2
* a1
- //
- // We need to solve for x at y.
-
- // Use the quadratic formula.
-
- // Numerical Recipes suggests this
variation:
- // 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)
- {
- // No real solutions.
- }
- else
- {
- float q;
- float sqrt_rad = sqrtf(rad);
- if (B < 0) {
- q = -0.5f * (B -
sqrt_rad);
- } else {
- q = -0.5f * (B +
sqrt_rad);
- }
-
- // The old-school way.
- // float t0 = (-B + sqrt_rad) /
(2 * A);
- // float t1 = (-B - sqrt_rad) /
(2 * A);
-
- if (A != 0)
- {
- float t0 = q / A;
- if (t0 >= 0 && t0 < 1) {
- float x_at_t0 =
- x0 + 2
* (cx - x0) * t0 + (x1 + x0 - 2 * cx) * t0 * t0;
- if (x_at_t0 >
x) {
-
ray_crossings++;
- }
- }
- }
-
- if (q != 0)
- {
- float t1 = C / q;
- if (t1 >= 0 && t1 < 1) {
- float x_at_t1 =
- x0 + 2
* (cx - x0) * t1 + (x1 + x0 - 2 * cx) * t1 * t1;
- if (x_at_t1 >
x) {
-
ray_crossings++;
- }
- }
- }
- }
- }
- }
-
- x0 = x1;
- y0 = y1;
- }
-
- if (ray_crossings & 1)
- {
- // Odd number of ray crossings means the point
- // is inside the poly.
- return true;
- }
- return false;
- }
-
-
- void path::tesselate() const
- // Push this path into the tesselator.
- {
- tesselate::begin_path(
- m_fill0 - 1,
- m_fill1 - 1,
- m_line - 1,
- m_ax, m_ay);
- for (unsigned int i = 0; i < m_edges.size(); i++)
- {
- m_edges[i].tesselate_curve();
- }
- tesselate::end_path();
- }
-
-
- // Utility.
-
-
- void write_coord_array(tu_file* out, const std::vector<Sint16>&
pt_array)
- // Dump the given coordinate array into the given stream.
- {
- int n = pt_array.size();
-
- out->write_le32(n);
- for (int i = 0; i < n; i++)
- {
- out->write_le16((Uint16) pt_array[i]);
- }
- }
-
-
- void read_coord_array(tu_file* in, std::vector<Sint16>* pt_array)
- // Read the coordinate array data from the stream into *pt_array.
- {
- int n = in->read_le32();
-
- pt_array->resize(n);
- for (int i = 0; i < n; i ++)
- {
- (*pt_array)[i] = (Sint16) in->read_le16();
- }
- }
-
-
- //
- // mesh
- //
+ // factor out the division; two cases depending on sign of dy
+ if (cross_up) {
+ assert(dy > 0);
+ if (x_intercept_times_dy > x * dy) {
+ ray_crossings++;
+ }
+ } else {
+ // dy is negative; reverse the inequality test
+ assert(dy < 0);
+ if (x_intercept_times_dy < x * dy) {
+ ray_crossings++;
+ }
+ }
+ }
+ } else {
+ // Curve case.
+ float cx = e.m_cx;
+ float cy = e.m_cy;
+
+ // Find whether & where the curve crosses y
+ if ((y0 < y && y1 < y && cy < y)
+ || (y0 > y && y1 > y && cy > y)) {
+ // All above or all below -- no possibility of crossing.
+ } else if (x0 < x && x1 < x && cx < x) {
+ // All to the left -- no possibility of crossing to the right.
+ } else {
+ // Find points where the curve crosses y.
+
+ // Quadratic bezier is:
+ //
+ // p = (1-t)^2 * a0 + 2t(1-t) * c + t^2 * a1
+ //
+ // We need to solve for x at y.
+
+ // Use the quadratic formula.
+
+ // Numerical Recipes suggests this variation:
+ // 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) {
+ // No real solutions.
+ } else {
+ float q;
+ float sqrt_rad = sqrtf(rad);
+ if (B < 0) {
+ q = -0.5f * (B - sqrt_rad);
+ } else {
+ q = -0.5f * (B + sqrt_rad);
+ }
+
+ // The old-school way.
+ // float t0 = (-B + sqrt_rad) / (2 * A);
+ // float t1 = (-B - sqrt_rad) / (2 * A);
+
+ if (A != 0) {
+ float t0 = q / A;
+ if (t0 >= 0 && t0 < 1) {
+ float x_at_t0 =
+ x0 + 2 * (cx - x0) * t0 + (x1 + x0 - 2 * cx) *
t0 * t0;
+ if (x_at_t0 > x) {
+ ray_crossings++;
+ }
+ }
+ }
+
+ if (q != 0) {
+ float t1 = C / q;
+ if (t1 >= 0 && t1 < 1) {
+ float x_at_t1 =
+ x0 + 2 * (cx - x0) * t1 + (x1 + x0 - 2 * cx) *
t1 * t1;
+ if (x_at_t1 > x) {
+ ray_crossings++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ x0 = x1;
+ y0 = y1;
+ }
+
+ if (ray_crossings & 1) {
+ // Odd number of ray crossings means the point
+ // is inside the poly.
+ return true;
+ }
+ return false;
+}
+
+
+void path::tesselate() const
+ // Push this path into the tesselator.
+{
+ tesselate::begin_path(
+ m_fill0 - 1,
+ m_fill1 - 1,
+ m_line - 1,
+ m_ax, m_ay);
+ for (unsigned int i = 0; i < m_edges.size(); i++) {
+ m_edges[i].tesselate_curve();
+ }
+ tesselate::end_path();
+}
+
+
+// Utility.
+
+
+void write_coord_array(tu_file* out, const std::vector<Sint16>& pt_array)
+ // Dump the given coordinate array into the given stream.
+{
+ int n = pt_array.size();
+
+ out->write_le32(n);
+ for (int i = 0; i < n; i++) {
+ out->write_le16((Uint16) pt_array[i]);
+ }
+}
+
+
+void read_coord_array(tu_file* in, std::vector<Sint16>* pt_array)
+ // Read the coordinate array data from the stream into *pt_array.
+{
+ int n = in->read_le32();
+
+ pt_array->resize(n);
+ for (int i = 0; i < n; i ++) {
+ (*pt_array)[i] = (Sint16) in->read_le16();
+ }
+}
+
+
+//
+// mesh
+//
- mesh::mesh()
- {
- }
+mesh::mesh()
+{
+}
- void mesh::set_tri_strip(const point pts[], int count)
- {
- m_triangle_strip.resize(count * 2); // 2 coords per point
+void mesh::set_tri_strip(const point pts[], int count)
+{
+ m_triangle_strip.resize(count * 2); // 2 coords per point
- // convert to ints.
- for (int i = 0; i < count; i++)
- {
- m_triangle_strip[i * 2] = Sint16(pts[i].m_x);
- m_triangle_strip[i * 2 + 1] = Sint16(pts[i].m_y);
- }
+ // convert to ints.
+ for (int i = 0; i < count; i++) {
+ m_triangle_strip[i * 2] = Sint16(pts[i].m_x);
+ m_triangle_strip[i * 2 + 1] = Sint16(pts[i].m_y);
+ }
// m_triangle_strip.resize(count);
// memcpy(&m_triangle_strip[0], &pts[0], count * sizeof(point));
- }
-
-
- void mesh::display(const base_fill_style& style, float ratio) const
- {
- GNASH_REPORT_FUNCTION;
-
- // pass mesh to renderer.
- if (m_triangle_strip.size() > 0)
- {
- style.apply(0, ratio);
- render::draw_mesh_strip(&m_triangle_strip[0],
m_triangle_strip.size() >> 1);
- }
- }
+}
- void mesh::output_cached_data(tu_file* out)
- // Dump our data to *out.
- {
- write_coord_array(out, m_triangle_strip);
- }
+void mesh::display(const base_fill_style& style, float ratio) const
+{
+// GNASH_REPORT_FUNCTION;
+
+ // pass mesh to renderer.
+ if (m_triangle_strip.size() > 0) {
+ style.apply(0, ratio);
+ render::draw_mesh_strip(&m_triangle_strip[0], m_triangle_strip.size()
>> 1);
+ }
+}
+
+
+void mesh::output_cached_data(tu_file* out)
+ // Dump our data to *out.
+{
+ write_coord_array(out, m_triangle_strip);
+}
- void mesh::input_cached_data(tu_file* in)
- // Slurp our data from *out.
- {
- read_coord_array(in, &m_triangle_strip);
- }
-
-
- //
- // line_strip
- //
-
-
- line_strip::line_strip()
- // Default constructor, for std::vector<>.
- :
- m_style(-1)
- {}
-
-
- line_strip::line_strip(int style, const point coords[], int coord_count)
- // Construct the line strip (polyline) made up of the given sequence of
points.
- :
- m_style(style)
- {
- assert(style >= 0);
- assert(coords != NULL);
- assert(coord_count > 1);
+void mesh::input_cached_data(tu_file* in)
+ // Slurp our data from *out.
+{
+ read_coord_array(in, &m_triangle_strip);
+}
+
+
+//
+// line_strip
+//
+
+
+line_strip::line_strip()
+ // Default constructor, for std::vector<>.
+ :
+m_style(-1)
+{}
+
+
+line_strip::line_strip(int style, const point coords[], int coord_count)
+ // Construct the line strip (polyline) made up of the given sequence of
points.
+ :
+m_style(style)
+{
+ assert(style >= 0);
+ assert(coords != NULL);
+ assert(coord_count > 1);
// m_coords.resize(coord_count);
// memcpy(&m_coords[0], coords, coord_count * sizeof(coords[0]));
- m_coords.resize(coord_count * 2); // 2 coords per vert
+ m_coords.resize(coord_count * 2); // 2 coords per vert
- // convert to ints.
- for (int i = 0; i < coord_count; i++)
- {
- m_coords[i * 2] = Sint16(coords[i].m_x);
- m_coords[i * 2 + 1] = Sint16(coords[i].m_y);
- }
- }
-
-
- void line_strip::display(const base_line_style& style, float ratio)
const
- // Render this line strip in the given style.
- {
- GNASH_REPORT_FUNCTION;
-
- assert(m_coords.size() > 1);
- assert((m_coords.size() & 1) == 0);
-
- style.apply(ratio);
- render::draw_line_strip(&m_coords[0], m_coords.size() >> 1);
- }
-
-
- void line_strip::output_cached_data(tu_file* out)
- // Dump our data to *out.
- {
- out->write_le32(m_style);
- write_coord_array(out, m_coords);
- }
+ // convert to ints.
+ for (int i = 0; i < coord_count; i++) {
+ m_coords[i * 2] = Sint16(coords[i].m_x);
+ m_coords[i * 2 + 1] = Sint16(coords[i].m_y);
+ }
+}
+
+
+void line_strip::display(const base_line_style& style, float ratio) const
+ // Render this line strip in the given style.
+{
+// GNASH_REPORT_FUNCTION;
+
+ assert(m_coords.size() > 1);
+ assert((m_coords.size() & 1) == 0);
+
+ style.apply(ratio);
+ render::draw_line_strip(&m_coords[0], m_coords.size() >> 1);
+}
+
+
+void line_strip::output_cached_data(tu_file* out)
+ // Dump our data to *out.
+{
+ out->write_le32(m_style);
+ write_coord_array(out, m_coords);
+}
- void line_strip::input_cached_data(tu_file* in)
- // Slurp our data from *out.
+void line_strip::input_cached_data(tu_file* in)
+ // Slurp our data from *out.
+{
+ m_style = in->read_le32();
+ read_coord_array(in, &m_coords);
+}
+
+
+// Utility: very simple greedy tri-stripper. Useful for
+// stripping the stacks of trapezoids that come out of our
+// tesselator.
+struct tri_stripper
+{
+ // A set of strips; we'll join them together into one
+ // strip during the flush.
+ std::vector< std::vector<point> > m_strips;
+ int m_last_strip_used;
+
+ tri_stripper()
+ : m_last_strip_used(-1)
{
- m_style = in->read_le32();
- read_coord_array(in, &m_coords);
}
-
- // Utility: very simple greedy tri-stripper. Useful for
- // stripping the stacks of trapezoids that come out of our
- // tesselator.
- struct tri_stripper
- {
- // A set of strips; we'll join them together into one
- // strip during the flush.
- std::vector< std::vector<point> > m_strips;
- int m_last_strip_used;
-
- tri_stripper()
- : m_last_strip_used(-1)
- {
- }
-
- void add_trapezoid(const point& l0, const point& r0, const
point& l1, const point& r1)
- // Add two triangles to our strip.
- {
- // See if we can attach this mini-strip to an existing
strip.
-
- if (l0.bitwise_equal(r0) == false)
- {
- // Check the next strip first; trapezoids will
- // tend to arrive in rotating order through
- // the active strips.
- assert(m_last_strip_used >= -1 &&
m_last_strip_used < (int) m_strips.size());
- int i = m_last_strip_used + 1, n =
m_strips.size();
- for ( ; i < n; i++)
- {
- std::vector<point>& str =
m_strips[i];
- assert(str.size() >= 3); //
should have at least one tri already.
-
- int last = str.size() - 1;
- if (str[last - 1].bitwise_equal(l0) &&
str[last].bitwise_equal(r0))
- {
- // Can join these tris to this
strip.
- str.push_back(l1);
- str.push_back(r1);
- m_last_strip_used = i;
- return;
- }
- }
- for (i = 0; i <= m_last_strip_used; i++)
- {
- std::vector<point>& str =
m_strips[i];
- assert(str.size() >= 3); //
should have at least one tri already.
+ void add_trapezoid(const point& l0, const point& r0, const point&
l1, const point& r1)
+ // Add two triangles to our strip.
+ {
+ // See if we can attach this mini-strip to an existing strip.
+
+ if (l0.bitwise_equal(r0) == false) {
+ // Check the next strip first; trapezoids will
+ // tend to arrive in rotating order through
+ // the active strips.
+ assert(m_last_strip_used >= -1 && m_last_strip_used < (int)
m_strips.size());
+ int i = m_last_strip_used + 1, n = m_strips.size();
+ for ( ; i < n; i++) {
+ std::vector<point>& str = m_strips[i];
+ assert(str.size() >= 3); // should have at least one tri
already.
- int last = str.size() - 1;
- if (str[last - 1].bitwise_equal(l0) &&
str[last].bitwise_equal(r0))
- {
- // Can join these tris to this
strip.
- str.push_back(l1);
- str.push_back(r1);
- m_last_strip_used = i;
- return;
- }
- }
+ int last = str.size() - 1;
+ if (str[last - 1].bitwise_equal(l0) &&
str[last].bitwise_equal(r0))
+ {
+ // Can join these tris to this strip.
+ str.push_back(l1);
+ str.push_back(r1);
+ m_last_strip_used = i;
+ return;
}
- // else this trapezoid is pointy on top, so
- // it's almost certainly the start of a new
- // strip. Don't bother searching current
- // strips.
-
- // Can't join with existing strip, so start a new strip.
- m_strips.resize(m_strips.size() + 1);
- m_strips.back().resize(4);
- m_strips.back()[0] = l0;
- m_strips.back()[1] = r0;
- m_strips.back()[2] = l1;
- m_strips.back()[3] = r1;
}
-
-
- void flush(mesh_set* m, int style) const
- // Join sub-strips together, and push the whole thing into the
given mesh_set,
- // under the given style.
- {
- if (m_strips.size())
- {
- std::vector<point> big_strip;
-
- big_strip = m_strips[0];
- assert(big_strip.size() >= 3);
-
- for (unsigned int i = 1, n = m_strips.size(); i
< n; i++)
- {
- // Append to the big strip.
- const std::vector<point>& str =
m_strips[i];
- assert(str.size() >= 3); //
should have at least one tri already.
+ for (i = 0; i <= m_last_strip_used; i++) {
+ std::vector<point>& str = m_strips[i];
+ assert(str.size() >= 3); // should have at least one tri
already.
- int last = big_strip.size() - 1;
- if (big_strip[last] == str[1]
- && big_strip[last - 1] == str[0])
- {
- // Strips fit right together.
Append.
-
big_strip.insert(big_strip.end(), str.begin() + 2, str.end());
- }
- else if (big_strip[last] == str[0]
- && big_strip[last - 1] ==
str[1])
- {
- // Strips fit together with a
half-twist.
- point to_dup = big_strip[last
- 1];
- big_strip.push_back(to_dup);
-
big_strip.insert(big_strip.end(), str.begin() + 2, str.end());
- }
- else
- {
- // Strips need a degenerate to
link them together.
- point to_dup =
big_strip[last];
- big_strip.push_back(to_dup);
- big_strip.push_back(str[0]);
-
big_strip.insert(big_strip.end(), str.begin(), str.end());
- }
- }
-
- m->set_tri_strip(style, &big_strip[0],
big_strip.size());
- }
+ int last = str.size() - 1;
+ if (str[last - 1].bitwise_equal(l0) &&
str[last].bitwise_equal(r0)) {
+ // Can join these tris to this strip.
+ str.push_back(l1);
+ str.push_back(r1);
+ m_last_strip_used = i;
+ return;
+ }
}
- };
+ }
+ // else this trapezoid is pointy on top, so
+ // it's almost certainly the start of a new
+ // strip. Don't bother searching current
+ // strips.
+
+ // Can't join with existing strip, so start a new strip.
+ m_strips.resize(m_strips.size() + 1);
+ m_strips.back().resize(4);
+ m_strips.back()[0] = l0;
+ m_strips.back()[1] = r0;
+ m_strips.back()[2] = l1;
+ m_strips.back()[3] = r1;
+ }
- //
- // mesh_set
- //
+ void flush(mesh_set* m, int style) const
+ // Join sub-strips together, and push the whole thing into the given
mesh_set,
+ // under the given style.
+ {
+ if (m_strips.size()) {
+ std::vector<point> big_strip;
+
+ big_strip = m_strips[0];
+ assert(big_strip.size() >= 3);
+
+ for (unsigned int i = 1, n = m_strips.size(); i < n; i++) {
+ // Append to the big strip.
+ const std::vector<point>& str = m_strips[i];
+ assert(str.size() >= 3); // should have at least one tri
already.
+
+ int last = big_strip.size() - 1;
+ if (big_strip[last] == str[1]
+ && big_strip[last - 1] == str[0]) {
+ // Strips fit right together. Append.
+ big_strip.insert(big_strip.end(), str.begin() + 2,
str.end());
+ } else if (big_strip[last] == str[0]
+ && big_strip[last - 1] == str[1]) {
+ // Strips fit together with a half-twist.
+ point to_dup = big_strip[last - 1];
+ big_strip.push_back(to_dup);
+ big_strip.insert(big_strip.end(), str.begin() + 2,
str.end());
+ } else {
+ // Strips need a degenerate to link them together.
+ point to_dup = big_strip[last];
+ big_strip.push_back(to_dup);
+ big_strip.push_back(str[0]);
+ big_strip.insert(big_strip.end(), str.begin(),
str.end());
+ }
+ }
+
+ m->set_tri_strip(style, &big_strip[0], big_strip.size());
+ }
+ }
+};
+
+
+//
+// mesh_set
+//
- mesh_set::mesh_set()
- :
+mesh_set::mesh_set()
+ :
// m_last_frame_rendered(-1),
- m_error_tolerance(0) // invalid -- don't use this
constructor; it's only here for array (@@ fix array)
- {
- }
-
- mesh_set::mesh_set(const tesselate::tesselating_shape* sh, float
error_tolerance)
- // Tesselate the shape's paths into a different mesh for each fill
style.
- :
+ m_error_tolerance(0) // invalid -- don't use this constructor; it's
only here for array (@@ fix array)
+{
+}
+
+mesh_set::mesh_set(const tesselate::tesselating_shape* sh, float
error_tolerance)
+ // Tesselate the shape's paths into a different mesh for each fill style.
+ :
// m_last_frame_rendered(0),
- m_error_tolerance(error_tolerance)
- {
- struct collect_traps : public tesselate::trapezoid_accepter
- {
- mesh_set* m; // the mesh_set that receives
trapezoids.
-
- // strips-in-progress.
- hash<int, tri_stripper*> m_strips;
-
- collect_traps(mesh_set* set) : m(set) {}
- virtual ~collect_traps() {}
-
- // Overrides from trapezoid_accepter
- virtual void accept_trapezoid(int style, const
tesselate::trapezoid& tr)
- {
- // Add trapezoid to appropriate stripper.
-
- tri_stripper* s = NULL;
- m_strips.get(style, &s);
- if (s == NULL)
- {
- s = new tri_stripper;
- m_strips.add(style, s);
- }
-
- s->add_trapezoid(
- point(tr.m_lx0, tr.m_y0),
- point(tr.m_rx0, tr.m_y0),
- point(tr.m_lx1, tr.m_y1),
- point(tr.m_rx1, tr.m_y1));
- }
-
- virtual void accept_line_strip(int style, const
point coords[], int coord_count)
- // Remember this line strip in our mesh set.
- {
- m->add_line_strip(style, coords, coord_count);
- }
-
- void flush() const
- // Push our strips into the mesh set.
- {
- for (hash<int, tri_stripper*>::const_iterator
it = m_strips.begin();
- it != m_strips.end();
- ++it)
- {
- // Push strip into m.
- tri_stripper* s = it->second;
- s->flush(m, it->first);
+m_error_tolerance(error_tolerance)
+{
+ struct collect_traps : public tesselate::trapezoid_accepter
+ {
+ mesh_set* m; // the mesh_set that receives trapezoids.
+
+ // strips-in-progress.
+ hash<int, tri_stripper*> m_strips;
+
+ collect_traps(mesh_set* set) : m(set) {}
+ virtual ~collect_traps() {}
+
+ // Overrides from trapezoid_accepter
+ virtual void accept_trapezoid(int style, const tesselate::trapezoid&
tr)
+ {
+ // Add trapezoid to appropriate stripper.
+
+ tri_stripper* s = NULL;
+ m_strips.get(style, &s);
+ if (s == NULL) {
+ s = new tri_stripper;
+ m_strips.add(style, s);
+ }
+
+ s->add_trapezoid(
+ point(tr.m_lx0, tr.m_y0),
+ point(tr.m_rx0, tr.m_y0),
+ point(tr.m_lx1, tr.m_y1),
+ point(tr.m_rx1, tr.m_y1));
+ }
+
+ virtual void accept_line_strip(int style, const point coords[], int
coord_count)
+ // Remember this line strip in our mesh set.
+ {
+ m->add_line_strip(style, coords, coord_count);
+ }
+
+ void flush() const
+ // Push our strips into the mesh set.
+ {
+ for (hash<int, tri_stripper*>::const_iterator it =
m_strips.begin();
+ it != m_strips.end();
+ ++it) {
+ // Push strip into m.
+ tri_stripper* s = it->second;
+ s->flush(m, it->first);
- delete s;
- }
- }
- };
- collect_traps accepter(this);
+ delete s;
+ }
+ }
+ };
+ collect_traps accepter(this);
- sh->tesselate(error_tolerance, &accepter);
- accepter.flush();
+ sh->tesselate(error_tolerance, &accepter);
+ accepter.flush();
- // triangles should be collected now into the meshes for each
fill style.
- }
+ // triangles should be collected now into the meshes for each fill style.
+}
// int mesh_set::get_last_frame_rendered() const { return
m_last_frame_rendered; }
// void mesh_set::set_last_frame_rendered(int frame_counter) {
m_last_frame_rendered = frame_counter; }
- void mesh_set::display(
- const matrix& mat,
- const cxform& cx,
- const std::vector<fill_style>& fills,
- const std::vector<line_style>& line_styles) const
- // Throw our meshes at the renderer.
- {
- GNASH_REPORT_FUNCTION;
-
- assert(m_error_tolerance > 0);
-
- // Setup transforms.
- render::set_matrix(mat);
- render::set_cxform(cx);
-
- // Dump meshes into renderer, one mesh per style.
- for (unsigned int i = 0; i < m_meshes.size(); i++)
- {
- m_meshes[i].display(fills[i], 1.0);
- }
-
- // Dump line-strips into renderer.
- {for (unsigned int i = 0; i < m_line_strips.size(); i++)
- {
- int style = m_line_strips[i].get_style();
- m_line_strips[i].display(line_styles[style], 1.0);
- }}
- }
-
- void mesh_set::display(
- const matrix& mat,
- const cxform& cx,
- const std::vector<morph_fill_style>& fills,
- const std::vector<morph_line_style>& line_styles,
- float ratio) const
- // Throw our meshes at the renderer.
- {
- GNASH_REPORT_FUNCTION;
-
- assert(m_error_tolerance > 0);
-
- // Setup transforms.
- render::set_matrix(mat);
- render::set_cxform(cx);
-
- // Dump meshes into renderer, one mesh per style.
- for (unsigned int i = 0; i < m_meshes.size(); i++)
- {
- m_meshes[i].display(fills[i], ratio);
- }
-
- // Dump line-strips into renderer.
- {for (unsigned int i = 0; i < m_line_strips.size(); i++)
- {
- int style = m_line_strips[i].get_style();
- m_line_strips[i].display(line_styles[style], ratio);
- }}
- }
+void mesh_set::display(
+ const matrix& mat,
+ const cxform& cx,
+ const std::vector<fill_style>& fills,
+ const std::vector<line_style>& line_styles) const
+ // Throw our meshes at the renderer.
+{
+// GNASH_REPORT_FUNCTION;
+
+ assert(m_error_tolerance > 0);
+
+ // Setup transforms.
+ render::set_matrix(mat);
+ render::set_cxform(cx);
+
+ // Dump meshes into renderer, one mesh per style.
+ for (unsigned int i = 0; i < m_meshes.size(); i++) {
+ m_meshes[i].display(fills[i], 1.0);
+ }
+
+ // Dump line-strips into renderer.
+ {for (unsigned int i = 0; i < m_line_strips.size(); i++)
+ {
+ int style = m_line_strips[i].get_style();
+ m_line_strips[i].display(line_styles[style], 1.0);
+ }}
+}
+
+void mesh_set::display(
+ const matrix& mat,
+ const cxform& cx,
+ const std::vector<morph_fill_style>& fills,
+ const std::vector<morph_line_style>& line_styles,
+ float ratio) const
+ // Throw our meshes at the renderer.
+{
+// GNASH_REPORT_FUNCTION;
+
+ assert(m_error_tolerance > 0);
+
+ // Setup transforms.
+ render::set_matrix(mat);
+ render::set_cxform(cx);
+
+ // Dump meshes into renderer, one mesh per style.
+ for (unsigned int i = 0; i < m_meshes.size(); i++) {
+ m_meshes[i].display(fills[i], ratio);
+ }
+
+ // Dump line-strips into renderer.
+ {for (unsigned int i = 0; i < m_line_strips.size(); i++)
+ {
+ int style = m_line_strips[i].get_style();
+ m_line_strips[i].display(line_styles[style], ratio);
+ }}
+}
+
+void mesh_set::set_tri_strip(int style, const point pts[], int count)
+ // Set mesh associated with the given fill style to the
+ // specified triangle strip.
+{
+ assert(style >= 0);
+ assert(style < 10000); // sanity check
+
+ // Expand our mesh list if necessary.
+ if (style >= (int) m_meshes.size()) {
+ m_meshes.resize(style + 1);
+ }
- void mesh_set::set_tri_strip(int style, const point pts[], int count)
- // Set mesh associated with the given fill style to the
- // specified triangle strip.
- {
- assert(style >= 0);
- assert(style < 10000); // sanity check
-
- // Expand our mesh list if necessary.
- if (style >= (int) m_meshes.size())
- {
- m_meshes.resize(style + 1);
- }
-
- m_meshes[style].set_tri_strip(pts, count);
- }
+ m_meshes[style].set_tri_strip(pts, count);
+}
- void mesh_set::add_line_strip(int style, const point coords[], int
coord_count)
- // Add the specified line strip to our list of things to render.
- {
- assert(style >= 0);
- assert(style < 1000); // sanity check
- assert(coords != NULL);
- assert(coord_count > 1);
-
- m_line_strips.push_back(line_strip(style, coords, coord_count));
- }
-
-
- void mesh_set::output_cached_data(tu_file* out)
- // Dump our data to the output stream.
- {
- out->write_float32(m_error_tolerance);
-
- int mesh_n = m_meshes.size();
- out->write_le32(mesh_n);
- for (int i = 0; i < mesh_n; i++)
- {
- m_meshes[i].output_cached_data(out);
- }
-
- int lines_n = m_line_strips.size();
- out->write_le32(lines_n);
- {for (int i = 0; i < lines_n; i++)
- {
- m_line_strips[i].output_cached_data(out);
- }}
- }
-
-
- void mesh_set::input_cached_data(tu_file* in)
- // Grab our data from the input stream.
- {
- m_error_tolerance = in->read_float32();
-
- int mesh_n = in->read_le32();
- m_meshes.resize(mesh_n);
- for (int i = 0; i < mesh_n; i++)
- {
- m_meshes[i].input_cached_data(in);
- }
-
- int lines_n = in->read_le32();
- m_line_strips.resize(lines_n);
- {for (int i = 0; i < lines_n; i++)
- {
- m_line_strips[i].input_cached_data(in);
- }}
- }
-
-
- //
- // helper functions.
- //
-
-
- static void read_fill_styles(std::vector<fill_style>* styles,
stream* in, int tag_type, movie_definition* m)
- // Read fill styles, and push them onto the given style array.
- {
- assert(styles);
-
- // Get the count.
- int fill_style_count = in->read_u8();
- if (tag_type > 2)
- {
- if (fill_style_count == 0xFF)
- {
- fill_style_count = in->read_u16();
- }
- }
-
- IF_VERBOSE_PARSE(log_msg(" read_fill_styles: count = %d\n",
fill_style_count));
-
- // Read the styles.
- for (int i = 0; i < fill_style_count; i++)
- {
- (*styles).resize((*styles).size() + 1);
- (*styles)[(*styles).size() - 1].read(in, tag_type, m);
- }
- }
-
-
- static void read_line_styles(std::vector<line_style>* styles,
stream* in, int tag_type)
- // Read line styles and push them onto the back of the given array.
- {
- // Get the count.
- int line_style_count = in->read_u8();
-
- IF_VERBOSE_PARSE(log_msg(" read_line_styles: count = %d\n",
line_style_count));
-
- // @@ does the 0xFF flag apply to all tag types?
- // if (tag_type > 2)
- // {
- if (line_style_count == 0xFF)
- {
- line_style_count = in->read_u16();
- IF_VERBOSE_PARSE(log_msg(" read_line_styles:
count2 = %d\n", line_style_count));
- }
- // }
-
- // Read the styles.
- for (int i = 0; i < line_style_count; i++)
- {
- (*styles).resize((*styles).size() + 1);
- (*styles)[(*styles).size() - 1].read(in, tag_type);
- }
- }
-
-
- //
- // shape_character_def
- //
-
-
- shape_character_def::shape_character_def()
- {
- }
-
-
- shape_character_def::~shape_character_def()
- {
- // Free our mesh_sets.
- for (unsigned int i = 0; i < m_cached_meshes.size(); i++)
- {
- delete m_cached_meshes[i];
- }
- }
-
-
- void shape_character_def::read(stream* in, int tag_type, bool
with_style, movie_definition* m)
- {
- if (with_style)
- {
- m_bound.read(in);
- read_fill_styles(&m_fill_styles, in, tag_type, m);
- read_line_styles(&m_line_styles, in, tag_type);
- }
-
- //
- // SHAPE
- //
- int num_fill_bits = in->read_uint(4);
- int num_line_bits = in->read_uint(4);
-
- IF_VERBOSE_PARSE(log_msg(" shape_character_def read: nfillbits
= %d, nlinebits = %d\n", num_fill_bits, num_line_bits));
-
- // These are state variables that keep the
- // current position & style of the shape
- // outline, and vary as we read the edge data.
- //
- // At the moment we just store each edge with
- // the full necessary info to render it, which
- // is simple but not optimally efficient.
- int fill_base = 0;
- int line_base = 0;
- float x = 0, y = 0;
- path current_path;
+void mesh_set::add_line_strip(int style, const point coords[], int
coord_count)
+ // Add the specified line strip to our list of things to render.
+{
+ assert(style >= 0);
+ assert(style < 1000); // sanity check
+ assert(coords != NULL);
+ assert(coord_count > 1);
+
+ m_line_strips.push_back(line_strip(style, coords, coord_count));
+}
+
+
+void mesh_set::output_cached_data(tu_file* out)
+ // Dump our data to the output stream.
+{
+ out->write_float32(m_error_tolerance);
+
+ int mesh_n = m_meshes.size();
+ out->write_le32(mesh_n);
+ for (int i = 0; i < mesh_n; i++) {
+ m_meshes[i].output_cached_data(out);
+ }
+
+ int lines_n = m_line_strips.size();
+ out->write_le32(lines_n);
+ {for (int i = 0; i < lines_n; i++)
+ {
+ m_line_strips[i].output_cached_data(out);
+ }}
+}
+
+
+void mesh_set::input_cached_data(tu_file* in)
+ // Grab our data from the input stream.
+{
+ m_error_tolerance = in->read_float32();
+
+ int mesh_n = in->read_le32();
+ m_meshes.resize(mesh_n);
+ for (int i = 0; i < mesh_n; i++) {
+ m_meshes[i].input_cached_data(in);
+ }
+
+ int lines_n = in->read_le32();
+ m_line_strips.resize(lines_n);
+ {for (int i = 0; i < lines_n; i++)
+ {
+ m_line_strips[i].input_cached_data(in);
+ }}
+}
+
+
+//
+// helper functions.
+//
+
+
+static void read_fill_styles(std::vector<fill_style>* styles, stream* in,
int tag_type, movie_definition* m)
+ // Read fill styles, and push them onto the given style array.
+{
+ assert(styles);
+
+ // Get the count.
+ int fill_style_count = in->read_u8();
+ if (tag_type > 2) {
+ if (fill_style_count == 0xFF)
+ {
+ fill_style_count = in->read_u16();
+ }
+ }
+
+ IF_VERBOSE_PARSE(log_msg(" read_fill_styles: count = %d\n",
fill_style_count));
+
+ // Read the styles.
+ for (int i = 0; i < fill_style_count; i++) {
+ (*styles).resize((*styles).size() + 1);
+ (*styles)[(*styles).size() - 1].read(in, tag_type, m);
+ }
+}
+
+
+static void read_line_styles(std::vector<line_style>* styles, stream* in,
int tag_type)
+ // Read line styles and push them onto the back of the given array.
+{
+ // Get the count.
+ int line_style_count = in->read_u8();
+
+ IF_VERBOSE_PARSE(log_msg(" read_line_styles: count = %d\n",
line_style_count));
+
+ // @@ does the 0xFF flag apply to all tag types?
+ // if (tag_type > 2)
+ // {
+ if (line_style_count == 0xFF) {
+ line_style_count = in->read_u16();
+ IF_VERBOSE_PARSE(log_msg(" read_line_styles: count2 = %d\n",
line_style_count));
+ }
+ // }
+
+ // Read the styles.
+ for (int i = 0; i < line_style_count; i++) {
+ (*styles).resize((*styles).size() + 1);
+ (*styles)[(*styles).size() - 1].read(in, tag_type);
+ }
+}
+
+
+//
+// shape_character_def
+//
+
+
+shape_character_def::shape_character_def()
+{
+}
+
+
+shape_character_def::~shape_character_def()
+{
+ // Free our mesh_sets.
+ for (unsigned int i = 0; i < m_cached_meshes.size(); i++) {
+ delete m_cached_meshes[i];
+ }
+}
+
+
+void shape_character_def::read(stream* in, int tag_type, bool with_style,
movie_definition* m)
+{
+ if (with_style) {
+ m_bound.read(in);
+ read_fill_styles(&m_fill_styles, in, tag_type, m);
+ read_line_styles(&m_line_styles, in, tag_type);
+ }
+
+ //
+ // SHAPE
+ //
+ int num_fill_bits = in->read_uint(4);
+ int num_line_bits = in->read_uint(4);
+
+ IF_VERBOSE_PARSE(log_msg(" shape_character_def read: nfillbits = %d,
nlinebits = %d\n", num_fill_bits, num_line_bits));
+
+ // These are state variables that keep the
+ // current position & style of the shape
+ // outline, and vary as we read the edge data.
+ //
+ // At the moment we just store each edge with
+ // the full necessary info to render it, which
+ // is simple but not optimally efficient.
+ int fill_base = 0;
+ int line_base = 0;
+ float x = 0, y = 0;
+ path current_path;
#define SHAPE_LOG 0
- // SHAPERECORDS
- for (;;) {
- int type_flag = in->read_uint(1);
- if (type_flag == 0)
- {
- // Parse the record.
- int flags = in->read_uint(5);
- if (flags == 0) {
- // End of shape records.
-
- // Store the current path if any.
- if (! current_path.is_empty())
- {
- m_paths.push_back(current_path);
- current_path.m_edges.resize(0);
- }
-
- break;
- }
- if (flags & 0x01)
- {
- // move_to = 1;
-
- // Store the current path if any, and
prepare a fresh one.
- if (! current_path.is_empty())
- {
- m_paths.push_back(current_path);
- current_path.m_edges.resize(0);
- }
-
- int num_move_bits =
in->read_uint(5);
- int move_x =
in->read_sint(num_move_bits);
- int move_y =
in->read_sint(num_move_bits);
-
- x = (float) move_x;
- y = (float) move_y;
-
- // Set the beginning of the path.
- current_path.m_ax = x;
- current_path.m_ay = y;
-
- if (SHAPE_LOG)
IF_VERBOSE_PARSE(log_msg(" shape_character read: moveto %4g %4g\n", x, y));
- }
- if ((flags & 0x02)
- && num_fill_bits > 0)
- {
- // fill_style_0_change = 1;
- if (! current_path.is_empty())
- {
- m_paths.push_back(current_path);
- current_path.m_edges.resize(0);
- current_path.m_ax = x;
- current_path.m_ay = y;
- }
- int style =
in->read_uint(num_fill_bits);
- if (style > 0)
- {
- style += fill_base;
- }
- current_path.m_fill0 = style;
- if (SHAPE_LOG)
IF_VERBOSE_PARSE(log_msg(" shape_character read: fill0 = %d\n",
current_path.m_fill0));
- }
- if ((flags & 0x04)
- && num_fill_bits > 0)
- {
- // fill_style_1_change = 1;
- if (! current_path.is_empty())
- {
- m_paths.push_back(current_path);
- current_path.m_edges.resize(0);
- current_path.m_ax = x;
- current_path.m_ay = y;
- }
- int style =
in->read_uint(num_fill_bits);
- if (style > 0)
- {
- style += fill_base;
- }
- current_path.m_fill1 = style;
- if (SHAPE_LOG)
IF_VERBOSE_PARSE(log_msg(" shape_character read: fill1 = %d\n",
current_path.m_fill1));
- }
- if ((flags & 0x08)
- && num_line_bits > 0)
- {
- // line_style_change = 1;
- if (! current_path.is_empty())
- {
- m_paths.push_back(current_path);
- current_path.m_edges.resize(0);
- current_path.m_ax = x;
- current_path.m_ay = y;
- }
- int style =
in->read_uint(num_line_bits);
- if (style > 0)
- {
- style += line_base;
- }
- current_path.m_line = style;
- if (SHAPE_LOG)
IF_VERBOSE_PARSE(log_msg(" shape_character_read: line = %d\n",
current_path.m_line));
- }
- if (flags & 0x10) {
- assert(tag_type >= 22);
-
- IF_VERBOSE_PARSE(log_msg("
shape_character read: more fill styles\n"));
-
- // Store the current path if any.
- if (! current_path.is_empty())
- {
- m_paths.push_back(current_path);
- current_path.m_edges.resize(0);
-
- // Clear styles.
- current_path.m_fill0 = -1;
- current_path.m_fill1 = -1;
- current_path.m_line = -1;
- }
- // Tack on an empty path signalling a
new shape.
- // @@ need better understanding of
whether this is correct??!?!!
- // @@ i.e., we should just start a
whole new shape here, right?
- m_paths.push_back(path());
- m_paths.back().m_new_shape = true;
-
- fill_base = m_fill_styles.size();
- line_base = m_line_styles.size();
- read_fill_styles(&m_fill_styles, in,
tag_type, m);
- read_line_styles(&m_line_styles, in,
tag_type);
- num_fill_bits = in->read_uint(4);
- num_line_bits = in->read_uint(4);
- }
- }
- else
- {
- // EDGERECORD
- int edge_flag = in->read_uint(1);
- if (edge_flag == 0)
- {
- // curved edge
- int num_bits = 2 + in->read_uint(4);
- float cx = x +
in->read_sint(num_bits);
- float cy = y +
in->read_sint(num_bits);
- float ax = cx +
in->read_sint(num_bits);
- float ay = cy +
in->read_sint(num_bits);
-
- if (SHAPE_LOG)
IF_VERBOSE_PARSE(log_msg(" shape_character read: curved edge = %4g %4g - %4g
%4g - %4g %4g\n", x, y, cx, cy, ax, ay));
-
- current_path.m_edges.push_back(edge(cx,
cy, ax, ay));
-
- x = ax;
- y = ay;
- }
- else
- {
- // straight edge
- int num_bits = 2 + in->read_uint(4);
- int line_flag = in->read_uint(1);
- float dx = 0, dy = 0;
- if (line_flag)
- {
- // General line.
- dx = (float)
in->read_sint(num_bits);
- dy = (float)
in->read_sint(num_bits);
- }
- else
- {
- int vert_flag =
in->read_uint(1);
- if (vert_flag == 0) {
- // Horizontal line.
- dx = (float)
in->read_sint(num_bits);
- } else {
- // Vertical line.
- dy = (float)
in->read_sint(num_bits);
- }
- }
-
- if (SHAPE_LOG)
IF_VERBOSE_PARSE(log_msg(" shape_character_read: straight edge = %4g %4g - %4g
%4g\n", x, y, x + dx, y + dy));
-
- current_path.m_edges.push_back(edge(x +
dx, y + dy, x + dx, y + dy));
-
- x += dx;
- y += dy;
- }
- }
- }
- }
-
-
- void shape_character_def::display(character* inst)
- // Draw the shape using our own inherent styles.
- {
- GNASH_REPORT_FUNCTION;
-
- 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);
- }
+ // SHAPERECORDS
+ for (;;) {
+ int type_flag = in->read_uint(1);
+ if (type_flag == 0) {
+ // Parse the record.
+ int flags = in->read_uint(5);
+ if (flags == 0) {
+ // End of shape records.
+
+ // Store the current path if any.
+ if (! current_path.is_empty())
+ {
+ m_paths.push_back(current_path);
+ current_path.m_edges.resize(0);
+ }
+
+ break;
+ }
+ if (flags & 0x01) {
+ // move_to = 1;
+
+ // Store the current path if any, and prepare a fresh one.
+ if (! current_path.is_empty()) {
+ m_paths.push_back(current_path);
+ current_path.m_edges.resize(0);
+ }
+
+ int num_move_bits = in->read_uint(5);
+ int move_x = in->read_sint(num_move_bits);
+ int move_y = in->read_sint(num_move_bits);
+
+ x = (float) move_x;
+ y = (float) move_y;
+
+ // Set the beginning of the path.
+ current_path.m_ax = x;
+ current_path.m_ay = y;
+
+ if (SHAPE_LOG) IF_VERBOSE_PARSE(log_msg(" shape_character
read: moveto %4g %4g\n", x, y));
+ }
+ if ((flags & 0x02) && num_fill_bits > 0) {
+ // fill_style_0_change = 1;
+ if (! current_path.is_empty()) {
+ m_paths.push_back(current_path);
+ current_path.m_edges.resize(0);
+ current_path.m_ax = x;
+ current_path.m_ay = y;
+ }
+ int style = in->read_uint(num_fill_bits);
+ if (style > 0) {
+ style += fill_base;
+ }
+ current_path.m_fill0 = style;
+ if (SHAPE_LOG) IF_VERBOSE_PARSE(log_msg(" shape_character
read: fill0 = %d\n", current_path.m_fill0));
+ }
+ if ((flags & 0x04) && num_fill_bits > 0) {
+ // fill_style_1_change = 1;
+ if (! current_path.is_empty()) {
+ m_paths.push_back(current_path);
+ current_path.m_edges.resize(0);
+ current_path.m_ax = x;
+ current_path.m_ay = y;
+ }
+ int style = in->read_uint(num_fill_bits);
+ if (style > 0) {
+ style += fill_base;
+ }
+ current_path.m_fill1 = style;
+ if (SHAPE_LOG) IF_VERBOSE_PARSE(log_msg(" shape_character
read: fill1 = %d\n", current_path.m_fill1));
+ }
+ if ((flags & 0x08) && num_line_bits > 0) {
+ // line_style_change = 1;
+ if (! current_path.is_empty()) {
+ m_paths.push_back(current_path);
+ current_path.m_edges.resize(0);
+ current_path.m_ax = x;
+ current_path.m_ay = y;
+ }
+ int style = in->read_uint(num_line_bits);
+ if (style > 0) {
+ style += line_base;
+ }
+ current_path.m_line = style;
+ if (SHAPE_LOG) IF_VERBOSE_PARSE(log_msg("
shape_character_read: line = %d\n", current_path.m_line));
+ }
+ if (flags & 0x10) {
+ assert(tag_type >= 22);
+
+ IF_VERBOSE_PARSE(log_msg(" shape_character read: more fill
styles\n"));
+
+ // Store the current path if any.
+ if (! current_path.is_empty()) {
+ m_paths.push_back(current_path);
+ current_path.m_edges.resize(0);
+
+ // Clear styles.
+ current_path.m_fill0 = -1;
+ current_path.m_fill1 = -1;
+ current_path.m_line = -1;
+ }
+ // Tack on an empty path signalling a new shape.
+ // @@ need better understanding of whether this is correct??!?!!
+ // @@ i.e., we should just start a whole new shape here, right?
+ m_paths.push_back(path());
+ m_paths.back().m_new_shape = true;
+
+ fill_base = m_fill_styles.size();
+ line_base = m_line_styles.size();
+ read_fill_styles(&m_fill_styles, in, tag_type, m);
+ read_line_styles(&m_line_styles, in, tag_type);
+ num_fill_bits = in->read_uint(4);
+ num_line_bits = in->read_uint(4);
+ }
+ } else {
+ // EDGERECORD
+ int edge_flag = in->read_uint(1);
+ if (edge_flag == 0) {
+ // curved edge
+ int num_bits = 2 + in->read_uint(4);
+ float cx = x + in->read_sint(num_bits);
+ float cy = y + in->read_sint(num_bits);
+ float ax = cx + in->read_sint(num_bits);
+ float ay = cy + in->read_sint(num_bits);
+
+ if (SHAPE_LOG) IF_VERBOSE_PARSE(log_msg(" shape_character
read: curved edge = %4g %4g - %4g %4g - %4g %4g\n", x, y, cx, cy, ax, ay));
+
+ current_path.m_edges.push_back(edge(cx, cy, ax, ay));
+
+ x = ax;
+ y = ay;
+ } else {
+ // straight edge
+ int num_bits = 2 + in->read_uint(4);
+ int line_flag = in->read_uint(1);
+ float dx = 0, dy = 0;
+ if (line_flag) {
+ // General line.
+ dx = (float) in->read_sint(num_bits);
+ dy = (float) in->read_sint(num_bits);
+ } else {
+ int vert_flag = in->read_uint(1);
+ if (vert_flag == 0) {
+ // Horizontal line.
+ dx = (float) in->read_sint(num_bits);
+ } else {
+ // Vertical line.
+ dy = (float) in->read_sint(num_bits);
+ }
+ }
+
+ if (SHAPE_LOG) IF_VERBOSE_PARSE(log_msg("
shape_character_read: straight edge = %4g %4g - %4g %4g\n", x, y, x + dx, y +
dy));
+
+ current_path.m_edges.push_back(edge(x + dx, y + dy, x + dx, y +
dy));
+
+ x += dx;
+ y += dy;
+ }
+ }
+ }
+}
+
+
+void shape_character_def::display(character* inst)
+ // Draw the shape using our own inherent styles.
+{
+// GNASH_REPORT_FUNCTION;
+
+ 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
@@ -1105,371 +1029,342 @@
#include "ogl.h"
- static void point_normalize(point* p)
- {
- float mag2 = p->m_x * p->m_x + p->m_y * p->m_y;
- if (mag2 < 1e-9f)
- {
- // Very short vector.
- // @@ log error
-
- // Arbitrary unit vector.
- p->m_x = 1;
- p->m_y = 0;
- }
-
- float inv_mag = 1.0f / sqrtf(mag2);
- p->m_x *= inv_mag;
- p->m_y *= inv_mag;
- }
-
-
- 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...
- float x = p.m_x;
- float y = p.m_y;
-
- int mask = 8;
- while (mask)
- {
- if (mask & fill_number)
- {
- // Vert line --> 1.
- glVertex2f(x, y - 40.0f);
- glVertex2f(x, y + 40.0f);
- }
- else
- {
- // Rectangle --> 0.
- glVertex2f(x - 10.0f, y - 40.0f);
- glVertex2f(x + 10.0f, y - 40.0f);
-
- glVertex2f(x + 10.0f, y - 40.0f);
- glVertex2f(x + 10.0f, y + 40.0f);
-
- glVertex2f(x - 10.0f, y + 40.0f);
- glVertex2f(x + 10.0f, y + 40.0f);
-
- glVertex2f(x - 10.0f, y - 40.0f);
- glVertex2f(x - 10.0f, y + 40.0f);
- }
- x += 40.0f;
- mask >>= 1;
- }
- }
-
-
- 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++)
- {
+static void point_normalize(point* p)
+{
+ float mag2 = p->m_x * p->m_x + p->m_y * p->m_y;
+ if (mag2 < 1e-9f) {
+ // Very short vector.
+ // @@ log error
+
+ // Arbitrary unit vector.
+ p->m_x = 1;
+ p->m_y = 0;
+ }
+
+ float inv_mag = 1.0f / sqrtf(mag2);
+ p->m_x *= inv_mag;
+ p->m_y *= inv_mag;
+}
+
+
+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...
+ float x = p.m_x;
+ float y = p.m_y;
+
+ int mask = 8;
+ while (mask) {
+ if (mask & fill_number) {
+ // Vert line --> 1.
+ glVertex2f(x, y - 40.0f);
+ glVertex2f(x, y + 40.0f);
+ } else {
+ // Rectangle --> 0.
+ glVertex2f(x - 10.0f, y - 40.0f);
+ glVertex2f(x + 10.0f, y - 40.0f);
+
+ glVertex2f(x + 10.0f, y - 40.0f);
+ glVertex2f(x + 10.0f, y + 40.0f);
+
+ glVertex2f(x - 10.0f, y + 40.0f);
+ glVertex2f(x + 10.0f, y + 40.0f);
+
+ glVertex2f(x - 10.0f, y - 40.0f);
+ glVertex2f(x - 10.0f, y + 40.0f);
+ }
+ x += 40.0f;
+ mask >>= 1;
+ }
+}
+
+
+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
- const path& p = paths[i];
-
- if (p.m_fill0 == 0 && p.m_fill1 == 0)
- {
- continue;
- }
-
- gnash::render::set_matrix(mat);
-
- // Color the line according to which side has
- // fills.
- if (p.m_fill0 == 0) glColor4f(1, 0, 0, 0.5);
- else if (p.m_fill1 == 0) glColor4f(0, 1, 0, 0.5);
- else glColor4f(0, 0, 1, 0.5);
-
- // Offset according to which loop we are.
- float offset_x = (i & 1) * 80.0f;
- float offset_y = ((i & 2) >> 1) * 80.0f;
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glTranslatef(offset_x, offset_y, 0.f);
-
- point pt;
-
- glBegin(GL_LINE_STRIP);
-
- mat.transform(&pt, point(p.m_ax, p.m_ay));
- glVertex2f(pt.m_x, pt.m_y);
+ const path& p = paths[i];
- for (unsigned int j = 0; j < p.m_edges.size(); j++)
- {
- mat.transform(&pt, point(p.m_edges[j].m_cx,
p.m_edges[j].m_cy));
- glVertex2f(pt.m_x, pt.m_y);
- mat.transform(&pt, point(p.m_edges[j].m_ax,
p.m_edges[j].m_ay));
- glVertex2f(pt.m_x, pt.m_y);
- }
-
- glEnd();
+ if (p.m_fill0 == 0 && p.m_fill1 == 0) {
+ continue;
+ }
- // Draw arrowheads.
- point dir, right, p0, p1;
- glBegin(GL_LINES);
- {for (unsigned int j = 0; j < p.m_edges.size(); j++)
- {
- mat.transform(&p0, point(p.m_edges[j].m_cx,
p.m_edges[j].m_cy));
- mat.transform(&p1, point(p.m_edges[j].m_ax,
p.m_edges[j].m_ay));
- dir = point(p1.m_x - p0.m_x, p1.m_y - p0.m_y);
- point_normalize(&dir);
- right = point(-dir.m_y, dir.m_x); //
perpendicular
-
- const float ARROW_MAG = 60.f; //
TWIPS?
- if (p.m_fill0 != 0)
- {
- glColor4f(0, 1, 0, 0.5);
- glVertex2f(p0.m_x,
- p0.m_y);
- glVertex2f(p0.m_x - dir.m_x * ARROW_MAG
- right.m_x * ARROW_MAG,
- p0.m_y - dir.m_y * ARROW_MAG
- right.m_y * ARROW_MAG);
-
- show_fill_number(point(p0.m_x -
right.m_x * ARROW_MAG * 4,
- p0.m_y -
right.m_y * ARROW_MAG * 4),
- p.m_fill0);
- }
- if (p.m_fill1 != 0)
- {
- glColor4f(1, 0, 0, 0.5);
- glVertex2f(p0.m_x,
- p0.m_y);
- glVertex2f(p0.m_x - dir.m_x * ARROW_MAG
+ right.m_x * ARROW_MAG,
- p0.m_y - dir.m_y * ARROW_MAG
+ right.m_y * ARROW_MAG);
-
- show_fill_number(point(p0.m_x +
right.m_x * ARROW_MAG * 4,
- p0.m_y +
right.m_y * ARROW_MAG * 4),
- p.m_fill1);
- }
- }}
- glEnd();
+ gnash::render::set_matrix(mat);
- glPopMatrix();
- }
- }
+ // Color the line according to which side has
+ // fills.
+ if (p.m_fill0 == 0) glColor4f(1, 0, 0, 0.5);
+ else if (p.m_fill1 == 0) glColor4f(0, 1, 0, 0.5);
+ else glColor4f(0, 0, 1, 0.5);
+
+ // Offset according to which loop we are.
+ float offset_x = (i & 1) * 80.0f;
+ float offset_y = ((i & 2) >> 1) * 80.0f;
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslatef(offset_x, offset_y, 0.f);
+
+ point pt;
+
+ glBegin(GL_LINE_STRIP);
+
+ mat.transform(&pt, point(p.m_ax, p.m_ay));
+ glVertex2f(pt.m_x, pt.m_y);
+
+ for (unsigned int j = 0; j < p.m_edges.size(); j++) {
+ mat.transform(&pt, point(p.m_edges[j].m_cx, p.m_edges[j].m_cy));
+ glVertex2f(pt.m_x, pt.m_y);
+ mat.transform(&pt, point(p.m_edges[j].m_ax, p.m_edges[j].m_ay));
+ glVertex2f(pt.m_x, pt.m_y);
+ }
+
+ glEnd();
+
+ // Draw arrowheads.
+ point dir, right, p0, p1;
+ glBegin(GL_LINES);
+ {for (unsigned int j = 0; j < p.m_edges.size(); j++)
+ {
+ mat.transform(&p0, point(p.m_edges[j].m_cx, p.m_edges[j].m_cy));
+ mat.transform(&p1, point(p.m_edges[j].m_ax, p.m_edges[j].m_ay));
+ dir = point(p1.m_x - p0.m_x, p1.m_y - p0.m_y);
+ point_normalize(&dir);
+ right = point(-dir.m_y, dir.m_x); // perpendicular
+
+ const float ARROW_MAG = 60.f; // TWIPS?
+ if (p.m_fill0 != 0)
+ {
+ glColor4f(0, 1, 0, 0.5);
+ glVertex2f(p0.m_x,
+ p0.m_y);
+ glVertex2f(p0.m_x - dir.m_x * ARROW_MAG - right.m_x *
ARROW_MAG,
+ p0.m_y - dir.m_y * ARROW_MAG - right.m_y *
ARROW_MAG);
+
+ show_fill_number(point(p0.m_x - right.m_x * ARROW_MAG *
4,
+ p0.m_y - right.m_y * ARROW_MAG *
4),
+ p.m_fill0);
+ }
+ if (p.m_fill1 != 0)
+ {
+ glColor4f(1, 0, 0, 0.5);
+ glVertex2f(p0.m_x,
+ p0.m_y);
+ glVertex2f(p0.m_x - dir.m_x * ARROW_MAG + right.m_x *
ARROW_MAG,
+ p0.m_y - dir.m_y * ARROW_MAG + right.m_y *
ARROW_MAG);
+
+ show_fill_number(point(p0.m_x + right.m_x * ARROW_MAG *
4,
+ p0.m_y + right.m_y * ARROW_MAG *
4),
+ p.m_fill1);
+ }
+ }}
+ glEnd();
+
+ glPopMatrix();
+ }
+}
#endif // DEBUG_DISPLAY_SHAPE_PATHS
- 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
- // Display our shape. Use the fill_styles arg to
- // override our default set of fill styles (e.g. when
- // rendering text).
- {
- GNASH_REPORT_FUNCTION;
-
- // Compute the error tolerance in object-space.
- float max_scale = mat.get_max_scale();
- if (fabsf(max_scale) < 1e-6f)
- {
- // Scale is essentially zero.
- return;
- }
+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
+ // Display our shape. Use the fill_styles arg to
+ // override our default set of fill styles (e.g. when
+ // rendering text).
+{
+// GNASH_REPORT_FUNCTION;
+
+ // Compute the error tolerance in object-space.
+ float max_scale = mat.get_max_scale();
+ if (fabsf(max_scale) < 1e-6f) {
+ // Scale is essentially zero.
+ return;
+ }
- float object_space_max_error = 20.0f / max_scale /
pixel_scale * s_curve_max_pixel_error;
+ float object_space_max_error = 20.0f / max_scale / pixel_scale *
s_curve_max_pixel_error;
#ifdef DEBUG_DISPLAY_SHAPE_PATHS
- // Render a debug view of shape path outlines, instead
- // of the tesselated shapes themselves.
- if (gnash_debug_show_paths)
- {
- debug_display_shape_paths(mat, object_space_max_error,
m_paths, fill_styles, line_styles);
+ // Render a debug view of shape path outlines, instead
+ // of the tesselated shapes themselves.
+ if (gnash_debug_show_paths) {
+ debug_display_shape_paths(mat, object_space_max_error, m_paths,
fill_styles, line_styles);
- return;
- }
+ return;
+ }
#endif // DEBUG_DISPLAY_SHAPE_PATHS
- // See if we have an acceptable mesh available; if so then
render with it.
- for (unsigned int i = 0, n = m_cached_meshes.size(); i < n; i++)
- {
- const mesh_set* candidate = m_cached_meshes[i];
-
- if (object_space_max_error >
candidate->get_error_tolerance() * 3.0f)
- {
- // Mesh is too high-res; the remaining meshes
are higher res,
- // so stop searching and build an appropriately
scaled mesh.
- break;
- }
-
- if (object_space_max_error >
candidate->get_error_tolerance())
- {
- // Do it.
- candidate->display(mat, cx, fill_styles,
line_styles);
- return;
- }
- }
-
- // Construct a new mesh to handle this error tolerance.
- mesh_set* m = new mesh_set(this, object_space_max_error *
0.75f);
- m_cached_meshes.push_back(m);
- m->display(mat, cx, fill_styles, line_styles);
+ // See if we have an acceptable mesh available; if so then render with it.
+ for (unsigned int i = 0, n = m_cached_meshes.size(); i < n; i++) {
+ const mesh_set* candidate = m_cached_meshes[i];
+
+ if (object_space_max_error > candidate->get_error_tolerance() * 3.0f)
+ {
+ // Mesh is too high-res; the remaining meshes are higher res,
+ // so stop searching and build an appropriately scaled mesh.
+ break;
+ }
+
+ if (object_space_max_error > candidate->get_error_tolerance()) {
+ // Do it.
+ candidate->display(mat, cx, fill_styles, line_styles);
+ return;
+ }
+ }
+
+ // Construct a new mesh to handle this error tolerance.
+ mesh_set* m = new mesh_set(this, object_space_max_error * 0.75f);
+ m_cached_meshes.push_back(m);
+ m->display(mat, cx, fill_styles, line_styles);
- sort_and_clean_meshes();
- }
+ sort_and_clean_meshes();
+}
- static int sort_by_decreasing_error(const void* A, const void* B)
- {
- const mesh_set* a = *(const mesh_set**) A;
- const mesh_set* b = *(const mesh_set**) B;
-
- if (a->get_error_tolerance() < b->get_error_tolerance())
- {
- return 1;
- }
- else if (a->get_error_tolerance() > b->get_error_tolerance())
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
-
-
- void shape_character_def::sort_and_clean_meshes() const
- // Maintain cached meshes. Clean out mesh_sets that haven't
- // been used recently, and make sure they're sorted from high
- // error to low error.
- {
- // Re-sort.
- if (m_cached_meshes.size() > 0)
- {
- qsort(
- &m_cached_meshes[0],
- m_cached_meshes.size(),
- sizeof(m_cached_meshes[0]),
- sort_by_decreasing_error);
-
- // Check to make sure the sort worked as intended.
- #ifndef NDEBUG
- for (unsigned int i = 0, n = m_cached_meshes.size() -
1; i < n; i++)
- {
- const mesh_set* a = m_cached_meshes[i];
- const mesh_set* b = m_cached_meshes[i + 1];
-
- assert(a->get_error_tolerance() >
b->get_error_tolerance());
- }
- #endif // not NDEBUG
- }
- }
+static int sort_by_decreasing_error(const void* A, const void* B)
+{
+ const mesh_set* a = *(const mesh_set**) A;
+ const mesh_set* b = *(const mesh_set**) B;
+
+ if (a->get_error_tolerance() < b->get_error_tolerance()) {
+ return 1;
+ } else if (a->get_error_tolerance() > b->get_error_tolerance()) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+
+void shape_character_def::sort_and_clean_meshes() const
+ // Maintain cached meshes. Clean out mesh_sets that haven't
+ // been used recently, and make sure they're sorted from high
+ // error to low error.
+{
+ // Re-sort.
+ if (m_cached_meshes.size() > 0) {
+ qsort(
+ &m_cached_meshes[0],
+ m_cached_meshes.size(),
+ sizeof(m_cached_meshes[0]),
+ sort_by_decreasing_error);
+
+ // Check to make sure the sort worked as intended.
+#ifndef NDEBUG
+ for (unsigned int i = 0, n = m_cached_meshes.size() - 1; i < n; i++) {
+ const mesh_set* a = m_cached_meshes[i];
+ const mesh_set* b = m_cached_meshes[i + 1];
+
+ assert(a->get_error_tolerance() > b->get_error_tolerance());
+ }
+#endif // not NDEBUG
+ }
+}
- void shape_character_def::tesselate(float error_tolerance,
tesselate::trapezoid_accepter* accepter) const
- // Push our shape data through the tesselator.
- {
- tesselate::begin_shape(accepter, error_tolerance);
- for (unsigned int i = 0; i < m_paths.size(); i++)
- {
- if (m_paths[i].m_new_shape == true)
- {
- // Hm; should handle separate sub-shapes in a
less lame way.
- tesselate::end_shape();
- tesselate::begin_shape(accepter,
error_tolerance);
- }
- else
- {
- m_paths[i].tesselate();
- }
- }
- tesselate::end_shape();
- }
-
-
- 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.
- {
- if (m_bound.point_test(x, y) == false)
- {
- // Early out.
- return false;
- }
-
- // Try each of the paths.
- for (unsigned int i = 0; i < m_paths.size(); i++)
- {
- if (m_paths[i].point_test(x, y))
- {
- return true;
- }
- }
-
- return false;
- }
-
-
- float shape_character_def::get_height_local()
- {
- return m_bound.height();
- }
-
- float shape_character_def::get_width_local()
- {
- return m_bound.width();
- }
-
-
- void shape_character_def::compute_bound(rect* r) const
- // Find the bounds of this shape, and store them in
- // the given rectangle.
- {
- r->m_x_min = 1e10f;
- r->m_y_min = 1e10f;
- r->m_x_max = -1e10f;
- r->m_y_max = -1e10f;
-
- for (unsigned int i = 0; i < m_paths.size(); i++)
- {
- const path& p = m_paths[i];
- r->expand_to_point(p.m_ax, p.m_ay);
- for (unsigned int j = 0; j < p.m_edges.size(); j++)
- {
- r->expand_to_point(p.m_edges[j].m_ax,
p.m_edges[j].m_ay);
+void shape_character_def::tesselate(float error_tolerance,
tesselate::trapezoid_accepter* accepter) const
+ // Push our shape data through the tesselator.
+{
+ tesselate::begin_shape(accepter, error_tolerance);
+ for (unsigned int i = 0; i < m_paths.size(); i++) {
+ if (m_paths[i].m_new_shape == true) {
+ // Hm; should handle separate sub-shapes in a less lame way.
+ tesselate::end_shape();
+ tesselate::begin_shape(accepter, error_tolerance);
+ } else {
+ m_paths[i].tesselate();
+ }
+ }
+ tesselate::end_shape();
+}
+
+
+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.
+{
+ if (m_bound.point_test(x, y) == false) {
+ // Early out.
+ return false;
+ }
+
+ // Try each of the paths.
+ for (unsigned int i = 0; i < m_paths.size(); i++) {
+ if (m_paths[i].point_test(x, y))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+float shape_character_def::get_height_local()
+{
+ return m_bound.height();
+}
+
+float shape_character_def::get_width_local()
+{
+ return m_bound.width();
+}
+
+
+void shape_character_def::compute_bound(rect* r) const
+ // Find the bounds of this shape, and store them in
+ // the given rectangle.
+{
+ r->m_x_min = 1e10f;
+ r->m_y_min = 1e10f;
+ r->m_x_max = -1e10f;
+ r->m_y_max = -1e10f;
+
+ for (unsigned int i = 0; i < m_paths.size(); i++) {
+ const path& p = m_paths[i];
+ r->expand_to_point(p.m_ax, p.m_ay);
+ for (unsigned int j = 0; j < p.m_edges.size(); j++) {
+ r->expand_to_point(p.m_edges[j].m_ax, p.m_edges[j].m_ay);
// r->expand_to_point(p.m_edges[j].m_cx,
p.m_edges[j].m_cy);
- }
- }
}
+ }
+}
- void shape_character_def::output_cached_data(tu_file* out, const
cache_options& options)
- // Dump our precomputed mesh data to the given stream.
- {
- int n = m_cached_meshes.size();
- out->write_le32(n);
-
- for (int i = 0; i < n; i++)
- {
- m_cached_meshes[i]->output_cached_data(out);
- }
- }
-
-
- void shape_character_def::input_cached_data(tu_file* in)
- // Initialize our mesh data from the given stream.
- {
- int n = in->read_le32();
-
- m_cached_meshes.resize(n);
-
- for (int i = 0; i < n; i++)
- {
- mesh_set* ms = new mesh_set();
- ms->input_cached_data(in);
- m_cached_meshes[i] = ms;
- }
- }
+void shape_character_def::output_cached_data(tu_file* out, const
cache_options& options)
+ // Dump our precomputed mesh data to the given stream.
+{
+ int n = m_cached_meshes.size();
+ out->write_le32(n);
+
+ for (int i = 0; i < n; i++) {
+ m_cached_meshes[i]->output_cached_data(out);
+ }
+}
+
+
+void shape_character_def::input_cached_data(tu_file* in)
+ // Initialize our mesh data from the given stream.
+{
+ int n = in->read_le32();
+
+ m_cached_meshes.resize(n);
+
+ for (int i = 0; i < n; i++) {
+ mesh_set* ms = new mesh_set();
+ ms->input_cached_data(in);
+ m_cached_meshes[i] = ms;
+ }
+}
} // end namespace gnash
Index: gnash/server/styles.cpp
diff -u gnash/server/styles.cpp:1.6 gnash/server/styles.cpp:1.7
--- gnash/server/styles.cpp:1.6 Sun Feb 26 21:44:53 2006
+++ gnash/server/styles.cpp Wed Mar 29 05:42:41 2006
@@ -14,347 +14,325 @@
#include "Movie.h"
namespace gnash {
- //
- // gradient_record
- //
-
- gradient_record::gradient_record()
- :
- m_ratio(0)
- {
- }
-
-
- void gradient_record::read(stream* in, int tag_type)
- {
- m_ratio = in->read_u8();
- m_color.read(in, tag_type);
- }
-
-
- //
- // fill_style
- //
-
-
- fill_style::fill_style()
- :
- m_type(0),
- m_gradient_bitmap_info(0),
- m_bitmap_character(0)
- {
- assert(m_gradients.size() == 0);
- }
-
-
- fill_style::~fill_style()
- {
- }
-
- void fill_style::read(stream* in, int tag_type, movie_definition* md)
- {
- m_type = in->read_u8();
-
- IF_VERBOSE_PARSE(log_msg(" fill_style read type = 0x%X\n",
m_type));
-
- if (m_type == 0x00)
- {
- // 0x00: solid fill
- if (tag_type <= 22) {
- m_color.read_rgb(in);
- } else {
- m_color.read_rgba(in);
- }
-
- IF_VERBOSE_PARSE(log_msg(" color: ");
- m_color.print());
- }
- else if (m_type == 0x10 || m_type == 0x12)
- {
- // 0x10: linear gradient fill
- // 0x12: radial gradient fill
-
- matrix input_matrix;
- input_matrix.read(in);
-
- if (m_type == 0x10)
- {
- m_gradient_matrix.set_identity();
-
m_gradient_matrix.concatenate_translation(128.f, 0.f);
- m_gradient_matrix.concatenate_scale(1.0f /
128.0f);
- }
- else
- {
- m_gradient_matrix.set_identity();
- m_gradient_matrix.concatenate_translation(32.f,
32.f);
- m_gradient_matrix.concatenate_scale(1.0f /
512.0f);
- }
-
-
- matrix m;
- m.set_inverse(input_matrix);
- m_gradient_matrix.concatenate(m);
+//
+// gradient_record
+//
+
+gradient_record::gradient_record()
+ :
+ m_ratio(0)
+{
+}
+
+
+void
+gradient_record::read(stream* in, int tag_type)
+{
+ m_ratio = in->read_u8();
+ m_color.read(in, tag_type);
+}
+
+
+//
+// fill_style
+//
+
+
+fill_style::fill_style()
+ :
+ m_type(0),
+ m_gradient_bitmap_info(0),
+ m_bitmap_character(0)
+{
+ assert(m_gradients.size() == 0);
+}
+
+
+fill_style::~fill_style()
+{
+}
+
+void
+fill_style::read(stream* in, int tag_type, movie_definition* md)
+{
+ m_type = in->read_u8();
+
+ IF_VERBOSE_PARSE(log_msg(" fill_style read type = 0x%X\n", m_type));
+
+ if (m_type == 0x00) {
+ // 0x00: solid fill
+ if (tag_type <= 22) {
+ m_color.read_rgb(in);
+ } else {
+ m_color.read_rgba(in);
+ }
+
+ IF_VERBOSE_PARSE(log_msg(" color: ");
+ m_color.print());
+ } else if (m_type == 0x10 || m_type == 0x12) {
+ // 0x10: linear gradient fill
+ // 0x12: radial gradient fill
+
+ matrix input_matrix;
+ input_matrix.read(in);
+
+ if (m_type == 0x10) {
+ m_gradient_matrix.set_identity();
+ m_gradient_matrix.concatenate_translation(128.f, 0.f);
+ m_gradient_matrix.concatenate_scale(1.0f / 128.0f);
+ } else {
+ m_gradient_matrix.set_identity();
+ m_gradient_matrix.concatenate_translation(32.f, 32.f);
+ m_gradient_matrix.concatenate_scale(1.0f / 512.0f);
+ }
+
+
+ matrix m;
+ m.set_inverse(input_matrix);
+ m_gradient_matrix.concatenate(m);
- // GRADIENT
- int num_gradients = in->read_u8();
- if (num_gradients < 1 || num_gradients > 8) {
- fprintf(stderr, "WARNING: %s (%d): %d read bad
gradient value!\n",
- __PRETTY_FUNCTION__, __LINE__,
- num_gradients);
- }
- m_gradients.resize(num_gradients);
- for (int i = 0; i < num_gradients; i++)
- {
- m_gradients[i].read(in, tag_type);
- }
-
- IF_VERBOSE_PARSE(log_msg(" gradients: num_gradients =
%d\n", num_gradients));
-
- // @@ hack.
- if (num_gradients > 0)
- {
- m_color = m_gradients[0].m_color;
- }
-
- if (md->get_create_bitmaps() == DO_LOAD_BITMAPS)
- {
- m_gradient_bitmap_info =
create_gradient_bitmap();
- }
- else
- {
- m_gradient_bitmap_info =
render::create_bitmap_info_empty();
- }
-
- // Make sure our movie_def_impl knows about this bitmap.
- md->add_bitmap_info(m_gradient_bitmap_info.get_ptr());
- }
- else if (m_type == 0x40 || m_type == 0x41)
- {
- // 0x40: tiled bitmap fill
- // 0x41: clipped bitmap fill
-
- int bitmap_char_id = in->read_u16();
- IF_VERBOSE_PARSE(log_msg(" bitmap_char = %d\n",
bitmap_char_id));
-
- // Look up the bitmap character.
- m_bitmap_character =
md->get_bitmap_character(bitmap_char_id);
-
- matrix m;
- m.read(in);
-
- // For some reason, it looks like they store the
inverse of the
- // TWIPS-to-texcoords matrix.
- m_bitmap_matrix.set_inverse(m);
- IF_VERBOSE_PARSE(m_bitmap_matrix.print());
- }
- }
-
-
- rgba fill_style::sample_gradient(int ratio) const
- // Return the color at the specified ratio into our gradient.
- // Ratio is in [0, 255].
- {
- assert(ratio >= 0 && ratio <= 255);
- assert(m_type == 0x10 || m_type == 0x12);
- assert(m_gradients.size() > 0);
+ // GRADIENT
+ int num_gradients = in->read_u8();
+ if (num_gradients < 1 || num_gradients > 8) {
+ fprintf(stderr, "WARNING: %s (%d): %d read bad gradient value!\n",
+ __PRETTY_FUNCTION__, __LINE__,
+ num_gradients);
+ }
+ m_gradients.resize(num_gradients);
+ for (int i = 0; i < num_gradients; i++) {
+ m_gradients[i].read(in, tag_type);
+ }
+
+ IF_VERBOSE_PARSE(log_msg(" gradients: num_gradients = %d\n",
num_gradients));
+
+ // @@ hack.
+ if (num_gradients > 0) {
+ m_color = m_gradients[0].m_color;
+ }
+
+ if (md->get_create_bitmaps() == DO_LOAD_BITMAPS) {
+ m_gradient_bitmap_info = create_gradient_bitmap();
+ } else {
+ m_gradient_bitmap_info = render::create_bitmap_info_empty();
+ }
+
+ // Make sure our movie_def_impl knows about this bitmap.
+ md->add_bitmap_info(m_gradient_bitmap_info.get_ptr());
+ } else if (m_type == 0x40 || m_type == 0x41) {
+ // 0x40: tiled bitmap fill
+ // 0x41: clipped bitmap fill
+
+ int bitmap_char_id = in->read_u16();
+ IF_VERBOSE_PARSE(log_msg(" bitmap_char = %d\n", bitmap_char_id));
+
+ // Look up the bitmap character.
+ m_bitmap_character = md->get_bitmap_character(bitmap_char_id);
+
+ matrix m;
+ m.read(in);
+
+ // For some reason, it looks like they store the inverse of the
+ // TWIPS-to-texcoords matrix.
+ m_bitmap_matrix.set_inverse(m);
+ IF_VERBOSE_PARSE(m_bitmap_matrix.print());
+ }
+}
- if (ratio < m_gradients[0].m_ratio)
- return m_gradients[0].m_color;
+
+rgba
+fill_style::sample_gradient(int ratio) const
+ // Return the color at the specified ratio into our gradient.
+ // Ratio is in [0, 255].
+{
+ assert(ratio >= 0 && ratio <= 255);
+ assert(m_type == 0x10 || m_type == 0x12);
+ assert(m_gradients.size() > 0);
+
+ if (ratio < m_gradients[0].m_ratio) {
+ return m_gradients[0].m_color;
+ }
+
- for (unsigned int i = 1; i < m_gradients.size(); i++)
- {
- if (m_gradients[i].m_ratio >= ratio)
- {
- const gradient_record& gr0 = m_gradients[i - 1];
- const gradient_record& gr1 = m_gradients[i];
- float f = 0.0f;
- if (gr0.m_ratio != gr1.m_ratio)
- {
- f = (ratio - gr0.m_ratio) /
float(gr1.m_ratio - gr0.m_ratio);
- }
-
- rgba result;
- result.set_lerp(m_gradients[i - 1].m_color,
m_gradients[i].m_color, f);
- return result;
- }
- }
- return m_gradients.back().m_color;
- }
-
- gnash::bitmap_info* fill_style::create_gradient_bitmap() const
- // Make a bitmap_info* corresponding to our gradient.
- // We can use this to set the gradient fill style.
- {
- assert(m_type == 0x10 || m_type == 0x12);
-
- image::rgba* im = NULL;
-
- if (m_type == 0x10)
- {
- // Linear gradient.
- im = image::create_rgba(256, 1);
-
- for (int i = 0; i < im->m_width; i++)
- {
- rgba sample = sample_gradient(i);
- im->set_pixel(i, 0, sample.m_r, sample.m_g,
sample.m_b, sample.m_a);
- }
- }
- else if (m_type == 0x12)
- {
- // Radial gradient.
- im = image::create_rgba(64, 64);
-
- for (int j = 0; j < im->m_height; j++)
- {
- for (int i = 0; i < im->m_width; i++)
- {
- float radius = (im->m_height - 1) /
2.0f;
- float y = (j - radius) / radius;
- float x = (i - radius) / radius;
- int ratio = (int) floorf(255.5f *
sqrt(x * x + y * y));
- if (ratio > 255)
- {
- ratio = 255;
- }
- rgba sample = sample_gradient( ratio
);
- im->set_pixel(i, j, sample.m_r,
sample.m_g, sample.m_b, sample.m_a);
- }
- }
- }
-
- gnash::bitmap_info* bi =
gnash::render::create_bitmap_info_rgba(im);
- delete im;
-
- return bi;
- }
-
-
- void fill_style::apply(int fill_side, float ratio) const
- // Push our style parameters into the renderer.
- {
- UNUSED(ratio);
- if (m_type == 0x00)
- {
- // 0x00: solid fill
- gnash::render::fill_style_color(fill_side, m_color);
- }
- else if (m_type == 0x10 || m_type == 0x12)
- {
- // 0x10: linear gradient fill
- // 0x12: radial gradient fill
-
- if (m_gradient_bitmap_info == NULL)
- {
- // This can happen when morphing gradient
styles.
- // assert(morphing???);
- // log an error?
- fill_style* this_non_const =
const_cast<fill_style*>(this);
- this_non_const->m_gradient_bitmap_info =
create_gradient_bitmap();
- }
-
- if (m_gradient_bitmap_info != NULL)
- {
- gnash::render::fill_style_bitmap(
- fill_side,
- m_gradient_bitmap_info.get_ptr(),
- m_gradient_matrix,
- gnash::render_handler::WRAP_CLAMP);
- }
- }
- else if (m_type == 0x40
- || m_type == 0x41)
- {
- // bitmap fill (either tiled or clipped)
- gnash::bitmap_info* bi = NULL;
- if (m_bitmap_character != NULL)
- {
- bi = m_bitmap_character->get_bitmap_info();
- if (bi != NULL)
- {
- gnash::render_handler::bitmap_wrap_mode
wmode = gnash::render_handler::WRAP_REPEAT;
- if (m_type == 0x41)
- {
- wmode =
gnash::render_handler::WRAP_CLAMP;
- }
- gnash::render::fill_style_bitmap(
- fill_side,
- bi,
- m_bitmap_matrix,
- wmode);
- }
- }
- }
- }
-
-
- void fill_style::set_lerp(const fill_style& a, const fill_style& b,
float t)
- // Sets this style to a blend of a and b. t = [0,1]
- {
- assert(t >= 0 && t <= 1);
-
- // fill style type
- m_type = a.get_type();
- assert(m_type == b.get_type());
-
- // fill style color
- m_color.set_lerp(a.get_color(), b.get_color(), t);
-
- // fill style gradient matrix
- //
- // @@ TODO morphed gradients don't come out exactly
- // right; they shift around some. Not sure where the
- // problem is.
- m_gradient_matrix.set_lerp(a.m_gradient_matrix,
b.m_gradient_matrix, t);
-
- // fill style gradients
- assert(m_gradients.size() == a.m_gradients.size());
- assert(m_gradients.size() == b.m_gradients.size());
- for (unsigned int j=0; j < m_gradients.size(); j++)
- {
- m_gradients[j].m_ratio =
- (Uint8) frnd(
- flerp(a.m_gradients[j].m_ratio,
b.m_gradients[j].m_ratio, t)
- );
-
m_gradients[j].m_color.set_lerp(a.m_gradients[j].m_color,
b.m_gradients[j].m_color, t);
- }
- m_gradient_bitmap_info = NULL;
-
- // fill style bitmap ID
- m_bitmap_character = a.m_bitmap_character;
- assert(m_bitmap_character == b.m_bitmap_character);
-
- // fill style bitmap matrix
- m_bitmap_matrix.set_lerp(a.m_bitmap_matrix, b.m_bitmap_matrix,
t);
- }
-
-
- //
- // line_style
- //
+ for (unsigned int i = 1; i < m_gradients.size(); i++) {
+ if (m_gradients[i].m_ratio >= ratio) {
+ const gradient_record& gr0 = m_gradients[i - 1];
+ const gradient_record& gr1 = m_gradients[i];
+ float f = 0.0f;
+ if (gr0.m_ratio != gr1.m_ratio) {
+ f = (ratio - gr0.m_ratio) / float(gr1.m_ratio - gr0.m_ratio);
+ }
+
+ rgba result;
+ result.set_lerp(m_gradients[i - 1].m_color,
m_gradients[i].m_color, f);
+ return result;
+ }
+ }
+ return m_gradients.back().m_color;
+}
+
+gnash::bitmap_info*
+fill_style::create_gradient_bitmap() const
+ // Make a bitmap_info* corresponding to our gradient.
+ // We can use this to set the gradient fill style.
+{
+ assert(m_type == 0x10 || m_type == 0x12);
+
+ image::rgba* im = NULL;
+
+ if (m_type == 0x10) {
+ // Linear gradient.
+ im = image::create_rgba(256, 1);
+
+ for (int i = 0; i < im->m_width; i++) {
+ rgba sample = sample_gradient(i);
+ im->set_pixel(i, 0, sample.m_r, sample.m_g, sample.m_b,
sample.m_a);
+ }
+ } else if (m_type == 0x12) {
+ // Radial gradient.
+ im = image::create_rgba(64, 64);
+
+ for (int j = 0; j < im->m_height; j++) {
+ for (int i = 0; i < im->m_width; i++) {
+ float radius = (im->m_height - 1) / 2.0f;
+ float y = (j - radius) / radius;
+ float x = (i - radius) / radius;
+ int ratio = (int) floorf(255.5f * sqrt(x * x + y * y));
+ if (ratio > 255) {
+ ratio = 255;
+ }
+ rgba sample = sample_gradient( ratio );
+ im->set_pixel(i, j, sample.m_r, sample.m_g, sample.m_b,
sample.m_a);
+ }
+ }
+ }
+
+ gnash::bitmap_info* bi = gnash::render::create_bitmap_info_rgba(im);
+ delete im;
+
+ return bi;
+}
+
+
+void
+fill_style::apply(int fill_side, float ratio) const
+ // Push our style parameters into the renderer.
+{
+// GNASH_REPORT_FUNCTION;
+
+ UNUSED(ratio);
+ if (m_type == 0x00) {
+ // 0x00: solid fill
+ gnash::render::fill_style_color(fill_side, m_color);
+ } else if (m_type == 0x10 || m_type == 0x12) {
+ // 0x10: linear gradient fill
+ // 0x12: radial gradient fill
+
+ if (m_gradient_bitmap_info == NULL) {
+ // This can happen when morphing gradient styles.
+ // assert(morphing???);
+ // log an error?
+ fill_style* this_non_const = const_cast<fill_style*>(this);
+ this_non_const->m_gradient_bitmap_info = create_gradient_bitmap();
+ }
+
+ if (m_gradient_bitmap_info != NULL) {
+ gnash::render::fill_style_bitmap(
+ fill_side,
+ m_gradient_bitmap_info.get_ptr(),
+ m_gradient_matrix,
+ gnash::render_handler::WRAP_CLAMP);
+ }
+ } else if (m_type == 0x40 || m_type == 0x41) {
+ // bitmap fill (either tiled or clipped)
+ gnash::bitmap_info* bi = NULL;
+ if (m_bitmap_character != NULL) {
+ bi = m_bitmap_character->get_bitmap_info();
+ if (bi != NULL) {
+ gnash::render_handler::bitmap_wrap_mode wmode =
gnash::render_handler::WRAP_REPEAT;
+ if (m_type == 0x41) {
+ wmode = gnash::render_handler::WRAP_CLAMP;
+ }
+ gnash::render::fill_style_bitmap(
+ fill_side,
+ bi,
+ m_bitmap_matrix,
+ wmode);
+ }
+ }
+ }
+}
+
+
+void
+fill_style::set_lerp(const fill_style& a, const fill_style& b, float t)
+ // Sets this style to a blend of a and b. t = [0,1]
+{
+ assert(t >= 0 && t <= 1);
+
+ // fill style type
+ m_type = a.get_type();
+ assert(m_type == b.get_type());
+
+ // fill style color
+ m_color.set_lerp(a.get_color(), b.get_color(), t);
+
+ // fill style gradient matrix
+ //
+ // @@ TODO morphed gradients don't come out exactly
+ // right; they shift around some. Not sure where the
+ // problem is.
+ m_gradient_matrix.set_lerp(a.m_gradient_matrix, b.m_gradient_matrix, t);
+
+ // fill style gradients
+ assert(m_gradients.size() == a.m_gradients.size());
+ assert(m_gradients.size() == b.m_gradients.size());
+ for (unsigned int j=0; j < m_gradients.size(); j++) {
+ m_gradients[j].m_ratio =
+ (Uint8) frnd(
+ flerp(a.m_gradients[j].m_ratio, b.m_gradients[j].m_ratio, t)
+ );
+ m_gradients[j].m_color.set_lerp(a.m_gradients[j].m_color,
b.m_gradients[j].m_color, t);
+ }
+ m_gradient_bitmap_info = NULL;
+
+ // fill style bitmap ID
+ m_bitmap_character = a.m_bitmap_character;
+ assert(m_bitmap_character == b.m_bitmap_character);
+
+ // fill style bitmap matrix
+ m_bitmap_matrix.set_lerp(a.m_bitmap_matrix, b.m_bitmap_matrix, t);
+}
+
+
+//
+// line_style
+//
- line_style::line_style()
- :
- m_width(0)
- {
- }
-
-
- void line_style::read(stream* in, int tag_type)
- {
- m_width = in->read_u16();
- m_color.read(in, tag_type);
- }
-
-
- void line_style::apply(float ratio) const
- {
- UNUSED(ratio);
- gnash::render::line_style_color(m_color);
- gnash::render::line_style_width(m_width);
- }
+line_style::line_style()
+ :
+ m_width(0)
+{
+}
+
+
+void
+line_style::read(stream* in, int tag_type)
+{
+ m_width = in->read_u16();
+ m_color.read(in, tag_type);
+}
+
+
+void
+line_style::apply(float ratio) const
+{
+ UNUSED(ratio);
+ gnash::render::line_style_color(m_color);
+ gnash::render::line_style_width(m_width);
+}
+// end of namespace
}
Index: gnash/server/styles.h
diff -u gnash/server/styles.h:1.4 gnash/server/styles.h:1.5
--- gnash/server/styles.h:1.4 Sun Feb 26 21:44:53 2006
+++ gnash/server/styles.h Wed Mar 29 05:42:41 2006
@@ -13,113 +13,113 @@
#include "types.h"
namespace gnash {
- struct stream;
+struct stream;
- struct gradient_record
- {
- gradient_record();
- void read(stream* in, int tag_type);
-
+struct gradient_record
+{
+ gradient_record();
+ void read(stream* in, int tag_type);
+
//data:
- Uint8 m_ratio;
- rgba m_color;
- };
-
- struct base_fill_style
- {
- virtual ~base_fill_style() {};
- virtual void apply(int fill_side, float ratio) const = 0;
- };
-
- struct fill_style : public base_fill_style
- // For the interior of outline shapes.
- {
- fill_style();
- virtual ~fill_style();
-
- void read(stream* in, int tag_type, movie_definition* m);
- rgba sample_gradient(int ratio) const;
- gnash::bitmap_info* create_gradient_bitmap() const;
- virtual void apply(int fill_side, float ratio) const;
-
- rgba get_color() const { return m_color; }
- void set_color(rgba new_color) { m_color = new_color; }
- int get_type() const { return m_type; }
-
- // For shape morphing
- void set_lerp(const fill_style& a, const fill_style& b,
float t);
-
- private:
- friend struct morph2_character_def;
-
- int m_type;
- rgba m_color;
- matrix m_gradient_matrix;
- std::vector<gradient_record> m_gradients;
- smart_ptr<gnash::bitmap_info> m_gradient_bitmap_info;
- smart_ptr<bitmap_character_def> m_bitmap_character;
- matrix m_bitmap_matrix;
- };
-
-
- struct morph_fill_style : public base_fill_style
- {
- morph_fill_style();
- morph_fill_style(stream* in, movie_definition* m);
- virtual ~morph_fill_style();
-
- void read(stream* in, movie_definition* m);
- rgba sample_gradient(int ratio, float morph);
- bitmap_info* create_gradient_bitmap(float morph) const;
- virtual void apply(int fill_side, float morph) const;
- rgba get_color(float morph) const;
- void set_colors(rgba new_color_orig, rgba new_color_target);
- private:
- int m_type;
- rgba m_color[2];
- matrix m_gradient_matrix[2];
- std::vector<gradient_record> m_gradients[2];
- smart_ptr<bitmap_info> m_gradient_bitmap_info[2];
- smart_ptr<bitmap_character_def> m_bitmap_character;
- matrix m_bitmap_matrix[2];
- };
-
- struct base_line_style
- {
- virtual ~base_line_style(){};
- virtual void apply(float ratio) const = 0;
- };
-
- struct line_style : public base_line_style
- // For the outside of outline shapes, or just bare lines.
- {
- line_style();
- void read(stream* in, int tag_type);
- virtual void apply(float ratio) const;
-
- Uint16 get_width() const { return m_width; }
- const rgba& get_color() const { return m_color; }
-
- private:
- friend struct morph2_character_def;
-
- Uint16 m_width; // in TWIPS
- rgba m_color;
- };
-
- struct morph_line_style : public base_line_style
- {
- morph_line_style();
- morph_line_style(stream* in);
-
- void read(stream* in);
- virtual void apply(float morph) const;
-
- private:
- Uint16 m_width[2];
- rgba m_color[2];
- };
+ Uint8 m_ratio;
+ rgba m_color;
+};
+
+struct base_fill_style
+{
+ virtual ~base_fill_style() {};
+ virtual void apply(int fill_side, float ratio) const = 0;
+};
+
+struct fill_style : public base_fill_style
+// For the interior of outline shapes.
+{
+ fill_style();
+ virtual ~fill_style();
+
+ void read(stream* in, int tag_type, movie_definition* m);
+ rgba sample_gradient(int ratio) const;
+ gnash::bitmap_info* create_gradient_bitmap() const;
+ virtual void apply(int fill_side, float ratio) const;
+
+ rgba get_color() const { return m_color; }
+ void set_color(rgba new_color) { m_color = new_color; }
+ int get_type() const { return m_type; }
+
+ // For shape morphing
+ void set_lerp(const fill_style& a, const fill_style& b, float t);
+
+private:
+ friend struct morph2_character_def;
+
+ int m_type;
+ rgba m_color;
+ matrix m_gradient_matrix;
+ std::vector<gradient_record> m_gradients;
+ smart_ptr<gnash::bitmap_info> m_gradient_bitmap_info;
+ smart_ptr<bitmap_character_def> m_bitmap_character;
+ matrix m_bitmap_matrix;
+};
+
+
+struct morph_fill_style : public base_fill_style
+{
+ morph_fill_style();
+ morph_fill_style(stream* in, movie_definition* m);
+ virtual ~morph_fill_style();
+
+ void read(stream* in, movie_definition* m);
+ rgba sample_gradient(int ratio, float morph);
+ bitmap_info* create_gradient_bitmap(float morph) const;
+ virtual void apply(int fill_side, float morph) const;
+ rgba get_color(float morph) const;
+ void set_colors(rgba new_color_orig, rgba new_color_target);
+private:
+ int m_type;
+ rgba m_color[2];
+ matrix m_gradient_matrix[2];
+ std::vector<gradient_record> m_gradients[2];
+ smart_ptr<bitmap_info> m_gradient_bitmap_info[2];
+ smart_ptr<bitmap_character_def> m_bitmap_character;
+ matrix m_bitmap_matrix[2];
+};
+
+struct base_line_style
+{
+ virtual ~base_line_style(){};
+ virtual void apply(float ratio) const = 0;
+};
+
+struct line_style : public base_line_style
+// For the outside of outline shapes, or just bare lines.
+{
+ line_style();
+ void read(stream* in, int tag_type);
+ virtual void apply(float ratio) const;
+
+ Uint16 get_width() const { return m_width; }
+ const rgba& get_color() const { return m_color; }
+
+private:
+ friend struct morph2_character_def;
+
+ Uint16 m_width; // in TWIPS
+ rgba m_color;
+};
+
+struct morph_line_style : public base_line_style
+{
+ morph_line_style();
+ morph_line_style(stream* in);
+
+ void read(stream* in);
+ virtual void apply(float morph) const;
+
+private:
+ Uint16 m_width[2];
+ rgba m_color[2];
+};
}
@@ -128,7 +128,5 @@
// Local Variables:
// mode: C++
-// c-basic-offset: 8
-// tab-width: 8
// indent-tabs-mode: t
// End:
Index: gnash/server/text.cpp
diff -u gnash/server/text.cpp:1.11 gnash/server/text.cpp:1.12
--- gnash/server/text.cpp:1.11 Sat Mar 18 23:39:34 2006
+++ gnash/server/text.cpp Wed Mar 29 05:42:41 2006
@@ -53,6 +53,8 @@
const std::vector<text_glyph_record>& records,
movie_definition* root_def)
{
+// GNASH_REPORT_FUNCTION;
+
static std::vector<fill_style> s_dummy_style; // used to pass
a color on to shape_character::display()
static std::vector<line_style> s_dummy_line_style;
s_dummy_style.resize(1);
@@ -290,7 +292,7 @@
void text_character_def::display(character* inst)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
display_glyph_records(m_matrix, inst,
m_text_glyph_records, m_root_def);
}
@@ -957,8 +959,6 @@
// Local Variables:
// mode: C++
-// c-basic-offset: 8
-// tab-width: 8
// indent-tabs-mode: t
// End:
Index: gnash/utilities/Makefile.am
diff -u gnash/utilities/Makefile.am:1.13 gnash/utilities/Makefile.am:1.14
--- gnash/utilities/Makefile.am:1.13 Sat Mar 11 19:24:27 2006
+++ gnash/utilities/Makefile.am Wed Mar 29 05:42:42 2006
@@ -33,7 +33,14 @@
../libgeometry/libgnashgeo.la \
../libbase/libgnashbase.la \
$(LIBXML_LIBS) \
- $(ZLIB_LIBS)
+ $(JPEG_LIBS) \
+ $(PNG_LIBS) \
+ $(OGG_LIBS) \
+ $(ZLIB_LIBS) \
+ $(LIBXML_LIBS) \
+ $(OPENGL_LIBS) \
+ $(GLEXT_LIBS) \
+ $(GTK2_LIBS)
INCLUDES = -I.. \
-I$(top_srcdir) \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ./ChangeLog ./configure.ac ./README macro...,
Rob Savoye <=